3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types = 1); /** * @template-covariant T */ final class Collection { /** * @param list<T> $items */ public function __construct( private array $items = [], ) { } /** * @template TValue * @param Closure(T, int): TValue $callback * @return Collection<TValue> */ public function map(Closure $callback): self { $mapped = []; foreach ($this->items as $key => $item) { $mapped[] = $callback($item, $key); } return new self($mapped); } } enum X: string { case CASE1 = 'case1'; case CASE2 = 'case2'; } (new Collection(['case1']))->map(X::from(...));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YWSEo
function name:  (null)
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   DECLARE_CLASS                                            'x'
   37     1        NEW                                              $0      'Collection'
          2        SEND_VAL_EX                                              <array>
          3        DO_FCALL                                      0          
          4        INIT_METHOD_CALL                                         $0, 'map'
          5        INIT_STATIC_METHOD_CALL                                  'X', 'from'
          6        ZEND_CALLABLE_CONVERT                            ~2      
          7        SEND_VAL_EX                                              ~2
          8        DO_FCALL                                      0          
          9      > RETURN                                                   1

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

End of function __construct

Function map:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 13
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 13
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/YWSEo
function name:  map
number of ops:  21
compiled vars:  !0 = $callback, !1 = $mapped, !2 = $item, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
   23     1        ASSIGN                                                   !1, <array>
   24     2        FETCH_OBJ_R                                      ~5      'items'
          3      > FE_RESET_R                                       $6      ~5, ->13
          4    > > FE_FETCH_R                                       ~7      $6, !2, ->13
          5    >   ASSIGN                                                   !3, ~7
   25     6        INIT_DYNAMIC_CALL                                        !0
          7        SEND_VAR_EX                                              !2
          8        SEND_VAR_EX                                              !3
          9        DO_FCALL                                      0  $10     
         10        ASSIGN_DIM                                               !1
         11        OP_DATA                                                  $10
   24    12      > JMP                                                      ->4
         13    >   FE_FREE                                                  $6
   28    14        NEW                          self                $11     
         15        SEND_VAR_EX                                              !1
         16        DO_FCALL                                      0          
         17        VERIFY_RETURN_TYPE                                       $11
         18      > RETURN                                                   $11
   29    19*       VERIFY_RETURN_TYPE                                       
         20*     > RETURN                                                   null

End of function map

End of class Collection.

Class X: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.68 ms | 1007 KiB | 13 Q