3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Outside { private $data; public function __construct($data) { $this->data = $data; } public function getArrayAccess() { return new class($this->data) extends Outside implements ArrayAccess { public function offsetGet($offset) { return $this->data[$offset]; } public function offsetSet($offset, $data) { return ($this->data[$offset] = $data); } public function offsetUnset($offset) { unset($this->data[$offset]); } public function offsetExists($offset) { return isset($this->data[$offset]); } }; } } $outer = new Outside('testingdata'); $test = $outer->getArrayAccess()->offsetGet(3); var_dump($test);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pJmnB
function name:  (null)
number of ops:  14
compiled vars:  !0 = $outer, !1 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   NEW                                              $2      'Outside'
          1        SEND_VAL_EX                                              'testingdata'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
   22     4        INIT_METHOD_CALL                                         !0, 'getArrayAccess'
          5        DO_FCALL                                      0  $5      
          6        INIT_METHOD_CALL                                         $5, 'offsetGet'
          7        SEND_VAL_EX                                              3
          8        DO_FCALL                                      0  $6      
          9        ASSIGN                                                   !1, $6
   24    10        INIT_FCALL                                               'var_dump'
         11        SEND_VAR                                                 !1
         12        DO_ICALL                                                 
         13      > RETURN                                                   1

Class Outside@anonymous:
Function offsetget:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pJmnB
function name:  offsetGet
number of ops:  5
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        FETCH_OBJ_R                                      ~1      'data'
          2        FETCH_DIM_R                                      ~2      ~1, !0
          3      > RETURN                                                   ~2
          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/pJmnB
function name:  offsetSet
number of ops:  7
compiled vars:  !0 = $offset, !1 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        FETCH_OBJ_W                                      $2      'data'
          3        ASSIGN_DIM                                       ~3      $2, !0
          4        OP_DATA                                                  !1
          5      > RETURN                                                   ~3
          6*     > 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/pJmnB
function name:  offsetUnset
number of ops:  4
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        FETCH_OBJ_UNSET                                  $1      'data'
          2        UNSET_DIM                                                $1, !0
          3      > RETURN                                                   null

End of function offsetunset

Function offsetexists:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pJmnB
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      
          1        FETCH_OBJ_IS                                     ~1      'data'
          2        ISSET_ISEMPTY_DIM_OBJ                         0  ~2      ~1, !0
          3      > RETURN                                                   ~2
          4*     > RETURN                                                   null

End of function offsetexists

End of class Outside@anonymous.

Class Outside:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pJmnB
function name:  __construct
number of ops:  4
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        ASSIGN_OBJ                                               'data'
          2        OP_DATA                                                  !0
    8     3      > RETURN                                                   null

End of function __construct

Function getarrayaccess:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pJmnB
function name:  getArrayAccess
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   DECLARE_ANON_CLASS                               <const ast>   'outside'
          1        NEW                                              $1      $0
          2        CHECK_FUNC_ARG                                           
          3        FETCH_OBJ_FUNC_ARG                               $2      'data'
          4        SEND_FUNC_ARG                                            $2
          5        DO_FCALL                                      0          
          6      > RETURN                                                   $1
   17     7*     > RETURN                                                   null

End of function getarrayaccess

End of class Outside.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
196.58 ms | 1400 KiB | 15 Q