3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Foo { #[MyAttr(msg: __PROPERTY__)] public string $i = __PROPERTY__ { #[MyAttr(msg: __PROPERTY__)] get { var_dump(__PROPERTY__); // dumps "i" return $this->i; } set ( #[MyAttr(msg: __PROPERTY__)] string $v ) { $this->i = $v; } } } $f = new Foo(); var_dump($f->i); // dumps "" because it does not work in default value $r = new ReflectionClass(Foo::class); $p = $r->getProperty('i'); var_dump($p->getAttributes()[0]->getArguments()); // dumps "" because it does not work in property attributes $get = $p->getHook(PropertyHookType::Get); var_dump($get->getAttributes()[0]->getArguments()); // dumps "" because it does not work in hook attributes $set = $p->getHook(PropertyHookType::Set); var_dump($set->getParameters()[0]->getAttributes()[0]->getArguments()); // dumps "i" because it only works in parameter attributes
Output for git.master_jit, git.master
string(1) "i" string(1) "i" array(1) { ["msg"]=> string(1) "i" } array(1) { ["msg"]=> string(1) "i" } array(1) { ["msg"]=> string(1) "i" }

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:
48.87 ms | 518 KiB | 3 Q