PluginProbe
Code Engine – PHP Snippets, AI Functions & Automation for WordPress / 0.4.5
Code Engine – PHP Snippets, AI Functions & Automation for WordPress v0.4.5
0.5.7 0.5.6 0.5.5 0.5.4 0.5.3 0.5.2 0.5.1 0.5.0 0.4.9 0.4.8 0.4.7 0.4.6 trunk 0.0.1 0.0.2 0.2.8 0.2.9 0.3.0 0.3.1 0.3.2 0.3.3 0.3.4 0.3.5 0.3.6 0.3.7 All 33 releases
code-engine / vendor / nikic / php-parser / lib / PhpParser / Modifiers.php

Modifiers.php in Code Engine – PHP Snippets, AI Functions & Automation for WordPress 0.4.5, at vendor/nikic/php-parser/lib/PhpParser/Modifiers.php

70 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php declare(strict_types=1);
2
3 namespace PhpParser;
4
5 /**
6 * Modifiers used (as a bit mask) by various flags subnodes, for example on classes, functions,
7 * properties and constants.
8 */
9 final class Modifiers {
10 public const PUBLIC = 1;
11 public const PROTECTED = 2;
12 public const PRIVATE = 4;
13 public const STATIC = 8;
14 public const ABSTRACT = 16;
15 public const FINAL = 32;
16 public const READONLY = 64;
17
18 public const VISIBILITY_MASK = 1 | 2 | 4;
19
20 /**
21 * @internal
22 */
23 public static function verifyClassModifier(int $a, int $b): void {
24 if ($a & Modifiers::ABSTRACT && $b & Modifiers::ABSTRACT) {
25 throw new Error('Multiple abstract modifiers are not allowed');
26 }
27
28 if ($a & Modifiers::FINAL && $b & Modifiers::FINAL) {
29 throw new Error('Multiple final modifiers are not allowed');
30 }
31
32 if ($a & Modifiers::READONLY && $b & Modifiers::READONLY) {
33 throw new Error('Multiple readonly modifiers are not allowed');
34 }
35
36 if ($a & 48 && $b & 48) {
37 throw new Error('Cannot use the final modifier on an abstract class');
38 }
39 }
40
41 /**
42 * @internal
43 */
44 public static function verifyModifier(int $a, int $b): void {
45 if ($a & Modifiers::VISIBILITY_MASK && $b & Modifiers::VISIBILITY_MASK) {
46 throw new Error('Multiple access type modifiers are not allowed');
47 }
48
49 if ($a & Modifiers::ABSTRACT && $b & Modifiers::ABSTRACT) {
50 throw new Error('Multiple abstract modifiers are not allowed');
51 }
52
53 if ($a & Modifiers::STATIC && $b & Modifiers::STATIC) {
54 throw new Error('Multiple static modifiers are not allowed');
55 }
56
57 if ($a & Modifiers::FINAL && $b & Modifiers::FINAL) {
58 throw new Error('Multiple final modifiers are not allowed');
59 }
60
61 if ($a & Modifiers::READONLY && $b & Modifiers::READONLY) {
62 throw new Error('Multiple readonly modifiers are not allowed');
63 }
64
65 if ($a & 48 && $b & 48) {
66 throw new Error('Cannot use the final modifier on an abstract class member');
67 }
68 }
69 }
70