Commit Graph

7237 Commits

Author SHA1 Message Date
Fabien Potencier 4698d15b8e Remove obsolete code, remove deprecations 2024-10-24 08:23:21 +02:00
Fabien Potencier ef63506239 Merge branch '3.x' into 4.x
* 3.x:
  Improve ImportNode impl
  Rename Node classes related to variables
2024-10-24 07:57:29 +02:00
Fabien Potencier b0017ad8c3 feature #4408 Improve ImportNode impl (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Improve ImportNode impl

Commits
-------

612c7a14be Improve ImportNode impl
2024-10-24 07:27:50 +02:00
Fabien Potencier 612c7a14be Improve ImportNode impl 2024-10-24 07:23:37 +02:00
Fabien Potencier 2735f81a22 feature #4398 Rename Node classes related to variables (fabpot)
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
2024-10-23 22:29:28 +02:00
Fabien Potencier 3663fa653d Merge branch '3.x' into 4.x
* 3.x:
  Documentation for types tag uses Twig types in examples instead of PHP
2024-10-23 16:55:25 +02:00
Fabien Potencier f43eba5b10 minor #4403 Documentation for types tag uses Twig types in examples instead of PHP (drjayvee)
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
2024-10-23 16:54:05 +02:00
Jeroen Versteeg f3e0a00cf0 Documentation for types tag uses Twig types in examples instead of PHP 2024-10-23 16:54:04 +02:00
Fabien Potencier fc15e7ccbc Rename Node classes related to variables 2024-10-23 12:36:57 +02:00
Fabien Potencier 99a85a7b5e Remove deprecated/obsolete features 2024-10-22 12:20:57 +02:00
Fabien Potencier 3c51c13a95 Fix merge 2024-10-22 12:19:15 +02:00
Fabien Potencier 8142a977e6 Remove obsolete code 2024-10-22 11:14:02 +02:00
Fabien Potencier 560988e2e1 Merge branch '3.x' into 4.x
* 3.x:
  Remove MacroAutoImportNodeVisitor
  Simplify code
  Rework macros handling
2024-10-22 11:13:46 +02:00
Fabien Potencier af4090757b feature #4402 Rework macros handling (fabpot)
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
2024-10-22 11:03:01 +02:00
Fabien Potencier f1481be00f Remove MacroAutoImportNodeVisitor 2024-10-21 12:09:30 +02:00
Fabien Potencier 72693884c4 Simplify code 2024-10-21 07:20:17 +02:00
Fabien Potencier dc34c2801f Merge branch '3.x' into 4.x
* 3.x:
  Remove default value for an argument
  reduce the deprecation noise when more than one argument is passed
2024-10-20 22:54:06 +02:00
Fabien Potencier 1105964873 Rework macros handling 2024-10-20 21:53:20 +02:00
Fabien Potencier bcceaa3468 minor #4401 reduce the deprecation noise when more than one argument is passed (xabbuh)
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
2024-10-20 21:48:23 +02:00
Fabien Potencier bde4efac5a Remove default value for an argument 2024-10-20 11:39:45 +02:00
Christian Flothmann 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.
2024-10-18 11:24:56 +02:00
Fabien Potencier b9606ae922 minor #4399 Call For recurseFunc inline (ruudk)
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
2024-10-18 09:45:38 +02:00
Ruud Kamphuis e4f6bf8e8a 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.
2024-10-17 12:28:35 +02:00
Fabien Potencier eca86f1a32 Remove obsolete code 2024-10-15 21:30:14 +02:00
Fabien Potencier 5da4b58fc5 Merge branch '3.x' into 4.x
* 3.x:
  Check reserved names in TempNameExpression
2024-10-15 21:29:05 +02:00
Fabien Potencier 448efb89bb bug #4397 Check reserved names in TempNameExpression (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Check reserved names in TempNameExpression

Commits
-------

66658a3c1d Check reserved names in TempNameExpression
2024-10-15 21:24:13 +02:00
Fabien Potencier 98f8d8ac10 Merge branch '3.x' into 4.x
* 3.x:
  Fix AssignNameExpression to forbid using names that won't work
  Do not allow : as macro definition separator
2024-10-14 19:59:38 +02:00
Fabien Potencier 66658a3c1d Check reserved names in TempNameExpression 2024-10-14 19:42:47 +02:00
Fabien Potencier 950ad5a2fc bug #4396 Fix AssignNameExpression to forbid using names that won't work (fabpot)
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
2024-10-14 14:07:02 +02:00
Fabien Potencier 9af72e6323 Fix AssignNameExpression to forbid using names that won't work 2024-10-14 13:55:40 +02:00
Fabien Potencier d45057536e bug #4395 Do not allow : as macro definition separator (fabpot)
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
2024-10-14 11:44:10 +02:00
Fabien Potencier 831e69b77e Do not allow : as macro definition separator 2024-10-14 10:42:32 +02:00
Fabien Potencier 10cb4be6ca Remove versionadded in docs 2024-10-11 11:53:01 +02:00
Fabien Potencier a2a492121b Remove deprecation code 2024-10-11 11:52:35 +02:00
Fabien Potencier 17ebb9a320 Remove dead code 2024-10-11 11:48:59 +02:00
Fabien Potencier ea0ed28111 Merge branch '3.x' into 4.x
* 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
2024-10-11 11:46:56 +02:00
Fabien Potencier 3eda65e94f feature #4391 Add support for named arguments on macro calls and dot operator arguments (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Add support for named arguments on macro calls and dot operator arguments

Closes #929
Closes #3635

Commits
-------

223d36bbae Add support for named arguments on macro calls and dot operator arguments
2024-10-11 11:40:44 +02:00
Fabien Potencier 223d36bbae Add support for named arguments on macro calls and dot operator arguments 2024-10-11 11:31:40 +02:00
Fabien Potencier 10a4c82149 minor #4392 Improve deprecation messages (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Improve deprecation messages

Refs [in string should](https://github.com/twigphp/Twig/pull/4344#issuecomment-2406110007)
cc `@smnandre`

Commits
-------

ed1b44470f Improve deprecation messages
2024-10-11 08:38:34 +02:00
Fabien Potencier ed1b44470f Improve deprecation messages 2024-10-11 08:16:49 +02:00
Fabien Potencier 4a762bda4f minor #4386 Simplify expression parser code (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Simplify expression parser code

Commits
-------

0ec3f4a7fe Simplify expression parser code
2024-10-09 10:57:18 +02:00
Fabien Potencier 0ec3f4a7fe Simplify expression parser code 2024-10-09 10:33:51 +02:00
Fabien Potencier 086c07f319 minor #4385 Refactor expression parser (fabpot)
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
2024-10-09 10:18:59 +02:00
Fabien Potencier 2cdca8cbeb Refactor expression parser 2024-10-09 09:14:02 +02:00
Fabien Potencier c25103752b minor #4384 chore: fix version added (94noni)
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
2024-10-09 07:44:35 +02:00
Antoine M 309d3f50cb chore: fix version added
comming from slack message of @javiereguiluz 
nice addition!
2024-10-08 22:19:25 +02:00
Fabien Potencier 7bf0f6f376 Cleanup code 2024-10-08 21:51:29 +02:00
Fabien Potencier dce4ba85b0 Remove obsolete code 2024-10-08 18:45:35 +02:00
Fabien Potencier 025278f576 Merge branch '3.x' into 4.x
* 3.x:
  Introduce a way to test Twig callables at compile time
  Allow arrow functions everywhere
  Fix deprecation dep feature
2024-10-08 18:44:24 +02:00
Fabien Potencier 818a07b591 feature #4304 Add a new guard tag that allows to test if some Twig callables are available at compilation time (fabpot)
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
2024-10-08 18:41:39 +02:00