3v4l.org

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

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

End of function bar

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.81 ms | 1395 KiB | 15 Q