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/DVmnI
function name:  (null)
number of ops:  25
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
   15     8        INIT_FCALL                                               'var_dump'
          9        FETCH_DIM_R                                      ~8      !1, 1
         10        INIT_METHOD_CALL                                         ~8, 'isOptional'
         11        DO_FCALL                                      0  $9      
         12        SEND_VAR                                                 $9
         13        DO_ICALL                                                 
   16    14        INIT_METHOD_CALL                                         !0, 'setAccessible'
         15        SEND_VAL_EX                                              <true>
         16        DO_FCALL                                      0          
   17    17        NEW                                              $12     'Foo'
         18        DO_FCALL                                      0          
         19        ASSIGN                                                   !2, $12
   18    20        INIT_METHOD_CALL                                         !0, 'invoke'
         21        SEND_VAR_EX                                              !2
         22        SEND_VAL_EX                                              <array>
         23        DO_FCALL                                      0          
         24      > RETURN                                                   1

Class Foo:
Function bar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DVmnI
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:
157.66 ms | 1396 KiB | 15 Q