3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { public function __construct($decorated) { $this->decorated = $decorated; } public function __call($method, $args) { $request = array_filter($args, function($arg) { return $arg instanceof Request; }); var_dump($args); var_dump($request); $response = call_user_func_array( array($this->decorated, $method), $args ); return $response; } } class Decorated { public function doSomething() { return 'did something'; } } class Request {} $x = new Decorated; $t = new Test($x); $response = $t->doSomething(new Request); echo $response;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/faobe
function name:  (null)
number of ops:  15
compiled vars:  !0 = $x, !1 = $t, !2 = $response
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   NEW                                              $3      'Decorated'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   29     3        NEW                                              $6      'Test'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $6
   30     7        INIT_METHOD_CALL                                         !1, 'doSomething'
          8        NEW                                              $9      'Request'
          9        DO_FCALL                                      0          
         10        SEND_VAR_NO_REF_EX                                       $9
         11        DO_FCALL                                      0  $11     
         12        ASSIGN                                                   !2, $11
   32    13        ECHO                                                     !2
         14      > RETURN                                                   1

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

End of function %00%7Bclosure%7D%2Fin%2Ffaobe%3A10%240

Class Test:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/faobe
function name:  __construct
number of ops:  4
compiled vars:  !0 = $decorated
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    6     1        ASSIGN_OBJ                                               'decorated'
          2        OP_DATA                                                  !0
    7     3      > RETURN                                                   null

End of function __construct

Function __call:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/faobe
function name:  __call
number of ops:  24
compiled vars:  !0 = $method, !1 = $args, !2 = $request, !3 = $response
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   10     2        INIT_FCALL                                               'array_filter'
          3        SEND_VAR                                                 !1
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Ffaobe%3A10%240'
          5        SEND_VAL                                                 ~4
          6        DO_ICALL                                         $5      
          7        ASSIGN                                                   !2, $5
   12     8        INIT_FCALL                                               'var_dump'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                                 
   13    11        INIT_FCALL                                               'var_dump'
         12        SEND_VAR                                                 !2
         13        DO_ICALL                                                 
   16    14        FETCH_OBJ_R                                      ~9      'decorated'
         15        INIT_ARRAY                                       ~10     ~9
         16        ADD_ARRAY_ELEMENT                                ~10     !0
         17        INIT_USER_CALL                                0          'call_user_func_array', ~10
   17    18        SEND_ARRAY                                               !1
         19        CHECK_UNDEF_ARGS                                         
         20        DO_FCALL                                      0  $11     
   15    21        ASSIGN                                                   !3, $11
   20    22      > RETURN                                                   !3
   21    23*     > RETURN                                                   null

End of function __call

End of class Test.

Class Decorated:
Function dosomething:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/faobe
function name:  doSomething
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E > > RETURN                                                   'did+something'
          1*     > RETURN                                                   null

End of function dosomething

End of class Decorated.

Class Request: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.53 ms | 1400 KiB | 17 Q