This PR was merged into the 3.x branch.
Discussion
----------
Rename Node classes related to variables
Whenever I work on Twig internals, it's always complicated to reason about variable names, probably because the class names are confusing. This PR is an attempt to find "better" and more explicit names.
This PR does the following renaming:
* `NameExpression` to `Variable\ContextVariable`
Represents the value of a context variable like `$context[VAR] ?? null`
* `AssignNameExpression` to `Variable\AssignContextVariable`
Represents a context variable assignment like in `$context[VAR] = `
* `TempNameExpression` to `Variable\LocalVariable`
Represents a "private" local variable like `$_l111`
Commits
-------
fc15e7ccbc Rename Node classes related to variables
This PR was squashed before being merged into the 3.x branch.
Discussion
----------
Documentation for types tag uses Twig types in examples instead of PHP
Specifically, "bool" => "boolean" and "int" => "number".
This aligns the `types` documentation with templates.rst. See #4362
Thanks, `@alexander`-schranz!
Commits
-------
f3e0a00cf0 Documentation for types tag uses Twig types in examples instead of PHP
This PR was squashed before being merged into the 3.x branch.
Discussion
----------
Rework macros handling
Commits
-------
f1481be00f Remove MacroAutoImportNodeVisitor
72693884c4 Simplify code
1105964873 Rework macros handling
This PR was merged into the 3.x branch.
Discussion
----------
reduce the deprecation noise when more than one argument is passed
When more than one argument is passed to parseArguments(), one deprecation is triggered for each argument. Since passing any argument is deprecated the number of triggered deprecations can be reduced for more than one argument being passed.
Commits
-------
26256fc488 reduce the deprecation noise when more than one argument is passed
When more than one argument is passed to parseArguments(), one deprecation
is triggered for each argument. Since passing any argument is deprecated
the number of triggered deprecations can be reduced for more than one
argument being passed.
This PR was merged into the 4.x branch.
Discussion
----------
Call For recurseFunc inline
After https://github.com/phpstan/phpstan-src/pull/3554 this now makes it easier for PHPStan to understands what's going on.
This will allow TwigStan to handle for loops in v4.
Commits
-------
e4f6bf8e8a Call For recurseFunc inline
This PR was merged into the 3.x branch.
Discussion
----------
Check reserved names in TempNameExpression
Commits
-------
66658a3c1d Check reserved names in TempNameExpression
This PR was merged into the 3.x branch.
Discussion
----------
Fix AssignNameExpression to forbid using names that won't work
Commits
-------
9af72e6323 Fix AssignNameExpression to forbid using names that won't work
This PR was merged into the 3.x branch.
Discussion
----------
Do not allow : as macro definition separator
Commits
-------
831e69b77e Do not allow : as macro definition separator
* 3.x:
Add support for named arguments on macro calls and dot operator arguments
Improve deprecation messages
Simplify expression parser code
Refactor expression parser
chore: fix version added
Cleanup code
This PR was merged into the 3.x branch.
Discussion
----------
Add support for named arguments on macro calls and dot operator arguments
Closes#929Closes#3635
Commits
-------
223d36bbae Add support for named arguments on macro calls and dot operator arguments
This PR was merged into the 3.x branch.
Discussion
----------
Refactor expression parser
Instead of having if statements under `default`, I've moved the code to the `switch` statement, which makes more sense.
Commits
-------
2cdca8cbeb Refactor expression parser
This PR was merged into the 3.x branch.
Discussion
----------
chore: fix version added
comming from slack message of `@javiereguiluz`
nice addition!
Commits
-------
309d3f50cb chore: fix version added
This PR was merged into the 3.x branch.
Discussion
----------
Add a new guard tag that allows to test if some Twig callables are available at compilation time
Closes#3655
~~`@javiereguiluz` Would that help?~~
~~Usage:~~
~~```php~~
~~$twig->registerFunctionStub('csrf_token', fn (string $tokenId) => '');~~
~~$twig->registerFunctionStub('importmap', fn (string|array $entryPoint = 'app', array $attributes = []): string => '');~~
~~$twig->registerTestStub('random', fn (string $value) => false);~~
~~```~~
See the docs on the new `guard` tag in the diff.
Commits
-------
62f0a96b68 Introduce a way to test Twig callables at compile time