3v4l.org

run code in 300+ PHP versions simultaneously
<?php //Tinker away! $periods = \App\Models\Period::query() ->select('id', 'period_type', 'period_name', 'period_year') ->groupBy('period_year', 'period_type') ->orderBy('period_year') ->get() ->groupBy('period_year') ->map(function ($item, $key) { return [ 'year' => $key, 'periods' => $item->groupBy('period_type')->map(function ($item, $key) { return [ 'type' => $key, 'periods' => $item->map(function ($key,$item) { return [ 'id' => $item->id, 'period_type' => $item->period_type, // 'semester', 'trimester', 'year 'period_name' => $item->period_name, 'period_year' => $item->period_year, 'formatted_period_start_date' => $item->formatted_period_start_date, 'formatted_period_end_date' => $item->formatted_period_end_date, ]; })->toArray() ]; }) ]; }) ->toArray();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TeCbL
function name:  (null)
number of ops:  28
compiled vars:  !0 = $periods
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   INIT_STATIC_METHOD_CALL                                  'App%5CModels%5CPeriod', 'query'
          1        DO_FCALL                                      0  $1      
    5     2        INIT_METHOD_CALL                                         $1, 'select'
          3        SEND_VAL_EX                                              'id'
          4        SEND_VAL_EX                                              'period_type'
          5        SEND_VAL_EX                                              'period_name'
          6        SEND_VAL_EX                                              'period_year'
          7        DO_FCALL                                      0  $2      
    6     8        INIT_METHOD_CALL                                         $2, 'groupBy'
          9        SEND_VAL_EX                                              'period_year'
         10        SEND_VAL_EX                                              'period_type'
         11        DO_FCALL                                      0  $3      
    7    12        INIT_METHOD_CALL                                         $3, 'orderBy'
         13        SEND_VAL_EX                                              'period_year'
         14        DO_FCALL                                      0  $4      
    8    15        INIT_METHOD_CALL                                         $4, 'get'
         16        DO_FCALL                                      0  $5      
    9    17        INIT_METHOD_CALL                                         $5, 'groupBy'
         18        SEND_VAL_EX                                              'period_year'
         19        DO_FCALL                                      0  $6      
   10    20        INIT_METHOD_CALL                                         $6, 'map'
         21        DECLARE_LAMBDA_FUNCTION                          ~7      [0]
   29    22        SEND_VAL_EX                                              ~7
   10    23        DO_FCALL                                      0  $8      
   30    24        INIT_METHOD_CALL                                         $8, 'toArray'
         25        DO_FCALL                                      0  $9      
    4    26        ASSIGN                                                   !0, $9
   30    27      > 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/TeCbL
function name:  {closure}
number of ops:  13
compiled vars:  !0 = $item, !1 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   12     2        INIT_ARRAY                                       ~2      !1, 'year'
   13     3        INIT_METHOD_CALL                                         !0, 'groupBy'
          4        SEND_VAL_EX                                              'period_type'
          5        DO_FCALL                                      0  $3      
          6        INIT_METHOD_CALL                                         $3, 'map'
          7        DECLARE_LAMBDA_FUNCTION                          ~4      [0]
   27     8        SEND_VAL_EX                                              ~4
   13     9        DO_FCALL                                      0  $5      
   27    10        ADD_ARRAY_ELEMENT                                ~2      $5, 'periods'
         11      > RETURN                                                   ~2
   29    12*     > 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/TeCbL
function name:  {closure}
number of ops:  12
compiled vars:  !0 = $item, !1 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   15     2        INIT_ARRAY                                       ~2      !1, 'type'
   16     3        INIT_METHOD_CALL                                         !0, 'map'
          4        DECLARE_LAMBDA_FUNCTION                          ~3      [0]
   25     5        SEND_VAL_EX                                              ~3
   16     6        DO_FCALL                                      0  $4      
   25     7        INIT_METHOD_CALL                                         $4, 'toArray'
          8        DO_FCALL                                      0  $5      
          9        ADD_ARRAY_ELEMENT                                ~2      $5, 'periods'
         10      > RETURN                                                   ~2
   27    11*     > 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/TeCbL
function name:  {closure}
number of ops:  16
compiled vars:  !0 = $key, !1 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   18     2        FETCH_OBJ_R                                      ~2      !1, 'id'
          3        INIT_ARRAY                                       ~3      ~2, 'id'
   19     4        FETCH_OBJ_R                                      ~4      !1, 'period_type'
          5        ADD_ARRAY_ELEMENT                                ~3      ~4, 'period_type'
   20     6        FETCH_OBJ_R                                      ~5      !1, 'period_name'
          7        ADD_ARRAY_ELEMENT                                ~3      ~5, 'period_name'
   21     8        FETCH_OBJ_R                                      ~6      !1, 'period_year'
          9        ADD_ARRAY_ELEMENT                                ~3      ~6, 'period_year'
   22    10        FETCH_OBJ_R                                      ~7      !1, 'formatted_period_start_date'
         11        ADD_ARRAY_ELEMENT                                ~3      ~7, 'formatted_period_start_date'
   23    12        FETCH_OBJ_R                                      ~8      !1, 'formatted_period_end_date'
         13        ADD_ARRAY_ELEMENT                                ~3      ~8, 'formatted_period_end_date'
         14      > RETURN                                                   ~3
   25    15*     > RETURN                                                   null

End of Dynamic Function 0

End of Dynamic Function 0

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.76 ms | 1428 KiB | 13 Q