3v4l.org

run code in 500+ PHP versions simultaneously
<?php declare(strict_types=1); final class RecursiveFixedArrayProxy implements IteratorAggregate, RecursiveIterator { private SplFixedArray $splFixedArray; public function __construct(iterable $iterable = []) { $this->splFixedArray = new SplFixedArray( is_countable($iterable) ? count($iterable) : iterator_count($iterable) ); $offset = 0; $size = $this->splFixedArray->count(); foreach ($iterable as $key => $value) { if($offset === $size){ // resize the SplFixedArray when nessary. (if the iterable passed in via the __construct implements countable differently eg. where count() returns the capacity/size of the iterable) $this->splFixedArray->setSize(++$size); } if(is_array($value)){ // save arrays as RecursiveFixedArrayProxy $this->splFixedArray->offsetSet($offset++, new self($value)); continue; } // save all other values as stdClass via Closure $this->splFixedArray->offsetSet( $offset++, (static function(mixed $key = null, mixed $value = null): stdClass{ $stdClass = new stdClass(); $stdClass->key = $key; $stdClass->value = $value; return $stdClass; })($key, $value) ); } $this->splFixedArray->setSize($offset); } // required from IteratorAggregate public function getIterator(): Generator { // to provide a Recursive SplFixedArray implemtation. yield from new RecursiveArrayIterator( // is this wrong? trying to avoid using arrays, for memory boost // avoids: $this->splFixedArray->toArray() $this->splFixedArray ); } // required from RecursiveIterator public function getChildren(): ?RecursiveIterator { /** @return RecursiveFixedArray */ return $this->current(); } // required from RecursiveIterator public function hasChildren(): bool { // traverse recursively if *current* is instance of RecursiveFixedArray return $this->current() instanceof RecursiveFixedArray; } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/usWZK
function name:  (null)
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    5     0  E >   DECLARE_CLASS                                                'recursivefixedarrayproxy'
   64     1      > RETURN                                                       1

Class RecursiveFixedArrayProxy:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 9
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
2 jumps found. (Code = 77) Position 1 = 23, Position 2 = 56
Branch analysis from position: 23
2 jumps found. (Code = 78) Position 1 = 24, Position 2 = 56
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 32
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 44
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 32
Branch analysis from position: 56
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 56
Branch analysis from position: 9
2 jumps found. (Code = 77) Position 1 = 23, Position 2 = 56
Branch analysis from position: 23
Branch analysis from position: 56
filename:       /in/usWZK
function name:  __construct
number of ops:  62
compiled vars:  !0 = $iterable, !1 = $offset, !2 = $size, !3 = $value, !4 = $key
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    8     0  E >   RECV_INIT                                            !0      <array>
   10     1        NEW                                                  $6      'SplFixedArray'
   11     2        INIT_FCALL                                                   'is_countable'
          3        SEND_VAR                                                     !0
          4        DO_ICALL                                             $7      
          5      > JMPZ                                                         $7, ->9
   12     6    >   COUNT                                                ~8      !0
          7        QM_ASSIGN                                            ~9      ~8
          8      > JMP                                                          ->13
   13     9    >   INIT_FCALL                                                   'iterator_count'
         10        SEND_VAR                                                     !0
         11        DO_ICALL                                             $10     
         12        QM_ASSIGN                                            ~9      $10
         13    >   SEND_VAL_EX                                                  ~9
   10    14        DO_FCALL                                          0          
         15        ASSIGN_OBJ                                                   'splFixedArray'
   13    16        OP_DATA                                                      $6
   16    17        ASSIGN                                                       !1, 0
   17    18        FETCH_OBJ_R                                          ~13     'splFixedArray'
         19        INIT_METHOD_CALL                                             ~13, 'count'
         20        DO_FCALL                                          0  $14     
         21        ASSIGN                                                       !2, $14
   18    22      > FE_RESET_R                                           $16     !0, ->56
         23    > > FE_FETCH_R                                           ~17     $16, !3, ->56
         24    >   ASSIGN                                                       !4, ~17
   19    25        IS_IDENTICAL                                                 !1, !2
         26      > JMPZ                                                         ~19, ->32
   21    27    >   FETCH_OBJ_R                                          ~20     'splFixedArray'
         28        INIT_METHOD_CALL                                             ~20, 'setSize'
         29        PRE_INC                                              ~21     !2
         30        SEND_VAL_EX                                                  ~21
         31        DO_FCALL                                          0          
   23    32    >   TYPE_CHECK                                      128          !3
         33      > JMPZ                                                         ~23, ->44
   25    34    >   FETCH_OBJ_R                                          ~24     'splFixedArray'
         35        INIT_METHOD_CALL                                             ~24, 'offsetSet'
         36        POST_INC                                             ~25     !1
         37        SEND_VAL_EX                                                  ~25
         38        NEW                              self                $26     
         39        SEND_VAR_EX                                                  !3
         40        DO_FCALL                                          0          
         41        SEND_VAR_NO_REF_EX                                           $26
         42        DO_FCALL                                          0          
   26    43      > JMP                                                          ->23
   29    44    >   FETCH_OBJ_R                                          ~29     'splFixedArray'
         45        INIT_METHOD_CALL                                             ~29, 'offsetSet'
   30    46        POST_INC                                             ~30     !1
         47        SEND_VAL_EX                                                  ~30
   31    48        DECLARE_LAMBDA_FUNCTION                              ~31     [0]
   37    49        INIT_DYNAMIC_CALL                                            ~31
         50        SEND_VAR_EX                                                  !4
         51        SEND_VAR_EX                                                  !3
         52        DO_FCALL                                          0  $32     
         53        SEND_VAR_NO_REF_EX                                           $32
   29    54        DO_FCALL                                          0          
   18    55      > JMP                                                          ->23
         56    >   FE_FREE                                                      $16
   40    57        FETCH_OBJ_R                                          ~34     'splFixedArray'
         58        INIT_METHOD_CALL                                             ~34, 'setSize'
         59        SEND_VAR_EX                                                  !1
         60        DO_FCALL                                          0          
   41    61      > RETURN                                                       null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/usWZK
function name:  {closure:RecursiveFixedArrayProxy::__construct():31}
number of ops:  13
compiled vars:  !0 = $key, !1 = $value, !2 = $stdClass
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   31     0  E >   RECV_INIT                                            !0      null
          1        RECV_INIT                                            !1      null
   32     2        NEW                                                  $3      'stdClass'
          3        DO_FCALL                                          0          
          4        ASSIGN                                                       !2, $3
   33     5        ASSIGN_OBJ                                                   !2, 'key'
          6        OP_DATA                                                      !0
   34     7        ASSIGN_OBJ                                                   !2, 'value'
          8        OP_DATA                                                      !1
   36     9        VERIFY_RETURN_TYPE                                           !2
         10      > RETURN                                                       !2
   37    11*       VERIFY_RETURN_TYPE                                           
         12*     > RETURN                                                       null

End of Dynamic Function 0

End of function __construct

Function getiterator:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/usWZK
function name:  getIterator
number of ops:  9
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   43     0  E >   GENERATOR_CREATE                                             
   46     1        NEW                                                  $0      'RecursiveArrayIterator'
          2        CHECK_FUNC_ARG                                               
   49     3        FETCH_OBJ_FUNC_ARG                                   $1      'splFixedArray'
          4        SEND_FUNC_ARG                                                $1
   46     5        DO_FCALL                                          0          
   49     6        YIELD_FROM                                           ~3      $0
          7        FREE                                                         ~3
   51     8      > GENERATOR_RETURN                                             

End of function getiterator

Function getchildren:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/usWZK
function name:  getChildren
number of ops:  6
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   56     0  E >   INIT_METHOD_CALL                                             'current'
          1        DO_FCALL                                          0  $0      
          2        VERIFY_RETURN_TYPE                                           $0
          3      > RETURN                                                       $0
   57     4*       VERIFY_RETURN_TYPE                                           
          5*     > RETURN                                                       null

End of function getchildren

Function haschildren:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/usWZK
function name:  hasChildren
number of ops:  7
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   62     0  E >   INIT_METHOD_CALL                                             'current'
          1        DO_FCALL                                          0  $0      
          2        INSTANCEOF                                           ~1      $0, 'RecursiveFixedArray'
          3        VERIFY_RETURN_TYPE                                           ~1
          4      > RETURN                                                       ~1
   63     5*       VERIFY_RETURN_TYPE                                           
          6*     > RETURN                                                       null

End of function haschildren

End of class RecursiveFixedArrayProxy.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
131.47 ms | 487 KiB | 9 Q