3v4l.org

run code in 300+ PHP versions simultaneously
<?php class WidgetCollection { private $widgetArray = []; public function addWidget(Widget $widget) { $this->widgetArray[spl_object_hash($widget)] = $widget; } public function removeWidget(Widget $widget) { unset($this->widgetArray[spl_object_hash($widget)]); } public function getEachWidget() { return array_values($this->widgetArray()); } } class Widget { } $widgetCollection = new WidgetCollection; $widgetCollection->addWidget($a = new Widget); $widgetCollection->addWidget($b = new Widget); $widgetCollection->addWidget($c = new Widget); var_dump($widgetCollection);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lCMQe
function name:  (null)
number of ops:  25
compiled vars:  !0 = $widgetCollection, !1 = $a, !2 = $b, !3 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   NEW                                              $4      'WidgetCollection'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $4
   26     3        INIT_METHOD_CALL                                         !0, 'addWidget'
          4        NEW                                              $7      'Widget'
          5        DO_FCALL                                      0          
          6        ASSIGN                                           ~9      !1, $7
          7        SEND_VAL_EX                                              ~9
          8        DO_FCALL                                      0          
   27     9        INIT_METHOD_CALL                                         !0, 'addWidget'
         10        NEW                                              $11     'Widget'
         11        DO_FCALL                                      0          
         12        ASSIGN                                           ~13     !2, $11
         13        SEND_VAL_EX                                              ~13
         14        DO_FCALL                                      0          
   28    15        INIT_METHOD_CALL                                         !0, 'addWidget'
         16        NEW                                              $15     'Widget'
         17        DO_FCALL                                      0          
         18        ASSIGN                                           ~17     !3, $15
         19        SEND_VAL_EX                                              ~17
         20        DO_FCALL                                      0          
   30    21        INIT_FCALL                                               'var_dump'
         22        SEND_VAR                                                 !0
         23        DO_ICALL                                                 
         24      > RETURN                                                   1

Class WidgetCollection:
Function addwidget:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lCMQe
function name:  addWidget
number of ops:  8
compiled vars:  !0 = $widget
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    9     1        INIT_FCALL                                               'spl_object_hash'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $2      
          4        FETCH_OBJ_W                                      $1      'widgetArray'
          5        ASSIGN_DIM                                               $1, $2
          6        OP_DATA                                                  !0
   10     7      > RETURN                                                   null

End of function addwidget

Function removewidget:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lCMQe
function name:  removeWidget
number of ops:  7
compiled vars:  !0 = $widget
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   14     1        INIT_FCALL                                               'spl_object_hash'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $2      
          4        FETCH_OBJ_UNSET                                  $1      'widgetArray'
          5        UNSET_DIM                                                $1, $2
   15     6      > RETURN                                                   null

End of function removewidget

Function geteachwidget:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lCMQe
function name:  getEachWidget
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   INIT_FCALL                                               'array_values'
          1        INIT_METHOD_CALL                                         'widgetArray'
          2        DO_FCALL                                      0  $0      
          3        SEND_VAR                                                 $0
          4        DO_ICALL                                         $1      
          5      > RETURN                                                   $1
   20     6*     > RETURN                                                   null

End of function geteachwidget

End of class WidgetCollection.

Class Widget: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.49 ms | 1404 KiB | 19 Q