3v4l.org

run code in 300+ PHP versions simultaneously
<?php $anon = function($arg1, $arg2 = 2) { var_dump($this->mine, $arg1, $arg2); }; class Me { protected $mine = 8; } $me = new Me; $args = [4, 2]; // This is ugly, and doesn't take a variable number of args $anon->call($me, $args[0], $args[1]); // This doesn't exist =( // $anon->apply($me, $args); // We took .bind() and .call() from JS, why not .apply()? // This is ugly too, but takes a variable number of args call_user_func_array(array($anon, 'call'), array_merge(array($me), $args));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MtJDj
function name:  (null)
number of ops:  27
compiled vars:  !0 = $anon, !1 = $me, !2 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FMtJDj%3A3%240'
          1        ASSIGN                                                   !0, ~3
   11     2        NEW                                              $5      'Me'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $5
   12     5        ASSIGN                                                   !2, <array>
   15     6        INIT_METHOD_CALL                                         !0, 'call'
          7        SEND_VAR_EX                                              !1
          8        CHECK_FUNC_ARG                                           
          9        FETCH_DIM_FUNC_ARG                               $9      !2, 0
         10        SEND_FUNC_ARG                                            $9
         11        CHECK_FUNC_ARG                                           
         12        FETCH_DIM_FUNC_ARG                               $10     !2, 1
         13        SEND_FUNC_ARG                                            $10
         14        DO_FCALL                                      0          
   21    15        INIT_ARRAY                                       ~12     !0
         16        ADD_ARRAY_ELEMENT                                ~12     'call'
         17        INIT_USER_CALL                                0          'call_user_func_array', ~12
         18        INIT_FCALL                                               'array_merge'
         19        INIT_ARRAY                                       ~13     !1
         20        SEND_VAL                                                 ~13
         21        SEND_VAR                                                 !2
         22        DO_ICALL                                         $14     
         23        SEND_ARRAY                                               $14
         24        CHECK_UNDEF_ARGS                                         
         25        DO_FCALL                                      0          
         26      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FMtJDj%3A3%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MtJDj
function name:  {closure}
number of ops:  10
compiled vars:  !0 = $arg1, !1 = $arg2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      2
    4     2        INIT_FCALL                                               'var_dump'
          3        FETCH_THIS                                       $2      
          4        FETCH_OBJ_R                                      ~3      $2, 'mine'
          5        SEND_VAL                                                 ~3
          6        SEND_VAR                                                 !0
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                                 
    5     9      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FMtJDj%3A3%240

Class Me: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
221.78 ms | 1396 KiB | 17 Q