3v4l.org

run code in 500+ PHP versions simultaneously
<?php /** * File permissions. */ enum Permission: int { /* Start compatibility */ #[Deprecated('use Permission::None instead', 'Mako 12.2.0')] public const NONE = self::None; #[Deprecated('use Permission::OwnerExecute instead', 'Mako 12.2.0')] public const OWNER_EXECUTE = self::OwnerExecute; #[Deprecated('use Permission::OwnerWrite instead', 'Mako 12.2.0')] public const OWNER_WRITE = self::OwnerWrite; #[Deprecated('use Permission::OwnerExecuteWrite instead', 'Mako 12.2.0')] public const OWNER_EXECUTE_WRITE = self::OwnerExecuteWrite; #[Deprecated('use Permission::OwnerRead instead', 'Mako 12.2.0')] public const OWNER_READ = self::OwnerRead; #[Deprecated('use Permission::OwnerExecuteRead instead', 'Mako 12.2.0')] public const OWNER_EXECUTE_READ = self::OwnerExecuteRead; #[Deprecated('use Permission::OwnerWriteRead instead', 'Mako 12.2.0')] public const OWNER_WRITE_READ = self::OwnerWriteRead; #[Deprecated('use Permission::OwnerFull instead', 'Mako 12.2.0')] public const OWNER_FULL = self::OwnerFull; #[Deprecated('use Permission::GroupExecute instead', 'Mako 12.2.0')] public const GROUP_EXECUTE = self::GroupExecute; #[Deprecated('use Permission::GroupWrite instead', 'Mako 12.2.0')] public const GROUP_WRITE = self::GroupWrite; #[Deprecated('use Permission::GroupExecuteWrite instead', 'Mako 12.2.0')] public const GROUP_EXECUTE_WRITE = self::GroupExecuteWrite; #[Deprecated('use Permission::GroupRead instead', 'Mako 12.2.0')] public const GROUP_READ = self::GroupRead; #[Deprecated('use Permission::GroupExecuteRead instead', 'Mako 12.2.0')] public const GROUP_EXECUTE_READ = self::GroupExecuteRead; #[Deprecated('use Permission::GroupWriteRead instead', 'Mako 12.2.0')] public const GROUP_WRITE_READ = self::GroupWriteRead; #[Deprecated('use Permission::GroupFull instead', 'Mako 12.2.0')] public const GROUP_FULL = self::GroupFull; #[Deprecated('use Permission::PublicExecute instead', 'Mako 12.2.0')] public const PUBLIC_EXECUTE = self::PublicExecute; #[Deprecated('use Permission::PublicWrite instead', 'Mako 12.2.0')] public const PUBLIC_WRITE = self::PublicWrite; #[Deprecated('use Permission::PublicExecuteWrite instead', 'Mako 12.2.0')] public const PUBLIC_EXECUTE_WRITE = self::PublicExecuteWrite; #[Deprecated('use Permission::PublicRead instead', 'Mako 12.2.0')] public const PUBLIC_READ = self::PublicRead; #[Deprecated('use Permission::PublicExecuteRead instead', 'Mako 12.2.0')] public const PUBLIC_EXECUTE_READ = self::PublicExecuteRead; #[Deprecated('use Permission::PublicWriteRead instead', 'Mako 12.2.0')] public const PUBLIC_WRITE_READ = self::PublicWriteRead; #[Deprecated('use Permission::PublicFull instead', 'Mako 12.2.0')] public const PUBLIC_FULL = self::PublicFull; #[Deprecated('use Permission::Full instead', 'Mako 12.2.0')] public const FULL = self::Full; #[Deprecated('use Permission::SpecialSticky instead', 'Mako 12.2.0')] public const SPECIAL_STICKY = self::SpecialSticky; #[Deprecated('use Permission::SpecialSetGid instead', 'Mako 12.2.0')] public const SPECIAL_SETGID = self::SpecialSetGid; #[Deprecated('use Permission::SpecialSetUid instead', 'Mako 12.2.0')] public const SPECIAL_SETUID = self::SpecialSetUid; #[Deprecated('use Permission::FullWithAllSpecial instead', 'Mako 12.2.0')] public const FULL_WITH_ALL_SPECIAL = self::FullWithAllSpecial; /* End compatibility */ // No permissions case None = 0o0000; // Owner permissions case OwnerExecute = 0o0100; case OwnerWrite = 0o0200; case OwnerExecuteWrite = 0o0300; case OwnerRead = 0o0400; case OwnerExecuteRead = 0o0500; case OwnerWriteRead = 0o0600; case OwnerFull = 0o0700; // Group permissions case GroupExecute = 0o0010; case GroupWrite = 0o0020; case GroupExecuteWrite = 0o0030; case GroupRead = 0o0040; case GroupExecuteRead = 0o0050; case GroupWriteRead = 0o0060; case GroupFull = 0o0070; // Public permissions case PublicExecute = 0o0001; case PublicWrite = 0o0002; case PublicExecuteWrite = 0o0003; case PublicRead = 0o0004; case PublicExecuteRead = 0o0005; case PublicWriteRead = 0o0006; case PublicFull = 0o0007; // Full permissions (owner, group, and public) case Full = 0o0777; // Special bits case SpecialSticky = 0o1000; case SpecialSetGid = 0o2000; case SpecialSetUid = 0o4000; // Full permissions (owner, group, and public) with all special bits case FullWithAllSpecial = 0o7777; /** * Calculates sum of the specified permissions. */ public static function calculate(Permission ...$permission): int { $permissions = static::None->value; foreach ($permission as $_permission) { $permissions |= $_permission->value; } return $permissions; } /** * Returns TRUE if the permissions contain the specified permissions and FALSE if not. */ public static function hasPermissions(int $permissions, Permission ...$permission): bool { if ($permissions < static::None->value || $permissions > static::FullWithAllSpecial->value) { throw new InvalidArgumentException(sprintf('The integer [ %s ] does not represent a valid octal between 0o0000 and 0o7777.', $permissions)); } $permission = empty($permission) ? static::None->value : static::calculate(...$permission); if ($permission === static::None->value) { return $permissions === static::None->value; } return ($permissions & $permission) === $permission; } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5F2pN
function name:  (null)
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   DECLARE_CLASS                                            'permission'
  144     1      > RETURN                                                   1

Class Permission:
Function calculate:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 9
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 9
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/5F2pN
function name:  calculate
number of ops:  14
compiled vars:  !0 = $permission, !1 = $permissions, !2 = $_permission
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  116     0  E >   RECV_VARIADIC                                    !0      
  118     1        FETCH_CLASS_CONSTANT                             ~3      'None'
          2        FETCH_OBJ_R                                      ~4      ~3, 'value'
          3        ASSIGN                                                   !1, ~4
  120     4      > FE_RESET_R                                       $6      !0, ->9
          5    > > FE_FETCH_R                                               $6, !2, ->9
  121     6    >   FETCH_OBJ_R                                      ~7      !2, 'value'
          7        ASSIGN_OP                                     9          !1, ~7
  120     8      > JMP                                                      ->5
          9    >   FE_FREE                                                  $6
  124    10        VERIFY_RETURN_TYPE                                       !1
         11      > RETURN                                                   !1
  125    12*       VERIFY_RETURN_TYPE                                       
         13*     > RETURN                                                   null

End of function calculate

Function haspermissions:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 6, Position 2 = 10
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 19
Branch analysis from position: 11
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 25
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 40
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 40
Branch analysis from position: 35
Branch analysis from position: 40
Branch analysis from position: 10
filename:       /in/5F2pN
function name:  hasPermissions
number of ops:  46
compiled vars:  !0 = $permissions, !1 = $permission
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  130     0  E >   RECV                                             !0      
          1        RECV_VARIADIC                                    !1      
  132     2        FETCH_CLASS_CONSTANT                             ~2      'None'
          3        FETCH_OBJ_R                                      ~3      ~2, 'value'
          4        IS_SMALLER                                       ~4      !0, ~3
          5      > JMPNZ_EX                                         ~4      ~4, ->10
          6    >   FETCH_CLASS_CONSTANT                             ~5      'FullWithAllSpecial'
          7        FETCH_OBJ_R                                      ~6      ~5, 'value'
          8        IS_SMALLER                                       ~7      ~6, !0
          9        BOOL                                             ~4      ~7
         10    > > JMPZ                                                     ~4, ->19
  133    11    >   NEW                                              $8      'InvalidArgumentException'
         12        INIT_FCALL                                               'sprintf'
         13        SEND_VAL                                                 'The+integer+%5B+%25s+%5D+does+not+represent+a+valid+octal+between+0o0000+and+0o7777.'
         14        SEND_VAR                                                 !0
         15        DO_ICALL                                         $9      
         16        SEND_VAR_NO_REF_EX                                       $9
         17        DO_FCALL                                      0          
         18      > THROW                                         0          $8
  136    19    >   ISSET_ISEMPTY_CV                                         !1
         20      > JMPZ                                                     ~11, ->25
         21    >   FETCH_CLASS_CONSTANT                             ~12     'None'
         22        FETCH_OBJ_R                                      ~13     ~12, 'value'
         23        QM_ASSIGN                                        ~14     ~13
         24      > JMP                                                      ->30
         25    >   INIT_STATIC_METHOD_CALL                                  'calculate'
         26        SEND_UNPACK                                              !1
         27        CHECK_UNDEF_ARGS                                         
         28        DO_FCALL                                      1  $15     
         29        QM_ASSIGN                                        ~14     $15
         30    >   ASSIGN                                                   !1, ~14
  138    31        FETCH_CLASS_CONSTANT                             ~17     'None'
         32        FETCH_OBJ_R                                      ~18     ~17, 'value'
         33        IS_IDENTICAL                                             !1, ~18
         34      > JMPZ                                                     ~19, ->40
  139    35    >   FETCH_CLASS_CONSTANT                             ~20     'None'
         36        FETCH_OBJ_R                                      ~21     ~20, 'value'
         37        IS_IDENTICAL                                     ~22     !0, ~21
         38        VERIFY_RETURN_TYPE                                       ~22
         39      > RETURN                                                   ~22
  142    40    >   BW_AND                                           ~23     !0, !1
         41        IS_IDENTICAL                                     ~24     !1, ~23
         42        VERIFY_RETURN_TYPE                                       ~24
         43      > RETURN                                                   ~24
  143    44*       VERIFY_RETURN_TYPE                                       
         45*     > RETURN                                                   null

End of function haspermissions

End of class Permission.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.79 ms | 1313 KiB | 14 Q