3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface StrategyInterface { public function run(); } class Strategy implements StrategyInterface { protected ?string $value = null; public function __construct(private Closure $closure) { $this->value = (string) rand(1, 100); } public function run() { $this->closure->call($this); } } for ($i = 0; $i < 10; $i++) { $strategy = new Strategy(function() { var_dump($this->value); }); $strategy->run(); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 3
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 3
Branch analysis from position: 13
Branch analysis from position: 3
filename:       /in/eCtZU
function name:  (null)
number of ops:  14
compiled vars:  !0 = $i, !1 = $strategy
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   DECLARE_CLASS                                            'strategy'
   21     1        ASSIGN                                                   !0, 0
          2      > JMP                                                      ->11
   22     3    >   NEW                                              $3      'Strategy'
          4        DECLARE_LAMBDA_FUNCTION                          ~4      [0]
   24     5        SEND_VAL_EX                                              ~4
   22     6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $3
   26     8        INIT_METHOD_CALL                                         !1, 'run'
          9        DO_FCALL                                      0          
   21    10        PRE_INC                                                  !0
         11    >   IS_SMALLER                                               !0, 10
         12      > JMPNZ                                                    ~9, ->3
   27    13    > > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eCtZU
function name:  {closure}
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   INIT_FCALL                                               'var_dump'
          1        FETCH_THIS                                       $0      
          2        FETCH_OBJ_R                                      ~1      $0, 'value'
          3        SEND_VAL                                                 ~1
          4        DO_ICALL                                                 
   24     5      > RETURN                                                   null

End of Dynamic Function 0

Class StrategyInterface:
Function run:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eCtZU
function name:  run
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E > > RETURN                                                   null

End of function run

End of class StrategyInterface.

Class Strategy:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eCtZU
function name:  __construct
number of ops:  11
compiled vars:  !0 = $closure
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        ASSIGN_OBJ                                               'closure'
          2        OP_DATA                                                  !0
   12     3        INIT_FCALL                                               'rand'
          4        SEND_VAL                                                 1
          5        SEND_VAL                                                 100
          6        DO_ICALL                                         $2      
          7        CAST                                          6  ~3      $2
          8        ASSIGN_OBJ                                               'value'
          9        OP_DATA                                                  ~3
   13    10      > RETURN                                                   null

End of function __construct

Function run:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eCtZU
function name:  run
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   FETCH_OBJ_R                                      ~0      'closure'
          1        INIT_METHOD_CALL                                         ~0, 'call'
          2        FETCH_THIS                                       $1      
          3        SEND_VAR_EX                                              $1
          4        DO_FCALL                                      0          
   18     5      > RETURN                                                   null

End of function run

End of class Strategy.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
136.64 ms | 1004 KiB | 15 Q