3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test extends \ArrayObject { public $defaults = array( 'k3' => 'v3', ); public function __construct() { parent::__construct( array( 'k1' => 'v1', 'k2' => 'v2', 'k3' => null, ) ); } public function offsetGet( $index ) { if ( isset( $this[$index] ) ) { return parent::offsetGet( $index ); } elseif ( isset( $this->defaults[ $index ] ) ) { return $this->defaults[ $index ]; } else { return null; } } } $o = new Test(); var_dump( isset( $o['k1'] ) ); var_dump( isset( $o['k3'] ) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fnKPG
function name:  (null)
number of ops:  12
compiled vars:  !0 = $o
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   NEW                                              $1      'Test'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   38     3        INIT_FCALL                                               'var_dump'
          4        ISSET_ISEMPTY_DIM_OBJ                         0  ~4      !0, 'k1'
          5        SEND_VAL                                                 ~4
          6        DO_ICALL                                                 
   39     7        INIT_FCALL                                               'var_dump'
          8        ISSET_ISEMPTY_DIM_OBJ                         0  ~6      !0, 'k3'
          9        SEND_VAL                                                 ~6
         10        DO_ICALL                                                 
         11      > RETURN                                                   1

Class Test:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fnKPG
function name:  __construct
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   INIT_STATIC_METHOD_CALL                                  
   12     1        SEND_VAL_EX                                              <array>
          2        DO_FCALL                                      0          
   17     3      > RETURN                                                   null

End of function __construct

Function offsetget:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 16
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fnKPG
function name:  offsetGet
number of ops:  18
compiled vars:  !0 = $index
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
   21     1        FETCH_THIS                                       ~1      
          2        ISSET_ISEMPTY_DIM_OBJ                         0          ~1, !0
          3      > JMPZ                                                     ~2, ->9
   23     4    >   INIT_STATIC_METHOD_CALL                                  'offsetGet'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0  $3      
          7      > RETURN                                                   $3
          8*       JMP                                                      ->17
   25     9    >   FETCH_OBJ_IS                                     ~4      'defaults'
         10        ISSET_ISEMPTY_DIM_OBJ                         0          ~4, !0
         11      > JMPZ                                                     ~5, ->16
   27    12    >   FETCH_OBJ_R                                      ~6      'defaults'
         13        FETCH_DIM_R                                      ~7      ~6, !0
         14      > RETURN                                                   ~7
         15*       JMP                                                      ->17
   31    16    > > RETURN                                                   null
   33    17*     > RETURN                                                   null

End of function offsetget

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.77 ms | 1400 KiB | 15 Q