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: echo 'No such file'; } $message = $shape->render(); echo $message; } } 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() { //echo $this->name; 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/avT75
function name:  (null)
number of ops:  8
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   DECLARE_CLASS                                            'squareshape'
   40     1        DECLARE_CLASS                                            'rectangleshape'
   51     2        NEW                                              $1      'ShapeFactory'
          3        SEND_VAL_EX                                              'rectangle'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $1
   53     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/avT75
function name:  __construct
number of ops:  22
compiled vars:  !0 = $type, !1 = $shape, !2 = $message
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                                                    ~4, ->8
   12     5    >   IS_EQUAL                                                 !0, 'square'
          6      > JMPNZ                                                    ~4, ->12
          7    > > JMP                                                      ->16
   10     8    >   NEW                                              $5      'RectangleShape'
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !1, $5
   11    11      > JMP                                                      ->17
   13    12    >   NEW                                              $8      'SquareShape'
         13        DO_FCALL                                      0          
         14        ASSIGN                                                   !1, $8
   14    15      > JMP                                                      ->17
   16    16    >   ECHO                                                     'No+such+file'
   18    17    >   INIT_METHOD_CALL                                         !1, 'render'
         18        DO_FCALL                                      0  $11     
         19        ASSIGN                                                   !2, $11
   20    20        ECHO                                                     !2
   21    21      > 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/avT75
function name:  render
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     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/avT75
function name:  render
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   FETCH_OBJ_R                                      ~0      'name'
          1      > RETURN                                                   ~0
   36     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/avT75
function name:  render
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   47     0  E >   FETCH_OBJ_R                                      ~0      'name'
          1      > RETURN                                                   ~0
   48     2*     > RETURN                                                   null

End of function render

End of class RectangleShape.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
185.07 ms | 1399 KiB | 13 Q