3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Command { public function run(): int { return $this->execute(); } protected function execute(): int { throw new LogicException('You must override the execute() method in the concrete command class.'); } } class FooCommand extends Command { protected function execute(): int { echo "Executing FooCommand\n"; return 0; } } class BarCommand extends Command { public function __construct(private readonly FooCommand $command) { } protected function execute(): int { $this->command->execute(); echo "Executing BarCommand\n"; return 0; } } $command = new BarCommand(new FooCommand()); $command->run();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hAU8q
function name:  (null)
number of ops:  9
compiled vars:  !0 = $command
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   NEW                                              $1      'BarCommand'
          1        NEW                                              $2      'FooCommand'
          2        DO_FCALL                                      0          
          3        SEND_VAR_NO_REF_EX                                       $2
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $1
   43     6        INIT_METHOD_CALL                                         !0, 'run'
          7        DO_FCALL                                      0          
          8      > RETURN                                                   1

Class Command:
Function run:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hAU8q
function name:  run
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   INIT_METHOD_CALL                                         'execute'
          1        DO_FCALL                                      0  $0      
          2        VERIFY_RETURN_TYPE                                       $0
          3      > RETURN                                                   $0
    8     4*       VERIFY_RETURN_TYPE                                       
          5*     > RETURN                                                   null

End of function run

Function execute:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/hAU8q
function name:  execute
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   NEW                                              $0      'LogicException'
          1        SEND_VAL_EX                                              'You+must+override+the+execute%28%29+method+in+the+concrete+command+class.'
          2        DO_FCALL                                      0          
          3      > THROW                                         0          $0
   13     4*       VERIFY_RETURN_TYPE                                       
          5*     > RETURN                                                   null

End of function execute

End of class Command.

Class FooCommand:
Function execute:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hAU8q
function name:  execute
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   ECHO                                                     'Executing+FooCommand%0A'
   22     1      > RETURN                                                   0
   23     2*       VERIFY_RETURN_TYPE                                       
          3*     > RETURN                                                   null

End of function execute

Function run:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hAU8q
function name:  run
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   INIT_METHOD_CALL                                         'execute'
          1        DO_FCALL                                      0  $0      
          2        VERIFY_RETURN_TYPE                                       $0
          3      > RETURN                                                   $0
    8     4*       VERIFY_RETURN_TYPE                                       
          5*     > RETURN                                                   null

End of function run

End of class FooCommand.

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

End of function __construct

Function execute:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hAU8q
function name:  execute
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   FETCH_OBJ_R                                      ~0      'command'
          1        INIT_METHOD_CALL                                         ~0, 'execute'
          2        DO_FCALL                                      0          
   36     3        ECHO                                                     'Executing+BarCommand%0A'
   38     4      > RETURN                                                   0
   39     5*       VERIFY_RETURN_TYPE                                       
          6*     > RETURN                                                   null

End of function execute

Function run:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hAU8q
function name:  run
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   INIT_METHOD_CALL                                         'execute'
          1        DO_FCALL                                      0  $0      
          2        VERIFY_RETURN_TYPE                                       $0
          3      > RETURN                                                   $0
    8     4*       VERIFY_RETURN_TYPE                                       
          5*     > RETURN                                                   null

End of function run

End of class BarCommand.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.57 ms | 1002 KiB | 13 Q