3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class HTMLDecorator { /** @var \ArrayObject */ protected $notes; public function format(){ $html = ''; foreach ($this->getNodes() as $node) $html .= "<p>{$node}</p>"; return $html; } } class HTML extends HTMLDecorator{ public function __construct(){ $this->nodes = new \ArrayObject(); } public function getNodes(){ return $this->nodes; } } class BlockHtml extends HTMLDecorator{ protected $html; public function __construct(HTMLDecorator $html){ $this->html = $html; } public function getNodes() { $this->html->getNodes()->append('Block html'); return $this->html->getNodes(); } } class ImageHtml extends HTMLDecorator{ protected $html; public function __construct(HTMLDecorator $html){ $this->html = $html; } public function getNodes() { $this->html->getNodes()->append('Image html'); return $this->html->getNodes(); } } $html = new HTML(); $html = new BlockHTML($html); $html = new ImageHTML($html); //echo $html->format();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0aWYR
function name:  (null)
number of ops:  12
compiled vars:  !0 = $html
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   64     0  E >   NEW                                              $1      'HTML'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   65     3        NEW                                              $4      'BlockHTML'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !0, $4
   66     7        NEW                                              $7      'ImageHTML'
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !0, $7
   67    11      > RETURN                                                   1

Class HTMLDecorator:
Function format:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 10
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 10
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/0aWYR
function name:  format
number of ops:  13
compiled vars:  !0 = $html, !1 = $node
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   ASSIGN                                                   !0, ''
   11     1        INIT_METHOD_CALL                                         'getNodes'
          2        DO_FCALL                                      0  $3      
          3      > FE_RESET_R                                       $4      $3, ->10
          4    > > FE_FETCH_R                                               $4, !1, ->10
   12     5    >   ROPE_INIT                                     3  ~6      '%3Cp%3E'
          6        ROPE_ADD                                      1  ~6      ~6, !1
          7        ROPE_END                                      2  ~5      ~6, '%3C%2Fp%3E'
          8        ASSIGN_OP                                     8          !0, ~5
   11     9      > JMP                                                      ->4
         10    >   FE_FREE                                                  $4
   14    11      > RETURN                                                   !0
   15    12*     > RETURN                                                   null

End of function format

End of class HTMLDecorator.

Class HTML:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0aWYR
function name:  __construct
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   NEW                                              $1      'ArrayObject'
          1        DO_FCALL                                      0          
          2        ASSIGN_OBJ                                               'nodes'
          3        OP_DATA                                                  $1
   23     4      > RETURN                                                   null

End of function __construct

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

End of function getnodes

Function format:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 10
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 10
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/0aWYR
function name:  format
number of ops:  13
compiled vars:  !0 = $html, !1 = $node
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   ASSIGN                                                   !0, ''
   11     1        INIT_METHOD_CALL                                         'getNodes'
          2        DO_FCALL                                      0  $3      
          3      > FE_RESET_R                                       $4      $3, ->10
          4    > > FE_FETCH_R                                               $4, !1, ->10
   12     5    >   ROPE_INIT                                     3  ~6      '%3Cp%3E'
          6        ROPE_ADD                                      1  ~6      ~6, !1
          7        ROPE_END                                      2  ~5      ~6, '%3C%2Fp%3E'
          8        ASSIGN_OP                                     8          !0, ~5
   11     9      > JMP                                                      ->4
         10    >   FE_FREE                                                  $4
   14    11      > RETURN                                                   !0
   15    12*     > RETURN                                                   null

End of function format

End of class HTML.

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

End of function __construct

Function getnodes:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0aWYR
function name:  getNodes
number of ops:  11
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   FETCH_OBJ_R                                      ~0      'html'
          1        INIT_METHOD_CALL                                         ~0, 'getNodes'
          2        DO_FCALL                                      0  $1      
          3        INIT_METHOD_CALL                                         $1, 'append'
          4        SEND_VAL_EX                                              'Block+html'
          5        DO_FCALL                                      0          
   42     6        FETCH_OBJ_R                                      ~3      'html'
          7        INIT_METHOD_CALL                                         ~3, 'getNodes'
          8        DO_FCALL                                      0  $4      
          9      > RETURN                                                   $4
   43    10*     > RETURN                                                   null

End of function getnodes

Function format:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 10
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 10
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/0aWYR
function name:  format
number of ops:  13
compiled vars:  !0 = $html, !1 = $node
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   ASSIGN                                                   !0, ''
   11     1        INIT_METHOD_CALL                                         'getNodes'
          2        DO_FCALL                                      0  $3      
          3      > FE_RESET_R                                       $4      $3, ->10
          4    > > FE_FETCH_R                                               $4, !1, ->10
   12     5    >   ROPE_INIT                                     3  ~6      '%3Cp%3E'
          6        ROPE_ADD                                      1  ~6      ~6, !1
          7        ROPE_END                                      2  ~5      ~6, '%3C%2Fp%3E'
          8        ASSIGN_OP                                     8          !0, ~5
   11     9      > JMP                                                      ->4
         10    >   FE_FREE                                                  $4
   14    11      > RETURN                                                   !0
   15    12*     > RETURN                                                   null

End of function format

End of class BlockHtml.

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

End of function __construct

Function getnodes:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0aWYR
function name:  getNodes
number of ops:  11
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   58     0  E >   FETCH_OBJ_R                                      ~0      'html'
          1        INIT_METHOD_CALL                                         ~0, 'getNodes'
          2        DO_FCALL                                      0  $1      
          3        INIT_METHOD_CALL                                         $1, 'append'
          4        SEND_VAL_EX                                              'Image+html'
          5        DO_FCALL                                      0          
   59     6        FETCH_OBJ_R                                      ~3      'html'
          7        INIT_METHOD_CALL                                         ~3, 'getNodes'
          8        DO_FCALL                                      0  $4      
          9      > RETURN                                                   $4
   60    10*     > RETURN                                                   null

End of function getnodes

Function format:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 10
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 10
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/0aWYR
function name:  format
number of ops:  13
compiled vars:  !0 = $html, !1 = $node
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   ASSIGN                                                   !0, ''
   11     1        INIT_METHOD_CALL                                         'getNodes'
          2        DO_FCALL                                      0  $3      
          3      > FE_RESET_R                                       $4      $3, ->10
          4    > > FE_FETCH_R                                               $4, !1, ->10
   12     5    >   ROPE_INIT                                     3  ~6      '%3Cp%3E'
          6        ROPE_ADD                                      1  ~6      ~6, !1
          7        ROPE_END                                      2  ~5      ~6, '%3C%2Fp%3E'
          8        ASSIGN_OP                                     8          !0, ~5
   11     9      > JMP                                                      ->4
         10    >   FE_FREE                                                  $4
   14    11      > RETURN                                                   !0
   15    12*     > RETURN                                                   null

End of function format

End of class ImageHtml.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.42 ms | 1398 KiB | 13 Q