Skip to content

Deprecate macro calls without parentheses - #4877

Merged
fabpot merged 1 commit into
twigphp:3.xfrom
fabpot:deprecate-macro-calls-without-parentheses
Jul 28, 2026
Merged

Deprecate macro calls without parentheses#4877
fabpot merged 1 commit into
twigphp:3.xfrom
fabpot:deprecate-macro-calls-without-parentheses

Conversation

@fabpot

@fabpot fabpot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@upsun-dispatch

upsun-dispatch Bot commented Jul 28, 2026

Copy link
Copy Markdown

📋 PR Summary

This PR deprecates calling a Twig macro without parentheses (e.g. macros.input or _self.(name)). MacroReferenceExpression gains a hasParentheses flag (defaulting to true) set by DotExpressionParser based on whether a ( follows the macro name; at compile time a deprecation is triggered when the flag is false and the node is not part of a defined test. Documentation, CHANGELOG, and a legacy integration test fixture are added.

Changes
Layer / File(s) Summary
macro-call parsing
src/ExpressionParser/Infix/DotExpressionParser.php Sets the new hasParentheses flag on the created MacroReferenceExpression based on whether the parsed dot access was a method call (Template::METHOD_CALL), for both static and dynamic macro names.
src/Node/Expression/MacroReferenceExpression.php Adds a $hasParentheses property (default true) with an @internal setter, and triggers a 3.29 deprecation with template name/line during compile when parentheses are omitted and the node is not a defined test.
docs & changelog
CHANGELOG Documents the new deprecation.
doc/deprecated.rst Explains the deprecation and that parentheses remain optional for defined tests.
tests
tests/Fixtures/macros/call_without_parentheses.legacy.test Adds an integration fixture asserting the deprecation fires for both static (macros.hello) and dynamic (_self.(name)) parenthesis-less calls.

Comment thread src/Node/Expression/MacroReferenceExpression.php
Comment thread src/Node/Expression/MacroReferenceExpression.php Outdated
@fabpot
fabpot force-pushed the deprecate-macro-calls-without-parentheses branch from 44394fb to ad305b4 Compare July 28, 2026 14:13
@fabpot
fabpot merged commit 5bbbe0d into twigphp:3.x Jul 28, 2026
54 checks passed
@fabpot
fabpot deleted the deprecate-macro-calls-without-parentheses branch July 28, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants