3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public function bar($param2, $param1 = true) { print $param2.PHP_EOL; print $param1; } } $reflectionMethod = new \ReflectionMethod('Foo', 'bar'); $methodArgs = $reflectionMethod->getParameters(); //var_dump($methodArgs[1]->isOptional()); $reflectionMethod->setAccessible(true); $foo = new Foo; $reflectionMethod->invoke($foo, ['param1' => 10, 'param2' => 20]);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DAQJt
function name:  (null)
number of ops:  19
compiled vars:  !0 = $reflectionMethod, !1 = $methodArgs, !2 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   NEW                                              $3      'ReflectionMethod'
          1        SEND_VAL_EX                                              'Foo'
          2        SEND_VAL_EX                                              'bar'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $3
   14     5        INIT_METHOD_CALL                                         !0, 'getParameters'
          6        DO_FCALL                                      0  $6      
          7        ASSIGN                                                   !1, $6
   16     8        INIT_METHOD_CALL                                         !0, 'setAccessible'
          9        SEND_VAL_EX                                              <true>
         10        DO_FCALL                                      0          
   17    11        NEW                                              $9      'Foo'
         12        DO_FCALL                                      0          
         13        ASSIGN                                                   !2, $9
   18    14        INIT_METHOD_CALL                                         !0, 'invoke'
         15        SEND_VAR_EX                                              !2
         16        SEND_VAL_EX                                              <array>
         17        DO_FCALL                                      0          
         18      > RETURN                                                   1

Class Foo:
Function bar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DAQJt
function name:  bar
number of ops:  6
compiled vars:  !0 = $param2, !1 = $param1
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <true>
    7     2        CONCAT                                           ~2      !0, '%0A'
          3        ECHO                                                     ~2
    8     4        ECHO                                                     !1
    9     5      > RETURN                                                   null

End of function bar

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.54 ms | 1385 KiB | 13 Q