3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ArrayExtended implements ArrayAccess{ protected $ary = array(); public function __construct(array $a = null) { if($a) $this->ary = $a; } // Useful methods public function reverse() { $this->ary = array_reverse($this->ary); return $this; } public function flip() { $this->ary = array_flip($this->ary); return $this; } // Mandatory methods for ArrayAccess implementation public function offsetExists($off){return array_key_exists($off,$this->ary);} public function offsetGet($off){return $this->ary[$off];} public function offsetSet($off,$val){if(is_null($off)) $this->ary[]=$val; else $this->ary[$off]=$val;} public function offsetUnset($off){unset($this->ary[$off]);} } $o = new ArrayExtended(array('a','b')); $o[] = 'c'; print_r((array)$o->reverse()->flip());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0SkWZ
function name:  (null)
number of ops:  16
compiled vars:  !0 = $o
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'arrayextended'
   29     1        NEW                                              $1      'ArrayExtended'
          2        SEND_VAL_EX                                              <array>
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $1
   30     5        ASSIGN_DIM                                               !0
          6        OP_DATA                                                  'c'
   31     7        INIT_FCALL                                               'print_r'
          8        INIT_METHOD_CALL                                         !0, 'reverse'
          9        DO_FCALL                                      0  $5      
         10        INIT_METHOD_CALL                                         $5, 'flip'
         11        DO_FCALL                                      0  $6      
         12        CAST                                          7  ~7      $6
         13        SEND_VAL                                                 ~7
         14        DO_ICALL                                                 
         15      > RETURN                                                   1

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

End of function __construct

Function reverse:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0SkWZ
function name:  reverse
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL                                               'array_reverse'
          1        FETCH_OBJ_R                                      ~1      'ary'
          2        SEND_VAL                                                 ~1
          3        DO_ICALL                                         $2      
          4        ASSIGN_OBJ                                               'ary'
          5        OP_DATA                                                  $2
   13     6        FETCH_THIS                                       ~3      
          7      > RETURN                                                   ~3
   14     8*     > RETURN                                                   null

End of function reverse

Function flip:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0SkWZ
function name:  flip
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   INIT_FCALL                                               'array_flip'
          1        FETCH_OBJ_R                                      ~1      'ary'
          2        SEND_VAL                                                 ~1
          3        DO_ICALL                                         $2      
          4        ASSIGN_OBJ                                               'ary'
          5        OP_DATA                                                  $2
   18     6        FETCH_THIS                                       ~3      
          7      > RETURN                                                   ~3
   19     8*     > RETURN                                                   null

End of function flip

Function offsetexists:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0SkWZ
function name:  offsetExists
number of ops:  5
compiled vars:  !0 = $off
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
          1        FETCH_OBJ_R                                      ~1      'ary'
          2        ARRAY_KEY_EXISTS                                 ~2      !0, ~1
          3      > RETURN                                                   ~2
          4*     > 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/0SkWZ
function name:  offsetGet
number of ops:  5
compiled vars:  !0 = $off
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
          1        FETCH_OBJ_R                                      ~1      'ary'
          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
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/0SkWZ
function name:  offsetSet
number of ops:  12
compiled vars:  !0 = $off, !1 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        TYPE_CHECK                                    2          !0
          3      > JMPZ                                                     ~2, ->8
          4    >   FETCH_OBJ_W                                      $3      'ary'
          5        ASSIGN_DIM                                               $3
          6        OP_DATA                                                  !1
          7      > JMP                                                      ->11
          8    >   FETCH_OBJ_W                                      $5      'ary'
          9        ASSIGN_DIM                                               $5, !0
         10        OP_DATA                                                  !1
         11    > > 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/0SkWZ
function name:  offsetUnset
number of ops:  4
compiled vars:  !0 = $off
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
          1        FETCH_OBJ_UNSET                                  $1      'ary'
          2        UNSET_DIM                                                $1, !0
          3      > RETURN                                                   null

End of function offsetunset

End of class ArrayExtended.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.08 ms | 1404 KiB | 19 Q