Commit Graph

7133 Commits

Author SHA1 Message Date
Fabien Potencier 69f8cf7092 Merge branch '3.x' into 4.x
* 3.x:
  Add missing is_iterable() checks
  Fix tests
  Add quotes on filters/functions in CoreExtension
  Use get_debug_type() everywhere
2024-09-29 18:26:00 +02:00
Fabien Potencier 3523d34b50 Add missing is_iterable() checks 2024-09-29 18:23:14 +02:00
Fabien Potencier 0f47aa7d1f Fix tests 2024-09-29 18:22:59 +02:00
Fabien Potencier bfa44742da Add quotes on filters/functions in CoreExtension 2024-09-29 18:18:48 +02:00
Fabien Potencier 5298b5598e minor #4361 Use get_debug_type() everywhere (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Use get_debug_type() everywhere

Commits
-------

0da899d911 Use get_debug_type() everywhere
2024-09-29 18:10:06 +02:00
Fabien Potencier 0da899d911 Use get_debug_type() everywhere 2024-09-29 18:08:29 +02:00
Fabien Potencier 87ebfd4142 Merge branch '3.x' into 4.x
* 3.x:
  Add an additional example in the docs
  Fix ignored parenthesis in expressions
  Tweak previous merge
  Added details in the doc of filters and functions of IntlExtension
  Add more information about the filter and the negative operators
  Update plural.rst: Fixing filter name
2024-09-29 17:54:25 +02:00
Fabien Potencier e83c3c888b Add an additional example in the docs 2024-09-29 17:54:02 +02:00
Fabien Potencier 85cbd0d7f0 minor #4360 Add more information about the filter and the negative operators (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Add more information about the filter and the negative operators

Refs #974
Refs #1368
Refs #1634
Refs #2470

Commits
-------

fae6cfc32f Add more information about the filter and the negative operators
2024-09-29 17:47:03 +02:00
Fabien Potencier c531c740f3 bug #4359 Fix ignored parenthesis in expressions (fabpot)
This PR was squashed before being merged into the 3.x branch.

Discussion
----------

Fix ignored parenthesis in expressions

Closes #3705
Closes #2891

Commits
-------

1488238e32 Fix ignored parenthesis in expressions
2024-09-28 23:47:06 +02:00
Fabien Potencier 1488238e32 Fix ignored parenthesis in expressions 2024-09-28 23:47:01 +02:00
Fabien Potencier 6d9103ec91 Tweak tests 2024-09-28 23:44:36 +02:00
Fabien Potencier 11a0f65103 Remove obsolete conditions in tests 2024-09-28 23:40:27 +02:00
Fabien Potencier 1d31ac4b77 Tweak previous merge 2024-09-28 09:57:08 +02:00
Fabien Potencier 8efdab4780 minor #3983 Added details in the doc of filters and functions of IntlExtension (FlorianChenot)
This PR was squashed before being merged into the 3.x branch.

Discussion
----------

Added details in the doc of filters and functions of IntlExtension

Commits
-------

8716392603 Added details in the doc of filters and functions of IntlExtension
2024-09-28 09:46:54 +02:00
unknown 8716392603 Added details in the doc of filters and functions of IntlExtension 2024-09-28 09:46:50 +02:00
Fabien Potencier fae6cfc32f Add more information about the filter and the negative operators 2024-09-28 09:22:47 +02:00
Fabien Potencier 10bbdd5007 minor #4358 Update plural.rst: Fixing filter name (ThomasLandauer)
This PR was merged into the 3.x branch.

Discussion
----------

Update plural.rst: Fixing filter name

Info is taken from https://github.com/twigphp/Twig/pull/4357#issuecomment-2378435199

Besides, I changed to a more illustrative example word. One of the rare cases where ChatGPT was indeed useful... ;-)

Commits
-------

bd33033fd1 Update plural.rst: Fixing filter name
2024-09-27 10:48:07 +02:00
Thomas Landauer bd33033fd1 Update plural.rst: Fixing filter name
Info is taken from https://github.com/twigphp/Twig/pull/4357#issuecomment-2378435199

Besides, I changed to a more illustrative example word. One of the rare cases where ChatGPT was indeed useful... ;-)
2024-09-27 10:46:21 +02:00
Fabien Potencier 741b79b6c2 Remove versionadded in docs 2024-09-27 08:29:00 +02:00
Fabien Potencier e8fba2d4cb Merge branch '3.x' into 4.x
* 3.x:
  Implement the `enum` function
2024-09-27 08:28:40 +02:00
Fabien Potencier f6972c42cf feature #4352 Implement the enum function (nicolas-grekas)
This PR was merged into the 3.x branch.

Discussion
----------

Implement the `enum` function

Fixes #3681
Requires #4353

Commits
-------

cff6f1ca80 Implement the `enum` function
2024-09-27 08:26:28 +02:00
Nicolas Grekas cff6f1ca80 Implement the enum function 2024-09-27 08:23:21 +02:00
Fabien Potencier 5d1334116d Remove obsolete code 2024-09-27 08:04:04 +02:00
Fabien Potencier d9eae4f3a1 Remove versionadded in docs 2024-09-27 08:03:21 +02:00
Fabien Potencier f4a596e5b0 Make Node abstract 2024-09-27 08:03:01 +02:00
Fabien Potencier 3b15ba5a4c Fix usages of Node() 2024-09-27 08:01:33 +02:00
Fabien Potencier 0c6bd47d6b Merge branch '3.x' into 4.x
* 3.x:
  Deprecate using Node directly, introduce EmptyNode and Nodes
  Add support for inline comments
  Update plural.rst: Fixing(?) broken links
  Fix CS
  Add support for accessing class constants with the dot operator
  Fix getting a property on an object casted to an array
  Replace strtr() by strtolower()
  Improve escape deprecation message
  Remove useless assign in compiled code
  Add fixture filename as key
  Be more precise about double-escaping
  Fix template name in error for an unknown dynamic extends called from an include
2024-09-27 07:59:52 +02:00
Fabien Potencier faf8471d47 feature #4335 Deprecate instantiating Node directly, introduce EmptyNode and Nodes (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Deprecate instantiating Node directly, introduce EmptyNode and Nodes

Based on some comments from `@stof`:

See https://github.com/twigphp/Twig/pull/4292#discussion_r1751651242
See https://github.com/twigphp/Twig/pull/4333#discussion_r1773531733

First interesting usage here: 65ee72a71f60c3680c2aceef7b9932cee7f84e89

Commits
-------

8b278986b8 Deprecate using Node directly, introduce EmptyNode and Nodes
2024-09-27 07:43:50 +02:00
Fabien Potencier 8b278986b8 Deprecate using Node directly, introduce EmptyNode and Nodes 2024-09-27 07:42:41 +02:00
Fabien Potencier a1daf1e551 minor #4357 Update plural.rst: Fixing(?) broken links (ThomasLandauer)
This PR was merged into the 3.x branch.

Discussion
----------

Update plural.rst: Fixing(?) broken links

More important question: Is the filter's name `plural` or `pluralize`??

Commits
-------

cc3a2b7bac Update plural.rst: Fixing(?) broken links
2024-09-27 07:34:31 +02:00
Fabien Potencier 1e4ceff2a8 feature #4349 Add support for inline comments (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Add support for inline comments

Closes #4001

Commits
-------

d9d8bb0df3 Add support for inline comments
2024-09-27 07:32:40 +02:00
Fabien Potencier d9d8bb0df3 Add support for inline comments 2024-09-27 07:32:09 +02:00
Fabien Potencier 61766f4d9a minor #4356 Add generics for LoopIterator (ruudk)
This PR was merged into the 4.x branch.

Discussion
----------

 Add generics for LoopIterator

/cc `@stof`

Commits
-------

a4dc388c62  Add generics for LoopIterator
2024-09-27 07:26:01 +02:00
Thomas Landauer cc3a2b7bac Update plural.rst: Fixing(?) broken links
More important question: Is the filter's name `plural` or `pluralize`??
2024-09-27 01:23:50 +02:00
Fabien Potencier a23cd9feeb Fix CS 2024-09-26 21:22:23 +02:00
Fabien Potencier f4b17ce8fa bug #4336 Fix template name in error for an unknown dynamic extends called from an include (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Fix template name in error for an unknown dynamic extends called from an include

Closes #3265

The code was introduced in #1529, but removing it nowadays does not break any existing test.

Review ignoring whitespace.

Commits
-------

4824f2a4a3 Fix template name in error for an unknown dynamic extends called from an include
2024-09-26 20:59:11 +02:00
Fabien Potencier b843e780bc minor #4355 Simplify compiled for loop code (ruudk)
This PR was squashed before being merged into the 4.x branch.

Discussion
----------

Simplify compiled `for` loop code

**Do not pass closure as reference**
It's not needed.

**Do not use same var names in loop function**
These variables are passed in when the loop function is invoked when yielding.
Giving them the same internal var names complicates things for no good reason.

Commits
-------

a096c202e3 Do not use same var names in loop function
fcb16a0f86 Do not pass closure as reference
2024-09-26 20:43:38 +02:00
Fabien Potencier 57147e7513 feature #4353 Add support for accessing class constants with the dot operator (nicolas-grekas)
This PR was merged into the 3.x branch.

Discussion
----------

Add support for accessing class constants with the dot operator

This PR allows accessing class constants from objects: `{{ foo.SOME_CONSTANT }}`. This should nicely replace the `constant()` function when an object is at hand, and is actually needed to make the `enum` function work in #4352.

Commits
-------

1ea0452323 Add support for accessing class constants with the dot operator
2024-09-26 20:37:32 +02:00
Fabien Potencier 5038a30c72 bug #4351 Fix getting a property on an object casted to an array (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Fix getting a property on an object casted to an array

Closes #3371

Commits
-------

7d5269e100 Fix getting a property on an object casted to an array
2024-09-26 20:35:25 +02:00
Fabien Potencier 63a04d8ab7 minor #4350 Replace strtr() by strtolower() (nicolas-grekas)
This PR was merged into the 3.x branch.

Discussion
----------

Replace strtr() by strtolower()

The performance of `strtolower()` has been fixed in PHP 8.

Commits
-------

04471ab8cd Replace strtr() by strtolower()
2024-09-26 20:34:22 +02:00
Ruud Kamphuis a4dc388c62 Add generics for LoopIterator
This makes it possible for PHPStan to understand what happens when iterating.
2024-09-26 20:21:01 +02:00
Ruud Kamphuis a096c202e3 Do not use same var names in loop function
These variables are passed in when the loop function is invoked when yielding.
Giving them the same internal var names complicates things for no good reason.
2024-09-26 19:36:47 +02:00
Ruud Kamphuis fcb16a0f86 Do not pass closure as reference
It's not needed.
2024-09-26 19:23:18 +02:00
Nicolas Grekas 1ea0452323 Add support for accessing class constants with the dot operator 2024-09-26 18:06:21 +02:00
Fabien Potencier 7d5269e100 Fix getting a property on an object casted to an array 2024-09-26 17:55:00 +02:00
Nicolas Grekas 04471ab8cd Replace strtr() by strtolower() 2024-09-26 17:48:39 +02:00
Fabien Potencier 355a80c5df minor #4347 Remove useless Closure::bind in for loop (ruudk)
This PR was merged into the 4.x branch.

Discussion
----------

Remove useless Closure::bind in for loop

This has no effect. The returned value is not used.

https://www.php.net/manual/en/closure.bind.php

Commits
-------

c48aa4649f Remove useless Closure::bind in for loop
2024-09-26 16:12:10 +02:00
Fabien Potencier 0123d22968 minor #4348 Replace return; yield with yield from [] (ruudk)
This PR was merged into the 4.x branch.

Discussion
----------

Replace `return; yield` with yield from `[]`

See #4259

Commits
-------

317c69d0ff Replace `return; yield` with yield from `[]`
2024-09-26 16:11:17 +02:00
Ruud Kamphuis 317c69d0ff Replace return; yield with yield from []
See #4259
2024-09-26 16:07:09 +02:00