3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Collection implements IteratorAggregate { private $list = []; public function __construct(array $list = []) { $this->list = $list; } public function add(string $string): void { $this->list[] = $string; } public function getIterator(): Traversable { return new ArrayIterator($this->list); } public function map(callable $callback): self { return new static(array_map($callback, $this->list)); } public function each(callable $callback) { foreach ($this->list as $key => $item) { $this->list[$key] = $callback($item); } return $this; } } function generateArray(): array { return array_fill(0, 400000, 'test'); } $collection = new Collection(generateArray()); $collection->each(fn($value) => $value . 's'); var_dump($collection);

Abusive script

This script was stopped while abusing our resources

Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tZruZ
function name:  (null)
number of ops:  15
compiled vars:  !0 = $collection
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'collection'
   42     1        NEW                                              $1      'Collection'
          2        INIT_FCALL                                               'generatearray'
          3        DO_FCALL                                      0  $2      
          4        SEND_VAR_NO_REF_EX                                       $2
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !0, $1
   43     7        INIT_METHOD_CALL                                         !0, 'each'
          8        DECLARE_LAMBDA_FUNCTION                          ~5      [0]
          9        SEND_VAL_EX                                              ~5
         10        DO_FCALL                                      0          
   45    11        INIT_FCALL                                               'var_dump'
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                                 
         14      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tZruZ
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   43     0  E >   RECV                                             !0      
          1        CONCAT                                           ~1      !0, 's'
          2      > RETURN                                                   ~1
          3*     > RETURN                                                   null

End of Dynamic Function 0

Function generatearray:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tZruZ
function name:  generateArray
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   INIT_FCALL                                               'array_fill'
          1        SEND_VAL                                                 0
          2        SEND_VAL                                                 400000
          3        SEND_VAL                                                 'test'
          4        DO_ICALL                                         $0      
          5        VERIFY_RETURN_TYPE                                       $0
          6      > RETURN                                                   $0
   40     7*       VERIFY_RETURN_TYPE                                       
          8*     > RETURN                                                   null

End of function generatearray

Class Collection:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tZruZ
function name:  __construct
number of ops:  4
compiled vars:  !0 = $list
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV_INIT                                        !0      <array>
    9     1        ASSIGN_OBJ                                               'list'
          2        OP_DATA                                                  !0
   10     3      > RETURN                                                   null

End of function __construct

Function add:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tZruZ
function name:  add
number of ops:  5
compiled vars:  !0 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   14     1        FETCH_OBJ_W                                      $1      'list'
          2        ASSIGN_DIM                                               $1
          3        OP_DATA                                                  !0
   15     4      > RETURN                                                   null

End of function add

Function getiterator:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tZruZ
function name:  getIterator
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   NEW                                              $0      'ArrayIterator'
          1        CHECK_FUNC_ARG                                           
          2        FETCH_OBJ_FUNC_ARG                               $1      'list'
          3        SEND_FUNC_ARG                                            $1
          4        DO_FCALL                                      0          
          5        VERIFY_RETURN_TYPE                                       $0
          6      > RETURN                                                   $0
   20     7*       VERIFY_RETURN_TYPE                                       
          8*     > RETURN                                                   null

End of function getiterator

Function map:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tZruZ
function name:  map
number of ops:  13
compiled vars:  !0 = $callback
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
   24     1        NEW                          static              $1      
          2        INIT_FCALL                                               'array_map'
          3        SEND_VAR                                                 !0
          4        FETCH_OBJ_R                                      ~2      'list'
          5        SEND_VAL                                                 ~2
          6        DO_ICALL                                         $3      
          7        SEND_VAR_NO_REF_EX                                       $3
          8        DO_FCALL                                      0          
          9        VERIFY_RETURN_TYPE                                       $1
         10      > RETURN                                                   $1
   25    11*       VERIFY_RETURN_TYPE                                       
         12*     > RETURN                                                   null

End of function map

Function each:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 12
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 12
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/tZruZ
function name:  each
number of ops:  16
compiled vars:  !0 = $callback, !1 = $item, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   RECV                                             !0      
   29     1        FETCH_OBJ_R                                      ~3      'list'
          2      > FE_RESET_R                                       $4      ~3, ->12
          3    > > FE_FETCH_R                                       ~5      $4, !1, ->12
          4    >   ASSIGN                                                   !2, ~5
   30     5        INIT_DYNAMIC_CALL                                        !0
          6        SEND_VAR_EX                                              !1
          7        DO_FCALL                                      0  $9      
          8        FETCH_OBJ_W                                      $7      'list'
          9        ASSIGN_DIM                                               $7, !2
         10        OP_DATA                                                  $9
   29    11      > JMP                                                      ->3
         12    >   FE_FREE                                                  $4
   33    13        FETCH_THIS                                       ~10     
         14      > RETURN                                                   ~10
   34    15*     > RETURN                                                   null

End of function each

End of class Collection.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.07 ms | 1013 KiB | 17 Q