3v4l.org

run code in 300+ PHP versions simultaneously
<?php $permissionsToTest = ['yes-sir', 'maybe-sir', 'no-sir']; # Result of Auth::user()->role->permissions->toArray() $permissions = array_column([ ['id' => 1, 'slug' => 'yes-sir'], ['id' => 2, 'slug' => 'maybe-sir'], ], 'slug'); $results = array_map(fn(string $permission): bool => in_array($permission, $permissions), $permissionsToTest); $failedResults = array_keys(array_filter($results, fn(bool $result): bool => !$result)); $missingPermissions = array_map(fn(int $key): string => implode(' ', explode('-', $permissionsToTest[$key])), $failedResults); var_dump($missingPermissions);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/F6p1T
function name:  (null)
number of ops:  33
compiled vars:  !0 = $permissionsToTest, !1 = $permissions, !2 = $results, !3 = $failedResults, !4 = $missingPermissions
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    6     1        INIT_FCALL                                               'array_column'
    7     2        SEND_VAL                                                 <array>
    9     3        SEND_VAL                                                 'slug'
    6     4        DO_ICALL                                         $6      
          5        ASSIGN                                                   !1, $6
   11     6        INIT_FCALL                                               'array_map'
          7        DECLARE_LAMBDA_FUNCTION                          ~8      [0]
          8        BIND_LEXICAL                                             ~8, !1
          9        SEND_VAL                                                 ~8
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $9      
         12        ASSIGN                                                   !2, $9
   12    13        INIT_FCALL                                               'array_keys'
         14        INIT_FCALL                                               'array_filter'
         15        SEND_VAR                                                 !2
         16        DECLARE_LAMBDA_FUNCTION                          ~11     [1]
         17        SEND_VAL                                                 ~11
         18        DO_ICALL                                         $12     
         19        SEND_VAR                                                 $12
         20        DO_ICALL                                         $13     
         21        ASSIGN                                                   !3, $13
   13    22        INIT_FCALL                                               'array_map'
         23        DECLARE_LAMBDA_FUNCTION                          ~15     [2]
         24        BIND_LEXICAL                                             ~15, !0
         25        SEND_VAL                                                 ~15
         26        SEND_VAR                                                 !3
         27        DO_ICALL                                         $16     
         28        ASSIGN                                                   !4, $16
   15    29        INIT_FCALL                                               'var_dump'
         30        SEND_VAR                                                 !4
         31        DO_ICALL                                                 
         32      > 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/F6p1T
function name:  {closure}
number of ops:  10
compiled vars:  !0 = $permission, !1 = $permissions
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        INIT_FCALL                                               'in_array'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $2      
          6        VERIFY_RETURN_TYPE                                       $2
          7      > RETURN                                                   $2
          8*       VERIFY_RETURN_TYPE                                       
          9*     > 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/F6p1T
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        BOOL_NOT                                         ~1      !0
          2        VERIFY_RETURN_TYPE                                       ~1
          3      > RETURN                                                   ~1
          4*       VERIFY_RETURN_TYPE                                       
          5*     > RETURN                                                   null

End of Dynamic Function 1

Dynamic Function 2
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/F6p1T
function name:  {closure}
number of ops:  15
compiled vars:  !0 = $key, !1 = $permissionsToTest
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        INIT_FCALL                                               'implode'
          3        SEND_VAL                                                 '+'
          4        INIT_FCALL                                               'explode'
          5        SEND_VAL                                                 '-'
          6        FETCH_DIM_R                                      ~2      !1, !0
          7        SEND_VAL                                                 ~2
          8        DO_ICALL                                         $3      
          9        SEND_VAR                                                 $3
         10        DO_ICALL                                         $4      
         11        VERIFY_RETURN_TYPE                                       $4
         12      > RETURN                                                   $4
         13*       VERIFY_RETURN_TYPE                                       
         14*     > RETURN                                                   null

End of Dynamic Function 2

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
239.86 ms | 1023 KiB | 21 Q