Skip to content

Commit 1f29666

Browse files
TysonAndreTysonAndre-tmg
authored andcommitted
Fix incorrect PHPdoc for src/Parser.php, nit on property assignment
Clarify phpdoc of parseDelimitedList Don't assign a DelimitedList to node->nameParts, it's declared as an array. (Has no side effects, this is overwritten afterwards unless nameParts was null)
1 parent da02e06 commit 1f29666

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

src/Parser.php

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,6 @@ private function getParseListElementFn($context) {
345345

346346
/**
347347
* Aborts parsing list when one of the parent contexts understands something
348-
* @param ParseContext $context
349348
* @return bool
350349
*/
351350
private function isCurrentTokenValidInEnclosingContexts() {
@@ -367,7 +366,7 @@ private function isInParseContext($contextToCheck) {
367366
* Retrieve the current token, and check that it's of the expected TokenKind.
368367
* If so, advance and return the token. Otherwise return a MissingToken for
369368
* the expected token.
370-
* @param int $kind
369+
* @param int|int[] ...$kinds
371370
* @return Token
372371
*/
373372
private function eat(...$kinds) {
@@ -385,6 +384,10 @@ private function eat(...$kinds) {
385384
return new MissingToken($kinds[0], $token->fullStart);
386385
}
387386

387+
/**
388+
* @param int|int[] ...$kinds (Can provide a single value with a list of kinds, or multiple kinds)
389+
* @return Token|null
390+
*/
388391
private function eatOptional(...$kinds) {
389392
$token = $this->token;
390393
if (\is_array($kinds[0])) {
@@ -849,6 +852,10 @@ private function isExpressionStartFn() {
849852
};
850853
}
851854

855+
/**
856+
* @param Node $parentNode
857+
* @return Token|MissingToken|Node
858+
*/
852859
private function parsePrimaryExpression($parentNode) {
853860
$token = $this->getCurrentToken();
854861
switch ($token->kind) {
@@ -1135,6 +1142,15 @@ private function isParameterStartFn() {
11351142
};
11361143
}
11371144

1145+
/**
1146+
* @param string $className (name of subclass of DelimitedList)
1147+
* @param int $delimiter
1148+
* @param callable $isElementStartFn
1149+
* @param callable $parseElementFn
1150+
* @param Node $parentNode
1151+
* @param bool $allowEmptyElements
1152+
* @return DelimitedList|null instance of $className
1153+
*/
11381154
private function parseDelimitedList($className, $delimiter, $isElementStartFn, $parseElementFn, $parentNode, $allowEmptyElements = false) {
11391155
// TODO consider allowing empty delimiter to be more tolerant
11401156
$node = new $className();
@@ -1191,7 +1207,7 @@ private function parseQualifiedNameFn() {
11911207
$node->globalSpecifier = $this->eatOptional(TokenKind::BackslashToken);
11921208
}
11931209

1194-
$node->nameParts =
1210+
$nameParts =
11951211
$this->parseDelimitedList(
11961212
DelimitedList\QualifiedNameParts::class,
11971213
TokenKind::BackslashToken,
@@ -1214,11 +1230,11 @@ function ($parentNode) {
12141230
$name->kind = TokenKind::Name; // bool/true/null/static should not be treated as keywords in this case
12151231
return $name;
12161232
}, $node);
1217-
if ($node->nameParts === null && $node->globalSpecifier === null && $node->relativeSpecifier === null) {
1233+
if ($nameParts === null && $node->globalSpecifier === null && $node->relativeSpecifier === null) {
12181234
return null;
12191235
}
12201236

1221-
$node->nameParts = $node->nameParts ? $node->nameParts->children : [];
1237+
$node->nameParts = $nameParts ? $nameParts->children : [];
12221238

12231239
return $node;
12241240
};

0 commit comments

Comments
 (0)