3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyAttributeBase {} class MyAttribute extends MyAttributeBase {} class C { public function __construct( #[\SensitiveParameter] #[MyAttribute] public string $x, ) {} } new C('hello'); $param = (new ReflectionMethod('C', '__construct'))->getParameters()[0]; spl_autoload_register(function (string $class) { $line = debug_backtrace()[1]['line']; print "Line $line: Trying to autoload $class.\n"; }); $attributes = $param->getAttributes(UnknownClass::class); assert($attributes === []); $attributes = $param->getAttributes(MyAttributeBase::class); assert($attributes === []); $attributes = $param->getAttributes(MyAttributeBase::class, \ReflectionAttribute::IS_INSTANCEOF); assert(count($attributes) === 1); assert($attributes[0]->getName() === MyAttribute::class); $attributes = $param->getAttributes(); assert(count($attributes) === 2); assert($attributes[0]->getName() === SensitiveParameter::class); assert($attributes[1]->getName() === MyAttribute::class); $attributes[0]->newInstance();
Output for git.master_jit, git.master

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:
27.15 ms | 405 KiB | 5 Q