3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ProfsimmException extends Exception { } class Foo implements ArrayAccess { public function offsetExists ( $offset ) { return array_key_exists($this->foo[$offset]); } public function offsetGet ( $offset ) { return $this->foo[$offset]; } public function offsetSet ( $offset, $value ) { $this->foo[$offset] = $value; } public function offsetUnset ( $offset ) { unset($this->foo[$offset]); } } class Bar { private $foo; public function __construct() { $this->foo = new Foo(); } public function __set($prop, $value) { $this->$prop = $value; } public function __get($prop) { if ($this->$prop instanceof \ArrayAccess) { throw new ProfsimmException("Nope."); } } } $bar = new Bar(); $bar->foo['abc'] = 'def'; var_dump($bar); $foo = $bar->foo;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/76auA
function name:  (null)
number of ops:  13
compiled vars:  !0 = $bar, !1 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   DECLARE_CLASS                                            'foo'
   42     1        NEW                                              $2      'Bar'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
   43     4        FETCH_OBJ_W                                      $5      !0, 'foo'
          5        ASSIGN_DIM                                               $5, 'abc'
          6        OP_DATA                                                  'def'
   44     7        INIT_FCALL                                               'var_dump'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                                 
   45    10        FETCH_OBJ_R                                      ~8      !0, 'foo'
         11        ASSIGN                                                   !1, ~8
         12      > RETURN                                                   1

Class ProfsimmException: [no user functions]
Class Foo:
Function offsetexists:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/76auA
function name:  offsetExists
number of ops:  8
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        INIT_FCALL                                               'array_key_exists'
          2        FETCH_OBJ_R                                      ~1      'foo'
          3        FETCH_DIM_R                                      ~2      ~1, !0
          4        SEND_VAL                                                 ~2
          5        DO_ICALL                                         $3      
          6      > RETURN                                                   $3
    8     7*     > 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/76auA
function name:  offsetGet
number of ops:  5
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   11     1        FETCH_OBJ_R                                      ~1      'foo'
          2        FETCH_DIM_R                                      ~2      ~1, !0
          3      > RETURN                                                   ~2
   12     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/76auA
function name:  offsetSet
number of ops:  6
compiled vars:  !0 = $offset, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   15     2        FETCH_OBJ_W                                      $2      'foo'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
   16     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/76auA
function name:  offsetUnset
number of ops:  4
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   19     1        FETCH_OBJ_UNSET                                  $1      'foo'
          2        UNSET_DIM                                                $1, !0
   20     3      > RETURN                                                   null

End of function offsetunset

End of class Foo.

Class Bar:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/76auA
function name:  __construct
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   NEW                                              $1      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN_OBJ                                               'foo'
          3        OP_DATA                                                  $1
   28     4      > RETURN                                                   null

End of function __construct

Function __set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/76auA
function name:  __set
number of ops:  5
compiled vars:  !0 = $prop, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   31     2        ASSIGN_OBJ                                               !0
          3        OP_DATA                                                  !1
   32     4      > RETURN                                                   null

End of function __set

Function __get:
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 = 108) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/76auA
function name:  __get
number of ops:  9
compiled vars:  !0 = $prop
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   RECV                                             !0      
   35     1        FETCH_OBJ_R                                      ~1      !0
          2        INSTANCEOF                                               ~1, 'ArrayAccess'
          3      > JMPZ                                                     ~2, ->8
   36     4    >   NEW                                              $3      'ProfsimmException'
          5        SEND_VAL_EX                                              'Nope.'
          6        DO_FCALL                                      0          
          7      > THROW                                         0          $3
   38     8    > > RETURN                                                   null

End of function __get

End of class Bar.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.39 ms | 1400 KiB | 17 Q