Commit Graph

6727 Commits

Author SHA1 Message Date
Fabien Potencier 22ff3f4f22 Merge branch '3.x' into 4.x
* 3.x:
  Fix typos in CHANGELOG
  Fix typo
  Fix some minor issues
  Add support for named arguments on special functions
2024-08-17 18:03:35 +02:00
Fabien Potencier ff55738f19 Fix typos in CHANGELOG 2024-08-17 17:59:11 +02:00
Fabien Potencier dbc934ba78 Fix typo 2024-08-17 11:28:14 +02:00
Fabien Potencier 2e43eaa4ad Fix some minor issues 2024-08-16 22:51:19 +02:00
Fabien Potencier 5a66385a3f feature #4173 Add support for named arguments on special functions (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Add support for named arguments on special functions

Commits
-------

0c30e78b Add support for named arguments on special functions
2024-08-16 22:50:11 +02:00
Fabien Potencier 0c30e78b1c Add support for named arguments on special functions 2024-08-16 08:37:24 +02:00
Fabien Potencier 5be29d0dd1 Merge branch '3.x' into 4.x
* 3.x:
  Fix missing code
2024-08-16 08:13:29 +02:00
Fabien Potencier 26bcadeaeb Fix missing code 2024-08-16 08:13:22 +02:00
Fabien Potencier d051ccde20 Merge branch '3.x' into 4.x
* 3.x:
  Throw a SyntaxError exception at compile time when a Twig callable has not the minimum number of required arguments
2024-08-16 08:12:37 +02:00
Fabien Potencier 5c52e2d361 feature #4207 Throw a SyntaxError exception at compile time when a Twig callable has not the minimum number of required arguments (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Throw a SyntaxError exception at compile time when a Twig callable has not the minimum number of required arguments

When using named arguments, a compilation error is thrown when some required arguments are missing.
But when not using arguments, the error was thrown at runtime. This PR fixed this.

Commits
-------

0823d234 Throw a SyntaxError exception at compile time when a Twig callable has not the minimum number of required arguments
2024-08-16 08:07:54 +02:00
Fabien Potencier 0823d23488 Throw a SyntaxError exception at compile time when a Twig callable has not the minimum number of required arguments 2024-08-15 23:00:02 +02:00
Fabien Potencier 4acc8b6556 Fix CS 2024-08-15 20:59:57 +02:00
Fabien Potencier a30d07eeb4 Remove obsolete code 2024-08-15 20:59:30 +02:00
Fabien Potencier 4bade436a4 Merge branch '3.x' into 4.x
* 3.x:
  Extract a new CallableArgumentsExtractor class
  Make Node::__toString() more readable
2024-08-15 20:57:57 +02:00
Fabien Potencier 55733a2da1 feature #4206 Extract a new CallableArgumentsExtractor class (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Extract a new CallableArgumentsExtractor class

Commits
-------

e1705f88 Extract a new CallableArgumentsExtractor class
2024-08-15 20:55:15 +02:00
Fabien Potencier e1705f8831 Extract a new CallableArgumentsExtractor class 2024-08-15 20:37:59 +02:00
Fabien Potencier fa1220951f minor #4205 Make Node::__toString() more readable (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Make Node::__toString() more readable

Commits
-------

b431ecad Make Node::__toString() more readable
2024-08-15 20:27:24 +02:00
Fabien Potencier 525461feb1 Fix CS 2024-08-15 20:26:39 +02:00
Fabien Potencier 62cc16f548 Merge branch '3.x' into 4.x
* 3.x:
  Remove remaining const optimizations
2024-08-15 20:26:12 +02:00
Fabien Potencier 3c7469ec09 minor #4204 Remove remaining const optimizations (smnandre)
This PR was merged into the 3.x branch.

Discussion
----------

Remove remaining const optimizations

After #4198, some Token:: constant optimizations remained.

This PR removes them.. **in case** this was not intended

Commits
-------

c662e0ce Remove remaining const optimizations
2024-08-15 20:22:54 +02:00
Fabien Potencier b431ecad3a Make Node::__toString() more readable 2024-08-15 20:18:30 +02:00
Simon André c662e0ce27 Remove remaining const optimizations
After #4198 some `Token::` const optimization remains.

This PR remove them.. **in case** it was not intended
2024-08-15 19:11:55 +02:00
Fabien Potencier 3b38f7c587 Simplify code 2024-08-14 23:45:21 +02:00
Fabien Potencier 7f45529f52 Merge branch '3.x' into 4.x
* 3.x:
  Fix RawFilter
2024-08-14 23:43:34 +02:00
Fabien Potencier 72d6d9c9c5 bug #4203 Fix RawFilter (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Fix RawFilter

Commits
-------

397b7c47 Fix RawFilter
2024-08-14 23:43:27 +02:00
Fabien Potencier 397b7c4782 Fix RawFilter 2024-08-14 23:42:25 +02:00
Fabien Potencier eaf04e53f0 Remove deprecated code 2024-08-14 23:34:13 +02:00
Fabien Potencier abee6fc583 Merge branch '3.x' into 4.x
* 3.x:
  Move FunctionExpression/FilterExpression/TestExpression attributes from compilation time to parsing time
  Cleanup the implementation of the defined test for constants
2024-08-14 23:07:43 +02:00
Fabien Potencier fb96eed2c6 feature #4184 Move FunctionExpression/FilterExpression/TestExpression attributes from compilation time to parsing time (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Move FunctionExpression/FilterExpression/TestExpression attributes from compilation time to parsing time

Closes #3895

Opened early to gather feedback.

Commits
-------

3156d809 Move FunctionExpression/FilterExpression/TestExpression attributes from compilation time to parsing time
2024-08-14 22:55:12 +02:00
Fabien Potencier 3156d8093e Move FunctionExpression/FilterExpression/TestExpression attributes from compilation time to parsing time 2024-08-14 18:45:35 +02:00
Fabien Potencier 85a5b7c2d1 minor #4202 Cleanup the implementation of the defined test for constants (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Cleanup the implementation of the defined test for constants

Let's avoid modifying the `TwigFunction`.

Commits
-------

6ecd1f13 Cleanup the implementation of the defined test for constants
2024-08-13 22:43:21 +02:00
Fabien Potencier 6ecd1f1350 Cleanup the implementation of the defined test for constants 2024-08-13 22:40:15 +02:00
Fabien Potencier 3ed166f0e4 minor #4201 Disable the drupal integration tests in the 4.x branch (stof)
This PR was merged into the 4.x branch.

Discussion
----------

Disable the drupal integration tests in the 4.x branch

Drupal uses the AbstractNodeVisitor which is deprecated in 3.x and removed in 4.x, so the job fails all the time. This should be re-enabled once Drupal can be tested against Twig 4.x.

Commits
-------

1d71e28a Disable the drupal integration tests in the 4.x branch
2024-08-13 18:39:08 +02:00
Fabien Potencier d7df8844e0 Merge branch '3.x' into 4.x
* 3.x:
  Add missing method in TwigCallableInterface
  Fix TwigCallableInterface
  Simplify code
  Make various optimization for dynamic Twig callables
2024-08-13 18:37:32 +02:00
Christophe Coevoet 1d71e28a0a Disable the drupal integration tests in the 4.x branch
Drupal uses the AbstractNodeVisitor which is deprecated in 3.x and removed in 4.x, so the job fails all the time.
This should be re-enabled once Drupal can be tested against Twig 4.x.
2024-08-13 16:39:04 +02:00
Fabien Potencier d3ab783595 Add missing method in TwigCallableInterface 2024-08-13 11:28:14 +02:00
Fabien Potencier 21df1ad782 Fix TwigCallableInterface 2024-08-12 11:03:48 +02:00
Fabien Potencier 1da763408b Simplify code 2024-08-12 10:49:48 +02:00
Fabien Potencier 66ace94b06 feature #4194 Make various optimizations for dynamic Twig callables (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Make various optimizations for dynamic Twig callables

Commits
-------

148d3e07 Make various optimization for dynamic Twig callables
2024-08-12 10:37:09 +02:00
Fabien Potencier 148d3e079d Make various optimization for dynamic Twig callables 2024-08-12 09:45:32 +02:00
Fabien Potencier c3791fe986 Merge branch '3.x' into 4.x
* 3.x:
  Remove const optimization
2024-08-12 09:43:20 +02:00
Fabien Potencier 2fa8a24e0b minor #4198 Remove const optimization (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Remove const optimization

Closes #4197

Commits
-------

cd0ac3cc Remove const optimization
2024-08-12 09:42:24 +02:00
Fabien Potencier cd0ac3cc0a Remove const optimization 2024-08-12 09:40:52 +02:00
Fabien Potencier 91f29731d4 Merge branch '3.x' into 4.x
* 3.x:
  Optimize stripcslashes
  (minor) Prefer `className` over `classname`
  Remove escape
  Deprecate unnecessary escape characters
  Micro-micro optimization
  Simplify tests
2024-08-12 09:28:43 +02:00
Fabien Potencier 93e66ad141 minor #4196 Optimize stripcslashes (ruudk)
This PR was squashed before being merged into the 3.x branch.

Discussion
----------

Optimize stripcslashes

See https://github.com/twigphp/Twig/pull/4176#issuecomment-2283168241 by `@smnandre`

```
# Old
Benchmark 1: php bench.php
  Time (mean ± σ):      1.192 s ±  0.004 s    [User: 1.163 s, System: 0.009 s]
  Range (min … max):    1.186 s …  1.198 s    10 runs

# New
Benchmark 1: php bench.php
  Time (mean ± σ):     356.5 ms ±   1.1 ms    [User: 342.0 ms, System: 7.6 ms]
  Range (min … max):   354.6 ms … 358.2 ms    10 runs
```

Using bench.php:
```php
<?php

require_once __DIR__.'/vendor/autoload.php';

$string = str_repeat("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut a tincidunt turpis. \\App\\Entity\\Product \World \065 App\#{var} \'quoted\' Donec pharetra enim quis erat pharetra, dignissim molestie erat laoreet. Vivamus auctor purus sed lorem vestibulum rhoncus.", 10);
$loader = new Twig\Loader\ArrayLoader([
    'index.twig' => <<<EOF
{{ "$string" }}
EOF
    ,
]);

$twig = new Twig\Environment($loader);

for ($i = 0; $i < 10000; $i++) {
    $twig->tokenize(new Twig\Source($twig->getLoader()->getSourceContext('index.twig')->getCode(), 'index.twig'));
}

```

Commits
-------

bc6e36de Optimize stripcslashes
2024-08-12 09:25:01 +02:00
Ruud Kamphuis bc6e36dee9 Optimize stripcslashes 2024-08-12 09:24:57 +02:00
Fabien Potencier 4e730d46ca minor #4195 (minor) Prefer className over classname (smnandre)
This PR was merged into the 3.x branch.

Discussion
----------

(minor) Prefer `className` over `classname`

For consistency with how it's written in the tested classes.

Commits
-------

03012f19 (minor) Prefer `className` over `classname`
2024-08-12 09:19:28 +02:00
Simon André 03012f190f (minor) Prefer className over classname
For consistency with how it's written in the tested classes.
2024-08-12 08:16:07 +02:00
Fabien Potencier 5541e6a6fc minor #4193 Remove escape (ruudk)
This PR was merged into the 3.x branch.

Discussion
----------

Remove escape

Interestingly this didn’t fail on the branch that introduced the change. Are we sure the integration tests work at all?

See [failing job](https://github.com/twigphp/Twig/actions/runs/10341129793) on merge to main.

Commits
-------

8ef12588 Remove escape
2024-08-11 22:46:36 +02:00
Ruud Kamphuis 8ef12588ea Remove escape 2024-08-11 18:59:31 +02:00