@flarum/cli 3.0.3 → 3.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +1 -1
  2. package/oclif.manifest.json +1 -1
  3. package/package.json +3 -3
  4. package/php-subsystem/composer.json +3 -0
  5. package/php-subsystem/composer.lock +76 -66
  6. package/php-subsystem/index.php +9 -0
  7. package/php-subsystem/vendor/composer/installed.json +63 -56
  8. package/php-subsystem/vendor/composer/installed.php +9 -9
  9. package/php-subsystem/vendor/composer/platform_check.php +2 -2
  10. package/php-subsystem/vendor/nikic/php-parser/README.md +1 -1
  11. package/php-subsystem/vendor/nikic/php-parser/composer.json +41 -41
  12. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Builder/ClassConst.php +2 -2
  13. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Builder/EnumCase.php +0 -1
  14. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Builder/Param.php +22 -0
  15. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php +63 -1
  16. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/BuilderFactory.php +1 -1
  17. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/BuilderHelpers.php +6 -1
  18. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Comment.php +2 -0
  19. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Error.php +2 -0
  20. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Internal/TokenStream.php +12 -5
  21. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Lexer/Emulative.php +4 -4
  22. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/AsymmetricVisibilityTokenEmulator.php +93 -0
  23. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/KeywordEmulator.php +6 -2
  24. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/PropertyTokenEmulator.php +19 -0
  25. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Modifiers.php +42 -26
  26. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/NameContext.php +1 -1
  27. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Identifier.php +11 -1
  28. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Name.php +10 -1
  29. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Param.php +28 -2
  30. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/PropertyHook.php +78 -0
  31. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Property.php +15 -0
  32. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Property.php +27 -2
  33. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node.php +4 -0
  34. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/NodeAbstract.php +3 -0
  35. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/NodeDumper.php +9 -0
  36. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/NameResolver.php +6 -0
  37. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Parser/Php7.php +1210 -1119
  38. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Parser/Php8.php +1210 -1141
  39. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/ParserAbstract.php +82 -57
  40. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/PhpVersion.php +1 -1
  41. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinter/Standard.php +17 -2
  42. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php +49 -11
  43. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/compatibility_tokens.php +5 -0
@@ -5,7 +5,10 @@ namespace PhpParser\Node;
5
5
  use PhpParser\NodeAbstract;
6
6
 
7
7
  class Name extends NodeAbstract {
8
- /** @var string Name as string */
8
+ /**
9
+ * @psalm-var non-empty-string
10
+ * @var string Name as string
11
+ */
9
12
  public string $name;
10
13
 
11
14
  /** @var array<string, bool> */
@@ -33,6 +36,7 @@ class Name extends NodeAbstract {
33
36
  /**
34
37
  * Get parts of name (split by the namespace separator).
35
38
  *
39
+ * @psalm-return non-empty-list<string>
36
40
  * @return string[] Parts of name
37
41
  */
38
42
  public function getParts(): array {
@@ -103,6 +107,7 @@ class Name extends NodeAbstract {
103
107
  * Returns a string representation of the name itself, without taking the name type into
104
108
  * account (e.g., not including a leading backslash for fully qualified names).
105
109
  *
110
+ * @psalm-return non-empty-string
106
111
  * @return string String representation
107
112
  */
108
113
  public function toString(): string {
@@ -113,6 +118,7 @@ class Name extends NodeAbstract {
113
118
  * Returns a string representation of the name as it would occur in code (e.g., including
114
119
  * leading backslash for fully qualified names.
115
120
  *
121
+ * @psalm-return non-empty-string
116
122
  * @return string String representation
117
123
  */
118
124
  public function toCodeString(): string {
@@ -123,6 +129,7 @@ class Name extends NodeAbstract {
123
129
  * Returns lowercased string representation of the name, without taking the name type into
124
130
  * account (e.g., no leading backslash for fully qualified names).
125
131
  *
132
+ * @psalm-return non-empty-string
126
133
  * @return string Lowercased string representation
127
134
  */
128
135
  public function toLowerString(): string {
@@ -142,6 +149,7 @@ class Name extends NodeAbstract {
142
149
  * Returns a string representation of the name by imploding the namespace parts with the
143
150
  * namespace separator.
144
151
  *
152
+ * @psalm-return non-empty-string
145
153
  * @return string String representation
146
154
  */
147
155
  public function __toString(): string {
@@ -237,6 +245,7 @@ class Name extends NodeAbstract {
237
245
  *
238
246
  * @param string|string[]|self $name Name to prepare
239
247
  *
248
+ * @psalm-return non-empty-string
240
249
  * @return string Prepared name
241
250
  */
242
251
  private static function prepareName($name): string {
@@ -21,6 +21,8 @@ class Param extends NodeAbstract {
21
21
  public int $flags;
22
22
  /** @var AttributeGroup[] PHP attribute groups */
23
23
  public array $attrGroups;
24
+ /** @var PropertyHook[] Property hooks for promoted properties */
25
+ public array $hooks;
24
26
 
25
27
  /**
26
28
  * Constructs a parameter node.
@@ -33,13 +35,15 @@ class Param extends NodeAbstract {
33
35
  * @param array<string, mixed> $attributes Additional attributes
34
36
  * @param int $flags Optional visibility flags
35
37
  * @param list<AttributeGroup> $attrGroups PHP attribute groups
38
+ * @param PropertyHook[] $hooks Property hooks for promoted properties
36
39
  */
37
40
  public function __construct(
38
41
  Expr $var, ?Expr $default = null, ?Node $type = null,
39
42
  bool $byRef = false, bool $variadic = false,
40
43
  array $attributes = [],
41
44
  int $flags = 0,
42
- array $attrGroups = []
45
+ array $attrGroups = [],
46
+ array $hooks = []
43
47
  ) {
44
48
  $this->attributes = $attributes;
45
49
  $this->type = $type;
@@ -49,10 +53,11 @@ class Param extends NodeAbstract {
49
53
  $this->default = $default;
50
54
  $this->flags = $flags;
51
55
  $this->attrGroups = $attrGroups;
56
+ $this->hooks = $hooks;
52
57
  }
53
58
 
54
59
  public function getSubNodeNames(): array {
55
- return ['attrGroups', 'flags', 'type', 'byRef', 'variadic', 'var', 'default'];
60
+ return ['attrGroups', 'flags', 'type', 'byRef', 'variadic', 'var', 'default', 'hooks'];
56
61
  }
57
62
 
58
63
  public function getType(): string {
@@ -81,4 +86,25 @@ class Param extends NodeAbstract {
81
86
  public function isReadonly(): bool {
82
87
  return (bool) ($this->flags & Modifiers::READONLY);
83
88
  }
89
+
90
+ /**
91
+ * Whether the promoted property has explicit public(set) visibility.
92
+ */
93
+ public function isPublicSet(): bool {
94
+ return (bool) ($this->flags & Modifiers::PUBLIC_SET);
95
+ }
96
+
97
+ /**
98
+ * Whether the promoted property has explicit protected(set) visibility.
99
+ */
100
+ public function isProtectedSet(): bool {
101
+ return (bool) ($this->flags & Modifiers::PROTECTED_SET);
102
+ }
103
+
104
+ /**
105
+ * Whether the promoted property has explicit private(set) visibility.
106
+ */
107
+ public function isPrivateSet(): bool {
108
+ return (bool) ($this->flags & Modifiers::PRIVATE_SET);
109
+ }
84
110
  }
@@ -0,0 +1,78 @@
1
+ <?php declare(strict_types=1);
2
+
3
+ namespace PhpParser\Node;
4
+
5
+ use PhpParser\Node\Stmt\Return_;
6
+ use PhpParser\NodeAbstract;
7
+
8
+ class PropertyHook extends NodeAbstract implements FunctionLike {
9
+ /** @var AttributeGroup[] PHP attribute groups */
10
+ public array $attrGroups;
11
+ /** @var int Modifiers */
12
+ public int $flags;
13
+ /** @var bool Whether hook returns by reference */
14
+ public bool $byRef;
15
+ /** @var Identifier Hook name */
16
+ public Identifier $name;
17
+ /** @var Param[] Parameters */
18
+ public array $params;
19
+ /** @var null|Expr|Stmt[] Hook body */
20
+ public $body;
21
+
22
+ /**
23
+ * Constructs a property hook node.
24
+ *
25
+ * @param string|Identifier $name Hook name
26
+ * @param null|Expr|Stmt[] $body Hook body
27
+ * @param array{
28
+ * flags?: int,
29
+ * byRef?: bool,
30
+ * params?: Param[],
31
+ * attrGroups?: AttributeGroup[],
32
+ * } $subNodes Array of the following optional subnodes:
33
+ * 'byRef' => false : Whether hook returns by reference
34
+ * 'params' => array(): Parameters
35
+ * 'attrGroups' => array(): PHP attribute groups
36
+ * @param array<string, mixed> $attributes Additional attributes
37
+ */
38
+ public function __construct($name, $body, array $subNodes = [], array $attributes = []) {
39
+ $this->attributes = $attributes;
40
+ $this->name = \is_string($name) ? new Identifier($name) : $name;
41
+ $this->body = $body;
42
+ $this->flags = $subNodes['flags'] ?? 0;
43
+ $this->byRef = $subNodes['byRef'] ?? false;
44
+ $this->params = $subNodes['params'] ?? [];
45
+ $this->attrGroups = $subNodes['attrGroups'] ?? [];
46
+ }
47
+
48
+ public function returnsByRef(): bool {
49
+ return $this->byRef;
50
+ }
51
+
52
+ public function getParams(): array {
53
+ return $this->params;
54
+ }
55
+
56
+ public function getReturnType() {
57
+ return null;
58
+ }
59
+
60
+ public function getStmts(): ?array {
61
+ if ($this->body instanceof Expr) {
62
+ return [new Return_($this->body)];
63
+ }
64
+ return $this->body;
65
+ }
66
+
67
+ public function getAttrGroups(): array {
68
+ return $this->attrGroups;
69
+ }
70
+
71
+ public function getType(): string {
72
+ return 'PropertyHook';
73
+ }
74
+
75
+ public function getSubNodeNames(): array {
76
+ return ['attrGroups', 'flags', 'byRef', 'name', 'params', 'body'];
77
+ }
78
+ }
@@ -0,0 +1,15 @@
1
+ <?php declare(strict_types=1);
2
+
3
+ namespace PhpParser\Node\Scalar\MagicConst;
4
+
5
+ use PhpParser\Node\Scalar\MagicConst;
6
+
7
+ class Property extends MagicConst {
8
+ public function getName(): string {
9
+ return '__PROPERTY__';
10
+ }
11
+
12
+ public function getType(): string {
13
+ return 'Scalar_MagicConst_Property';
14
+ }
15
+ }
@@ -18,6 +18,8 @@ class Property extends Node\Stmt {
18
18
  public ?Node $type;
19
19
  /** @var Node\AttributeGroup[] PHP attribute groups */
20
20
  public array $attrGroups;
21
+ /** @var Node\PropertyHook[] Property hooks */
22
+ public array $hooks;
21
23
 
22
24
  /**
23
25
  * Constructs a class property list node.
@@ -27,17 +29,19 @@ class Property extends Node\Stmt {
27
29
  * @param array<string, mixed> $attributes Additional attributes
28
30
  * @param null|Identifier|Name|ComplexType $type Type declaration
29
31
  * @param Node\AttributeGroup[] $attrGroups PHP attribute groups
32
+ * @param Node\PropertyHook[] $hooks Property hooks
30
33
  */
31
- public function __construct(int $flags, array $props, array $attributes = [], ?Node $type = null, array $attrGroups = []) {
34
+ public function __construct(int $flags, array $props, array $attributes = [], ?Node $type = null, array $attrGroups = [], array $hooks = []) {
32
35
  $this->attributes = $attributes;
33
36
  $this->flags = $flags;
34
37
  $this->props = $props;
35
38
  $this->type = $type;
36
39
  $this->attrGroups = $attrGroups;
40
+ $this->hooks = $hooks;
37
41
  }
38
42
 
39
43
  public function getSubNodeNames(): array {
40
- return ['attrGroups', 'flags', 'type', 'props'];
44
+ return ['attrGroups', 'flags', 'type', 'props', 'hooks'];
41
45
  }
42
46
 
43
47
  /**
@@ -76,6 +80,27 @@ class Property extends Node\Stmt {
76
80
  return (bool) ($this->flags & Modifiers::READONLY);
77
81
  }
78
82
 
83
+ /**
84
+ * Whether the property has explicit public(set) visibility.
85
+ */
86
+ public function isPublicSet(): bool {
87
+ return (bool) ($this->flags & Modifiers::PUBLIC_SET);
88
+ }
89
+
90
+ /**
91
+ * Whether the property has explicit protected(set) visibility.
92
+ */
93
+ public function isProtectedSet(): bool {
94
+ return (bool) ($this->flags & Modifiers::PROTECTED_SET);
95
+ }
96
+
97
+ /**
98
+ * Whether the property has explicit private(set) visibility.
99
+ */
100
+ public function isPrivateSet(): bool {
101
+ return (bool) ($this->flags & Modifiers::PRIVATE_SET);
102
+ }
103
+
79
104
  public function getType(): string {
80
105
  return 'Stmt_Property';
81
106
  }
@@ -6,6 +6,7 @@ interface Node {
6
6
  /**
7
7
  * Gets the type of the node.
8
8
  *
9
+ * @psalm-return non-empty-string
9
10
  * @return string Type of the node
10
11
  */
11
12
  public function getType(): string;
@@ -21,6 +22,7 @@ interface Node {
21
22
  * Gets line the node started in (alias of getStartLine).
22
23
  *
23
24
  * @return int Start line (or -1 if not available)
25
+ * @phpstan-return -1|positive-int
24
26
  *
25
27
  * @deprecated Use getStartLine() instead
26
28
  */
@@ -32,6 +34,7 @@ interface Node {
32
34
  * Requires the 'startLine' attribute to be enabled in the lexer (enabled by default).
33
35
  *
34
36
  * @return int Start line (or -1 if not available)
37
+ * @phpstan-return -1|positive-int
35
38
  */
36
39
  public function getStartLine(): int;
37
40
 
@@ -41,6 +44,7 @@ interface Node {
41
44
  * Requires the 'endLine' attribute to be enabled in the lexer (enabled by default).
42
45
  *
43
46
  * @return int End line (or -1 if not available)
47
+ * @phpstan-return -1|positive-int
44
48
  */
45
49
  public function getEndLine(): int;
46
50
 
@@ -19,6 +19,7 @@ abstract class NodeAbstract implements Node, \JsonSerializable {
19
19
  * Gets line the node started in (alias of getStartLine).
20
20
  *
21
21
  * @return int Start line (or -1 if not available)
22
+ * @phpstan-return -1|positive-int
22
23
  */
23
24
  public function getLine(): int {
24
25
  return $this->attributes['startLine'] ?? -1;
@@ -30,6 +31,7 @@ abstract class NodeAbstract implements Node, \JsonSerializable {
30
31
  * Requires the 'startLine' attribute to be enabled in the lexer (enabled by default).
31
32
  *
32
33
  * @return int Start line (or -1 if not available)
34
+ * @phpstan-return -1|positive-int
33
35
  */
34
36
  public function getStartLine(): int {
35
37
  return $this->attributes['startLine'] ?? -1;
@@ -41,6 +43,7 @@ abstract class NodeAbstract implements Node, \JsonSerializable {
41
43
  * Requires the 'endLine' attribute to be enabled in the lexer (enabled by default).
42
44
  *
43
45
  * @return int End line (or -1 if not available)
46
+ * @phpstan-return -1|positive-int
44
47
  */
45
48
  public function getEndLine(): int {
46
49
  return $this->attributes['endLine'] ?? -1;
@@ -185,6 +185,15 @@ class NodeDumper {
185
185
  if ($flags & Modifiers::READONLY) {
186
186
  $strs[] = 'READONLY';
187
187
  }
188
+ if ($flags & Modifiers::PUBLIC_SET) {
189
+ $strs[] = 'PUBLIC_SET';
190
+ }
191
+ if ($flags & Modifiers::PROTECTED_SET) {
192
+ $strs[] = 'PROTECTED_SET';
193
+ }
194
+ if ($flags & Modifiers::PRIVATE_SET) {
195
+ $strs[] = 'PRIVATE_SET';
196
+ }
188
197
 
189
198
  if ($strs) {
190
199
  return implode(' | ', $strs) . ' (' . $flags . ')';
@@ -110,6 +110,12 @@ class NameResolver extends NodeVisitorAbstract {
110
110
  $node->type = $this->resolveType($node->type);
111
111
  }
112
112
  $this->resolveAttrGroups($node);
113
+ } elseif ($node instanceof Node\PropertyHook) {
114
+ foreach ($node->params as $param) {
115
+ $param->type = $this->resolveType($param->type);
116
+ $this->resolveAttrGroups($param);
117
+ }
118
+ $this->resolveAttrGroups($node);
113
119
  } elseif ($node instanceof Stmt\Const_) {
114
120
  foreach ($node->consts as $const) {
115
121
  $this->addNamespacedName($const);