3v4l.org

run code in 300+ PHP versions simultaneously
<?php #[\Attribute(\Attribute::TARGET_PROPERTY)] final class AutowireProperty {} class A { #[AutowireProperty] protected string $foo; } class B extends A { } $fooA = new \ReflectionProperty(A::class, 'foo'); $fooB = new \ReflectionProperty(B::class, 'foo'); echo "Class A: "; var_export($fooA->getAttributes()[0]->getName()); echo "\n"; echo "Class B: "; var_export($fooA->getAttributes()[0]->getName()); echo "\n";
Output for 8.1.0 - 8.1.31, 8.2.0 - 8.2.26, 8.3.0 - 8.3.15, 8.4.1 - 8.4.2
Class A: 'AutowireProperty' Class B: 'AutowireProperty'

preferences:
62.33 ms | 406 KiB | 5 Q