3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ArrayObjectChild extends ArrayObject { public function offsetExists($offset) { var_dump('Called: '.__METHOD__); return parent::offsetExists($offset); } public function offsetGet($offset) { var_dump('Called: '.__METHOD__); return parent::offsetGet($offset); } } class ArrayAcessImplementation implements ArrayAccess { private $_array = array(); public function __construct(array $array) { $this->_array = $array; } public function offsetExists($offset) { var_dump('Called: '.__METHOD__); return array_key_exists($offset, $this->_array); } public function offsetGet($offset) { var_dump('Called: '.__METHOD__); return $this->_array[$offset]; } public function offsetSet($offset, $value) {} public function offsetUnset($offset) {} } $array = array('foo' => ''); echo "ArrayObject extended:\n"; $object = new ArrayObjectChild($array); var_dump(empty($object['foo'])); echo "ArrayObject:\n"; $object = new ArrayObject($array); var_dump(empty($object['foo'])); echo "ArrayAccess implemented:\n"; $object = new ArrayAcessImplementation($array); var_dump(empty($object['foo']));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vA7Qh
function name:  (null)
number of ops:  30
compiled vars:  !0 = $array, !1 = $object
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   DECLARE_CLASS                                            'arrayacessimplementation'
   39     1        ASSIGN                                                   !0, <array>
   41     2        ECHO                                                     'ArrayObject+extended%3A%0A'
   42     3        NEW                                              $3      'ArrayObjectChild'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $3
   43     7        INIT_FCALL                                               'var_dump'
          8        ISSET_ISEMPTY_DIM_OBJ                         1  ~6      !1, 'foo'
          9        SEND_VAL                                                 ~6
         10        DO_ICALL                                                 
   45    11        ECHO                                                     'ArrayObject%3A%0A'
   46    12        NEW                                              $8      'ArrayObject'
         13        SEND_VAR_EX                                              !0
         14        DO_FCALL                                      0          
         15        ASSIGN                                                   !1, $8
   47    16        INIT_FCALL                                               'var_dump'
         17        ISSET_ISEMPTY_DIM_OBJ                         1  ~11     !1, 'foo'
         18        SEND_VAL                                                 ~11
         19        DO_ICALL                                                 
   49    20        ECHO                                                     'ArrayAccess+implemented%3A%0A'
   50    21        NEW                                              $13     'ArrayAcessImplementation'
         22        SEND_VAR_EX                                              !0
         23        DO_FCALL                                      0          
         24        ASSIGN                                                   !1, $13
   51    25        INIT_FCALL                                               'var_dump'
         26        ISSET_ISEMPTY_DIM_OBJ                         1  ~16     !1, 'foo'
         27        SEND_VAL                                                 ~16
         28        DO_ICALL                                                 
         29      > RETURN                                                   1

Class ArrayObjectChild:
Function offsetexists:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vA7Qh
function name:  offsetExists
number of ops:  9
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    6     1        INIT_FCALL                                               'var_dump'
          2        SEND_VAL                                                 'Called%3A+ArrayObjectChild%3A%3AoffsetExists'
          3        DO_ICALL                                                 
    7     4        INIT_STATIC_METHOD_CALL                                  'offsetExists'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0  $2      
          7      > RETURN                                                   $2
    8     8*     > RETURN                                                   null

End of function offsetexists

Function offsetget:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vA7Qh
function name:  offsetGet
number of ops:  9
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   11     1        INIT_FCALL                                               'var_dump'
          2        SEND_VAL                                                 'Called%3A+ArrayObjectChild%3A%3AoffsetGet'
          3        DO_ICALL                                                 
   12     4        INIT_STATIC_METHOD_CALL                                  'offsetGet'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0  $2      
          7      > RETURN                                                   $2
   13     8*     > RETURN                                                   null

End of function offsetget

End of class ArrayObjectChild.

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

End of function __construct

Function offsetexists:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vA7Qh
function name:  offsetExists
number of ops:  8
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
   26     1        INIT_FCALL                                               'var_dump'
          2        SEND_VAL                                                 'Called%3A+ArrayAcessImplementation%3A%3AoffsetExists'
          3        DO_ICALL                                                 
   27     4        FETCH_OBJ_R                                      ~2      '_array'
          5        ARRAY_KEY_EXISTS                                 ~3      !0, ~2
          6      > RETURN                                                   ~3
   28     7*     > RETURN                                                   null

End of function offsetexists

Function offsetget:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vA7Qh
function name:  offsetGet
number of ops:  8
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
   31     1        INIT_FCALL                                               'var_dump'
          2        SEND_VAL                                                 'Called%3A+ArrayAcessImplementation%3A%3AoffsetGet'
          3        DO_ICALL                                                 
   32     4        FETCH_OBJ_R                                      ~2      '_array'
          5        FETCH_DIM_R                                      ~3      ~2, !0
          6      > RETURN                                                   ~3
   33     7*     > RETURN                                                   null

End of function offsetget

Function offsetset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vA7Qh
function name:  offsetSet
number of ops:  3
compiled vars:  !0 = $offset, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2      > RETURN                                                   null

End of function offsetset

Function offsetunset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vA7Qh
function name:  offsetUnset
number of ops:  2
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   RECV                                             !0      
          1      > RETURN                                                   null

End of function offsetunset

End of class ArrayAcessImplementation.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.04 ms | 1404 KiB | 15 Q