3v4l.org

run code in 300+ PHP versions simultaneously
<?php function foo(int $x, int $a, int $b = 2) { var_dump($x, $a, $b); } $rf = new ReflectionFunction("foo"); $rf->invokeArgs([1 => 0, 0 => 1, "b" => 6]); class Foo { public function __construct(int $x, int $a, int $b = 2) { var_dump($x, $a, $b); } public function method(int $x, int $a, int $b = 2) { var_dump($x, $a, $b); } } $rc = new ReflectionClass(Foo::class); $instance = $rc->newInstanceArgs([1 => 0, 0 => 1, "b" => 6]); $rc->getMethod("method")->invokeArgs($instance, [1 => 0, 0 => 1, "b" => 6]);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Wtas7
function name:  (null)
number of ops:  23
compiled vars:  !0 = $rf, !1 = $rc, !2 = $instance
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   NEW                                              $3      'ReflectionFunction'
          1        SEND_VAL_EX                                              'foo'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $3
    8     4        INIT_METHOD_CALL                                         !0, 'invokeArgs'
          5        SEND_VAL_EX                                              <array>
          6        DO_FCALL                                      0          
   20     7        NEW                                              $7      'ReflectionClass'
          8        SEND_VAL_EX                                              'Foo'
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !1, $7
   21    11        INIT_METHOD_CALL                                         !1, 'newInstanceArgs'
         12        SEND_VAL_EX                                              <array>
         13        DO_FCALL                                      0  $10     
         14        ASSIGN                                                   !2, $10
   22    15        INIT_METHOD_CALL                                         !1, 'getMethod'
         16        SEND_VAL_EX                                              'method'
         17        DO_FCALL                                      0  $12     
         18        INIT_METHOD_CALL                                         $12, 'invokeArgs'
         19        SEND_VAR_EX                                              !2
         20        SEND_VAL_EX                                              <array>
         21        DO_FCALL                                      0          
         22      > RETURN                                                   1

Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Wtas7
function name:  foo
number of ops:  9
compiled vars:  !0 = $x, !1 = $a, !2 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      2
    4     3        INIT_FCALL                                               'var_dump'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        SEND_VAR                                                 !2
          7        DO_ICALL                                                 
    5     8      > RETURN                                                   null

End of function foo

Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Wtas7
function name:  __construct
number of ops:  9
compiled vars:  !0 = $x, !1 = $a, !2 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      2
   12     3        INIT_FCALL                                               'var_dump'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        SEND_VAR                                                 !2
          7        DO_ICALL                                                 
   13     8      > RETURN                                                   null

End of function __construct

Function method:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Wtas7
function name:  method
number of ops:  9
compiled vars:  !0 = $x, !1 = $a, !2 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      2
   16     3        INIT_FCALL                                               'var_dump'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        SEND_VAR                                                 !2
          7        DO_ICALL                                                 
   17     8      > RETURN                                                   null

End of function method

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.73 ms | 1437 KiB | 14 Q