3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_exclude(array $arr, array $blacklist){ return array_diff_key($arr, array_flip($blacklist)); } function resource($data) { $name = $data["name"]; $prefix = isset($data["prefix"]) ? $data["prefix"] : ""; $except = isset($data["except"]) ? $data["except"] : []; $methods = $this->array_exclude(['create', 'edit', 'delete'], $except); $result = []; foreach($methods as $method){ array_push($result, "$prefix.$name.$method"); } return $result; } function makePermissions($blueprint){ $result = []; foreach ($blueprint as $item){ switch(gettype($item)){ case "string": array_push($result, $item); break; case "array": $result = array_merge($result, $this->resource($item)); break; } } return $result; } print_f(makePermissions([]));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/C6HCr
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   INIT_FCALL_BY_NAME                                       'print_f'
          1        INIT_FCALL                                               'makepermissions'
          2        SEND_VAL                                                 <array>
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR_NO_REF_EX                                       $0
          5        DO_FCALL                                      0          
          6      > RETURN                                                   1

Function array_exclude:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/C6HCr
function name:  array_exclude
number of ops:  11
compiled vars:  !0 = $arr, !1 = $blacklist
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        INIT_FCALL                                               'array_diff_key'
          3        SEND_VAR                                                 !0
          4        INIT_FCALL                                               'array_flip'
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $2      
          7        SEND_VAR                                                 $2
          8        DO_ICALL                                         $3      
          9      > RETURN                                                   $3
    5    10*     > RETURN                                                   null

End of function array_exclude

Function resource:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 15
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 77) Position 1 = 25, Position 2 = 36
Branch analysis from position: 25
2 jumps found. (Code = 78) Position 1 = 26, Position 2 = 36
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
Branch analysis from position: 15
2 jumps found. (Code = 77) Position 1 = 25, Position 2 = 36
Branch analysis from position: 25
Branch analysis from position: 36
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 15
Branch analysis from position: 12
Branch analysis from position: 15
filename:       /in/C6HCr
function name:  resource
number of ops:  39
compiled vars:  !0 = $data, !1 = $name, !2 = $prefix, !3 = $except, !4 = $methods, !5 = $result, !6 = $method
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        FETCH_DIM_R                                      ~7      !0, 'name'
          2        ASSIGN                                                   !1, ~7
    8     3        ISSET_ISEMPTY_DIM_OBJ                         0          !0, 'prefix'
          4      > JMPZ                                                     ~9, ->8
          5    >   FETCH_DIM_R                                      ~10     !0, 'prefix'
          6        QM_ASSIGN                                        ~11     ~10
          7      > JMP                                                      ->9
          8    >   QM_ASSIGN                                        ~11     ''
          9    >   ASSIGN                                                   !2, ~11
    9    10        ISSET_ISEMPTY_DIM_OBJ                         0          !0, 'except'
         11      > JMPZ                                                     ~13, ->15
         12    >   FETCH_DIM_R                                      ~14     !0, 'except'
         13        QM_ASSIGN                                        ~15     ~14
         14      > JMP                                                      ->16
         15    >   QM_ASSIGN                                        ~15     <array>
         16    >   ASSIGN                                                   !3, ~15
   10    17        FETCH_THIS                                       $17     
         18        INIT_METHOD_CALL                                         $17, 'array_exclude'
         19        SEND_VAL_EX                                              <array>
         20        SEND_VAR_EX                                              !3
         21        DO_FCALL                                      0  $18     
         22        ASSIGN                                                   !4, $18
   12    23        ASSIGN                                                   !5, <array>
   13    24      > FE_RESET_R                                       $21     !4, ->36
         25    > > FE_FETCH_R                                               $21, !6, ->36
   14    26    >   INIT_FCALL                                               'array_push'
         27        SEND_REF                                                 !5
         28        ROPE_INIT                                     5  ~23     !2
         29        ROPE_ADD                                      1  ~23     ~23, '.'
         30        ROPE_ADD                                      2  ~23     ~23, !1
         31        ROPE_ADD                                      3  ~23     ~23, '.'
         32        ROPE_END                                      4  ~22     ~23, !6
         33        SEND_VAL                                                 ~22
         34        DO_ICALL                                                 
   13    35      > JMP                                                      ->25
         36    >   FE_FREE                                                  $21
   17    37      > RETURN                                                   !5
   18    38*     > RETURN                                                   null

End of function resource

Function makepermissions:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 28
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 28
Branch analysis from position: 4
4 jumps found. (Code = 188) Position 1 = 11, Position 2 = 16, Position 3 = 26, Position 4 = 6
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
Branch analysis from position: 26
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 16
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
Branch analysis from position: 16
Branch analysis from position: 11
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
filename:       /in/C6HCr
function name:  makePermissions
number of ops:  31
compiled vars:  !0 = $blueprint, !1 = $result, !2 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
   20     1        ASSIGN                                                   !1, <array>
   22     2      > FE_RESET_R                                       $4      !0, ->28
          3    > > FE_FETCH_R                                               $4, !2, ->28
   23     4    >   GET_TYPE                                         ~5      !2
          5      > SWITCH_STRING                                            ~5, [ 'string':->11, 'array':->16, ], ->26
   24     6    >   CASE                                                     ~5, 'string'
          7      > JMPNZ                                                    ~6, ->11
   26     8    >   CASE                                                     ~5, 'array'
          9      > JMPNZ                                                    ~6, ->16
         10    > > JMP                                                      ->26
   25    11    >   INIT_FCALL                                               'array_push'
         12        SEND_REF                                                 !1
         13        SEND_VAR                                                 !2
         14        DO_ICALL                                                 
         15      > JMP                                                      ->26
   27    16    >   INIT_FCALL                                               'array_merge'
         17        SEND_VAR                                                 !1
         18        FETCH_THIS                                       $8      
         19        INIT_METHOD_CALL                                         $8, 'resource'
         20        SEND_VAR_EX                                              !2
         21        DO_FCALL                                      0  $9      
         22        SEND_VAR                                                 $9
         23        DO_ICALL                                         $10     
         24        ASSIGN                                                   !1, $10
         25      > JMP                                                      ->26
         26    >   FREE                                                     ~5
   22    27      > JMP                                                      ->3
         28    >   FE_FREE                                                  $4
   31    29      > RETURN                                                   !1
   32    30*     > RETURN                                                   null

End of function makepermissions

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.04 ms | 1407 KiB | 22 Q