3v4l.org

run code in 500+ PHP versions simultaneously
<?php declare(strict_types = 1); class HelloWorld { public static function createData(): array { $data = [ [ 'title' => 'Title 1', 'start_at' => new DateTime(), ], [ 'title' => 'Title 2', 'start_at' => new DateTime(), ], [ 'title' => 'Title 3', 'start_at' => new DateTime(), ], ]; foreach ($data as $key => &$row) { $row['end_at'] = $data[$key + 1]['start_at'] ?? null; } return array_filter($data, function ($row): bool { return $row['end_at'] !== null; }); } } print_R(HelloWorld::createData());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vDNLo
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   32     0  E >   INIT_FCALL                                                   'print_r'
          1        INIT_STATIC_METHOD_CALL                                      'HelloWorld', 'createData'
          2        DO_FCALL                                          0  $0      
          3        SEND_VAR                                                     $0
          4        DO_ICALL                                                     
          5      > RETURN                                                       1

Class HelloWorld:
Function createdata:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 17, Position 2 = 27
Branch analysis from position: 17
2 jumps found. (Code = 126) Position 1 = 18, Position 2 = 27
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/vDNLo
function name:  createData
number of ops:  37
compiled vars:  !0 = $data, !1 = $row, !2 = $key
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    9     0  E >   INIT_ARRAY                                           ~3      'Title+1', 'title'
   10     1        NEW                                                  $4      'DateTime'
          2        DO_FCALL                                          0          
          3        ADD_ARRAY_ELEMENT                                    ~3      $4, 'start_at'
          4        INIT_ARRAY                                           ~6      ~3
   13     5        INIT_ARRAY                                           ~7      'Title+2', 'title'
   14     6        NEW                                                  $8      'DateTime'
          7        DO_FCALL                                          0          
          8        ADD_ARRAY_ELEMENT                                    ~7      $8, 'start_at'
          9        ADD_ARRAY_ELEMENT                                    ~6      ~7
   17    10        INIT_ARRAY                                           ~10     'Title+3', 'title'
   18    11        NEW                                                  $11     'DateTime'
         12        DO_FCALL                                          0          
         13        ADD_ARRAY_ELEMENT                                    ~10     $11, 'start_at'
         14        ADD_ARRAY_ELEMENT                                    ~6      ~10
    7    15        ASSIGN                                                       !0, ~6
   22    16      > FE_RESET_RW                                          $14     !0, ->27
         17    > > FE_FETCH_RW                                          ~15     $14, !1, ->27
         18    >   ASSIGN                                                       !2, ~15
   23    19        ADD                                                  ~18     !2, 1
         20        FETCH_DIM_IS                                         ~19     !0, ~18
         21        FETCH_DIM_IS                                         ~20     ~19, 'start_at'
         22        COALESCE                                             ~21     ~20
         23        QM_ASSIGN                                            ~21     null
         24        ASSIGN_DIM                                                   !1, 'end_at'
         25        OP_DATA                                                      ~21
   22    26      > JMP                                                          ->17
         27    >   FE_FREE                                                      $14
   26    28        INIT_FCALL                                                   'array_filter'
         29        SEND_VAR                                                     !0
         30        DECLARE_LAMBDA_FUNCTION                              ~22     [0]
   28    31        SEND_VAL                                                     ~22
   26    32        DO_ICALL                                             $23     
   28    33        VERIFY_RETURN_TYPE                                           $23
         34      > RETURN                                                       $23
   29    35*       VERIFY_RETURN_TYPE                                           
         36*     > 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/vDNLo
function name:  {closure:HelloWorld::createData():26}
number of ops:  7
compiled vars:  !0 = $row
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   26     0  E >   RECV                                                 !0      
   27     1        FETCH_DIM_R                                          ~1      !0, 'end_at'
          2        TYPE_CHECK                                      1020  ~2      ~1
          3        VERIFY_RETURN_TYPE                                           ~2
          4      > RETURN                                                       ~2
   28     5*       VERIFY_RETURN_TYPE                                           
          6*     > RETURN                                                       null

End of Dynamic Function 0

End of function createdata

End of class HelloWorld.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
169.58 ms | 2253 KiB | 15 Q