3v4l.org

run code in 300+ PHP versions simultaneously
<?php enum Test: string { case AUTHENTICATED = 'authenticated'; case COURSES_ADMIN = 'courses.admin'; case BUNDLES_ADMIN = 'bundles.admin'; case COURSES_REPORTING_ACCESS = 'courses-reporting.access'; case B2B_DASHBOARD_ACCESS = 'b2b-dashboard.access'; case INSTRUCTORS_ADMIN = 'instructors.admin'; case USERS_ADMIN = 'users.admin'; case COUPONS_ADMIN = 'coupons.admin'; } $data = [ Test::COURSES_ADMIN, Test::COURSES_REPORTING_ACCESS, Test::BUNDLES_ADMIN, Test::USERS_ADMIN, Test::B2B_DASHBOARD_ACCESS, Test::B2B_DASHBOARD_ACCESS, Test::INSTRUCTORS_ADMIN, Test::INSTRUCTORS_ADMIN, Test::COUPONS_ADMIN, Test::AUTHENTICATED, ]; $values = array_map(fn ($el) => $el->value, $data); $uniqueValues = array_unique($values, flags: SORT_REGULAR); $uniqueData = array_map(fn ($el) => Test::from($el), $uniqueValues); var_dump($uniqueData);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4uv5s
function name:  (null)
number of ops:  43
compiled vars:  !0 = $data, !1 = $values, !2 = $uniqueValues, !3 = $uniqueData
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'test'
   16     1        FETCH_CLASS_CONSTANT                             ~4      'Test', 'COURSES_ADMIN'
          2        INIT_ARRAY                                       ~5      ~4
   17     3        FETCH_CLASS_CONSTANT                             ~6      'Test', 'COURSES_REPORTING_ACCESS'
          4        ADD_ARRAY_ELEMENT                                ~5      ~6
   18     5        FETCH_CLASS_CONSTANT                             ~7      'Test', 'BUNDLES_ADMIN'
          6        ADD_ARRAY_ELEMENT                                ~5      ~7
   19     7        FETCH_CLASS_CONSTANT                             ~8      'Test', 'USERS_ADMIN'
          8        ADD_ARRAY_ELEMENT                                ~5      ~8
   20     9        FETCH_CLASS_CONSTANT                             ~9      'Test', 'B2B_DASHBOARD_ACCESS'
         10        ADD_ARRAY_ELEMENT                                ~5      ~9
   21    11        FETCH_CLASS_CONSTANT                             ~10     'Test', 'B2B_DASHBOARD_ACCESS'
         12        ADD_ARRAY_ELEMENT                                ~5      ~10
   22    13        FETCH_CLASS_CONSTANT                             ~11     'Test', 'INSTRUCTORS_ADMIN'
         14        ADD_ARRAY_ELEMENT                                ~5      ~11
   23    15        FETCH_CLASS_CONSTANT                             ~12     'Test', 'INSTRUCTORS_ADMIN'
         16        ADD_ARRAY_ELEMENT                                ~5      ~12
   24    17        FETCH_CLASS_CONSTANT                             ~13     'Test', 'COUPONS_ADMIN'
         18        ADD_ARRAY_ELEMENT                                ~5      ~13
   25    19        FETCH_CLASS_CONSTANT                             ~14     'Test', 'AUTHENTICATED'
         20        ADD_ARRAY_ELEMENT                                ~5      ~14
   15    21        ASSIGN                                                   !0, ~5
   28    22        INIT_FCALL                                               'array_map'
         23        DECLARE_LAMBDA_FUNCTION                          ~16     [0]
         24        SEND_VAL                                                 ~16
         25        SEND_VAR                                                 !0
         26        DO_ICALL                                         $17     
         27        ASSIGN                                                   !1, $17
   29    28        INIT_FCALL                                               'array_unique'
         29        SEND_VAR                                                 !1
         30        SEND_VAL                                                 0
         31        DO_ICALL                                         $19     
         32        ASSIGN                                                   !2, $19
   30    33        INIT_FCALL                                               'array_map'
         34        DECLARE_LAMBDA_FUNCTION                          ~21     [1]
         35        SEND_VAL                                                 ~21
         36        SEND_VAR                                                 !2
         37        DO_ICALL                                         $22     
         38        ASSIGN                                                   !3, $22
   31    39        INIT_FCALL                                               'var_dump'
         40        SEND_VAR                                                 !3
         41        DO_ICALL                                                 
         42      > 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/4uv5s
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $el
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
          1        FETCH_OBJ_R                                      ~1      !0, 'value'
          2      > RETURN                                                   ~1
          3*     > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4uv5s
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $el
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
          1        INIT_STATIC_METHOD_CALL                                  'Test', 'from'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
          5*     > RETURN                                                   null

End of Dynamic Function 1

Class Test: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.97 ms | 1005 KiB | 16 Q