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.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.14
Class A: 'AutowireProperty' Class B: 'AutowireProperty'

preferences:
32.93 ms | 406 KiB | 5 Q