3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Menu { private $menus = []; private $name; public function __construct($name) { $this->name = $name; } public function addMenu(self $menu) { $this->menus[] = $menu; } public function getMenus() { return $this->menus; } public function __toString() { return $this->name; } } class SubMenu extends Menu {} $menu1 = new Menu('Top Level Menu'); $menu1->addMenu(new Menu('Child Menu')); $menu1->addMenu(new SubMenu('Sub Menu')); foreach ($menu1->getMenus() as $menu) { echo "{$menu}<br />"; }
based on WhXTn
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = 22, Position 2 = 27
Branch analysis from position: 22
Jump found. Position 1 = 23, Position 2 = 27
Branch analysis from position: 23
Jump found. Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 27
Jump found. Position 1 = -2
Branch analysis from position: 27
filename:       /in/YrK6d
function name:  (null)
number of ops:  29
compiled vars:  !0 = $menu1, !1 = $menu
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   NOP                                                      
  22     1        NOP                                                      
         2        NOP                                                      
  24     3        NEW                                              $5      :-4
         4        SEND_VAL_EX                                              'Top+Level+Menu'
         5        DO_FCALL                                      0          
         6        ASSIGN                                                   !0, $5
  25     7        INIT_METHOD_CALL                                         !0, 'addMenu'
         8        NEW                                              $8      :1
         9        SEND_VAL_EX                                              'Child+Menu'
        10        DO_FCALL                                      0          
        11        SEND_VAR_NO_REF                               0          $8
        12        DO_FCALL                                      0          
  26    13        INIT_METHOD_CALL                                         !0, 'addMenu'
        14        NEW                                              $11     :6
        15        SEND_VAL_EX                                              'Sub+Menu'
        16        DO_FCALL                                      0          
        17        SEND_VAR_NO_REF                               0          $11
        18        DO_FCALL                                      0          
  28    19        INIT_METHOD_CALL                                         !0, 'getMenus'
        20        DO_FCALL                                      0  $14     
        21      > FE_RESET_R                                       $15     $14, ->27
        22    > > FE_FETCH_R                                               $15, !1, ->27
  29    23    >   NOP                                                      
        24        FAST_CONCAT                                      ~16     !1, '%3Cbr+%2F%3E'
        25        ECHO                                                     ~16
        26      > JMP                                                      ->22
        27    >   FE_FREE                                                  $15
        28      > RETURN                                                   1

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

End of function __construct

Function addmenu:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/YrK6d
function name:  addMenu
number of ops:  5
compiled vars:  !0 = $menu
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  12     0  E >   RECV                                             !0      
  14     1        FETCH_OBJ_W                                      $1      'menus'
         2        ASSIGN_DIM                                               $1
         3        OP_DATA                                                  !0
  15     4      > RETURN                                                   null

End of function addmenu

Function getmenus:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/YrK6d
function name:  getMenus
number of ops:  3
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  17     0  E >   FETCH_OBJ_R                                      $0      'menus'
         1      > RETURN                                                   $0
         2*     > RETURN                                                   null

End of function getmenus

Function __tostring:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/YrK6d
function name:  __toString
number of ops:  3
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  19     0  E >   FETCH_OBJ_R                                      $0      'name'
         1      > RETURN                                                   $0
         2*     > RETURN                                                   null

End of function __tostring

End of class Menu.

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

End of function __construct

Function addmenu:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/YrK6d
function name:  addMenu
number of ops:  5
compiled vars:  !0 = $menu
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  12     0  E >   RECV                                             !0      
  14     1        FETCH_OBJ_W                                      $1      'menus'
         2        ASSIGN_DIM                                               $1
         3        OP_DATA                                                  !0
  15     4      > RETURN                                                   null

End of function addmenu

Function getmenus:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/YrK6d
function name:  getMenus
number of ops:  3
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  17     0  E >   FETCH_OBJ_R                                      $0      'menus'
         1      > RETURN                                                   $0
         2*     > RETURN                                                   null

End of function getmenus

Function __tostring:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/YrK6d
function name:  __toString
number of ops:  3
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  19     0  E >   FETCH_OBJ_R                                      $0      'name'
         1      > RETURN                                                   $0
         2*     > RETURN                                                   null

End of function __tostring

End of class SubMenu.

Generated using Vulcan Logic Dumper, using php 7.3.0