3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Item { private $id; public function __construct(int $id) { $this->id = $id; } public function id() : int { return $this->id; } } class Collection extends IteratorIterator { public function __construct(Item ...$items) { parent::__construct( (function() use ($items) { yield from $items; })() ); } public function current() : Item { return parent::current(); } } $items = []; for ($i=0; $i<10; $i++) { $items[] = new Item($i); } $collection = new Collection(...$items); foreach ($collection as $item) { printf("\tClass: %s. Calling id() method returns %d (%s)\n", get_class($item), $item->id(), gettype($item->id())); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 3
Branch analysis from position: 11
2 jumps found. (Code = 77) Position 1 = 17, Position 2 = 31
Branch analysis from position: 17
2 jumps found. (Code = 78) Position 1 = 18, Position 2 = 31
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 3
Branch analysis from position: 11
Branch analysis from position: 3
filename:       /in/YMQer
function name:  (null)
number of ops:  33
compiled vars:  !0 = $items, !1 = $i, !2 = $collection, !3 = $item
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   28     0  E >   ASSIGN                                                       !0, <array>
   29     1        ASSIGN                                                       !1, 0
          2      > JMP                                                          ->9
   30     3    >   NEW                                                  $7      'Item'
          4        SEND_VAR_EX                                                  !1
          5        DO_FCALL                                          0          
          6        ASSIGN_DIM                                                   !0
          7        OP_DATA                                                      $7
   29     8        PRE_INC                                                      !1
          9    >   IS_SMALLER                                                   !1, 10
         10      > JMPNZ                                                        ~10, ->3
   32    11    >   NEW                                                  $11     'Collection'
         12        SEND_UNPACK                                                  !0
         13        CHECK_UNDEF_ARGS                                             
         14        DO_FCALL                                          1          
         15        ASSIGN                                                       !2, $11
   34    16      > FE_RESET_R                                           $14     !2, ->31
         17    > > FE_FETCH_R                                                   $14, !3, ->31
   35    18    >   INIT_FCALL                                                   'printf'
         19        SEND_VAL                                                     '%09Class%3A+%25s.+Calling+id%28%29+method+returns+%25d+%28%25s%29%0A'
         20        GET_CLASS                                            ~15     !3
         21        SEND_VAL                                                     ~15
         22        INIT_METHOD_CALL                                             !3, 'id'
         23        DO_FCALL                                          0  $16     
         24        SEND_VAR                                                     $16
         25        INIT_METHOD_CALL                                             !3, 'id'
         26        DO_FCALL                                          0  $17     
         27        GET_TYPE                                             ~18     $17
         28        SEND_VAL                                                     ~18
         29        DO_ICALL                                                     
   34    30      > JMP                                                          ->17
         31    >   FE_FREE                                                      $14
   36    32      > RETURN                                                       1

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

End of function __construct

Function id:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YMQer
function name:  id
number of ops:  5
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   10     0  E >   FETCH_OBJ_R                                          ~0      'id'
          1        VERIFY_RETURN_TYPE                                           ~0
          2      > RETURN                                                       ~0
   11     3*       VERIFY_RETURN_TYPE                                           
          4*     > RETURN                                                       null

End of function id

End of class Item.

Class Collection:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YMQer
function name:  __construct
number of ops:  9
compiled vars:  !0 = $items
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   15     0  E >   RECV_VARIADIC                                        !0      
   17     1        INIT_STATIC_METHOD_CALL                                      
   18     2        DECLARE_LAMBDA_FUNCTION                              ~1      [0]
          3        BIND_LEXICAL                                                 ~1, !0
   20     4        INIT_DYNAMIC_CALL                                            ~1
          5        DO_FCALL                                          0  $2      
          6        SEND_VAR_NO_REF_EX                                           $2
   17     7        DO_FCALL                                          0          
   22     8      > RETURN                                                       null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/YMQer
function name:  {closure:Collection::__construct():18}
number of ops:  5
compiled vars:  !0 = $items
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   18     0  E >   GENERATOR_CREATE                                             
          1        BIND_STATIC                                                  !0
   19     2        YIELD_FROM                                           ~1      !0
          3        FREE                                                         ~1
   20     4      > GENERATOR_RETURN                                             

End of Dynamic Function 0

End of function __construct

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

End of function current

End of class Collection.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
657.07 ms | 2972 KiB | 14 Q