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, 1); $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 O6C3W
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught ReflectionException: The parameter specified by its offset could not be found in /in/3RBlm:15 Stack trace: #0 /in/3RBlm(15): ReflectionParameter->__construct(Object(Closure), 1) #1 {main} thrown in /in/3RBlm on line 15
Process exited with code 255.
Output for 5.3.18 - 5.6.28
Fatal error: Uncaught exception 'ReflectionException' with message 'The parameter specified by its offset could not be found' in /in/3RBlm:15 Stack trace: #0 /in/3RBlm(15): ReflectionParameter->__construct(Object(Closure), 1) #1 {main} thrown in /in/3RBlm on line 15
Process exited with code 255.