3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ExtendedArrayObject extends ArrayObject { function offsetGet($offset) { echo "Called", PHP_EOL; return parent::offsetGet($offset); } } class ExtendedArrayAccess implements ArrayAccess { private $data = array(); function __construct(array $array = array()) { $this->data = $array; } function offsetExists($offset) { return array_key_exists($offset, $this->data); } function offsetGet($offset) { return $this->data[$offset]; } function offsetSet($offset, $value) { $this->data[$offset] = $value; } function offsetUnset($offset) { unset($this->data[$offset]); } } function createInputs() { return array( array(), new ArrayObject(), new ExtendedArrayObject(), new ExtendedArrayAccess(), ); } class Tests { function isset_existing_key_with_not_empty_value($array) { $array['foo'] = 1; $this->expect(isset($array['foo']) === true, __FUNCTION__, $array); } function empty_existing_key_with_not_empty_value($array) { $array['foo'] = 1; $this->expect(empty($array['foo']) === false, __FUNCTION__, $array); } function isset_existing_key_with_empty_value($array) { $array['foo'] = 0; $this->expect(isset($array['foo']) === true, __FUNCTION__, $array); } function empty_existing_key_with_empty_value($array) { $array['foo'] = 0; $this->expect(empty($array['foo']) === true, __FUNCTION__, $array); } function isset_non_existent_key($array) { $this->expect(isset($array['foo']) === false, __FUNCTION__, $array); } function empty_non_existent_key($array) { $this->expect(empty($array['foo']) === true, __FUNCTION__, $array); } function isset_existing_key_with_null_value($array) { $array['foo'] = null; $this->expect(isset($array['foo']) === false, __FUNCTION__, $array); } function empty_existing_key_with_null_value($array) { $array['foo'] = null; $this->expect(empty($array['foo']) === true, __FUNCTION__, $array); } private function getType($v) { return is_array($v) ? 'array' : get_class($v); } private function expect($condition, $function, $array) { if (!$condition) { echo $this->getType($array), ' failed ', $function, PHP_EOL; } } } $tests = new Tests; foreach (get_class_methods($tests) as $test) { foreach (createInputs() as $structure) { $tests->$test($structure); } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 19
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 19
Branch analysis from position: 9
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 17
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 17
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 17
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/Gu3AU
function name:  (null)
number of ops:  21
compiled vars:  !0 = $tests, !1 = $test, !2 = $structure
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   DECLARE_CLASS                                            'extendedarrayaccess'
   88     1        NEW                                              $3      'Tests'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $3
   89     4        INIT_FCALL                                               'get_class_methods'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $6      
          7      > FE_RESET_R                                       $7      $6, ->19
          8    > > FE_FETCH_R                                               $7, !1, ->19
   90     9    >   INIT_FCALL                                               'createinputs'
         10        DO_FCALL                                      0  $8      
         11      > FE_RESET_R                                       $9      $8, ->17
         12    > > FE_FETCH_R                                               $9, !2, ->17
   91    13    >   INIT_METHOD_CALL                                         !0, !1
         14        SEND_VAR_EX                                              !2
         15        DO_FCALL                                      0          
   90    16      > JMP                                                      ->12
         17    >   FE_FREE                                                  $9
   89    18      > JMP                                                      ->8
         19    >   FE_FREE                                                  $7
   93    20      > RETURN                                                   1

Function createinputs:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Gu3AU
function name:  createInputs
number of ops:  12
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   INIT_ARRAY                                       ~0      <array>
   32     1        NEW                                              $1      'ArrayObject'
          2        DO_FCALL                                      0          
          3        ADD_ARRAY_ELEMENT                                ~0      $1
   33     4        NEW                                              $3      'ExtendedArrayObject'
          5        DO_FCALL                                      0          
          6        ADD_ARRAY_ELEMENT                                ~0      $3
   34     7        NEW                                              $5      'ExtendedArrayAccess'
          8        DO_FCALL                                      0          
          9        ADD_ARRAY_ELEMENT                                ~0      $5
         10      > RETURN                                                   ~0
   36    11*     > RETURN                                                   null

End of function createinputs

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

End of function offsetget

End of class ExtendedArrayObject.

Class ExtendedArrayAccess:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Gu3AU
function name:  __construct
number of ops:  4
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV_INIT                                        !0      <array>
   13     1        ASSIGN_OBJ                                               'data'
          2        OP_DATA                                                  !0
   14     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/Gu3AU
function name:  offsetExists
number of ops:  5
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   16     1        FETCH_OBJ_R                                      ~1      'data'
          2        ARRAY_KEY_EXISTS                                 ~2      !0, ~1
          3      > RETURN                                                   ~2
   17     4*     > 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/Gu3AU
function name:  offsetGet
number of ops:  5
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   19     1        FETCH_OBJ_R                                      ~1      'data'
          2        FETCH_DIM_R                                      ~2      ~1, !0
          3      > RETURN                                                   ~2
   20     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/Gu3AU
function name:  offsetSet
number of ops:  6
compiled vars:  !0 = $offset, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   22     2        FETCH_OBJ_W                                      $2      'data'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
   23     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/Gu3AU
function name:  offsetUnset
number of ops:  4
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
   25     1        FETCH_OBJ_UNSET                                  $1      'data'
          2        UNSET_DIM                                                $1, !0
   26     3      > RETURN                                                   null

End of function offsetunset

End of class ExtendedArrayAccess.

Class Tests:
Function isset_existing_key_with_not_empty_value:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Gu3AU
function name:  isset_existing_key_with_not_empty_value
number of ops:  11
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   RECV                                             !0      
   40     1        ASSIGN_DIM                                               !0, 'foo'
          2        OP_DATA                                                  1
   41     3        INIT_METHOD_CALL                                         'expect'
          4        ISSET_ISEMPTY_DIM_OBJ                         0  ~2      !0, 'foo'
          5        TYPE_CHECK                                    8  ~3      ~2
          6        SEND_VAL_EX                                              ~3
          7        SEND_VAL_EX                                              'isset_existing_key_with_not_empty_value'
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0          
   42    10      > RETURN                                                   null

End of function isset_existing_key_with_not_empty_value

Function empty_existing_key_with_not_empty_value:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Gu3AU
function name:  empty_existing_key_with_not_empty_value
number of ops:  11
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   44     0  E >   RECV                                             !0      
   45     1        ASSIGN_DIM                                               !0, 'foo'
          2        OP_DATA                                                  1
   46     3        INIT_METHOD_CALL                                         'expect'
          4        ISSET_ISEMPTY_DIM_OBJ                         1  ~2      !0, 'foo'
          5        TYPE_CHECK                                    4  ~3      ~2
          6        SEND_VAL_EX                                              ~3
          7        SEND_VAL_EX                                              'empty_existing_key_with_not_empty_value'
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0          
   47    10      > RETURN                                                   null

End of function empty_existing_key_with_not_empty_value

Function isset_existing_key_with_empty_value:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Gu3AU
function name:  isset_existing_key_with_empty_value
number of ops:  11
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   49     0  E >   RECV                                             !0      
   50     1        ASSIGN_DIM                                               !0, 'foo'
          2        OP_DATA                                                  0
   51     3        INIT_METHOD_CALL                                         'expect'
          4        ISSET_ISEMPTY_DIM_OBJ                         0  ~2      !0, 'foo'
          5        TYPE_CHECK                                    8  ~3      ~2
          6        SEND_VAL_EX                                              ~3
          7        SEND_VAL_EX                                              'isset_existing_key_with_empty_value'
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0          
   52    10      > RETURN                                                   null

End of function isset_existing_key_with_empty_value

Function empty_existing_key_with_empty_value:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Gu3AU
function name:  empty_existing_key_with_empty_value
number of ops:  11
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   54     0  E >   RECV                                             !0      
   55     1        ASSIGN_DIM                                               !0, 'foo'
          2        OP_DATA                                                  0
   56     3        INIT_METHOD_CALL                                         'expect'
          4        ISSET_ISEMPTY_DIM_OBJ                         1  ~2      !0, 'foo'
          5        TYPE_CHECK                                    8  ~3      ~2
          6        SEND_VAL_EX                                              ~3
          7        SEND_VAL_EX                                              'empty_existing_key_with_empty_value'
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0          
   57    10      > RETURN                                                   null

End of function empty_existing_key_with_empty_value

Function isset_non_existent_key:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Gu3AU
function name:  isset_non_existent_key
number of ops:  9
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   59     0  E >   RECV                                             !0      
   60     1        INIT_METHOD_CALL                                         'expect'
          2        ISSET_ISEMPTY_DIM_OBJ                         0  ~1      !0, 'foo'
          3        TYPE_CHECK                                    4  ~2      ~1
          4        SEND_VAL_EX                                              ~2
          5        SEND_VAL_EX                                              'isset_non_existent_key'
          6        SEND_VAR_EX                                              !0
          7        DO_FCALL                                      0          
   61     8      > RETURN                                                   null

End of function isset_non_existent_key

Function empty_non_existent_key:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Gu3AU
function name:  empty_non_existent_key
number of ops:  9
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   63     0  E >   RECV                                             !0      
   64     1        INIT_METHOD_CALL                                         'expect'
          2        ISSET_ISEMPTY_DIM_OBJ                         1  ~1      !0, 'foo'
          3        TYPE_CHECK                                    8  ~2      ~1
          4        SEND_VAL_EX                                              ~2
          5        SEND_VAL_EX                                              'empty_non_existent_key'
          6        SEND_VAR_EX                                              !0
          7        DO_FCALL                                      0          
   65     8      > RETURN                                                   null

End of function empty_non_existent_key

Function isset_existing_key_with_null_value:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Gu3AU
function name:  isset_existing_key_with_null_value
number of ops:  11
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   67     0  E >   RECV                                             !0      
   68     1        ASSIGN_DIM                                               !0, 'foo'
          2        OP_DATA                                                  null
   69     3        INIT_METHOD_CALL                                         'expect'
          4        ISSET_ISEMPTY_DIM_OBJ                         0  ~2      !0, 'foo'
          5        TYPE_CHECK                                    4  ~3      ~2
          6        SEND_VAL_EX                                              ~3
          7        SEND_VAL_EX                                              'isset_existing_key_with_null_value'
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0          
   70    10      > RETURN                                                   null

End of function isset_existing_key_with_null_value

Function empty_existing_key_with_null_value:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Gu3AU
function name:  empty_existing_key_with_null_value
number of ops:  11
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   72     0  E >   RECV                                             !0      
   73     1        ASSIGN_DIM                                               !0, 'foo'
          2        OP_DATA                                                  null
   74     3        INIT_METHOD_CALL                                         'expect'
          4        ISSET_ISEMPTY_DIM_OBJ                         1  ~2      !0, 'foo'
          5        TYPE_CHECK                                    8  ~3      ~2
          6        SEND_VAL_EX                                              ~3
          7        SEND_VAL_EX                                              'empty_existing_key_with_null_value'
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0          
   75    10      > RETURN                                                   null

End of function empty_existing_key_with_null_value

Function gettype:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Gu3AU
function name:  getType
number of ops:  9
compiled vars:  !0 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   77     0  E >   RECV                                             !0      
   78     1        TYPE_CHECK                                  128          !0
          2      > JMPZ                                                     ~1, ->5
          3    >   QM_ASSIGN                                        ~2      'array'
          4      > JMP                                                      ->7
          5    >   GET_CLASS                                        ~3      !0
          6        QM_ASSIGN                                        ~2      ~3
          7    > > RETURN                                                   ~2
   79     8*     > RETURN                                                   null

End of function gettype

Function expect:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/Gu3AU
function name:  expect
number of ops:  13
compiled vars:  !0 = $condition, !1 = $function, !2 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   81     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   82     3        BOOL_NOT                                         ~3      !0
          4      > JMPZ                                                     ~3, ->12
   83     5    >   INIT_METHOD_CALL                                         'getType'
          6        SEND_VAR                                                 !2
          7        DO_FCALL                                      0  $4      
          8        ECHO                                                     $4
          9        ECHO                                                     '+failed+'
         10        ECHO                                                     !1
         11        ECHO                                                     '%0A'
   85    12    > > RETURN                                                   null

End of function expect

End of class Tests.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.29 ms | 1419 KiB | 16 Q