Commit Graph

1355 Commits

Author SHA1 Message Date
Fabien Potencier 2337c7f812 Simplify code even more 2024-11-28 14:36:54 +01:00
Fabien Potencier 02cec77619 Simplify EscaperNodeVisitor code 2024-11-28 11:53:08 +01:00
Fabien Potencier c384fb4d8c bug #4475 Fix having macro variables starting with an underscore (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Fix having macro variables starting with an underscore

Closes #4452

Commits
-------

bdb0f3c042 Fix having macro variables starting with an underscore
2024-11-26 21:41:33 +01:00
Fabien Potencier bdb0f3c042 Fix having macro variables starting with an underscore 2024-11-26 16:59:45 +01:00
Fabien Potencier 0176de0fa9 Fix CS 2024-11-26 16:57:59 +01:00
Fabien Potencier c402debcb8 Fix EscapeNodeVisitor::isSafeFor() 2024-11-25 17:27:56 +01:00
Fabien Potencier b7dfe60398 minor #4470 Simplify code (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Simplify code

The current "optimizes" the generated code when possible, but it's probably useless (and removing the code makes compilation a bit faster):

```php
// Before
yield ((a) ? ("a") : ("b"));

// After
((a) ? (yield "a") : (yield "b"));
```

Commits
-------

e39a7af56e Simplify code
2024-11-25 17:27:03 +01:00
Fabien Potencier e7e72ff090 Deprecate not passing a Source to TokenStream 2024-11-24 19:41:42 +01:00
Fabien Potencier e39a7af56e Simplify code 2024-11-23 10:51:09 +01:00
Fabien Potencier 74aff6bb38 Bump version 2024-11-23 09:08:39 +01:00
Fabien Potencier cd611c144d minor #4431 Specify allow round methods (ruudk)
This PR was merged into the 3.x branch.

Discussion
----------

Specify allow round methods

This way, PHPStan can validate invalid input.

Commits
-------

fb43e7a854 Specify allow round methods
2024-11-23 09:07:32 +01:00
Fabien Potencier c8494b8ff9 feature #4465 Forbid adding Nodes to EmptyNode (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Forbid adding Nodes to EmptyNode

Commits
-------

ff55f590e7 Forbid adding Nodes to EmptyNode
2024-11-21 21:19:17 +01:00
Ruud Kamphuis fb43e7a854 Specify allow round methods
This way, PHPStan can validate invalid input.
2024-11-21 09:11:20 +01:00
Fabien Potencier ff55f590e7 Forbid adding Nodes to EmptyNode 2024-11-21 08:47:22 +01:00
Vincent Langlet 75d48db822 Add phpstan analysis 2024-11-20 20:05:33 +01:00
Christophe Coevoet b15ba0f963 Fix the exception message to match the expected one for not ready nodes 2024-11-20 13:36:08 +01:00
Vincent Langlet 51d10ba480 Add missing import 2024-11-20 10:18:47 +01:00
Fabien Potencier 8f3f8df9cd Bump version 2024-11-17 17:00:39 +01:00
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