3v4l.org

run code in 500+ PHP versions simultaneously
<?php #[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_METHOD)] readonly class UseFilter { /** * @param string $filterClass */ public function __construct( /** @phan-suppress PhanWriteOnlyPublicProperty */ public string $filterClass, ) { } } #[UseFilter('class level')] class Foobar { #[UseFilter('method level')] public function foobaz(): void { } } $class = new ReflectionClass(Foobar::class); $allFilters = []; foreach ($class->getAttributes(UseFilter::class) as $attr) { var_dump($attr->getTarget()); } $method = $class->getMethod('foobaz'); foreach ($method->getAttributes(UseFilter::class) as $attr) { var_dump($attr->getTarget()); }
Output for git.master, git.master_jit
int(1) int(4)

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
52.58 ms | 710 KiB | 4 Q