3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ExtendedArrayObject extends ArrayObject { function offsetExists($offset) { //echo "\t", __METHOD__, PHP_EOL; return parent::offsetExists($offset); } function offsetGet($offset) { //echo "\t", __METHOD__, 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, $array); } function empty_existing_key_with_not_empty_value($array) { $array['foo'] = 1; $this->expect(empty($array['foo']) === false, $array); } function isset_existing_key_with_empty_value($array) { $array['foo'] = 0; $this->expect(isset($array['foo']) === true, $array); } function empty_existing_key_with_empty_value($array) { $array['foo'] = 0; $this->expect(empty($array['foo']) === true, $array); } function isset_non_existent_key($array) { $this->expect(isset($array['foo']) === false, $array); } function empty_non_existent_key($array) { $this->expect(empty($array['foo']) === true, $array); } function isset_existing_key_with_null_value($array) { $array['foo'] = null; $this->expect(isset($array['foo']) === false, $array); } function empty_existing_key_with_null_value($array) { $array['foo'] = null; $this->expect(empty($array['foo']) === true, $array); } private function getType($v) { return is_array($v) ? 'array' : get_class($v); } private function expect($condition, $array) { if (!$condition) { echo "\t", $this->getType($array), ' failed ', PHP_EOL; } } } $tests = new Tests; foreach (get_class_methods($tests) as $test) { echo "$test:", PHP_EOL; foreach (createInputs() as $structure) { $tests->$test($structure); } echo PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 24
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 24
Branch analysis from position: 9
2 jumps found. (Code = 77) Position 1 = 16, Position 2 = 21
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 21
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 21
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/SoFnK
function name:  (null)
number of ops:  26
compiled vars:  !0 = $tests, !1 = $test, !2 = $structure
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   DECLARE_CLASS                                            'extendedarrayaccess'
   92     1        NEW                                              $3      'Tests'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $3
   93     4        INIT_FCALL                                               'get_class_methods'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $6      
          7      > FE_RESET_R                                       $7      $6, ->24
          8    > > FE_FETCH_R                                               $7, !1, ->24
   94     9    >   NOP                                                      
         10        FAST_CONCAT                                      ~8      !1, '%3A'
         11        ECHO                                                     ~8
         12        ECHO                                                     '%0A'
   95    13        INIT_FCALL                                               'createinputs'
         14        DO_FCALL                                      0  $9      
         15      > FE_RESET_R                                       $10     $9, ->21
         16    > > FE_FETCH_R                                               $10, !2, ->21
   96    17    >   INIT_METHOD_CALL                                         !0, !1
         18        SEND_VAR_EX                                              !2
         19        DO_FCALL                                      0          
   95    20      > JMP                                                      ->16
         21    >   FE_FREE                                                  $10
   98    22        ECHO                                                     '%0A'
   93    23      > JMP                                                      ->8
         24    >   FE_FREE                                                  $7
   99    25      > RETURN                                                   1

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

End of function createinputs

Class ExtendedArrayObject:
Function offsetexists:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SoFnK
function name:  offsetExists
number of ops:  6
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    6     1        INIT_STATIC_METHOD_CALL                                  'offsetExists'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
    7     5*     > 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/SoFnK
function name:  offsetGet
number of ops:  6
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
   10     1        INIT_STATIC_METHOD_CALL                                  'offsetGet'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
   11     5*     > 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/SoFnK
function name:  __construct
number of ops:  4
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV_INIT                                        !0      <array>
   17     1        ASSIGN_OBJ                                               'data'
          2        OP_DATA                                                  !0
   18     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/SoFnK
function name:  offsetExists
number of ops:  5
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
   20     1        FETCH_OBJ_R                                      ~1      'data'
          2        ARRAY_KEY_EXISTS                                 ~2      !0, ~1
          3      > RETURN                                                   ~2
   21     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/SoFnK
function name:  offsetGet
number of ops:  5
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
   23     1        FETCH_OBJ_R                                      ~1      'data'
          2        FETCH_DIM_R                                      ~2      ~1, !0
          3      > RETURN                                                   ~2
   24     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/SoFnK
function name:  offsetSet
number of ops:  6
compiled vars:  !0 = $offset, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   26     2        FETCH_OBJ_W                                      $2      'data'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
   27     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/SoFnK
function name:  offsetUnset
number of ops:  4
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
   29     1        FETCH_OBJ_UNSET                                  $1      'data'
          2        UNSET_DIM                                                $1, !0
   30     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/SoFnK
function name:  isset_existing_key_with_not_empty_value
number of ops:  10
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   43     0  E >   RECV                                             !0      
   44     1        ASSIGN_DIM                                               !0, 'foo'
          2        OP_DATA                                                  1
   45     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_VAR_EX                                              !0
          8        DO_FCALL                                      0          
   46     9      > 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/SoFnK
function name:  empty_existing_key_with_not_empty_value
number of ops:  10
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   48     0  E >   RECV                                             !0      
   49     1        ASSIGN_DIM                                               !0, 'foo'
          2        OP_DATA                                                  1
   50     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_VAR_EX                                              !0
          8        DO_FCALL                                      0          
   51     9      > 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/SoFnK
function name:  isset_existing_key_with_empty_value
number of ops:  10
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   53     0  E >   RECV                                             !0      
   54     1        ASSIGN_DIM                                               !0, 'foo'
          2        OP_DATA                                                  0
   55     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_VAR_EX                                              !0
          8        DO_FCALL                                      0          
   56     9      > 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/SoFnK
function name:  empty_existing_key_with_empty_value
number of ops:  10
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   58     0  E >   RECV                                             !0      
   59     1        ASSIGN_DIM                                               !0, 'foo'
          2        OP_DATA                                                  0
   60     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_VAR_EX                                              !0
          8        DO_FCALL                                      0          
   61     9      > 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/SoFnK
function name:  isset_non_existent_key
number of ops:  8
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                         0  ~1      !0, 'foo'
          3        TYPE_CHECK                                    4  ~2      ~1
          4        SEND_VAL_EX                                              ~2
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   65     7      > 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/SoFnK
function name:  empty_non_existent_key
number of ops:  8
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   67     0  E >   RECV                                             !0      
   68     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_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   69     7      > 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/SoFnK
function name:  isset_existing_key_with_null_value
number of ops:  10
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   71     0  E >   RECV                                             !0      
   72     1        ASSIGN_DIM                                               !0, 'foo'
          2        OP_DATA                                                  null
   73     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_VAR_EX                                              !0
          8        DO_FCALL                                      0          
   74     9      > 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/SoFnK
function name:  empty_existing_key_with_null_value
number of ops:  10
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   76     0  E >   RECV                                             !0      
   77     1        ASSIGN_DIM                                               !0, 'foo'
          2        OP_DATA                                                  null
   78     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_VAR_EX                                              !0
          8        DO_FCALL                                      0          
   79     9      > 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/SoFnK
function name:  getType
number of ops:  9
compiled vars:  !0 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   81     0  E >   RECV                                             !0      
   82     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
   83     8*     > RETURN                                                   null

End of function gettype

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

End of function expect

End of class Tests.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.69 ms | 1419 KiB | 16 Q