3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private int $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, 'Type' => $prop->getTypeText(), ]; }, $foo_reflection->getProperties() ) );
Output for 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
Fatal error: Uncaught Error: Call to undefined method ReflectionProperty::getTypeText() in /in/7gefZ:29 Stack trace: #0 [internal function]: {closure:/in/7gefZ:11}(Object(ReflectionProperty)) #1 /in/7gefZ(10): array_map(Object(Closure), Array) #2 {main} thrown in /in/7gefZ on line 29
Process exited with code 255.
Output for 8.2.0 - 8.2.30, 8.3.0 - 8.3.30
Fatal error: Uncaught Error: Call to undefined method ReflectionProperty::getTypeText() in /in/7gefZ:29 Stack trace: #0 [internal function]: {closure}(Object(ReflectionProperty)) #1 /in/7gefZ(10): array_map(Object(Closure), Array) #2 {main} thrown in /in/7gefZ on line 29
Process exited with code 255.
Output for 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.34
Fatal error: Uncaught Error: Call to undefined method ReflectionProperty::getTypeText() in /in/7gefZ:29 Stack trace: #0 [internal function]: {closure}(Object(ReflectionProperty)) #1 /in/7gefZ(32): array_map(Object(Closure), Array) #2 {main} thrown in /in/7gefZ on line 29
Process exited with code 255.
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33
Parse error: syntax error, unexpected 'int' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in /in/7gefZ on line 4
Process exited with code 255.
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33
Parse error: syntax error, unexpected 'int' (T_STRING), expecting variable (T_VARIABLE) in /in/7gefZ on line 4
Process exited with code 255.

preferences:
93.91 ms | 2172 KiB | 4 Q