3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Wl\A; class B { public function get() { return "BBBBB"; } } $b = new B(); $funct = function (B $b) { print_r($b::get()); }; $refParam = new \ReflectionParameter($funct, 0); $export = \ReflectionParameter::export( array( $refParam->getDeclaringClass()->name, $refParam->getDeclaringFunction()->name ), $refParam->name, true ); $type = preg_replace('/.*?(\w+)\s+\$'.$refParam->name.'.*/', '\\1', $export); echo "ARGS:\n"; echo $type; exit; try { $a->b(""); } catch (\Exception $e) { echo "catched"; } catch (\TypeError $e) { echo "subidubi"; }
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught Error: Call to undefined method ReflectionParameter::export() in /in/CMZT6:16 Stack trace: #0 {main} thrown in /in/CMZT6 on line 16
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Notice: Trying to get property 'name' of non-object in /in/CMZT6 on line 18 Deprecated: Function ReflectionParameter::export() is deprecated in /in/CMZT6 on line 22 Fatal error: Uncaught ReflectionException: Class does not exist in /in/CMZT6:22 Stack trace: #0 [internal function]: ReflectionParameter->__construct(Array, 'b') #1 /in/CMZT6(22): ReflectionParameter::export(Array, 'b', true) #2 {main} thrown in /in/CMZT6 on line 22
Process exited with code 255.
Output for 7.3.32 - 7.3.33
Fatal error: Uncaught ReflectionException: Class does not exist in /in/CMZT6:22 Stack trace: #0 [internal function]: ReflectionParameter->__construct(Array, 'b') #1 /in/CMZT6(22): ReflectionParameter::export(Array, 'b', true) #2 {main} thrown in /in/CMZT6 on line 22
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.31
Notice: Trying to get property 'name' of non-object in /in/CMZT6 on line 18 Fatal error: Uncaught ReflectionException: Class does not exist in /in/CMZT6:22 Stack trace: #0 [internal function]: ReflectionParameter->__construct(Array, 'b') #1 /in/CMZT6(22): ReflectionParameter::export(Array, 'b', true) #2 {main} thrown in /in/CMZT6 on line 22
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33
Notice: Trying to get property of non-object in /in/CMZT6 on line 18 Fatal error: Uncaught ReflectionException: Class does not exist in /in/CMZT6:22 Stack trace: #0 [internal function]: ReflectionParameter->__construct(Array, 'b') #1 /in/CMZT6(22): ReflectionParameter::export(Array, 'b', true) #2 {main} thrown in /in/CMZT6 on line 22
Process exited with code 255.
Output for 5.4.8 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28
Notice: Trying to get property of non-object in /in/CMZT6 on line 18 Fatal error: Uncaught exception 'ReflectionException' with message 'Class does not exist' in /in/CMZT6:23 Stack trace: #0 [internal function]: ReflectionParameter->__construct(Array, 'b') #1 /in/CMZT6(23): ReflectionParameter::export(Array, 'b', true) #2 {main} thrown in /in/CMZT6 on line 23
Process exited with code 255.

preferences:
210.48 ms | 402 KiB | 251 Q