1237 Commits

Author SHA1 Message Date
Fabien Potencier 2d5b3964cc Prepare the 3.15.0 release 2024-11-17 16:59:19 +01:00
Fabien Potencier 41a7988cef Simplify code 2024-11-17 16:45:52 +01:00
Fabien Potencier c5d0d593d2 minor #4446 Improve YieldReady support docs (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Improve YieldReady support docs

Refs https://github.com/twigphp/Twig/discussions/4428

Commits
-------

9d9c9d81e9 Improve YieldReady support docs
2024-11-12 08:12:30 +01:00
Fabien Potencier 9d9c9d81e9 Improve YieldReady support docs 2024-11-11 09:38:36 +01:00
Fabien Potencier 5b380e5b3b minor #4435 Fix wrong type for cycle position (ruudk)
This PR was merged into the 3.x branch.

Discussion
----------

Fix wrong type for cycle position

It also accepts 0, which is not a positive int.

Commits
-------

c78499bda9 Fix wrong type for cycle position
2024-11-07 18:02:41 +01:00
Fabien Potencier 8f1ae67b73 minor #4421 Add type for join method (ruudk)
This PR was merged into the 3.x branch.

Discussion
----------

Add type for join method

Looking at the code, this method is very forgiving in what it accepts.

This helps PHPStan to not complain when something other than an array is passed.

Did I miss other types?

/cc `@stof`

Commits
-------

226f0ff0dd Add type for join method
2024-11-07 18:02:05 +01:00
Nicolas Grekas 5cd1ff1977 Rely on reflection to access null properties 2024-11-07 11:23:04 +01:00
Nicolas Grekas d72ae2447e Merge branch '3.14.x' into 3.x
* 3.14.x:
  Improve detection of recursion
  Fix recursion when arrays contain self-references in sandboxed mode
  Fix code
  Prepare the 3.11.2 release
  Update CHANGELOG
  Sandbox ArrayAccess and do sandbox checks before isset() checks
  Fix sandbox handling for __toString()
  Prepare the 3.14.1 release
  Update CHANGELOG
  Sandbox ArrayAccess and do sandbox checks before isset() checks
  Fix sandbox handling for __toString()
  Prepare the 3.11.1 release
  Fix a security issue when an included sandboxed template has been loaded before without the sandbox context
2024-11-07 11:17:57 +01:00
Nicolas Grekas 83a21d31e5 Merge branch '3.11.x' into 3.14.x
* 3.11.x:
  Improve detection of recursion
  Fix recursion when arrays contain self-references in sandboxed mode
  Fix code
  Prepare the 3.11.2 release
  Update CHANGELOG
  Sandbox ArrayAccess and do sandbox checks before isset() checks
  Fix sandbox handling for __toString()
  Prepare the 3.11.1 release
  Fix a security issue when an included sandboxed template has been loaded before without the sandbox context
2024-11-07 11:11:36 +01:00
Nicolas Grekas d3fc074171 Improve detection of recursion 2024-11-07 10:15:07 +01:00
Lee Rowlands a0f775683d Fix recursion when arrays contain self-references in sandboxed mode 2024-11-07 09:42:22 +01:00
Fabien Potencier 32e99c263d Remove obsolete code 2024-11-06 21:45:08 +01:00
Nicolas Grekas b957e5a44c Sandbox ArrayAccess and do sandbox checks before isset() checks 2024-11-06 21:41:25 +01:00
Fabien Potencier d4a302681b Fix sandbox handling for __toString() 2024-11-06 21:35:53 +01:00
Fabien Potencier 5b580ec188 Fix code 2024-11-06 19:50:16 +01:00
Fabien Potencier 94612e7602 Prepare the 3.11.2 release 2024-11-06 19:48:59 +01:00
Nicolas Grekas ec39a9dccc Sandbox ArrayAccess and do sandbox checks before isset() checks 2024-11-06 19:48:59 +01:00
Fabien Potencier cafc608ece Fix sandbox handling for __toString() 2024-11-06 19:27:48 +01:00
Fabien Potencier f405356d20 Prepare the 3.14.1 release 2024-11-06 19:17:38 +01:00
Nicolas Grekas 831c148e78 Sandbox ArrayAccess and do sandbox checks before isset() checks 2024-11-06 19:16:07 +01:00
Fabien Potencier 2bb8c2460a Fix sandbox handling for __toString() 2024-11-05 17:54:37 +01:00
Ruud Kamphuis c78499bda9 Fix wrong type for cycle position
It also accepts 0, which is not a positive int.
2024-11-04 11:31:38 +01:00
Ruud Kamphuis 226f0ff0dd Add type for join method
Looking at the code, this method is very forgiving in what it accepts.
2024-10-30 15:44:01 +01:00
Fabien Potencier 494f010d29 Revert "minor #4411 Add return type to getDebugInfo (ruudk)"
This reverts commit 868b429853, reversing
changes made to b0017ad8c3.
2024-10-25 16:01:04 +02:00
Ruud Kamphuis 92e4989002 Add $this return type to Template::unwrap
See https://phpstan.org/writing-php-code/phpdoc-types#static-and-%24this

This way, PHPStan understands that the returned template is the exact same instance, and not just a Template.
2024-10-25 13:19:27 +02:00
Fabien Potencier 05550cafb1 minor #4410 Add return type to compiled macro (ruudk)
This PR was merged into the 3.x branch.

Discussion
----------

Add return type to compiled macro

This makes it easier for TwigStan to analyze the return type.

Commits
-------

1e7c719e24 Add return type to compiled macro
2024-10-25 08:22:06 +02:00
Fabien Potencier 89fdc7d31d Refactor code 2024-10-25 07:47:55 +02:00
Christian Flothmann 5b0209ffa3 do not drop none digit characters from generated variable names 2024-10-24 17:52:15 +02:00
Fabien Potencier 1d22d300fa Revert "feature #4409 Deprecate the range function (fabpot)"
This reverts commit 99c6fbd517, reversing
changes made to 868b429853.
2024-10-24 15:37:54 +02:00
Fabien Potencier 99c6fbd517 feature #4409 Deprecate the range function (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Deprecate the range function

Commits
-------

3d99e595c8 Deprecate the range function
2024-10-24 15:34:03 +02:00
Fabien Potencier 3d99e595c8 Deprecate the range function 2024-10-24 14:02:46 +02:00
Ruud Kamphuis 1e7c719e24 Add return type to compiled macro
This makes it easier for TwigStan to analyze the return type.
2024-10-24 13:51:09 +02:00
Ruud Kamphuis 0bb49dc40f Add return type to getDebugInfo 2024-10-24 13:37:17 +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 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 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 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 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 831e69b77e Do not allow : as macro definition separator 2024-10-14 10:42:32 +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