Commit Graph

6632 Commits

Author SHA1 Message Date
Fabien Potencier 6b37522774 minor #4264 Fix MacroTest (derrabus)
This PR was merged into the 3.x branch.

Discussion
----------

Fix MacroTest

Because of a typo in a variable name, `MacroTest` was never executed. This PR fixes the typo and adjusts the expected compiled PHP code, assuming that the current behavior is correct.

Commits
-------

1e5dea44 Fix MacroTest
2024-09-02 19:26:05 +02:00
Alexander M. Turek 1e5dea44f9 Fix MacroTest 2024-09-02 18:57:57 +02:00
Fabien Potencier 54590ec86b minor #4258 Allow extra extensions to use Twig 4 (on 3.x) (fabpot)
This PR was squashed before being merged into the 3.x branch.

Discussion
----------

Allow extra extensions to use Twig 4 (on 3.x)

Commits
-------

976cea04 Fix tests
031c7bda Allow extra extensions to use Twig 4
2024-09-01 22:59:50 +02:00
Fabien Potencier 976cea0403 Fix tests 2024-09-01 22:54:59 +02:00
Fabien Potencier 031c7bda4d Allow extra extensions to use Twig 4 2024-09-01 22:39:12 +02:00
Fabien Potencier d55f7adcbe minor #4257 Only unset _iterated when there is an else node (ruudk)
This PR was merged into the 3.x branch.

Discussion
----------

Only unset `_iterated` when there is an `else` node

Same as #4249

Even though PHP does not complain, PHPStan does.
> Cannot unset offset '_iterated' 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
-------

a16910e1 Only unset `_iterated` when there is an `else` node
2024-09-01 09:43:32 +02:00
Ruud Kamphuis a16910e14d Only unset _iterated when there is an else node
Same as #4249

Even though PHP does not complain, PHPStan does.
> Cannot unset offset '_iterated' on array{ ... the context values ... }

Since this is compiled code, we can easily produce a bit more valid code in the eyes of PHPStan.
2024-09-01 08:53:55 +02:00
Fabien Potencier a39b6e164c minor #4241 Adjust cycle implementation (smnandre)
This PR was squashed before being merged into the 3.x branch.

Discussion
----------

Adjust `cycle` implementation

Update code following [#4158](https://github.com/twigphp/Twig/issues/4158)
* return mixed
* trigger when non countable
* type the position argument

Add doc precisions

Commits
-------

7c3c1615 Adjust `cycle` implementation
2024-08-30 20:43:09 +02:00
Simon André 7c3c16154e Adjust cycle implementation 2024-08-30 20:43:06 +02:00
Fabien Potencier 938ee704b4 Fix CS 2024-08-30 16:22:35 +02:00
Fabien Potencier 375b477cb4 minor #4255 Add more types to Template class and compiled templates (ruudk)
This PR was squashed before being merged into the 3.x branch.

Discussion
----------

Add more types to Template class and compiled templates

Similar to https://github.com/twigphp/Twig/pull/4250.

Commits
-------

7e52a680 Add more types to Template class and compiled templates
2024-08-30 16:17:58 +02:00
Ruud Kamphuis 7e52a68097 Add more types to Template class and compiled templates 2024-08-30 16:17:55 +02:00
Fabien Potencier 22abdfafae Remove unneeded whitespace 2024-08-30 12:44:06 +02:00
Fabien Potencier 2efb955ab5 Remove unneeded whitespace 2024-08-30 12:41:04 +02:00
Fabien Potencier 08a571753b minor #4253 Document how to iterate over a string (fabpot)
This PR was squashed before being merged into the 3.x branch.

Discussion
----------

Document how to iterate over a string

Commits
-------

2f8c6218 Fix doc markup
a68804d6 Add an example on how to iterate over a string
2024-08-30 11:46:47 +02:00
Fabien Potencier 2f8c621898 Fix doc markup 2024-08-30 11:43:48 +02:00
Fabien Potencier a68804d614 Add an example on how to iterate over a string 2024-08-30 11:23:14 +02:00
Fabien Potencier 18b4ceb987 minor #4254 Remove NodeCaptureInterface from TypesNode (ruudk)
This PR was merged into the 3.x branch.

Discussion
----------

Remove NodeCaptureInterface from TypesNode

This was accidentally copied from SetNode

Commits
-------

5e3f9d9f Remove NodeCaptureInterface from TypesNode
2024-08-29 20:08:45 +02:00
Ruud Kamphuis 5e3f9d9f26 Remove NodeCaptureInterface from TypesNode
This was accidentally copied from SetNode
2024-08-29 19:39:20 +02:00
Fabien Potencier 70b912fa10 minor #4228 Use CPP in full code base (andreybolonin)
This PR was squashed before being merged into the 3.x branch.

Discussion
----------

Use CPP in full code base

Commits
-------

28923f42 Use CPP in full code base
2024-08-29 19:29:42 +02:00
andreybolonin1989@gmail.com 28923f4269 Use CPP in full code base 2024-08-29 19:29:39 +02:00
Fabien Potencier 8aedebee29 feature #4235 Add types tag (drjayvee)
This PR was squashed before being merged into the 3.x branch.

Discussion
----------

Add types tag

The is a draft implementation for #4165.

Commits
-------

67dabd81 Add types tag
2024-08-29 19:26:49 +02:00
Jeroen Versteeg 67dabd8182 Add types tag 2024-08-29 19:26:49 +02:00
Fabien Potencier 9120e9f3d1 Bump version 2024-08-29 16:16:01 +02:00
Fabien Potencier edcea8bce0 Bump version 2024-08-29 11:53:10 +02:00
Fabien Potencier 4d19472d4a Prepare the 3.12.0 release v3.12.0 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
Fabien Potencier bd48875bbb minor #4246 fix typo (xabbuh)
This PR was merged into the 3.x branch.

Discussion
----------

fix typo

Commits
-------

8663ec24 fix typo
2024-08-28 15:20:39 +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 d379eef2aa feature #4244 Deprecate the fact that the extends and use tags are always allowed in a sandboxed template (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Deprecate the fact that the `extends` and `use` tags are always allowed in a sandboxed template

Commits
-------

5fca700c Deprecate the fact that the `extends` and `use` tags are always allowed in a sandboxed template
2024-08-28 13:46:49 +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
Fabien Potencier df63bead99 minor #4243 Clarify block function (ruudk)
This PR was merged into the 3.x branch.

Discussion
----------

Clarify block function

It actually renders the block again.

Commits
-------

8c3df0c0 Clarify block function
2024-08-28 08:24:18 +02:00
Ruud Kamphuis 8c3df0c0bc Clarify block function
It actually renders the block again.
2024-08-28 08:20:39 +02:00
Fabien Potencier f9b7e815b0 bug #4242 Fix CoreExtension::captureOutput (nicolas-grekas)
This PR was merged into the 3.x branch.

Discussion
----------

Fix CoreExtension::captureOutput

Fix #4146

I forgot these lines in #4216

Commits
-------

7ba68667 Fix CoreExtension::captureOutput
2024-08-27 16:10:32 +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 7e7808d56e bug #4237 Fix two-word tests precedence over one-word tests (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Fix two-word tests precedence over one-word tests

Closes #3282

Commits
-------

58d5780e Fix two-word tests precedence over one-word tests
2024-08-26 17:47:48 +02:00
Fabien Potencier 58d5780ef3 Fix two-word tests precedence over one-word tests 2024-08-26 17:47:41 +02:00
Fabien Potencier 220b95c080 minor #4239 Use Stringable when possible (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Use Stringable when possible

Commits
-------

11813da8 Use Stringable when possible
2024-08-26 17:46:18 +02:00
Fabien Potencier 11813da84d Use Stringable when possible 2024-08-26 17:41:21 +02:00