Fabien Potencier
2b2ac80d34
Fxi some errors reported by phpstan
2024-02-05 17:48:36 +01:00
Fabien Potencier
d21666f728
Throws proper Twig exception when using cycle on an empty array
2024-01-11 21:47:04 +01:00
Malte Wunsch
3963851a41
Improve error message
...
It is not obvious that you cannot use the Twig function `constant` to get the special `::class` constants of classes like so: `{{ constant('Twig\\Extension\\CoreExtension::class') }}`, due to the underlying PHP function `\constant()`.
The previous error message in this case: 'Constant "Twig\Extension\CoreExtension::class" is undefined.' was not very helpful.
2023-12-22 08:51:25 +01:00
Fabien Potencier
bc22e38ce6
Fix bad merge
2023-12-20 20:34:40 +01:00
Fabien Potencier
204cd6f412
Merge branch '2.x' into 3.x
...
* 2.x:
Add SourcePolicyInterface to selectively enable the Sandbox based on a template's Source
2023-12-19 08:19:15 +01:00
Yaakov Saxon
a18da1614a
Add SourcePolicyInterface to selectively enable the Sandbox based on a template's Source
2023-12-19 08:18:35 +01:00
Fabien Potencier
aa7c454e2d
Fix CS
2023-12-10 20:34:32 +01:00
Fabien Potencier
54d34b969b
Move functions for CoreExtension
2023-12-10 20:13:10 +01:00
Fabien Potencier
72071e8ece
Move functions for EscaperExtension
2023-12-10 11:49:57 +01:00
Fabien Potencier
196e91dd72
Move functions for StringLoaderExtension
2023-12-10 11:38:36 +01:00
Fabien Potencier
d4d016034c
Move functions for DebugExtension
2023-12-10 11:35:00 +01:00
Fabien Potencier
51cfad8039
minor #3855 Update signature to acknowledge a TemplateWrapper (richardhj)
...
This PR was merged into the 3.x branch.
Discussion
----------
Update signature to acknowledge a TemplateWrapper
`$name` legitimately can be of type `Twig\TemplateWrapper`. This is already considered in line 1331. This PR updates the method signature in the PHPDoc.
This PR is necessary because other developers may rely on the signature, see contao/contao#6169 .
Commits
-------
b0cabc09 Update signature to acknowledge a TemplateWrapper
2023-10-20 17:52:20 +02:00
Fabien Potencier
f1b5227477
minor #3884 Use PHP 8.0 functions with polyfill (GromNaN)
...
This PR was merged into the 3.x branch.
Discussion
----------
Use PHP 8.0 functions with polyfill
Backport some changes from #3881 into 3.x using `symfony/polyfill-php80`.
- `str_starts_with`
- `str_ends_with`
- `str_contains`
- `get_debug_type`
Benefits:
- Less conflicts when both 3.x and 4.x branches will be maintained.
- Performance gain for PHP 8.0+ ([83,7% of installs](https://packagist.org/packages/twig/twig/php-stats#3 ))
Commits
-------
1d5c0928 Use PHP 8.0 functions with polyfill
2023-10-20 17:49:50 +02:00
Jérôme Tamarelle
991f518d32
Replace calls to twig_test_iterable to is_iterable
2023-10-20 17:47:18 +02:00
Jérôme Tamarelle
6ca0d773c5
Convert Ternary to Elvis or Null Coalescing
2023-10-20 17:47:17 +02:00
Jérôme Tamarelle
cb8a824784
Use is_iterable when possible
2023-10-20 17:46:53 +02:00
Jérôme Tamarelle
6d715e2002
Remove unused variables and unreachable code
2023-10-08 21:18:06 +02:00
Jérôme Tamarelle
1d5c09285f
Use PHP 8.0 functions with polyfill
2023-10-08 17:11:07 +02:00
Fabien Potencier
5193653ecb
Fix CS
2023-10-08 09:05:22 +02:00
Ryan Weaver
ba4fe3ba34
Adding support for the ...spread operator on arrays and hashes
2023-07-20 16:08:57 +02:00
Richard Henkenjohann
b0cabc093c
Update signature to acknowledge a TemplateWrapper
2023-07-01 16:42:59 +02:00
Jacob Richardson
f136668933
Restores the leniency of the matches twig comparison, allowing null subject to result in a non-match.
...
Resolves BC break introduced in PR https://github.com/twigphp/Twig/pull/3687
As per pattern in https://github.com/twigphp/Twig/pull/3617
2023-02-07 17:07:16 +00:00
ju1ius
4f2f3f814e
pass the current key to reduce filter's callback
2023-01-25 10:42:37 +01:00
Christophe Coevoet
44c46712b8
Fix error messages in sandboxed mode for has some and has every
2023-01-03 18:06:19 +01:00
Fabien Potencier
a82e94d911
Add some tests
2022-12-27 12:31:54 +01:00
Matheo Daninos
61672c43f9
throwing syntaxt error when the matches regexp is not valid
2022-12-27 12:25:33 +01:00
Fabien Potencier
d769ae90d1
feature #3670 Add "some" and "every" filters (Jean-Beru)
...
This PR was merged into the 3.x branch.
Discussion
----------
Add "some" and "every" filters
This PR adds 2 new tests inspired from Javascript's functions: [some](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some ) and [every](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every ).
Usage :
```twig
Value {{ ([1, 2, 3] has some v => v == 2) ? 'found' : 'not found' }}
Key {{ ([1, 2, 3] has some (v, k) => k == 2) ? 'found' : 'not found' }}
Every values {{ ([1, 2, 3] has every v => 42 > v) ? 'match' : 'do not match' }}
Every keys {{ ([1, 2, 3] has every (v, k) => 42 > k) ? 'match' : 'do not match' }}
```
Commits
-------
009bb4fd Add "some" and "every" filters
2022-12-26 17:18:29 +01:00
Fabien Potencier
fe347bbf1b
Merge branch '2.x' into 3.x
...
* 2.x:
Fix tests
Updates CoreExtension::twig_constant to check for definition first to avoid hard crash
2022-12-26 16:12:53 +01:00
Alex Henderson-Roche
56b31224bd
Updates CoreExtension::twig_constant to check for definition first to avoid hard crash
2022-12-26 13:36:01 +01:00
Vincent Langlet
e98a652a6c
Improve phpdoc of ExtensionInterface/Environment/Expressionparser arrays
2022-11-18 10:55:01 +01:00
hubert.lenoir
009bb4fd82
Add "some" and "every" filters
2022-03-25 11:04:50 +01:00
Kévin Dunglas
0d6bd45844
add support for the class constant on objects
2022-03-25 09:58:48 +01:00
Fabien Potencier
d6f9a4e7a2
Merge branch '2.x' into 3.x
...
* 2.x:
Fix custom escapers when using multiple Twig environments
Rename variable
2022-03-25 09:06:57 +01:00
Fabien Potencier
9c03ef0d21
Fix custom escapers when using multiple Twig environments
2022-03-25 08:56:44 +01:00
Vincent Langlet
3f07c38c9a
Rename variable
2022-03-15 08:59:44 +01:00
Fabien Potencier
9e5ca747b6
Merge branch '2.x' into 3.x
...
* 2.x:
Disallow non closures in `sort` filter when the sanbox mode is enabled
2022-02-04 07:56:23 +01:00
Fabien Potencier
2eb3308055
Disallow non closures in sort filter when the sanbox mode is enabled
2022-02-04 07:52:21 +01:00
Fabien Potencier
5981815757
Merge branch '2.x' into 3.x
...
* 2.x:
Rename variables used in map method
The deprecated null value for the method round has been changed to zero.
2022-01-14 12:47:50 +01:00
v.arsentev
7d0e5d6a1e
The deprecated null value for the method round has been changed to zero.
2022-01-11 16:12:44 +01:00
Fabien Potencier
1231fd4096
Merge branch '2.x' into 3.x
...
* 2.x:
Allow null for nl2br, striptags and format filters
2022-01-03 17:03:55 +01:00
Ruud Kamphuis
e9cd55def5
Allow null for nl2br, striptags and format filters
...
Same as https://github.com/twigphp/Twig/pull/3617
2022-01-03 14:28:28 +01:00
Fabien Potencier
ec23eba2ad
Merge branch '2.x' into 3.x
...
* 2.x:
Add 8.1 in tests
Allow null when Twig expects a string
2022-01-02 17:23:10 +01:00
Fabien Potencier
92bc110bcf
Allow null when Twig expects a string
2022-01-02 16:05:53 +01:00
Fabien Potencier
5f20d4a362
Merge branch '2.x' into 3.x
...
* 2.x:
Explicitly specify the encoding for mb_ord in JS escaper
2021-07-08 13:01:29 +02:00
Fabien Potencier
feeaba3fea
Merge branch '1.x' into 2.x
...
* 1.x:
Explicitly specify the encoding for mb_ord in JS escaper
2021-07-08 13:01:04 +02:00
Oleg Stepanischev
da24c9340e
Explicitly specify the encoding for mb_ord in JS escaper
...
Explicitly specify the encoding for mb_ord in JS escaper - fix
2021-07-08 12:58:33 +02:00
Fabien Potencier
ed29f0010f
Merge branch '2.x' into 3.x
...
* 2.x:
Add ReturnTypeWillChange to JsonSerializable implementation
Fix implicit flot to int casts
2021-06-06 18:31:44 +02:00
Fabien Potencier
7926399e0a
Merge branch '1.x' into 2.x
...
* 1.x:
Fix implicit flot to int casts
2021-06-06 18:31:25 +02:00
Alexander M. Turek
de9cd76d7c
Fix implicit flot to int casts
2021-06-06 00:32:22 +02:00
Fabien Potencier
4659a99cdf
Merge branch '2.x' into 3.x
...
* 2.x:
Fix URLs
Replace secure.php.net with www.php.net
2021-05-19 09:38:07 +02:00