Skip to content

Fix PHPStan errors on 4.x#4867

Merged
fabpot merged 1 commit into
twigphp:4.xfrom
fabpot:fix-4.x-phpstan
Jul 19, 2026
Merged

Fix PHPStan errors on 4.x#4867
fabpot merged 1 commit into
twigphp:4.xfrom
fabpot:fix-4.x-phpstan

Conversation

@fabpot

@fabpot fabpot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@upsun-dispatch

Copy link
Copy Markdown

📋 PR Summary

This PR fixes PHPStan errors on the 4.x branch by tightening parameter type declarations from the generic Node to AbstractExpression in several expression/binary/unary node constructors and in TrueTest::wrap, and by removing a now-redundant array_map in Environment::resolveTemplate. The changes align the enforced runtime types with the existing docblock intent and add a @var annotation in IfNode to satisfy static analysis.

Changes
Layer / File(s) Summary
type-hint tightening
src/Node/Expression/Binary/AndBinary.php Narrows constructor params from Node to AbstractExpression, swapping the import accordingly.
src/Node/Expression/Binary/OrBinary.php Narrows constructor params from Node to AbstractExpression.
src/Node/Expression/Binary/XorBinary.php Narrows constructor params from Node to AbstractExpression.
src/Node/Expression/Binary/ElvisBinary.php Replaces Node params (plus redundant docblock) with AbstractExpression type hints.
src/Node/Expression/Unary/NotUnary.php Narrows the constructor param from Node to AbstractExpression.
src/Node/Expression/Test/TrueTest.php Changes wrap() signature and return type from Node to AbstractExpression.
src/Node/IfNode.php Adds an @var AbstractExpression annotation for the test node before passing it to TrueTest::wrap.
dead-code removal
src/Environment.php Drops the array_map handling of TemplateWrapper in the error message, imploding $names directly.

@fabpot
fabpot merged commit 66cb19f into twigphp:4.x Jul 19, 2026
41 checks passed
@fabpot
fabpot deleted the fix-4.x-phpstan branch July 19, 2026 16:22
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.

1 participant