3v4l.org

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

Function %00%7Bclosure%7D%2Fin%2FKlIF7%3A10%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KlIF7
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, 'Decorated'
          2      > RETURN                                                   ~1
          3*     > RETURN                                                   null

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

Class Test:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KlIF7
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/KlIF7
function name:  __call
number of ops:  19
compiled vars:  !0 = $method, !1 = $args, !2 = $decorated, !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%2FKlIF7%3A10%240'
          5        SEND_VAL                                                 ~4
          6        DO_ICALL                                         $5      
          7        FETCH_DIM_R                                      ~6      $5, 0
          8        ASSIGN                                                   !2, ~6
   13     9        FETCH_OBJ_R                                      ~8      'service'
         10        INIT_ARRAY                                       ~9      ~8
         11        ADD_ARRAY_ELEMENT                                ~9      !0
         12        INIT_USER_CALL                                0          'call_user_func_array', ~9
   14    13        SEND_ARRAY                                               !1
         14        CHECK_UNDEF_ARGS                                         
         15        DO_FCALL                                      0  $10     
   12    16        ASSIGN                                                   !3, $10
   17    17      > RETURN                                                   !3
   18    18*     > 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/KlIF7
function name:  doSomething
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E > > RETURN                                                   'did+something'
          1*     > RETURN                                                   null

End of function dosomething

End of class Decorated.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.83 ms | 1400 KiB | 15 Q