* 3.x: (26 commits)
Remove the documentation comments compilation overhead
Clarify source function trust requirements
Throw on PCRE errors in the matches operator
Document that reusing a non-rewindable iterator after destructuring is unsupported
Release destructuring temporaries after assignment
Deprecate prefixed macro definedness checks
Fix duplicate macro deprecation wording
Throw when list formatting fails
Document that sequence destructuring consumes one value per pattern slot
Fix the html_attr documentation about iterables in data attributes
Warn about untrusted input with the default Tempest markdown converter
Document that overriding MacroNode::compile() is not supported anymore
Merge overlapping CHANGELOG entries for the destructuring fatal error fix
Document that include_only keeps global variables available
Remove lazy macro import resolution
Honor date formatter prototype calendars
Fix Stringable keys for ArrayAccess implementations
Fix repeated object destructuring evaluation
Restore void return type compatibility for extension points
Reject destructuring patterns containing no variables
...
# Conflicts:
# CHANGELOG
# doc/deprecated.rst
# doc/filters/format_datetime.rst
# extra/twig-extra-bundle/DependencyInjection/Compiler/MissingExtensionSuggestorPass.php
# extra/twig-extra-bundle/DependencyInjection/TwigExtraExtension.php
# extra/twig-extra-bundle/TwigExtraBundle.php
# src/MacroNamespace.php
# src/Node/MacrosNode.php
# src/Parser.php
# src/Test/IntegrationTestCase.php
# src/Test/NodeTestCase.php
# tests/CallMacroTest.php
# tests/ExpressionParserTest.php
# tests/Fixtures/macros/duplicate_definition.legacy.test
# tests/Node/MacrosTest.php
# tests/ParserTest.php
* 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
* 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
* 3.x:
Update CHANGELOG
Add `html_attr_relaxed` escaping strategy
re-add mixed return type
Support short-circuiting in null-safe operator chains
Add support for renaming variables in object destructuring
Update .gitattributes to remove splitsh.json
Fix intro for operator precedence table ?
This PR was merged into the 3.x branch.
Discussion
----------
Support short-circuiting in null-safe operator chains
This PR adds short-circuiting for null-safe operator chains, using the same rules as PHP, `PropertyAccess`, and the `ExpressionLanguage`.
Previously, only the immediate null-safe access was guarded. With this change, as soon as a `null` is encountered at a null-safe access, the rest of the chain is skipped.
My approach was to move the null check outside of the `getAttribute()` calls so the expression can immediately return `null`, eg:
```twig
foo?.bar.baz
```
Before:
```php
yield $this->env
->getRuntime('Twig\Runtime\EscaperRuntime')
->escape(
CoreExtension::getAttribute(
$this->env,
$this->source,
(
null === (
$_v0 = (
isset($context['foo']) || array_key_exists('foo', $context)
? $context['foo']
: throw new RuntimeError('Variable "foo" does not exist.', 3, $this->source)
)
)
? null
: CoreExtension::getAttribute(
$this->env,
$this->source,
$_v0,
'bar',
[],
'any',
false,
false,
false,
3
)
),
'baz',
[],
'any',
false,
false,
false,
3
),
'html',
null,
true
);
```
Now:
```php
yield $this->env
->getRuntime('Twig\Runtime\EscaperRuntime')
->escape(
(
null === (
$_v0 = (
isset($context['foo']) || array_key_exists('foo', $context)
? $context['foo']
: throw new RuntimeError('Variable "foo" does not exist.', 3, $this->source)
)
)
? null
: CoreExtension::getAttribute(
$this->env,
$this->source,
CoreExtension::getAttribute(
$this->env,
$this->source,
$_v0,
'bar',
[],
'any',
false,
false,
false,
3
),
'baz',
[],
'any',
false,
false,
false,
3
)
),
'html',
null,
true
);
```
Commits
-------
d56e8e2dba Support short-circuiting in null-safe operator chains
* 3.x:
Bump version
Add a not about the return value of destructuring
Fix null-safe operator test
Bump version
Prepare the release
Update CHANGELOG
Add support for object and mapping destructuring
Rename classes
Assignment operator array destructuring
Fix doc notes
Fix doc notes
Add the = assignment operator
Fix grammar and spelling mistakes in documentation
* 3.x:
Fix version
Fix CS
Remove obsolete code
Use generics in ExpressionParsers
Fix precedence rules
Add deprecation notices in CHANGELOG and docs
Move Operators to ExpressionParsers, deprecate ExpressionParser
Add a script to update operator precedence documentation
Extract operators logic from ExpressionParser to their own classes
Introduce operator classes to describe operators provided by extensions instead of arrays
Bump version to 3.21
* 3.x:
Fixing minor typo in Update inline_css.rst
Ignore static properties when using the dot operator
Fix CS
Fix constant() behavior when used with ??
Finish the work
fix indentation
Apply suggestions from code review
typo
fix merge
docs and changelog
typehint instead of checkArrow
checkArrow, typehints
invoke filter
* 3.x: (30 commits)
Make {} optional for the types tag
Remove the note about types mapping argument
Add a note on the types locality
Fix CS
Fix typos in the docs
Use spl_object_id() instead of spl_object_hash()
Add `LastModifiedExtensionInterface` and implementation in `AbstractExtension` to track modification of runtime classes
Bump version
Optimize NameExpression compilation
Fix typo in enum twig doc functions
Remove dead method in ModuleNode
Bump version
Prepare the 3.18.0 release
Add support for `Twig\Markup`
Fix unary operator precedence change
Replace Twigfiddle by the new Twig playground
Fix MacroNode $name argument can be overridden
Ignore exceptions from undefined handlers when using the guard tag
[Doc] Update the docs about attribute() function
Fix doc
...
* 3.x:
Add support for named arguments on macro calls and dot operator arguments
Improve deprecation messages
Simplify expression parser code
Refactor expression parser
chore: fix version added
Cleanup code
* 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