3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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"; }
based on 3RBlm
Output for 7.2.0
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.1.10
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.3.18 - 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.