diff --git a/CHANGELOG b/CHANGELOG index 2fafecb65..5d1d55626 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,7 @@ * Add the `invoke` filter * Make `{}` optional for the `types` tag * Add `LastModifiedExtensionInterface` and implementation in `AbstractExtension` to track modification of runtime classes + * Ignore static properties when using the dot operator # 3.18.0 (2024-12-29) diff --git a/src/Extension/CoreExtension.php b/src/Extension/CoreExtension.php index b83a0fed1..29d13e629 100644 --- a/src/Extension/CoreExtension.php +++ b/src/Extension/CoreExtension.php @@ -2151,7 +2151,7 @@ final class CoreExtension extends AbstractExtension $property = $class->getProperty($property); - if (!$property->isPublic()) { + if (!$property->isPublic() || $property->isStatic()) { static $false; return $false ??= static fn () => false; diff --git a/tests/IntegrationTest.php b/tests/IntegrationTest.php index 2a88c6af2..f4889cd75 100644 --- a/tests/IntegrationTest.php +++ b/tests/IntegrationTest.php @@ -67,6 +67,8 @@ class TwigTestFoo implements \Iterator public $position = 0; public $array = [1, 2]; + public static $foo = 'Foo'; + public function bar($param1 = null, $param2 = null) { return 'bar'.($param1 ? '_'.$param1 : '').($param2 ? '-'.$param2 : '');