3v4l.org

run code in 300+ PHP versions simultaneously
<?php class NumberWrapper { private $number; public function __construct($number) { $this->number = $number; } } class CollectionGenerator { public function create($array, $class) { $collection = []; foreach($array as $item) { $collection[] = new $class($item); } return $collection; } } $someArray = [1, 2, 3]; $wrappedArray = CollectionGenerator::create($someArray, 'NumberWrapper1'); var_dump($wrappedArray);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/do3R4
function name:  (null)
number of ops:  10
compiled vars:  !0 = $someArray, !1 = $wrappedArray
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   ASSIGN                                                   !0, <array>
   22     1        INIT_STATIC_METHOD_CALL                                  'CollectionGenerator', 'create'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 'NumberWrapper1'
          4        DO_FCALL                                      0  $3      
          5        ASSIGN                                                   !1, $3
   23     6        INIT_FCALL                                               'var_dump'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

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

End of function __construct

End of class NumberWrapper.

Class CollectionGenerator:
Function create:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 12
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/do3R4
function name:  create
number of ops:  15
compiled vars:  !0 = $array, !1 = $class, !2 = $collection, !3 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   13     2        ASSIGN                                                   !2, <array>
   14     3      > FE_RESET_R                                       $5      !0, ->12
          4    > > FE_FETCH_R                                               $5, !3, ->12
   15     5    >   FETCH_CLASS                                   0  $7      !1
          6        NEW                                              $8      $7
          7        SEND_VAR_EX                                              !3
          8        DO_FCALL                                      0          
          9        ASSIGN_DIM                                               !2
         10        OP_DATA                                                  $8
   14    11      > JMP                                                      ->4
         12    >   FE_FREE                                                  $5
   17    13      > RETURN                                                   !2
   18    14*     > RETURN                                                   null

End of function create

End of class CollectionGenerator.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.47 ms | 1392 KiB | 15 Q