270 Commits

Author SHA1 Message Date
Fabien Potencier 2d347b42cd minor #4250 Add return type isTraitable (ruudk)
This PR was squashed before being merged into the 3.x branch.

Discussion
----------

Add return type `isTraitable`

I'd like to do this for more methods that are exposed in the compiled code. This will ease static analysis as there are less errors that are coming from Twig.

This is just a first small PR to see if this is acceptable 😊

Commits
-------

bb8b9c19 Add return type `isTraitable`
2024-08-29 10:29:50 +02:00
Ruud Kamphuis bb8b9c197c Add return type isTraitable 2024-08-29 10:29:47 +02:00
Fabien Potencier fecfbd8860 minor #4249 Only unset loop when with_loop (ruudk)
This PR was merged into the 3.x branch.

Discussion
----------

Only unset loop when with_loop

Even though PHP does not complain, PHPStan does.
> Cannot unset offset 'loop' on array{ ... the context values ... }

Since this is compiled code, we can easily produce a bit more valid code in the eyes of PHPStan.

Commits
-------

42245310 Only unset loop when with_loop
2024-08-28 16:12:05 +02:00
Ruud Kamphuis 42245310ee Only unset loop when with_loop
Even though PHP does not complain, PHPStan does.

Since this is compiled code, we can easily produce a bit more valid code in the eyes of PHPStan.
2024-08-28 15:47:07 +02:00
Christian Flothmann 70396d75dc deprecate passing a tag to ImportNode 2024-08-28 14:40:27 +02:00
Fabien Potencier 5fca700cbd Deprecate the fact that the extends and use tags are always allowed in a sandboxed template 2024-08-28 13:40:53 +02:00
Fabien Potencier 41459e0ddb Fix CS 2024-08-27 13:18:23 +02:00
Fabien Potencier 157d36ae43 Update Node::__toString() to include the node tag if set 2024-08-24 17:28:38 +02:00
Fabien Potencier 4b99692e2a Fix class name 2024-08-24 17:12:56 +02:00
Fabien Potencier 51e93aa130 Deprecate not passing a BodyNode instance as the body of a ModuleNode constructor 2024-08-24 10:49:53 +02:00
Fabien Potencier fb46572f94 minor #4224 Update a phpdoc (ModuleNode is final now) (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Update a phpdoc (ModuleNode is final now)

Commits
-------

313303b3 Update a phpdoc (ModuleNode is final now)
2024-08-24 10:48:55 +02:00
Fabien Potencier 313303b366 Update a phpdoc (ModuleNode is final now) 2024-08-24 09:53:44 +02:00
Fabien Potencier 1ee4210ba9 Deprecate node names that are not strings or integers 2024-08-23 22:35:24 +02:00
Fabien Potencier 31037d0e51 Refactor code 2024-08-20 15:39:54 +02:00
Nicolas Grekas 5d1a19a80c Swap BC layer for yield-ready and reclaim perf loss 2024-08-19 17:31:12 +02:00
Fabien Potencier 675cb2d141 Fix CS 2024-08-18 19:25:19 +02:00
Fabien Potencier e1705f8831 Extract a new CallableArgumentsExtractor class 2024-08-15 20:37:59 +02:00
Fabien Potencier b431ecad3a Make Node::__toString() more readable 2024-08-15 20:18:30 +02:00
Fabien Potencier 397b7c4782 Fix RawFilter 2024-08-14 23:42:25 +02:00
Fabien Potencier 3156d8093e Move FunctionExpression/FilterExpression/TestExpression attributes from compilation time to parsing time 2024-08-14 18:45:35 +02:00
Fabien Potencier 6ecd1f1350 Cleanup the implementation of the defined test for constants 2024-08-13 22:40:15 +02:00
Fabien Potencier 1da763408b Simplify code 2024-08-12 10:49:48 +02:00
Fabien Potencier 148d3e079d Make various optimization for dynamic Twig callables 2024-08-12 09:45:32 +02:00
Christophe Coevoet ff4d01f940 Implement the enum_cases function
The implementation contains an optimized implementation of the function
for the common case of using a string literal as the argument. It will
validate the enum existence during compilation and compile the code to
use `MyEnum::cases()` directly.
2024-08-09 21:21:58 +02:00
Fabien Potencier 18894cf91e Add the possibility to deprecate attributes and nodes on Node 2024-08-08 14:48:20 +02:00
Fabien Potencier 0ce79df5c4 Use trigger_deprecation() instead of trigger_error() for deprecations 2024-08-08 14:28:28 +02:00
Fabien Potencier e8141bbd34 Move static attributes for Function|Filter|TestExpression to the constructor 2024-08-07 22:29:43 +02:00
Fabien Potencier 15854ca9bf feature #4178 Constant expr as final (fabpot)
This PR was squashed before being merged into the 3.x branch.

Discussion
----------

Constant expr as final

Closes #4119

Commits
-------

230e31d3 Add a recipe about how to mark a node as safe
693693ba Mark ConstantExpression as `@final`
2024-08-07 21:01:58 +02:00
Fabien Potencier f5e10e10f1 Fix CS 2024-08-07 19:34:09 +02:00
Fabien Potencier 693693ba3a Mark ConstantExpression as @final 2024-08-07 19:00:30 +02:00
Fabien Potencier fc64472145 Fix dumping callables on Node::__toString() 2024-08-04 16:35:01 +02:00
Fabien Potencier ae4f284043 Fix various phpstan errors 2024-07-30 11:17:22 +02:00
Fabien Potencier 6e55b5f956 Simplify usage of RawFilter 2024-07-28 11:10:04 +02:00
Fabien Potencier a17891292c Fix raw filter compat 2024-07-28 10:51:52 +02:00
Fabien Potencier 84b1b3e0b3 Remove magic handling of the raw filter 2024-07-27 20:37:22 +02:00
Fabien Potencier 27f6171f2f Add support for yielding from a generator in PrintNode 2024-07-27 16:57:14 +02:00
Simon André 3531f959d3 Deprecate NameExpression internal methods
Deprecate two methods from NameExpression:
* isSimple(): did not find any usage in Twig (or even Symfony) repositories
* isSpecial(): inlined for better performance ($name is available in the method)
2024-07-22 01:25:30 +02:00
Fabien Potencier bb967b3dd3 Make compatible with PHP<8 2024-07-14 12:13:12 +02:00
Fabien Potencier 093f51a8b9 Extract ReflectionCallable to make it reusable 2024-07-14 12:06:15 +02:00
Fabien Potencier 6f12d008be Make a small optimization 2024-07-14 11:04:52 +02:00
Fabien Potencier 5157402a77 Rename hash to mapping 2024-06-22 19:36:24 +02:00
Fabien Potencier b63bde3063 Optimize sprintf() calls for PHP 8.4 2024-06-21 08:16:55 +02:00
Fabien Potencier 71d6c82de6 Deprecate CallExpression::compileArguments 2024-06-18 17:13:26 +02:00
Nicolas Grekas 504252835c Fix parse error in generated code when using CaptureNode 2024-05-16 11:46:35 +02:00
Fabien Potencier 6da7a95fba bug #4081 Fix blocks not available under some circumstancies (fabpot)
This PR was squashed before being merged into the 3.x branch.

Discussion
----------

Fix blocks not available under some circumstancies

Fix #4079

Commits
-------

55ae2149 Add more tests
d30b72c3 Fix blocks not available under some circumstancies
2024-05-11 09:03:44 +02:00
Fabien Potencier d30b72c364 Fix blocks not available under some circumstancies 2024-05-11 08:44:27 +02:00
Fabien Potencier 799355dc82 Remove double ; in generated code 2024-05-08 11:17:29 +02:00
Fabien Potencier 0d1a937f61 Fix CS 2024-05-01 18:23:14 +02:00
Fabien Potencier c63f695e8a Add needs_charset option for filters and functions 2024-05-01 13:12:48 +02:00
Fabien Potencier 16acdf69fe Rename some internal methods 2024-05-01 10:19:22 +02:00