3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class Component { protected $data; abstract public function getHtml(); } class ConcreteComponent extends Component { // public function __construct() // { // $this->data = "<body></body>"; // } public function getHtml() { // return $this->data; return "<body></body>"; } } abstract class Decorator extends Component { } class ConcreteDecorator1 extends Decorator { public function __construct(Component $data) { $this->data = $data; } public function getHtml() { return $this->data->getHtml() . "<p> </p>"; } } class ConcreteDecorator2 extends Decorator { public function __construct(Component $data) { $this->value = 500; $this->data = $data; } public function getHtml() { return "<span>".$this->data->getHtml()."</span>"; } } $compo = new ConcreteDecorator2(new ConcreteDecorator1(new ConcreteComponent())); echo $compo->getHtml(); // echo "Client:\t\t\t"; // echo $compo->getValue();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qic3G
function name:  (null)
number of ops:  13
compiled vars:  !0 = $compo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   56     0  E >   NEW                                              $1      'ConcreteDecorator2'
          1        NEW                                              $2      'ConcreteDecorator1'
          2        NEW                                              $3      'ConcreteComponent'
          3        DO_FCALL                                      0          
          4        SEND_VAR_NO_REF_EX                                       $3
          5        DO_FCALL                                      0          
          6        SEND_VAR_NO_REF_EX                                       $2
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !0, $1
   58     9        INIT_METHOD_CALL                                         !0, 'getHtml'
         10        DO_FCALL                                      0  $8      
         11        ECHO                                                     $8
   60    12      > RETURN                                                   1

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

End of function gethtml

End of class Component.

Class ConcreteComponent:
Function gethtml:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qic3G
function name:  getHtml
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E > > RETURN                                                   '%3Cbody%3E%3C%2Fbody%3E'
   21     1*     > RETURN                                                   null

End of function gethtml

End of class ConcreteComponent.

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

End of function gethtml

End of class Decorator.

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

End of function __construct

Function gethtml:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qic3G
function name:  getHtml
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   FETCH_OBJ_R                                      ~0      'data'
          1        INIT_METHOD_CALL                                         ~0, 'getHtml'
          2        DO_FCALL                                      0  $1      
          3        CONCAT                                           ~2      $1, '%3Cp%3E+++%3C%2Fp%3E'
          4      > RETURN                                                   ~2
   39     5*     > RETURN                                                   null

End of function gethtml

End of class ConcreteDecorator1.

Class ConcreteDecorator2:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qic3G
function name:  __construct
number of ops:  6
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   44     0  E >   RECV                                             !0      
   46     1        ASSIGN_OBJ                                               'value'
          2        OP_DATA                                                  500
   47     3        ASSIGN_OBJ                                               'data'
          4        OP_DATA                                                  !0
   48     5      > RETURN                                                   null

End of function __construct

Function gethtml:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qic3G
function name:  getHtml
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   52     0  E >   FETCH_OBJ_R                                      ~0      'data'
          1        INIT_METHOD_CALL                                         ~0, 'getHtml'
          2        DO_FCALL                                      0  $1      
          3        CONCAT                                           ~2      '%3Cspan%3E', $1
          4        CONCAT                                           ~3      ~2, '%3C%2Fspan%3E'
          5      > RETURN                                                   ~3
   53     6*     > RETURN                                                   null

End of function gethtml

End of class ConcreteDecorator2.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
181.32 ms | 1399 KiB | 13 Q