Commit Graph

293 Commits

Author SHA1 Message Date
Fabien Potencier 151aa4ecda Fix CS 2025-02-14 12:57:03 +01:00
Fabien Potencier 3964aeba78 Add a proper prefix spread operator 2025-02-14 11:45:39 +01:00
Fabien Potencier 8ff19090f3 Fix precedence rules 2025-02-14 08:38:53 +01:00
Fabien Potencier f67078b5c4 Move Operators to ExpressionParsers, deprecate ExpressionParser 2025-02-14 08:38:53 +01:00
Fabien Potencier 42c82e1e9b Extract operators logic from ExpressionParser to their own classes 2025-02-14 08:38:53 +01:00
Fabien Potencier df877a1d53 Introduce operator classes to describe operators provided by extensions instead of arrays 2025-02-14 08:38:53 +01:00
Fabien Potencier fab1a37d8e bug #4546 Fix timezone conversion on strings (PrinsFrank)
This PR was squashed before being merged into the 3.x branch.

Discussion
----------

Fix timezone conversion on strings

When setting a default application timezone, and a display timezone:
```php
date_default_timezone_set('UTC');
$twig->getExtension(\Twig\Extension\CoreExtension::class)->setTimezone('Europe/Paris');
```

Date objects get converted, but strings don't. See #4545.

For most other paths in `convertDate`, the dateTime object is initialized, and afterwards the timezone gets set. For strings, the timezone is passed as a constructor argument before having the timezone set again, losing its converting behaviour. This makes the convertDate method work identical for DateTime objects as strings. This different behaviour was already spotted in #3568.

Fixes #4545 #3568 #2819

Commits
-------

f69531fa00 Fix timezone conversion on strings
2025-02-07 22:52:13 +01:00
PrinsFrank f69531fa00 Fix timezone conversion on strings 2025-02-07 22:52:10 +01:00
Nicolas Grekas 1d5180549f Ignore static properties when using the dot operator 2025-01-22 09:18:31 +01:00
Fabien Potencier 76062c8d51 Fix CS 2025-01-19 16:54:05 +01:00
Lorenz edecc13f08 typehint instead of checkArrow 2025-01-12 18:44:45 +01:00
Lorenz f27115857d checkArrow, typehints 2025-01-12 18:44:45 +01:00
Lorenz 8b432758f6 invoke filter 2025-01-12 18:44:45 +01:00
Faizan Akram 0a61801d9a adds support for invoking closures 2024-12-14 20:06:34 +01:00
Fabien Potencier 1af334be89 Fix the Elvis operator when there is some space between ? and : 2024-12-11 10:38:21 +01:00
Gregor Harlan 32a75b7869 Fix ArrayAccess with objects as keys 2024-12-05 12:31:45 +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 4f8ba93600 Enforce AbstractBinary for all binary operators 2024-11-29 16:51:09 +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 5b380e5b3b minor #4435 Fix wrong type for cycle position (ruudk)
This PR was merged into the 3.x branch.

Discussion
----------

Fix wrong type for cycle position

It also accepts 0, which is not a positive int.

Commits
-------

c78499bda9 Fix wrong type for cycle position
2024-11-07 18:02:41 +01:00
Fabien Potencier 8f1ae67b73 minor #4421 Add type for join method (ruudk)
This PR was merged into the 3.x branch.

Discussion
----------

Add type for join method

Looking at the code, this method is very forgiving in what it accepts.

This helps PHPStan to not complain when something other than an array is passed.

Did I miss other types?

/cc `@stof`

Commits
-------

226f0ff0dd Add type for join method
2024-11-07 18:02:05 +01:00
Nicolas Grekas 5cd1ff1977 Rely on reflection to access null properties 2024-11-07 11:23:04 +01:00
Nicolas Grekas d72ae2447e Merge branch '3.14.x' into 3.x
* 3.14.x:
  Improve detection of recursion
  Fix recursion when arrays contain self-references in sandboxed mode
  Fix code
  Prepare the 3.11.2 release
  Update CHANGELOG
  Sandbox ArrayAccess and do sandbox checks before isset() checks
  Fix sandbox handling for __toString()
  Prepare the 3.14.1 release
  Update CHANGELOG
  Sandbox ArrayAccess and do sandbox checks before isset() checks
  Fix sandbox handling for __toString()
  Prepare the 3.11.1 release
  Fix a security issue when an included sandboxed template has been loaded before without the sandbox context
2024-11-07 11:17:57 +01:00
Fabien Potencier 32e99c263d Remove obsolete code 2024-11-06 21:45:08 +01:00
Nicolas Grekas b957e5a44c Sandbox ArrayAccess and do sandbox checks before isset() checks 2024-11-06 21:41:25 +01:00
Nicolas Grekas 831c148e78 Sandbox ArrayAccess and do sandbox checks before isset() checks 2024-11-06 19:16:07 +01:00
Ruud Kamphuis c78499bda9 Fix wrong type for cycle position
It also accepts 0, which is not a positive int.
2024-11-04 11:31:38 +01:00
Ruud Kamphuis 226f0ff0dd Add type for join method
Looking at the code, this method is very forgiving in what it accepts.
2024-10-30 15:44:01 +01:00
Fabien Potencier 1d22d300fa Revert "feature #4409 Deprecate the range function (fabpot)"
This reverts commit 99c6fbd517, reversing
changes made to 868b429853.
2024-10-24 15:37:54 +02:00
Fabien Potencier 3d99e595c8 Deprecate the range function 2024-10-24 14:02:46 +02:00
Fabien Potencier 72693884c4 Simplify code 2024-10-21 07:20:17 +02:00
Fabien Potencier 1105964873 Rework macros handling 2024-10-20 21:53:20 +02:00
Fabien Potencier 62f0a96b68 Introduce a way to test Twig callables at compile time 2024-10-08 18:41:34 +02:00
Fabien Potencier 5e9448310d Deprecate passing a string or an array to Twig callable arguments accepting arrow functions (pass a Closure) 2024-10-04 18:51:37 +02:00
Fabien Potencier 247658c730 feature #4367 Trigger deprecations when using "??" and "not" without explicit parentheses when precedence will change in 4.0 (fabpot)
This PR was squashed before being merged into the 3.x branch.

Discussion
----------

Trigger deprecations when using "??" and "not" without explicit parentheses when precedence will change in 4.0

Closes #3387
Closes #3642

Commits
-------

2081b1ff74 Deprecate using the not unary operator without parenthesis
f4aacafd78 Deprecate using ?? without explicit parentheses
2024-10-02 14:17:10 +02:00
Fabien Potencier 2081b1ff74 Deprecate using the not unary operator without parenthesis 2024-10-02 14:16:34 +02:00
Fabien Potencier f4aacafd78 Deprecate using ?? without explicit parentheses 2024-10-01 21:58:05 +02:00
HypeMC 8893944e0c Add support for logical xor operator 2024-10-01 20:43:59 +02:00
Fabien Potencier 816c510cef Deprecate using ~ with + or - in an expression without using parentheses to clarify precedence 2024-09-30 13:51:47 +02:00
Fabien Potencier c599125a39 Unify error messages when a filter expects a mapping/sequence 2024-09-29 18:29:04 +02:00
Fabien Potencier 3523d34b50 Add missing is_iterable() checks 2024-09-29 18:23:14 +02:00
Fabien Potencier bfa44742da Add quotes on filters/functions in CoreExtension 2024-09-29 18:18:48 +02:00
Fabien Potencier 0da899d911 Use get_debug_type() everywhere 2024-09-29 18:08:29 +02:00
Nicolas Grekas cff6f1ca80 Implement the enum function 2024-09-27 08:23:21 +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
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