3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface WorldInterface { function doAThing($foo); } class World implements WorldInterface { public function __construct(string $name) { $this->name = $name; } public function doAThing($foo) { echo $foo; } } class BackwardsWorld implements WorldInterface { public function __construct(string $name) { $this->name = strrev($name); } public function doAThing($foo) { echo strrev($foo); } } class Hello { /** * @var World */ private $world; public function setWorld( WorldInterface $world ) { $this->world = $world; } } class WorldFactory { // full disclosure: I'm still bad at factories public static function makeWorld($name) { return new World($name); } public static function makeDlrow($name) { return new BackwardsWorld($name); } } $hey = new Hello(); $hey->setWorld(WorldFactory::makeWorld('blorp')); $yeh = new Hello(); $yeh->setWorld(WorldFactory::makeDlrow('blorp')); var_dump($hey, $yeh);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cK3Wo
function name:  (null)
number of ops:  25
compiled vars:  !0 = $hey, !1 = $yeh
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   DECLARE_CLASS                                            'world'
   17     1        DECLARE_CLASS                                            'backwardsworld'
   48     2        NEW                                              $2      'Hello'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $2
   49     5        INIT_METHOD_CALL                                         !0, 'setWorld'
          6        INIT_STATIC_METHOD_CALL                                  'WorldFactory', 'makeWorld'
          7        SEND_VAL                                                 'blorp'
          8        DO_FCALL                                      0  $5      
          9        SEND_VAR_NO_REF_EX                                       $5
         10        DO_FCALL                                      0          
   51    11        NEW                                              $7      'Hello'
         12        DO_FCALL                                      0          
         13        ASSIGN                                                   !1, $7
   52    14        INIT_METHOD_CALL                                         !1, 'setWorld'
         15        INIT_STATIC_METHOD_CALL                                  'WorldFactory', 'makeDlrow'
         16        SEND_VAL                                                 'blorp'
         17        DO_FCALL                                      0  $10     
         18        SEND_VAR_NO_REF_EX                                       $10
         19        DO_FCALL                                      0          
   54    20        INIT_FCALL                                               'var_dump'
         21        SEND_VAR                                                 !0
         22        SEND_VAR                                                 !1
         23        DO_ICALL                                                 
         24      > RETURN                                                   1

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

End of function doathing

End of class WorldInterface.

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

End of function __construct

Function doathing:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cK3Wo
function name:  doAThing
number of ops:  3
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   13     1        ECHO                                                     !0
   14     2      > RETURN                                                   null

End of function doathing

End of class World.

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

End of function __construct

Function doathing:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cK3Wo
function name:  doAThing
number of ops:  6
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
   23     1        INIT_FCALL                                               'strrev'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $1      
          4        ECHO                                                     $1
   24     5      > RETURN                                                   null

End of function doathing

End of class BackwardsWorld.

Class Hello:
Function setworld:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cK3Wo
function name:  setWorld
number of ops:  4
compiled vars:  !0 = $world
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   RECV                                             !0      
   34     1        ASSIGN_OBJ                                               'world'
          2        OP_DATA                                                  !0
   35     3      > RETURN                                                   null

End of function setworld

End of class Hello.

Class WorldFactory:
Function makeworld:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cK3Wo
function name:  makeWorld
number of ops:  6
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   RECV                                             !0      
   41     1        NEW                                              $1      'World'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4      > RETURN                                                   $1
   42     5*     > RETURN                                                   null

End of function makeworld

Function makedlrow:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cK3Wo
function name:  makeDlrow
number of ops:  6
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   43     0  E >   RECV                                             !0      
   44     1        NEW                                              $1      'BackwardsWorld'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4      > RETURN                                                   $1
   45     5*     > RETURN                                                   null

End of function makedlrow

End of class WorldFactory.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
175.66 ms | 1404 KiB | 17 Q