3v4l.org

run code in 500+ PHP versions simultaneously
<?php class IteratorWithFilter { public $generator; public function __construct(array $data) { $this->generator = new \ArrayIterator($data); } public function filter() { $this->generator = new \CallbackFilterIterator($this->generator, static function ($row) { return true; }); return $this; } } function createIterator() { $iter = new IteratorWithFilter([['a'], ['b']]); return $iter->filter(); } for ($i = 0; $i < 50 * 1000; $i++) { createIterator(); if (($i % 1000) === 0) { // gc_collect_cycles(); // explicit GC does not help... echo round(memory_get_usage() / (1024 * 1024), 3) . " MiB\n"; } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 2
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 16
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 2
Branch analysis from position: 19
Branch analysis from position: 2
Branch analysis from position: 16
filename:       /in/QPlkq
function name:  (null)
number of ops:  20
compiled vars:  !0 = $i
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   27     0  E >   ASSIGN                                                       !0, 0
          1      > JMP                                                          ->17
   28     2    >   INIT_FCALL                                                   'createiterator'
          3        DO_FCALL                                          0          
   30     4        MOD                                                  ~3      !0, 1000
          5        IS_IDENTICAL                                                 ~3, 0
          6      > JMPZ                                                         ~4, ->16
   32     7    >   INIT_FCALL                                                   'round'
          8        INIT_FCALL                                                   'memory_get_usage'
          9        DO_ICALL                                             $5      
         10        DIV                                                  ~6      $5, 1048576
         11        SEND_VAL                                                     ~6
         12        SEND_VAL                                                     3
         13        DO_ICALL                                             $7      
         14        CONCAT                                               ~8      $7, '+MiB%0A'
         15        ECHO                                                         ~8
   27    16    >   PRE_INC                                                      !0
         17    >   IS_SMALLER                                                   !0, 50000
         18      > JMPNZ                                                        ~10, ->2
   34    19    > > RETURN                                                       1

Function createiterator:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QPlkq
function name:  createIterator
number of ops:  8
compiled vars:  !0 = $iter
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   23     0  E >   NEW                                                  $1      'IteratorWithFilter'
          1        SEND_VAL_EX                                                  <array>
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !0, $1
   24     4        INIT_METHOD_CALL                                             !0, 'filter'
          5        DO_FCALL                                          0  $4      
          6      > RETURN                                                       $4
   25     7*     > RETURN                                                       null

End of function createiterator

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

End of function __construct

Function filter:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QPlkq
function name:  filter
number of ops:  12
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   14     0  E >   NEW                                                  $1      'CallbackFilterIterator'
          1        CHECK_FUNC_ARG                                               
          2        FETCH_OBJ_FUNC_ARG                                   $2      'generator'
          3        SEND_FUNC_ARG                                                $2
          4        DECLARE_LAMBDA_FUNCTION                              ~3      [0]
   16     5        SEND_VAL_EX                                                  ~3
   14     6        DO_FCALL                                          0          
          7        ASSIGN_OBJ                                                   'generator'
   16     8        OP_DATA                                                      $1
   18     9        FETCH_THIS                                           ~5      
         10      > RETURN                                                       ~5
   19    11*     > 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/QPlkq
function name:  {closure:IteratorWithFilter::filter():14}
number of ops:  3
compiled vars:  !0 = $row
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   14     0  E >   RECV                                                 !0      
   15     1      > RETURN                                                       <true>
   16     2*     > RETURN                                                       null

End of Dynamic Function 0

End of function filter

End of class IteratorWithFilter.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
158.58 ms | 1417 KiB | 16 Q