3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface ArrayAccessInterface extends ArrayAccess { public function keyExists(string $offset): bool; public function offsetIsset(string $offset): bool; } abstract class ArrayAccessAbstract implements ArrayAccessInterface { public function offsetExists($offset): bool { return static::offsetIsset((string) $offset); } } class C extends ArrayAccessAbstract { public $data = array( "foo" => null ); public function keyExists(string $offset): bool { return array_key_exists($offset, $this->data); } public function offsetIsset(string $offset): bool { return isset($this->data[$offset]); } public function offsetGet($offset) { return $this->data[$offset]; } public function offsetSet($offset, $value): void { $this->data[$offset] = $value; } public function offsetUnset($offset): void { unset($this->data[$offset]); } } $o = new C(); var_dump(empty($o['foo'])); var_dump(isset($o['foo'])); var_dump($o->keyExists('foo')); var_dump(property_exists($o, 'foo')); #var_dump(array_key_exists('foo', $o)); #var_dump(array_key_exists('foo', ['foo' => null]));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GDOuR
function name:  (null)
number of ops:  28
compiled vars:  !0 = $o
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'arrayaccessinterface'
    9     1        DECLARE_CLASS                                            'arrayaccessabstract'
   17     2        DECLARE_CLASS                                            'c', 'arrayaccessabstract'
   44     3        NEW                                              $1      'C'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $1
   46     6        INIT_FCALL                                               'var_dump'
          7        ISSET_ISEMPTY_DIM_OBJ                         1  ~4      !0, 'foo'
          8        SEND_VAL                                                 ~4
          9        DO_ICALL                                                 
   47    10        INIT_FCALL                                               'var_dump'
         11        ISSET_ISEMPTY_DIM_OBJ                         0  ~6      !0, 'foo'
         12        SEND_VAL                                                 ~6
         13        DO_ICALL                                                 
   48    14        INIT_FCALL                                               'var_dump'
         15        INIT_METHOD_CALL                                         !0, 'keyExists'
         16        SEND_VAL_EX                                              'foo'
         17        DO_FCALL                                      0  $8      
         18        SEND_VAR                                                 $8
         19        DO_ICALL                                                 
   49    20        INIT_FCALL                                               'var_dump'
         21        INIT_FCALL                                               'property_exists'
         22        SEND_VAR                                                 !0
         23        SEND_VAL                                                 'foo'
         24        DO_ICALL                                         $10     
         25        SEND_VAR                                                 $10
         26        DO_ICALL                                                 
   51    27      > RETURN                                                   1

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

End of function keyexists

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

End of function offsetisset

End of class ArrayAccessInterface.

Class ArrayAccessAbstract:
Function offsetexists:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GDOuR
function name:  offsetExists
number of ops:  9
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   13     1        INIT_STATIC_METHOD_CALL                                  'offsetIsset'
          2        CAST                                          6  ~1      !0
          3        SEND_VAL_EX                                              ~1
          4        DO_FCALL                                      0  $2      
          5        VERIFY_RETURN_TYPE                                       $2
          6      > RETURN                                                   $2
   14     7*       VERIFY_RETURN_TYPE                                       
          8*     > RETURN                                                   null

End of function offsetexists

End of class ArrayAccessAbstract.

Class C:
Function keyexists:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GDOuR
function name:  keyExists
number of ops:  7
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
   24     1        FETCH_OBJ_R                                      ~1      'data'
          2        ARRAY_KEY_EXISTS                                 ~2      !0, ~1
          3        VERIFY_RETURN_TYPE                                       ~2
          4      > RETURN                                                   ~2
   25     5*       VERIFY_RETURN_TYPE                                       
          6*     > RETURN                                                   null

End of function keyexists

Function offsetisset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GDOuR
function name:  offsetIsset
number of ops:  7
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   RECV                                             !0      
   28     1        FETCH_OBJ_IS                                     ~1      'data'
          2        ISSET_ISEMPTY_DIM_OBJ                         0  ~2      ~1, !0
          3        VERIFY_RETURN_TYPE                                       ~2
          4      > RETURN                                                   ~2
   29     5*       VERIFY_RETURN_TYPE                                       
          6*     > RETURN                                                   null

End of function offsetisset

Function offsetget:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GDOuR
function name:  offsetGet
number of ops:  5
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
   32     1        FETCH_OBJ_R                                      ~1      'data'
          2        FETCH_DIM_R                                      ~2      ~1, !0
          3      > RETURN                                                   ~2
   33     4*     > 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/GDOuR
function name:  offsetSet
number of ops:  6
compiled vars:  !0 = $offset, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   36     2        FETCH_OBJ_W                                      $2      'data'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
   37     5      > 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/GDOuR
function name:  offsetUnset
number of ops:  4
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   RECV                                             !0      
   40     1        FETCH_OBJ_UNSET                                  $1      'data'
          2        UNSET_DIM                                                $1, !0
   41     3      > RETURN                                                   null

End of function offsetunset

End of class C.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.64 ms | 1010 KiB | 15 Q