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); } public function offsetGet($offset) { var_dump('Called: '.__METHOD__); return $this->_array($offset); } public function offsetSet($offset, $value) {} public function offsetUnset($offset) {} } $array = array('foo' => ''); // ArrayObject: empty string is set, but empty $object = new ArrayObject($array); var_dump(isset($object['foo']), empty($object['foo'])); // ArrayObject extended: empty string is set, but not empty $object = new ArrayObjectChild($array); var_dump(isset($object['foo']), empty($object['foo'])); // ArrayAccess implemented: empty string is set, but empty $object = new ArrayAcessImplementation($array); var_dump(isset($object['foo']), empty($object['foo']));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HGPBG
function name:  (null)
number of ops:  33
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>
   42     2        NEW                                              $3      'ArrayObject'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $3
   43     6        INIT_FCALL                                               'var_dump'
          7        ISSET_ISEMPTY_DIM_OBJ                         0  ~6      !1, 'foo'
          8        SEND_VAL                                                 ~6
          9        ISSET_ISEMPTY_DIM_OBJ                         1  ~7      !1, 'foo'
         10        SEND_VAL                                                 ~7
         11        DO_ICALL                                                 
   46    12        NEW                                              $9      'ArrayObjectChild'
         13        SEND_VAR_EX                                              !0
         14        DO_FCALL                                      0          
         15        ASSIGN                                                   !1, $9
   47    16        INIT_FCALL                                               'var_dump'
         17        ISSET_ISEMPTY_DIM_OBJ                         0  ~12     !1, 'foo'
         18        SEND_VAL                                                 ~12
         19        ISSET_ISEMPTY_DIM_OBJ                         1  ~13     !1, 'foo'
         20        SEND_VAL                                                 ~13
         21        DO_ICALL                                                 
   50    22        NEW                                              $15     'ArrayAcessImplementation'
         23        SEND_VAR_EX                                              !0
         24        DO_FCALL                                      0          
         25        ASSIGN                                                   !1, $15
   51    26        INIT_FCALL                                               'var_dump'
         27        ISSET_ISEMPTY_DIM_OBJ                         0  ~18     !1, 'foo'
         28        SEND_VAL                                                 ~18
         29        ISSET_ISEMPTY_DIM_OBJ                         1  ~19     !1, 'foo'
         30        SEND_VAL                                                 ~19
         31        DO_ICALL                                                 
         32      > RETURN                                                   1

Class ArrayObjectChild:
Function offsetexists:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HGPBG
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/HGPBG
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/HGPBG
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/HGPBG
function name:  offsetExists
number of ops:  9
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        INIT_FCALL                                               'array_key_exists'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $2      
          7      > RETURN                                                   $2
   28     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/HGPBG
function name:  offsetGet
number of ops:  9
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        INIT_METHOD_CALL                                         '_array'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0  $2      
          7      > RETURN                                                   $2
   33     8*     > 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/HGPBG
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/HGPBG
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:
152.85 ms | 1396 KiB | 17 Q