3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Command{ /** @var callable $code */ private $code; /** * @param callable $code */ public function setCode(callable $code): static { $this->code = $code; return $this; } public function execute(): void { ($this->code)(); } } class CustomCommand extends Command{ public function __construct(){ parent::setCode([$this, 'runCustomCommand']); } protected function runCustomCommand(): void { echo 'Protected function called'; } } $code = new CustomCommand(); $code->execute();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/k9tTa
function name:  (null)
number of ops:  6
compiled vars:  !0 = $code
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   NEW                                              $1      'CustomCommand'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   35     3        INIT_METHOD_CALL                                         !0, 'execute'
          4        DO_FCALL                                      0          
          5      > RETURN                                                   1

Class Command:
Function setcode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/k9tTa
function name:  setCode
number of ops:  8
compiled vars:  !0 = $code
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   13     1        ASSIGN_OBJ                                               'code'
          2        OP_DATA                                                  !0
   14     3        FETCH_THIS                                       ~2      
          4        VERIFY_RETURN_TYPE                                       ~2
          5      > RETURN                                                   ~2
   15     6*       VERIFY_RETURN_TYPE                                       
          7*     > RETURN                                                   null

End of function setcode

Function execute:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/k9tTa
function name:  execute
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   FETCH_OBJ_R                                      ~0      'code'
          1        INIT_DYNAMIC_CALL                                        ~0
          2        DO_FCALL                                      0          
   20     3      > RETURN                                                   null

End of function execute

End of class Command.

Class CustomCommand:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/k9tTa
function name:  __construct
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   INIT_STATIC_METHOD_CALL                                  'setCode'
          1        FETCH_THIS                                       ~0      
          2        INIT_ARRAY                                       ~1      ~0
          3        ADD_ARRAY_ELEMENT                                ~1      'runCustomCommand'
          4        SEND_VAL_EX                                              ~1
          5        DO_FCALL                                      0          
   26     6      > RETURN                                                   null

End of function __construct

Function runcustomcommand:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/k9tTa
function name:  runCustomCommand
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   ECHO                                                     'Protected+function+called'
   31     1      > RETURN                                                   null

End of function runcustomcommand

Function setcode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/k9tTa
function name:  setCode
number of ops:  8
compiled vars:  !0 = $code
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   13     1        ASSIGN_OBJ                                               'code'
          2        OP_DATA                                                  !0
   14     3        FETCH_THIS                                       ~2      
          4        VERIFY_RETURN_TYPE                                       ~2
          5      > RETURN                                                   ~2
   15     6*       VERIFY_RETURN_TYPE                                       
          7*     > RETURN                                                   null

End of function setcode

Function execute:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/k9tTa
function name:  execute
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   FETCH_OBJ_R                                      ~0      'code'
          1        INIT_DYNAMIC_CALL                                        ~0
          2        DO_FCALL                                      0          
   20     3      > RETURN                                                   null

End of function execute

End of class CustomCommand.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.26 ms | 1428 KiB | 13 Q