3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $foo; protected $bar; public $baz; } $map = []; foreach ([new ReflectionProperty('Foo', 'foo'), new ReflectionProperty('Foo', 'bar'), new ReflectionProperty('Foo', 'baz')] as $property) { $class = & $map[$property->getDeclaringClass()->getName()]; $class[$property->getName()] = ($property->isPublic() && \ReflectionProperty::IS_PUBLIC) | ($property->isProtected() && \ReflectionProperty::IS_PROTECTED) | ($property->isPrivate() && \ReflectionProperty::IS_PRIVATE); } var_dump($map);

preferences:
47.5 ms | 402 KiB | 5 Q