3v4l.org

run code in 300+ PHP versions simultaneously
<?php $closure1 = function($val){ return $val; }; $closure2 = function($val){ return $val; }; $reflection_class = new ReflectionClass($closure1); $reflection_method = $reflection_class->getMethod('__invoke'); $arguments1 = array('hello'); $arguments2 = array('world'); // Invoking once is OK... print $reflection_method->invokeArgs($closure1, $arguments1); if(true){ // But don't do it again! #print $reflection_method->invokeArgs($closure1, $arguments1); // Using different arguments per invokation makes no difference :( #print $reflection_method->invokeArgs($closure1, $arguments2); // Doesn't matter if you attempt to invoke a different closure with the same reflection. print $reflection_method->invokeArgs($closure2, $arguments1); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 25
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/ls5YL
function name:  (null)
number of ops:  26
compiled vars:  !0 = $closure1, !1 = $closure2, !2 = $reflection_class, !3 = $reflection_method, !4 = $arguments1, !5 = $arguments2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fls5YL%3A2%240'
          1        ASSIGN                                                   !0, ~6
    3     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fls5YL%3A3%241'
          3        ASSIGN                                                   !1, ~8
    5     4        NEW                                              $10     'ReflectionClass'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !2, $10
    6     8        INIT_METHOD_CALL                                         !2, 'getMethod'
          9        SEND_VAL_EX                                              '__invoke'
         10        DO_FCALL                                      0  $13     
         11        ASSIGN                                                   !3, $13
    8    12        ASSIGN                                                   !4, <array>
    9    13        ASSIGN                                                   !5, <array>
   12    14        INIT_METHOD_CALL                                         !3, 'invokeArgs'
         15        SEND_VAR_EX                                              !0
         16        SEND_VAR_EX                                              !4
         17        DO_FCALL                                      0  $17     
         18        ECHO                                                     $17
   14    19      > JMPZ                                                     <true>, ->25
   22    20    >   INIT_METHOD_CALL                                         !3, 'invokeArgs'
         21        SEND_VAR_EX                                              !1
         22        SEND_VAR_EX                                              !4
         23        DO_FCALL                                      0  $18     
         24        ECHO                                                     $18
   23    25    > > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2Fls5YL%3A2%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ls5YL
function name:  {closure}
number of ops:  3
compiled vars:  !0 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1      > RETURN                                                   !0
          2*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fls5YL%3A2%240

Function %00%7Bclosure%7D%2Fin%2Fls5YL%3A3%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ls5YL
function name:  {closure}
number of ops:  3
compiled vars:  !0 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1      > RETURN                                                   !0
          2*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fls5YL%3A3%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.67 ms | 1403 KiB | 13 Q