3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test implements ArrayAccess{ private $r; function __construct() { $this->r = range("A","Z"); } public function offsetSet($offset, $value) { $this->r[$offset] = $value; } public function offsetExists($offset) { return isset($this->r[$offset]); } public function offsetUnset($offset) { unset($this->r[$offset]); } public function offsetGet($offset) { return isset($this->r[$offset]) ? $this->r[$offset] : null; } function __invoke($var) { return range("A", "Z")[$var]; } function a() { return range("A", "Z"); } function b($v) { return range("A", "Z")[$v]; } } $t = new Test(); echo $t(0); // Works echo (new Test())[0]; // works echo (new Test())->a()[0]; // works echo (new Test())->b(0); // works //echo (new Test())(0); // error ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/isgU2
function name:  (null)
number of ops:  25
compiled vars:  !0 = $t
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   DECLARE_CLASS                                            'test'
   38     1        NEW                                              $1      'Test'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   39     4        INIT_DYNAMIC_CALL                                        !0
          5        SEND_VAL_EX                                              0
          6        DO_FCALL                                      0  $4      
          7        ECHO                                                     $4
   41     8        NEW                                              $5      'Test'
          9        DO_FCALL                                      0          
         10        FETCH_DIM_R                                      ~7      $5, 0
         11        ECHO                                                     ~7
   42    12        NEW                                              $8      'Test'
         13        DO_FCALL                                      0          
         14        INIT_METHOD_CALL                                         $8, 'a'
         15        DO_FCALL                                      0  $10     
         16        FETCH_DIM_R                                      ~11     $10, 0
         17        ECHO                                                     ~11
   43    18        NEW                                              $12     'Test'
         19        DO_FCALL                                      0          
         20        INIT_METHOD_CALL                                         $12, 'b'
         21        SEND_VAL_EX                                              0
         22        DO_FCALL                                      0  $14     
         23        ECHO                                                     $14
   48    24      > RETURN                                                   1

Class Test:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/isgU2
function name:  __construct
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   INIT_FCALL                                               'range'
          1        SEND_VAL                                                 'A'
          2        SEND_VAL                                                 'Z'
          3        DO_ICALL                                         $1      
          4        ASSIGN_OBJ                                               'r'
          5        OP_DATA                                                  $1
    7     6      > RETURN                                                   null

End of function __construct

Function offsetset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/isgU2
function name:  offsetSet
number of ops:  6
compiled vars:  !0 = $offset, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   10     2        FETCH_OBJ_W                                      $2      'r'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
   11     5      > 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/isgU2
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      
   14     1        FETCH_OBJ_IS                                     ~1      'r'
          2        ISSET_ISEMPTY_DIM_OBJ                         0  ~2      ~1, !0
          3      > RETURN                                                   ~2
   15     4*     > 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/isgU2
function name:  offsetUnset
number of ops:  4
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
   18     1        FETCH_OBJ_UNSET                                  $1      'r'
          2        UNSET_DIM                                                $1, !0
   19     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/isgU2
function name:  offsetGet
number of ops:  11
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
   22     1        FETCH_OBJ_IS                                     ~1      'r'
          2        ISSET_ISEMPTY_DIM_OBJ                         0          ~1, !0
          3      > JMPZ                                                     ~2, ->8
          4    >   FETCH_OBJ_R                                      ~3      'r'
          5        FETCH_DIM_R                                      ~4      ~3, !0
          6        QM_ASSIGN                                        ~5      ~4
          7      > JMP                                                      ->9
          8    >   QM_ASSIGN                                        ~5      null
          9    > > RETURN                                                   ~5
   23    10*     > RETURN                                                   null

End of function offsetget

Function __invoke:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/isgU2
function name:  __invoke
number of ops:  8
compiled vars:  !0 = $var
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
   25     1        INIT_FCALL                                               'range'
          2        SEND_VAL                                                 'A'
          3        SEND_VAL                                                 'Z'
          4        DO_ICALL                                         $1      
          5        FETCH_DIM_R                                      ~2      $1, !0
          6      > RETURN                                                   ~2
   26     7*     > RETURN                                                   null

End of function __invoke

Function a:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/isgU2
function name:  a
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   INIT_FCALL                                               'range'
          1        SEND_VAL                                                 'A'
          2        SEND_VAL                                                 'Z'
          3        DO_ICALL                                         $0      
          4      > RETURN                                                   $0
   30     5*     > RETURN                                                   null

End of function a

Function b:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/isgU2
function name:  b
number of ops:  8
compiled vars:  !0 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   RECV                                             !0      
   33     1        INIT_FCALL                                               'range'
          2        SEND_VAL                                                 'A'
          3        SEND_VAL                                                 'Z'
          4        DO_ICALL                                         $1      
          5        FETCH_DIM_R                                      ~2      $1, !0
          6      > RETURN                                                   ~2
   34     7*     > RETURN                                                   null

End of function b

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.25 ms | 1404 KiB | 15 Q