3v4l.org

run code in 300+ PHP versions simultaneously
<?php class States implements \ArrayAccess { private $states = []; /** * @param mixed $offset * * @return bool */ public function offsetExists($offset) { return array_key_exists($offset, $this->states); } /** * @param mixed $offset * * @throws UnknownStateException * * @return AllianceState */ public function offsetGet($offset) { if ( ! $this->offsetExists($offset)) { throw new UnknownStateException(); } return $this->states[$offset]; } /** * @param mixed $offset * @param mixed $value * * @throws InvalidArgumentException */ public function offsetSet($offset, $value) { $offset = count($this->states); $this->states[$offset] = $value; } /** * @param mixed $offset * * @throws UnknownStateException */ public function offsetUnset($offset) { unset($this->states[$offset]); $this->states = array_values($this->states); } } $states = new States(); $states->add('foo'); $states->add('bar'); var_dump($states);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/b89Xl
function name:  (null)
number of ops:  14
compiled vars:  !0 = $states
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'states'
   61     1        NEW                                              $1      'States'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   62     4        INIT_METHOD_CALL                                         !0, 'add'
          5        SEND_VAL_EX                                              'foo'
          6        DO_FCALL                                      0          
   63     7        INIT_METHOD_CALL                                         !0, 'add'
          8        SEND_VAL_EX                                              'bar'
          9        DO_FCALL                                      0          
   65    10        INIT_FCALL                                               'var_dump'
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                                 
         13      > RETURN                                                   1

Class States:
Function offsetexists:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/b89Xl
function name:  offsetExists
number of ops:  5
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   15     1        FETCH_OBJ_R                                      ~1      'states'
          2        ARRAY_KEY_EXISTS                                 ~2      !0, ~1
          3      > RETURN                                                   ~2
   16     4*     > RETURN                                                   null

End of function offsetexists

Function offsetget:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 9
Branch analysis from position: 6
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/b89Xl
function name:  offsetGet
number of ops:  13
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
   27     1        INIT_METHOD_CALL                                         'offsetExists'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $1      
          4        BOOL_NOT                                         ~2      $1
          5      > JMPZ                                                     ~2, ->9
   28     6    >   NEW                                              $3      'UnknownStateException'
          7        DO_FCALL                                      0          
          8      > THROW                                         0          $3
   31     9    >   FETCH_OBJ_R                                      ~5      'states'
         10        FETCH_DIM_R                                      ~6      ~5, !0
         11      > RETURN                                                   ~6
   32    12*     > 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/b89Xl
function name:  offsetSet
number of ops:  9
compiled vars:  !0 = $offset, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   43     2        FETCH_OBJ_R                                      ~2      'states'
          3        COUNT                                            ~3      ~2
          4        ASSIGN                                                   !0, ~3
   45     5        FETCH_OBJ_W                                      $5      'states'
          6        ASSIGN_DIM                                               $5, !0
          7        OP_DATA                                                  !1
   46     8      > 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/b89Xl
function name:  offsetUnset
number of ops:  10
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   53     0  E >   RECV                                             !0      
   55     1        FETCH_OBJ_UNSET                                  $1      'states'
          2        UNSET_DIM                                                $1, !0
   57     3        INIT_FCALL                                               'array_values'
          4        FETCH_OBJ_R                                      ~3      'states'
          5        SEND_VAL                                                 ~3
          6        DO_ICALL                                         $4      
          7        ASSIGN_OBJ                                               'states'
          8        OP_DATA                                                  $4
   58     9      > RETURN                                                   null

End of function offsetunset

End of class States.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.31 ms | 1400 KiB | 17 Q