3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types = 1); use function PHPStan\dumpType; use function PHPStan\Testing\assertType; class Obj implements ArrayAccess { private $container = [ ]; public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; } else { $this->container[$offset] = $value; } } public function offsetExists($offset): bool { return isset($this->container[$offset]); } public function offsetUnset($offset): void { unset($this->container[$offset]); } public function offsetGet($offset): mixed { return isset($this->container[$offset]) ? $this->container[$offset] : null; } } $o = new Obj(); var_dump(is_iterable($o)); var_dump(is_array($o)); var_dump($o instanceof Traversable); foreach($o as $k => $v) { var_dump($k, $v); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 26
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 26
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/NMrFZ
function name:  (null)
number of ops:  28
compiled vars:  !0 = $o, !1 = $v, !2 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   DECLARE_CLASS                                            'obj'
   31     1        NEW                                              $3      'Obj'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $3
   33     4        INIT_FCALL                                               'var_dump'
          5        INIT_FCALL                                               'is_iterable'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $6      
          8        SEND_VAR                                                 $6
          9        DO_ICALL                                                 
   34    10        INIT_FCALL                                               'var_dump'
         11        TYPE_CHECK                                  128  ~8      !0
         12        SEND_VAL                                                 ~8
         13        DO_ICALL                                                 
   35    14        INIT_FCALL                                               'var_dump'
         15        INSTANCEOF                                       ~10     !0, 'Traversable'
         16        SEND_VAL                                                 ~10
         17        DO_ICALL                                                 
   37    18      > FE_RESET_R                                       $12     !0, ->26
         19    > > FE_FETCH_R                                       ~13     $12, !1, ->26
         20    >   ASSIGN                                                   !2, ~13
   38    21        INIT_FCALL                                               'var_dump'
         22        SEND_VAR                                                 !2
         23        SEND_VAR                                                 !1
         24        DO_ICALL                                                 
   37    25      > JMP                                                      ->19
         26    >   FE_FREE                                                  $12
   39    27      > RETURN                                                   1

Class Obj:
Function offsetset:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NMrFZ
function name:  offsetSet
number of ops:  12
compiled vars:  !0 = $offset, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   11     2        TYPE_CHECK                                    2          !0
          3      > JMPZ                                                     ~2, ->8
   12     4    >   FETCH_OBJ_W                                      $3      'container'
          5        ASSIGN_DIM                                               $3
          6        OP_DATA                                                  !1
   11     7      > JMP                                                      ->11
   14     8    >   FETCH_OBJ_W                                      $5      'container'
          9        ASSIGN_DIM                                               $5, !0
         10        OP_DATA                                                  !1
   16    11    > > RETURN                                                   null

End of function offsetset

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

End of function offsetexists

Function offsetunset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NMrFZ
function name:  offsetUnset
number of ops:  4
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
   23     1        FETCH_OBJ_UNSET                                  $1      'container'
          2        UNSET_DIM                                                $1, !0
   24     3      > RETURN                                                   null

End of function offsetunset

Function offsetget:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NMrFZ
function name:  offsetGet
number of ops:  12
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   RECV                                             !0      
   27     1        FETCH_OBJ_IS                                     ~1      'container'
          2        ISSET_ISEMPTY_DIM_OBJ                         0          ~1, !0
          3      > JMPZ                                                     ~2, ->8
          4    >   FETCH_OBJ_R                                      ~3      'container'
          5        FETCH_DIM_R                                      ~4      ~3, !0
          6        QM_ASSIGN                                        ~5      ~4
          7      > JMP                                                      ->9
          8    >   QM_ASSIGN                                        ~5      null
          9    > > RETURN                                                   ~5
   28    10*       VERIFY_RETURN_TYPE                                       
         11*     > RETURN                                                   null

End of function offsetget

End of class Obj.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.59 ms | 1016 KiB | 15 Q