Commit Graph

219 Commits

Author SHA1 Message Date
Fabien Potencier 3d849eab57 Merge branch '3.x' into 4.x
* 3.x:
  Simplify code
2023-12-20 20:48:01 +01:00
Fabien Potencier 0b9e30e3d2 Simplify code 2023-12-20 20:43:49 +01:00
Fabien Potencier 87953c0d08 Merge branch '3.x' into 4.x
* 3.x:
  Fix bad merge
  Fix test without any assertions
  Simplify tests
2023-12-20 20:37:25 +01:00
Fabien Potencier e6a98a000f Fix test without any assertions 2023-12-20 20:34:04 +01:00
Fabien Potencier fca89954f1 Simplify tests 2023-12-20 20:34:04 +01:00
Fabien Potencier d27c50850d Merge branch '3.x' into 4.x
* 3.x:
  Add SourcePolicyInterface to selectively enable the Sandbox based on a template's Source
  add docs & links
2023-12-19 08:20:44 +01:00
Fabien Potencier 204cd6f412 Merge branch '2.x' into 3.x
* 2.x:
  Add SourcePolicyInterface to selectively enable the Sandbox based on a template's Source
2023-12-19 08:19:15 +01:00
Yaakov Saxon a18da1614a Add SourcePolicyInterface to selectively enable the Sandbox based on a template's Source 2023-12-19 08:18:35 +01:00
Fabien Potencier 35640b6d2d Add type hints to private properties 2023-12-14 20:43:37 +01:00
Fabien Potencier f84c2172bf Remove deprecated code 2023-12-10 21:02:11 +01:00
Fabien Potencier ac423430aa Merge branch '3.x' into 4.x
* 3.x:
  Fix CS
  Move functions for CoreExtension
  Move functions for EscaperExtension
  Move functions for StringLoaderExtension
  Move functions for DebugExtension
  Move functions for MarkdownExtension
  Move functions for InkyExtension
  Move functions for CssInlinerExtension
  Move functions for HtmlExtension
  Deprecate internal extension functions in favor of methods on the extension classes
  Tweak deprecated docs
2023-12-10 20:55:15 +01:00
Fabien Potencier 54d34b969b Move functions for CoreExtension 2023-12-10 20:13:10 +01:00
Fabien Potencier 72071e8ece Move functions for EscaperExtension 2023-12-10 11:49:57 +01:00
Fabien Potencier 196e91dd72 Move functions for StringLoaderExtension 2023-12-10 11:38:36 +01:00
Fabien Potencier d4d016034c Move functions for DebugExtension 2023-12-10 11:35:00 +01:00
Fabien Potencier c8d6df7eb2 Remove usage of isset before array_key_exists as performance is not an issue anymore 2023-12-09 17:24:12 +01:00
Fabien Potencier bce22e4c32 Use named arguments 2023-12-09 17:18:55 +01:00
Fabien Potencier be67e9690f Use str_* when possible 2023-12-09 15:33:38 +01:00
Fabien Potencier fed8dd102b Use ::class 2023-12-09 15:33:38 +01:00
Fabien Potencier b9cf29d53d Remove obsolete code 2023-12-09 14:56:21 +01:00
Fabien Potencier 583d7b2d2c Remove hack to inline throwing an exception 2023-12-09 14:52:04 +01:00
Fabien Potencier bcfe41efff Remove obsolete docs 2023-12-09 13:46:54 +01:00
Fabien Potencier 2f73ee35ca minor #3900 Minor rename of Sandbox test: functions->methods (YSaxon)
This PR was merged into the 3.x branch.

Discussion
----------

Minor rename of Sandbox test: functions->methods

Commits
-------

62732646 Minor rename of SandboxTest functions->methods
2023-11-21 17:18:42 +01:00
Fabien Potencier 4be326aeeb Fix tests and CS 2023-11-21 14:57:52 +01:00
Yaakov Saxon 62732646c8 Minor rename of SandboxTest functions->methods 2023-10-27 12:15:56 -04:00
Fabien Potencier b285fccd59 bug #3830 Catch errors thrown during template rendering (richards-square)
This PR was squashed before being merged into the 3.x branch.

Discussion
----------

Catch errors thrown during template rendering

Some errors, like not providing a function the proper number of arguments or division by zero, extend from `\Error` rather than `\Exception`. This PR catches these types of errors during template rendering and throws a `RuntimeError` in order to provide better debugging information.

Commits
-------

85bf01b4 Catch errors thrown during template rendering
2023-10-26 17:55:51 -07:00
Drew Richards 85bf01b4ab Catch errors thrown during template rendering 2023-10-26 17:55:48 -07:00
Fabien Potencier 248855b34b Merge branch '2.x' into 3.x
* 2.x:
  Fix premature loop exit in Security Policy lookup of allowed methods/properties
2023-10-26 17:38:13 -07:00
Yaakov Saxon 5e1838dbca Fix premature loop exit in Security Policy lookup of allowed methods/properties 2023-10-26 17:37:13 -07:00
Fabien Potencier 5193653ecb Fix CS 2023-10-08 09:05:22 +02:00
Fabien Potencier 974c866961 Remove Drupal tests 2023-09-11 17:40:51 +02:00
Fabien Potencier 5f7c48ca7d Fix tests 2023-09-11 17:36:13 +02:00
Fabien Potencier da38e858e3 Update Drupal version in tests 2023-07-28 12:21:15 +02:00
Nicolas Grekas 75efa5e1ba Fix spread operator implementation 2023-07-20 18:11:45 +02:00
Ryan Weaver ba4fe3ba34 Adding support for the ...spread operator on arrays and hashes 2023-07-20 16:08:57 +02:00
Jacob Richardson f136668933 Restores the leniency of the matches twig comparison, allowing null subject to result in a non-match.
Resolves BC break introduced in PR https://github.com/twigphp/Twig/pull/3687

As per pattern in https://github.com/twigphp/Twig/pull/3617
2023-02-07 17:07:16 +00:00
ju1ius 4f2f3f814e pass the current key to reduce filter's callback 2023-01-25 10:42:37 +01:00
Fabien Potencier a82e94d911 Add some tests 2022-12-27 12:31:54 +01:00
Fabien Potencier f6ef36a447 Merge branch '2.x' into 3.x
* 2.x:
  do not clean up whitespace text nodes inside if tags
2022-12-26 20:36:12 +01:00
Christian Flothmann c8ec092ceb do not clean up whitespace text nodes inside if tags 2022-12-26 18:04:52 +01:00
Fabien Potencier d769ae90d1 feature #3670 Add "some" and "every" filters (Jean-Beru)
This PR was merged into the 3.x branch.

Discussion
----------

Add "some" and "every" filters

This PR adds 2 new tests inspired from Javascript's functions: [some](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some) and [every](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every).

Usage :
```twig
Value {{ ([1, 2, 3] has some v => v == 2) ? 'found' : 'not found' }}

Key {{ ([1, 2, 3] has some (v, k) => k == 2) ? 'found' : 'not found' }}

Every values {{ ([1, 2, 3] has every v => 42 > v) ? 'match' : 'do not match' }}

Every keys {{ ([1, 2, 3] has every (v, k) => 42 > k) ? 'match' : 'do not match' }}
```

Commits
-------

009bb4fd Add "some" and "every" filters
2022-12-26 17:18:29 +01:00
Fabien Potencier 589655c1b9 Re-enable Drupal integration tests 2022-12-26 13:27:08 +01:00
Fabien Potencier 201baa76a6 Merge branch '2.x' into 3.x
* 2.x:
  Do more Github actions updates
  Use checkout actions v3
  Add PHP 8.2 to the tests
  Remove a test that was a regression test for the C extension
2022-12-26 13:19:29 +01:00
Fabien Potencier ef7a5ef2e3 Remove a test that was a regression test for the C extension 2022-12-26 12:42:02 +01:00
Fabien Potencier e5c87f8821 Merge branch '2.x' into 3.x
* 2.x:
  Add output
  Fix the drupal testing script
  Add missing argument for the cycle function
2022-12-15 11:46:42 +01:00
Christophe Coevoet f3b8c01262 Fix the drupal testing script 2022-12-15 11:35:27 +01:00
Fabien Potencier 2e8acd94ca Merge branch '2.x' into 3.x
* 2.x:
  Fix a security issue on filesystem loader (possibility to load a template outside a configured directory)
2022-09-28 10:36:55 +02:00
Fabien Potencier d6ea14aa84 Merge branch '1.x' into 2.x
* 1.x:
  Fix a security issue on filesystem loader (possibility to load a template outside a configured directory)
2022-09-28 10:36:46 +02:00
Fabien Potencier bcda6c3323 Merge branch '2.x' into 3.x
* 2.x:
  Fix CS
  Allow inherited magic method to still run with calling class
2022-08-12 08:33:18 +02:00
Fabien Potencier f2cb718bdb Fix CS 2022-08-12 08:33:05 +02:00