Commit Graph

6852 Commits

Author SHA1 Message Date
Fabien Potencier cdd35adcec feature #4251 Add back the if condition on for loops (fabpot)
This PR was merged into the 4.x branch.

Discussion
----------

Add back the if condition on for loops

Now that the `for` tag implementation has been improved, I think we can add back the `if` condition on `for` loops.

Commits
-------

47d745b7 Add back the if condition on for loops
2024-08-29 10:03:09 +02:00
Fabien Potencier 47d745b7ed Add back the if condition on for loops 2024-08-28 22:14:47 +02:00
Fabien Potencier 4b671fa38d Fix typo 2024-08-28 22:03:32 +02:00
Fabien Potencier 38082c67b1 Fix CS 2024-08-28 22:02:38 +02:00
Fabien Potencier e4c9d7aff6 Merge branch '3.x' into 4.x
* 3.x:
  Only unset loop when with_loop
2024-08-28 16:14:26 +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 08281273a0 Remove deprecated code 2024-08-28 15:24:00 +02:00
Fabien Potencier 4fa4254a54 Merge branch '3.x' into 4.x
* 3.x:
  deprecate passing a tag to ImportNode
  fix typo
2024-08-28 15:23:30 +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 7cfcefcaef Remove deprecated code 2024-08-28 14:01:55 +02:00
Fabien Potencier e2f0128774 Merge branch '3.x' into 4.x
* 3.x:
  Deprecate the fact that the `extends` and `use` tags are always allowed in a sandboxed template
  Clarify block function
2024-08-28 13:56:42 +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 6d97dc9cf3 Merge branch '3.x' into 4.x
* 3.x:
  Fix CoreExtension::captureOutput
2024-08-27 16:11:14 +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 7c2f55b3d2 Merge branch '3.x' into 4.x
* 3.x:
  Mark implicit macro argument default values as such with an attribute in AST
2024-08-27 13:22:48 +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 76ed01d48a Merge branch '3.x' into 4.x
* 3.x:
  Fix CS
  Fix two-word tests precedence over one-word tests
2024-08-27 13:19:46 +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 fee3b221e9 Merge branch '3.x' into 4.x
* 3.x:
  Use Stringable when possible
2024-08-26 17:46:36 +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 44d0a26807 Remove the spaceless filter 2024-08-26 17:45:00 +02:00
Fabien Potencier 3f42d4e41f Merge branch '3.x' into 4.x
* 3.x:
  Fix tests
  Deprecate the spaceless filter
2024-08-26 17:43:29 +02:00
Fabien Potencier 11813da84d Use Stringable when possible 2024-08-26 17:41:21 +02:00
Fabien Potencier 303e3ea9d6 minor #4240 Fix tests (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Fix tests

Commits
-------

2511b658 Fix tests
2024-08-26 17:41:05 +02:00
Fabien Potencier 2511b658da Fix tests 2024-08-26 17:29:01 +02:00
Fabien Potencier 40bd341c29 minor #4234 Use proper node names when they are integers (fabpot)
This PR was merged into the 4.x branch.

Discussion
----------

Use proper node names when they are integers

Commits
-------

cde9e7dc Use proper node names when they are integers
2024-08-26 17:03:05 +02:00
Fabien Potencier 98a8210e25 feature #4236 Deprecate the spaceless filter (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Deprecate the spaceless filter

Closes #3576

Deprecate the `spaceless` filter for the following reasons:

* The performance is bad (as the work is done at runtime via a regexp)
* Optimizing the size of an HTML doc server side is "almost never" a good idea (compression is better and enough)
* There are some edge cases where you want to keep some spaces (see #3576)
* Controlling whitespace is possible and fine-grained via the dedicated Twig modifiers on `{{ }}`

If someone find it useful, re-creating it is trivial (`return trim(preg_replace('/>\s+</', '><', $content ?? ''));`),
but with so many caveats and not so many use cases, I think it does not belong to core.

Commits
-------

9fd4c487 Deprecate the spaceless filter
2024-08-26 17:00:09 +02:00
Fabien Potencier 9fd4c487e7 Deprecate the spaceless filter 2024-08-26 16:25:20 +02:00
Fabien Potencier cde9e7dcd4 Use proper node names when they are integers 2024-08-26 09:59:54 +02:00
Fabien Potencier 4696eeba1d Remove deprecated code 2024-08-26 09:30:21 +02:00
Fabien Potencier d1f9097c7b Merge branch '3.x' into 4.x
* 3.x:
  Deprecate some internal methods from Parser
  Move code from ExtendsTokenParser to Parser
  Update Node::__toString() to include the node tag if set
  Fix class name
  Fix error message
2024-08-26 09:28:17 +02:00
Fabien Potencier 727cbe9a39 feature #4232 Deprecate some internal methods from Parser (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Deprecate some internal methods from Parser

Commits
-------

9e6c4a6a Deprecate some internal methods from Parser
2024-08-26 09:27:11 +02:00
Fabien Potencier 9e6c4a6ac1 Deprecate some internal methods from Parser 2024-08-26 09:24:03 +02:00
Fabien Potencier a8c5100e45 minor #4230 Move code from ExtendsTokenParser to Parser (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Move code from ExtendsTokenParser to Parser

Commits
-------

cf472760 Move code from ExtendsTokenParser to Parser
2024-08-26 07:57:31 +02:00
Fabien Potencier cf4727606a Move code from ExtendsTokenParser to Parser 2024-08-26 07:56:37 +02:00
Fabien Potencier e2f3435c81 feature #4229 Update Node::__toString() to include the node tag if set (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Update Node::__toString() to include the node tag if set

Commits
-------

157d36ae Update Node::__toString() to include the node tag if set
2024-08-24 17:34:12 +02:00
Fabien Potencier 157d36ae43 Update Node::__toString() to include the node tag if set 2024-08-24 17:28:38 +02:00
Fabien Potencier 4b99692e2a Fix class name 2024-08-24 17:12:56 +02:00
Fabien Potencier 758be4dde3 Fix error message 2024-08-24 12:57:39 +02:00