3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ShapeFactory { public function __construct($type) { $shape = null; switch ($type){ case 'rectangle': $shape = new RectangleShape; break; case 'square': $shape = new SquareShape; break; default: return 'No such file'; } return $shape->render(); } } interface Shape { public function render(); } class SquareShape implements Shape { public $name = 'square'; public function render() { return $this->name; } } class RectangleShape implements Shape { public $name = 'rectangle'; public function render() { return $this->name; } } $test = new ShapeFactory('rectangle'); echo $test;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1cWJe
function name:  (null)
number of ops:  8
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   DECLARE_CLASS                                            'squareshape'
   39     1        DECLARE_CLASS                                            'rectangleshape'
   49     2        NEW                                              $1      'ShapeFactory'
          3        SEND_VAL_EX                                              'rectangle'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $1
   51     6        ECHO                                                     !0
          7      > RETURN                                                   1

Class ShapeFactory:
Function __construct:
Finding entry points
Branch analysis from position: 0
4 jumps found. (Code = 188) Position 1 = 8, Position 2 = 12, Position 3 = 16, Position 4 = 3
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 7, Position 2 = 12
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 12
Branch analysis from position: 8
filename:       /in/1cWJe
function name:  __construct
number of ops:  21
compiled vars:  !0 = $type, !1 = $shape
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    7     1        ASSIGN                                                   !1, null
    8     2      > SWITCH_STRING                                            !0, [ 'rectangle':->8, 'square':->12, ], ->16
    9     3    >   IS_EQUAL                                                 !0, 'rectangle'
          4      > JMPNZ                                                    ~3, ->8
   12     5    >   IS_EQUAL                                                 !0, 'square'
          6      > JMPNZ                                                    ~3, ->12
          7    > > JMP                                                      ->16
   10     8    >   NEW                                              $4      'RectangleShape'
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !1, $4
   11    11      > JMP                                                      ->17
   13    12    >   NEW                                              $7      'SquareShape'
         13        DO_FCALL                                      0          
         14        ASSIGN                                                   !1, $7
   14    15      > JMP                                                      ->17
   16    16    > > RETURN                                                   'No+such+file'
   19    17    >   INIT_METHOD_CALL                                         !1, 'render'
         18        DO_FCALL                                      0  $10     
         19      > RETURN                                                   $10
   20    20*     > RETURN                                                   null

End of function __construct

End of class ShapeFactory.

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

End of function render

End of class Shape.

Class SquareShape:
Function render:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1cWJe
function name:  render
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   FETCH_OBJ_R                                      ~0      'name'
          1      > RETURN                                                   ~0
   35     2*     > RETURN                                                   null

End of function render

End of class SquareShape.

Class RectangleShape:
Function render:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1cWJe
function name:  render
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   45     0  E >   FETCH_OBJ_R                                      ~0      'name'
          1      > RETURN                                                   ~0
   46     2*     > RETURN                                                   null

End of function render

End of class RectangleShape.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.45 ms | 1399 KiB | 13 Q