53 Commits

Author SHA1 Message Date
Fabien Potencier 5ca7debf6e Fix merge conflict resolution 2026-07-12 15:08:38 +02:00
Fabien Potencier 0b6e824ea8 Merge branch '3.x' into 4.x
* 3.x:
  Add void return type hint even in tests
  Run php-cs-fixer sequentially so the void_return src-only customiser is applied
  Fix CHANGELOG
  [Intl] Add format_list filter using PHP 8.5's IntlListFormatter

# Conflicts:
#	.github/workflows/ci.yml
#	CHANGELOG
#	extra/cssinliner-extra/Tests/LegacyFunctionsTest.php
#	extra/html-extra/Tests/CvaTest.php
#	extra/html-extra/Tests/HtmlAttrMergeTest.php
#	extra/html-extra/Tests/HtmlAttrTest.php
#	extra/html-extra/Tests/LegacyFunctionsTest.php
#	extra/inky-extra/Tests/LegacyFunctionsTest.php
#	extra/markdown-extra/Tests/FunctionalTest.php
#	extra/markdown-extra/Tests/LegacyFunctionsTest.php
#	extra/twig-extra-bundle/DependencyInjection/Compiler/MissingExtensionSuggestorPass.php
#	extra/twig-extra-bundle/DependencyInjection/TwigExtraExtension.php
#	extra/twig-extra-bundle/TwigExtraBundle.php
#	src/Extension/CoreExtension.php
#	src/Extension/EscaperExtension.php
#	src/Node/CheckSecurityCallNode.php
#	src/Node/Expression/FunctionExpression.php
#	src/Node/ModuleNode.php
#	src/Node/Node.php
#	src/Node/TypesNode.php
#	src/Resources/core.php
#	src/Resources/debug.php
#	src/Test/IntegrationTestCase.php
#	tests/CustomExtensionTest.php
#	tests/EnvironmentTest.php
#	tests/ExpressionParserTest.php
#	tests/Extension/CoreTest.php
#	tests/Extension/EscaperTest.php
#	tests/Extension/LegacyDebugFunctionsTest.php
#	tests/Extension/LegacyStringLoaderFunctionsTest.php
#	tests/Extension/SandboxStateChangeTest.php
#	tests/Extension/SandboxTest.php
#	tests/LexerTest.php
#	tests/Node/Expression/CallTest.php
#	tests/Node/Expression/ConditionalTest.php
#	tests/Node/NodeTest.php
#	tests/Resources/LegacyCoreTest.php
#	tests/TemplateTest.php
#	tests/Util/CallableArgumentsExtractorTest.php
2026-07-12 13:55:37 +02:00
Fabien Potencier 9c6d76b61c Add void return type hint even in tests 2026-07-12 13:43:08 +02:00
Fabien Potencier ea8aadf94d Merge branch '3.x' into 4.x
* 3.x:
  Exempt test files from the void_return rule regardless of the config location
  fix version in deprecation message for tag usage outside of root template
  Fix array access with a Stringable key on ArrayAccess objects using object keys
  Throw a SyntaxError instead of a PHP fatal error when a macro argument is defined twice
  Bump version
  Prepare the 3.28.0 release
  Render backed enums using their backing value in the html_attr function
  Tweak previous merge
  Add documention note about variable scope of override blocks in {% embed ... only %}
  Define the macro at the template root in the cache macro fixture
  Update CHANGELOG
  Fix a PHP 8.5 chr() deprecation when decoding octal string escapes
  Fix Markup truthiness in boolean expressions

# Conflicts:
#	CHANGELOG
#	doc/deprecated.rst
#	src/Environment.php
#	src/Node/Expression/TempNameExpression.php
#	src/Node/IfNode.php
#	src/Node/MacroNode.php
#	src/NodeVisitor/CorrectnessNodeVisitor.php
#	tests/Fixtures/tags/inheritance/extends_in_condition.test
#	tests/Fixtures/tags/inheritance/use_in_condition.test
#	tests/Fixtures/tags/inheritance/use_in_macro.test
#	tests/Fixtures/tags/macro/macro_in_block.test
#	tests/Fixtures/tags/macro/macro_in_condition.test
2026-07-08 21:22:49 +02:00
Derrick Austin 153094b601 Fix a PHP 8.5 chr() deprecation when decoding octal string escapes
PHP 8.5 deprecates passing a value outside the [0, 255] range to chr().
The string-escape decoder in the lexer accepts up to three octal digits,
so an escape such as "\777" (= 511) reaches chr() out of range and emits:

    chr(): Providing a value not in-between 0 and 255 is deprecated ...

chr() already constrains the value with "% 256", so applying "% 256"
explicitly preserves the exact byte while silencing the deprecation. The
hex escape branch is unaffected because it is capped at two digits (0xff).
2026-06-13 07:22:26 +02:00
Fabien Potencier 82bc07bc64 Merge branch '3.x' into 4.x
* 3.x:
  Reduce memory usage of the context restoration compiled at the end of for loops
  Clarify sandbox always-allowed trust boundary
  Bump version to 3.28.0 for the always_allowed_in_sandbox feature
  Add regression tests that always-allowed callables still enforce the sandbox __toString policy on arguments
  Document the criteria for always-allowed sandbox items and list 4.0 built-ins
  Add an always_allowed_in_sandbox flag for filters, functions, and tags
  Remove issue references in tests
  Avoid allocating a normalized copy when counting newlines without carriage returns
  Report columns in syntax errors
  Track the source offset of each token

# Conflicts:
#	CHANGELOG
#	doc/deprecated.rst
#	doc/sandbox.rst
#	src/Environment.php
#	src/Error/Error.php
#	src/Lexer.php
#	src/Node/ForNode.php
#	src/Token.php
#	src/TwigCallableInterface.php
#	tests/Extension/SandboxTest.php
#	tests/Node/ForTest.php
2026-06-06 11:03:40 +02:00
Fabien Potencier a82782ac30 Report columns in syntax errors 2026-06-05 20:28:45 +02:00
Fabien Potencier 4943bb405c Track the source offset of each token 2026-06-05 20:28:45 +02:00
Fabien Potencier 8a4b77920a Add PHPUnit attributes alongside annotations to silence doc-comment metadata deprecations on PHPUnit 11 2026-06-03 18:26:39 +02:00
Fabien Potencier 0ab904677b Fix risky test 2026-05-23 11:34:00 +02:00
Fabien Potencier b8e6b314b3 Merge branch '3.x' into 4.x
* 3.x:
  fix documentation typos for singular filter arguments
  Add getOperatorTokens() to ExpressionParserInterface to separate operator token registration from parser identity
  Ensure filters/attributes aren't mistaken for operators
2026-02-25 09:40:35 +01:00
Fabien Potencier e5eb95d0d7 Add getOperatorTokens() to ExpressionParserInterface to separate operator token registration from parser identity 2026-02-24 21:13:06 +01:00
brandonkelly a9ac993938 Ensure filters/attributes aren't mistaken for operators 2026-02-24 21:10:18 +01:00
Nicolas Grekas c649c1658b Merge branch '3.x' into 4.x
* 3.x:
  CS fixes
  Enable Fabbot as a GHA
2025-07-29 10:27:55 +02:00
Nicolas Grekas 85a4817128 CS fixes 2025-07-29 10:07:07 +02:00
Fabien Potencier 50cdb7bf4a Remove usage of @dataProvider 2025-02-26 22:01:08 +01:00
Fabien Potencier 9bccdf438d Merge branch '3.x' into 4.x
* 3.x:
  Add a proper prefix spread operator
  Avoid storing expression parser instances in Node attributes
2025-02-14 12:51:14 +01:00
Fabien Potencier 3964aeba78 Add a proper prefix spread operator 2025-02-14 11:45:39 +01:00
Fabien Potencier c142a3268e Merge branch '3.x' into 4.x
* 3.x:
  Fix CHANGELOG
  Fix support for ignoring syntax erros in an undefined handler in guard
  Add missing CHANGELOG
  Fix timezone conversion on strings
  Use correct lineno for ForElseNode
  Add support for registered undefined element callbacks in tests
  Add UnaryInterface
  Add BinaryInterface
  Reimplement the cache tag in an adhoc way
  Fix CS
  Fix wrong array index
  Fix wrong array index
  Bump min PHP version to 8.1
  Add even more tests
  Add some tests on balanced brackets
  Bump version
  Prepare the 3.19.0 release
  Added configuration for commonmark use in twig-extra-bundle.
2025-02-09 18:23:27 +01:00
Fabien Potencier e48abfe47c Add even more tests 2025-01-31 19:03:58 +01:00
Fabien Potencier 3b605c4180 Add some tests on balanced brackets 2025-01-30 13:38:40 +01:00
Fabien Potencier d564048b9c Merge branch '3.x' into 4.x
* 3.x:
  Fix CS
  Fix Token::__toString()
  fix intl-extra tests
  add missing parentheses to deprecation message
  Deprecate Token::getType()
2025-01-26 11:56:31 +01:00
Fabien Potencier ade8bce516 Deprecate Token::getType() 2025-01-24 15:48:04 +01:00
Fabien Potencier 196c9dcf85 minor #4472 [Twig 4] Add PHPUnit as dev dependency (ruudk)
This PR was squashed before being merged into the 4.x branch.

Discussion
----------

[Twig 4] Add PHPUnit as dev dependency

This makes it easier to run the tests locally.

I understand we didn't do this previously (Twig 3) because of `symfony/simple-phpunit`. But that is now removed in Twig 4, so maybe we can do this as well?

Commits
-------

c352a8d283 [Twig 4] Add PHPUnit as dev dependency
2024-12-01 10:29:11 +01:00
Ruud Kamphuis c352a8d283 [Twig 4] Add PHPUnit as dev dependency 2024-12-01 10:29:08 +01:00
Fabien Potencier cf105b566a Merge branch '3.x' into 4.x
* 3.x:
  Fix CS
2024-11-30 09:43:08 +01:00
Fabien Potencier 14fc89ebea Fix CS 2024-11-30 09:42:13 +01:00
Fabien Potencier ed1b44470f Improve deprecation messages 2024-10-11 08:16:49 +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 d9d8bb0df3 Add support for inline comments 2024-09-27 07:32:09 +02:00
Ruud Kamphuis 7256713c86 Improve escape deprecation message 2024-09-26 15:09:41 +02:00
Fabien Potencier 995e7c2270 Fix CS 2024-09-09 08:49:09 +02:00
Fabien Potencier fa1c9f0bf9 Merge branch '3.x' into 4.x
* 3.x:
  Remove obsolete code
  Deprecate Environment::mergeGlobals()
  Bump version
  Prepare the 3.13.0 release
  Fix wrong format of `Environment::VERSION_ID` constant
  Fix minor things
  Fix CS
  Fix isset in ForLoopNode
  Fix iterable return type
  Improve exception expectations reliability
2024-09-07 17:03:10 +02:00
Alexandre Daubois 797e490356 Improve exception expectations reliability 2024-09-04 15:22:48 +02:00
Alexander M. Turek f2053bbea0 PHPUnit 11 2024-09-04 12:11:51 +02:00
Fabien Potencier a789eca738 Merge branch '3.x' into 4.x
* 3.x:
  Validate the input of CoreExtension::map()
  Rename AbstractTest to ProfilerTestCase
  Make data providers static
  Prepare IntegrationTestCase for static data providers
2024-09-03 22:20:28 +02:00
Alexander M. Turek 6ddb76bb76 Make data providers static 2024-09-03 16:32:00 +02:00
Ruud Kamphuis 53c24bfc33 Do not hide unnecessary escape characters 2024-08-21 19:42:26 +02:00
Ruud Kamphuis 90107929da Improve deprecation message
See https://github.com/twigphp/Twig/pull/4199#discussion_r1723456834
2024-08-21 19:36:27 +02:00
Fabien Potencier 302971f34e Fix CS 2024-08-20 18:10:26 +02:00
Fabien Potencier 675cb2d141 Fix CS 2024-08-18 19:25:19 +02:00
Ruud Kamphuis c6656cf5d0 Deprecate unnecessary escape characters
See #4123 #2712

This allows to change the implementation in v4 so that we no longer have to escape backslashes.
2024-08-11 16:21:05 +02:00
Fabien Potencier 38250b91ca Add more tests to the Lexer 2024-08-10 12:17:25 +02:00
Fabien Potencier e4e95f5b86 Replace template loader mocks by ArrayLoader 2024-07-24 08:27:23 +02:00
Fabien Potencier ccc20cbd1b Fix a warning 2024-04-24 08:06:10 +02:00
Ryan Weaver ba4fe3ba34 Adding support for the ...spread operator on arrays and hashes 2023-07-20 16:08:57 +02:00
Fabien Potencier 656c295ed9 Merge branch '1.x' into 2.x
* 1.x:
  removed usage of getmockBuilder() when not needed
2019-08-08 13:33:07 +02:00
Fabien Potencier 5861a539e4 removed usage of getmockBuilder() when not needed 2019-08-08 11:59:51 +02:00
Fabien Potencier 5ebcecf24b Fix PHPUnit deprecations 2019-08-08 11:03:05 +02:00
Fabien Potencier c829dafd75 Merge branch '1.x' into 2.x
* 1.x:
  Update to PhpUnitBridge and fix deprecations
2019-08-08 10:19:01 +02:00