1062 Commits

Author SHA1 Message Date
Fabien Potencier 4d19472d4a Prepare the 3.12.0 release 2024-08-29 11:51:12 +02:00
Fabien Potencier 33c4879dd8 Fix CS 2024-08-29 10:31:04 +02:00
Fabien Potencier d5b7120bdb minor #4248 Add conditional return types to ensureTraversable (ruudk)
This PR was squashed before being merged into the 3.x branch.

Discussion
----------

Add conditional return types to `ensureTraversable`

This way, static analyzers can understand what the output of this call will be.

Commits
-------

956d09bf Add conditional return types to `ensureTraversable`
2024-08-29 10:30:39 +02:00
Ruud Kamphuis 956d09bf08 Add conditional return types to ensureTraversable 2024-08-29 10:30:36 +02:00
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
Fabien Potencier 1211c9a490 feature #4247 deprecate passing a tag to ImportNode (xabbuh)
This PR was merged into the 3.x branch.

Discussion
----------

deprecate passing a tag to ImportNode

following #4244

Commits
-------

70396d75 deprecate passing a tag to ImportNode
2024-08-28 15:22:10 +02:00
Christian Flothmann 70396d75dc deprecate passing a tag to ImportNode 2024-08-28 14:40:27 +02:00
Christian Flothmann 8663ec242b fix typo 2024-08-28 14:18:47 +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
Nicolas Grekas 7ba6866759 Fix CoreExtension::captureOutput 2024-08-27 16:00:06 +02:00
Fabien Potencier f9f7b7959f feature #4010 Mark implicit macro argument default values as such with an attribute in AST (drjayvee)
This PR was squashed before being merged into the 3.x branch.

Discussion
----------

Mark implicit macro argument default values as such with an attribute in AST

This change causes no difference to compiled templates or to macro argument semantics.

Consider the following macro:
```twig
{% macro marco(po, lo = null) %}{% endmacro %}
```

With this change, the `ConstantExpression` for argument `po` will have an attribute `is_implicit`, whose value will be `true`. (Note that `lo` will not have that attribute.)

This allows node visitors to distinguish between arguments that do and those that do not have explicit default values even if the value is `null`.

This is useful for [static code analysis](https://github.com/twigphp/Twig/issues/4003).

For example, a static analysis tool might consider arguments with no explicit default value as non-optional.

Commits
-------

e83a8028 Mark implicit macro argument default values as such with an attribute in AST
2024-08-27 13:21:41 +02:00
Jeroen Versteeg e83a8028f0 Mark implicit macro argument default values as such with an attribute in AST 2024-08-27 13:21:06 +02:00
Fabien Potencier 41459e0ddb Fix CS 2024-08-27 13:18:23 +02:00
Fabien Potencier 58d5780ef3 Fix two-word tests precedence over one-word tests 2024-08-26 17:47:41 +02:00
Fabien Potencier 11813da84d Use Stringable when possible 2024-08-26 17:41:21 +02:00
Fabien Potencier 9fd4c487e7 Deprecate the spaceless filter 2024-08-26 16:25:20 +02:00
Fabien Potencier 9e6c4a6ac1 Deprecate some internal methods from Parser 2024-08-26 09:24:03 +02:00
Fabien Potencier cf4727606a Move code from ExtendsTokenParser to Parser 2024-08-26 07:56:37 +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 758be4dde3 Fix error message 2024-08-24 12:57:39 +02:00
Fabien Potencier 7173182537 Fix code 2024-08-24 10:55:34 +02:00
Fabien Potencier 0c75136162 Deprecate returning null from TokenParserInterface::parse() 2024-08-24 10:52:24 +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 992f637297 feature #4223 Add support for integers in methods of Twig\Node\Node that take a Node name (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Add support for integers in methods of `Twig\Node\Node` that take a Node name

Closes #3811

Commits
-------

1ee4210b Deprecate node names that are not strings or integers
2024-08-24 10:45:55 +02:00
Simon André 094892aa3b Remove Template::*_CALL const optimisations
* Template::ANY_CALL
* Template::ARRAY_CALL
* Template::METHOD_CALL
2024-08-24 10:03:24 +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 1fe2c00fa2 bug #4221 Deprecate OptimizerNodeVisitor::OPTIMIZE_TEXT_NODES (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Deprecate OptimizerNodeVisitor::OPTIMIZE_TEXT_NODES

Refs #4146

While trying to debug #4146, I realized that this optimization is not possible as we don't know how nodes are going to be used.

See the script provided in #4146 to reproduce the problem.

`@brandonkelly` Can you confirm that this fixes your problem? Maybe there is also an issue with yield vs echo, but the script provided in the issue runs fine for me after this PR.

Commits
-------

7121673c Deprecate OptimizerNodeVisitor::OPTIMIZE_TEXT_NODES
2024-08-23 09:23:28 +02:00
Fabien Potencier 7121673c9c Deprecate OptimizerNodeVisitor::OPTIMIZE_TEXT_NODES 2024-08-23 09:22:06 +02:00
Ruud Kamphuis 90107929da Improve deprecation message
See https://github.com/twigphp/Twig/pull/4199#discussion_r1723456834
2024-08-21 19:36:27 +02:00
Fabien Potencier 302971f34e Fix CS 2024-08-20 18:10:26 +02:00
Fabien Potencier f4bca4fa44 Remove obsolete comment 2024-08-20 18:06:11 +02:00
Nikola Svitlica a.k.a TheCelavi 6ef13d1e0b Resolves #4200 2024-08-20 17:30:37 +02:00
Fabien Potencier 31037d0e51 Refactor code 2024-08-20 15:39:54 +02:00
Fabien Potencier 3a307cd41d Update CHANGELOG and docs 2024-08-19 20:06:41 +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 84116e5ff7 Fix typos in CHANGELOG 2024-08-18 17:52:16 +02:00
Fabien Potencier 8370e8a9a7 Move some methods to static calls 2024-08-17 23:15:53 +02:00
Fabien Potencier 4428079003 Add an extension point for parsing special functions 2024-08-17 18:06:14 +02:00
Fabien Potencier 2e43eaa4ad Fix some minor issues 2024-08-16 22:51:19 +02:00
Fabien Potencier 0c30e78b1c Add support for named arguments on special functions 2024-08-16 08:37:24 +02:00
Fabien Potencier 26bcadeaeb Fix missing code 2024-08-16 08:13:22 +02:00
Fabien Potencier 0823d23488 Throw a SyntaxError exception at compile time when a Twig callable has not the minimum number of required arguments 2024-08-15 23:00:02 +02:00
Fabien Potencier e1705f8831 Extract a new CallableArgumentsExtractor class 2024-08-15 20:37:59 +02:00