Commit Graph

6998 Commits

Author SHA1 Message Date
Fabien Potencier 57bf519af2 minor #4492 fix version numbers for deprecations (xabbuh)
This PR was merged into the 3.x branch.

Discussion
----------

fix version numbers for deprecations

#4482 was merged after the release of 3.16.0

Commits
-------

f90105d0ac fix version numbers for deprecations
2024-12-02 10:21:10 +01:00
Christian Flothmann f90105d0ac fix version numbers for deprecations 2024-12-02 10:21:03 +01:00
Fabien Potencier e1a5aa175e minor #4493 Require "erusev/parsedown": "dev-master as 1.x-dev" (nicolas-grekas)
This PR was merged into the 3.x branch.

Discussion
----------

Require "erusev/parsedown": "dev-master as 1.x-dev"

Should fix the CI until https://github.com/erusev/parsedown/pull/891 is merged.

Commits
-------

5287da57cc Require "erusev/parsedown": "dev-master as 1.x-dev"
2024-12-02 10:19:22 +01:00
Nicolas Grekas 5287da57cc Require "erusev/parsedown": "dev-master as 1.x-dev" 2024-12-02 09:57:02 +01:00
Fabien Potencier d894f92d12 feature #4487 Support underscores in number literals (smnandre)
This PR was squashed before being merged into the 3.x branch.

Discussion
----------

Support underscores in number literals

```twig
{{ 1000 == 1_000 ? 'yes' : 'no' }}
# now: syntax error
# this PR: "yes"
```

> As of PHP 7.4.0, integer literals may contain underscores (_) between digits, for better readability of literals. These underscores are removed by PHP's scanner.

https://www.php.net/manual/en/language.types.integer.php

This PR replicates that behaviour, using the regexp to match the literals and then remove the "_".

I'm targeting **Twig4** but maybe 3.x would be ok?

I cannot think of a real case that
- does not trigger an error currently
- would work differently after this PR

Commits
-------

da4d96692a Support underscores in number literals
2024-12-02 09:47:00 +01:00
Simon André da4d96692a Support underscores in number literals 2024-12-02 09:46:54 +01:00
Fabien Potencier 6cc64f2357 minor #4489 Remove deprecate usage of AssignNameExpression in For Node (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Remove deprecate usage of AssignNameExpression in For Node

Commits
-------

616cd06914 Remove deprecate usage of AssignNameExpression in For Node
2024-12-01 14:37:18 +01:00
Fabien Potencier 616cd06914 Remove deprecate usage of AssignNameExpression in For Node 2024-12-01 10:44:44 +01:00
Fabien Potencier c5ebc12cde minor #4488 Update coding standards (VincentLanglet)
This PR was squashed before being merged into the 3.x branch.

Discussion
----------

Update coding standards

Commits
-------

07a4ed17d2 Update coding standards
2024-11-30 10:52:06 +01:00
Vincent Langlet 07a4ed17d2 Update coding standards 2024-11-30 10:52:04 +01:00
Fabien Potencier 14fc89ebea Fix CS 2024-11-30 09:42:13 +01:00
Fabien Potencier 44516133e2 Fix CS 2024-11-30 09:33:57 +01:00
Fabien Potencier f0066c8682 minor #4474 Add more coding standard rules (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Add more coding standard rules

Commits
-------

c96aefdf04 Add more coding standard rules
2024-11-30 09:31:25 +01:00
Fabien Potencier 101d181cc1 minor #4486 Use [] instead of array() to represent a constant value in compiled code (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Use [] instead of array() to represent a constant value in compiled code

Commits
-------

49f384f107 Use [] instead of array() to represent a constant value in compiled code
2024-11-30 09:30:56 +01:00
Fabien Potencier 49f384f107 Use [] instead of array() to represent a constant value in compiled code 2024-11-29 21:57:12 +01:00
Fabien Potencier c96aefdf04 Add more coding standard rules 2024-11-29 21:26:34 +01:00
Fabien Potencier 3eed037eed minor #4485 Update phpdoc for operators (VincentLanglet)
This PR was merged into the 3.x branch.

Discussion
----------

Update phpdoc for operators

Commits
-------

fab565ca34 Update phpdoc for operators
2024-11-29 21:19:27 +01:00
Vincent Langlet fab565ca34 Update phpdoc for operators 2024-11-29 19:30:47 +01:00
Fabien Potencier d1d8e3c62a feature #4482 Enforce AbstractBinary for all binary operators (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Enforce AbstractBinary for all binary operators

Commits
-------

4f8ba93600 Enforce AbstractBinary for all binary operators
2024-11-29 19:21:56 +01:00
Fabien Potencier 4f8ba93600 Enforce AbstractBinary for all binary operators 2024-11-29 16:51:09 +01:00
Fabien Potencier 4e1cbc74ef Fix CHANGELOG 2024-11-29 09:29:04 +01:00
Fabien Potencier 5307894b0c Bump version 2024-11-29 09:28:25 +01:00
Fabien Potencier 475ad2dc97 Prepare the 3.16.0 release v3.16.0 2024-11-29 09:27:05 +01:00
Fabien Potencier ef3dbab6b1 minor #4481 Simplify code even more (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Simplify code even more

More simplifications

Commits
-------

2337c7f812 Simplify code even more
2024-11-28 16:07:17 +01:00
Fabien Potencier 2337c7f812 Simplify code even more 2024-11-28 14:36:54 +01:00
Fabien Potencier ae82e8bd0d feature #4479 Simplify EscaperNodeVisitor code (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Simplify EscaperNodeVisitor code

This PR simplifies how we escape the ternary operator, and simplifies the whole strategy.
Instead of replacing the `PrintNode`s, we instead "just" wrap the inner expressions.

For the ternary operator, the `InlinePrint` expression is useless and even weird as printing something in the middle of an expression looks very wrong. This is not done anymore and the node is deprecated.

Overall, this PR makes fewer changes to the Node tree which should make things use a bit less memory.

Commits
-------

02cec77619 Simplify EscaperNodeVisitor code
2024-11-28 12:30:00 +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 b08968fecf feature #4469 Fix SafeAnalysisNodeVisitor::getSafe() return value (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Fix SafeAnalysisNodeVisitor::getSafe() return value

`SafeAnalysisNodeVisitor::getSafe()` can return `[]` or `null`. Both mean the same thing, but `null` is partially supported as `EscaperNodeVisitor` does not support `null` everywhere (as the node visitor never set `safe` to `null`). But a third party might return `null`. This PR makes the code more robust by deprecating using `null`.

Commits
-------

c402debcb8 Fix EscapeNodeVisitor::isSafeFor()
2024-11-25 17:28:02 +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 c0689e3e68 feature #4471 Deprecate not passing a Source to TokenStream (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Deprecate not passing a Source to TokenStream

Closes #4457

Commits
-------

e7e72ff090 Deprecate not passing a Source to TokenStream
2024-11-25 09:23:53 +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 a4a11ca90f minor #4447 Clarify documentation for escape filter (dmjohnsson23)
This PR was merged into the 3.x branch.

Discussion
----------

Clarify documentation for escape filter

It was somewhat unclear from the documentation what the intended purpose of the 'js' escape strategy is. I wasn't certain *where* exactly in JavaScript such strings were intended to be output. Someone (by that I mean me--though maybe I'm just an idiot...) might inadvertently think the filter was meant to be used somewhere in actual JavaScript code, rather than simply in strings.

Commits
-------

728b361e9d Clarify documentation for escape filter
2024-11-22 11:54:36 +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 2dfc9f3751 minor #4455 Simplify enum usage in docs (ruudk)
This PR was squashed before being merged into the 3.x branch.

Discussion
----------

Simplify enum usage in docs

There is no need to use `()`.

Commits
-------

7556fe1c6f Simplify enum usage in docs
2024-11-21 09:11:13 +01:00
Ruud Kamphuis 7556fe1c6f Simplify enum usage in docs 2024-11-21 09:11:11 +01:00
Fabien Potencier ff55f590e7 Forbid adding Nodes to EmptyNode 2024-11-21 08:47:22 +01:00
Fabien Potencier 679e41394a feature #4458 Add phpstan analysis (VincentLanglet)
This PR was squashed before being merged into the 3.x branch.

Discussion
----------

Add phpstan analysis

As suggested by `@ruudk` here: https://github.com/twigphp/Twig/pull/4456#issuecomment-2488087625
I think it could be useful to add phpstan analysis on twig.

This is an example of all the things reported when checking level 3 PHPStan (more will get more errors to fix).

Commits
-------

75d48db822 Add phpstan analysis
2024-11-20 20:05:36 +01:00
Vincent Langlet 75d48db822 Add phpstan analysis 2024-11-20 20:05:33 +01:00
Fabien Potencier 8c91bd7093 minor #4461 Fix the intl-extra tests (stof)
This PR was merged into the 3.x branch.

Discussion
----------

Fix the intl-extra tests

symfony/intl has updated its data from ICU 75.1 to ICU 76.1, which includes new currency and scripts.

Commits
-------

d69c66643f Fix the intl-extra tests
2024-11-20 17:23:39 +01:00
Fabien Potencier 21c40ea2fb minor #4460 Fix the string-extra tests when running with older symfony/string (stof)
This PR was merged into the 3.x branch.

Discussion
----------

Fix the string-extra tests when running with older symfony/string

My review comment in https://github.com/twigphp/Twig/pull/4426#discussion_r1822452803 was not taken into account to handle the case of using a version of `symfony/string` without the SpanishInflector, and the PR was merged with broken tests.

Commits
-------

abc34bd263 Fix the string-extra tests when running with older symfony/string
2024-11-20 17:23:12 +01:00
Fabien Potencier 4d3ee19d22 bug #4459 Fix the exception message to match the expected one for not ready nodes (stof)
This PR was merged into the 3.x branch.

Discussion
----------

Fix the exception message to match the expected one for not ready nodes

This fixes the tests that got broken in https://github.com/twigphp/Twig/pull/4446 because that PR updated the expected message to include the FQCN of the attribute for both the deprecation and the exception, but forgot to use the FQCN in the actual exception.

Commits
-------

b15ba0f963 Fix the exception message to match the expected one for not ready nodes
2024-11-20 17:22:27 +01:00
Christophe Coevoet d69c66643f Fix the intl-extra tests
symfony/intl has updated its data from ICU 75.1 to ICU 76.1, which
includes new currency and scripts.
2024-11-20 14:19:52 +01:00