3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $bar, $baz; } $foo_reflection = new ReflectionObject(new Foo); var_dump( array_map( function (ReflectionProperty $prop) { $visibility = null; switch ($prop->getModifiers()) { case ReflectionProperty::IS_PUBLIC: $visibility = 'public'; break; case ReflectionProperty::IS_PROTECTED: $visibility = 'protected'; break; case ReflectionProperty::IS_PRIVATE: $visibility = 'private'; break; } return [ 'Name' => $prop->getName(), 'Visibility' => $visibility, ]; }, $foo_reflection->getProperties() ) );
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.38, 7.0.0 - 7.0.32, 7.1.0 - 7.1.24, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.29, 8.2.0 - 8.2.21, 8.3.0 - 8.3.9
array(2) { [0]=> array(2) { ["Name"]=> string(3) "bar" ["Visibility"]=> string(7) "private" } [1]=> array(2) { ["Name"]=> string(3) "baz" ["Visibility"]=> string(7) "private" } }

preferences:
200.81 ms | 405 KiB | 296 Q