Skip to content

Commit da02e06

Browse files
authored
Merge pull request microsoft#176 from TysonAndre/Node-phpdoc-phan-nits
Make phpdoc of Node and its subclasses more accurate
2 parents 5bfa8bb + 3558e79 commit da02e06

File tree

6 files changed

+9
-8
lines changed

6 files changed

+9
-8
lines changed

src/Node.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function getParent() {
7878
* Gets first ancestor that is an instance of one of the provided classes.
7979
* Returns null if there is no match.
8080
*
81-
* @param array ...$classNames
81+
* @param string ...$classNames
8282
* @return Node|null
8383
*/
8484
public function getFirstAncestor(...$classNames) {
@@ -139,7 +139,7 @@ public function getFirstDescendantNode(...$classNames) {
139139

140140
/**
141141
* Gets root of the syntax tree (returns self if has no parents)
142-
* @return Node
142+
* @return SourceFileNode (expect root to be SourceFileNode unless the tree was manipulated)
143143
*/
144144
public function getRoot() : Node {
145145
$node = $this;
@@ -450,7 +450,7 @@ public function __toString() {
450450
* @throws \Exception
451451
*/
452452
public function getImportTablesForCurrentScope() {
453-
$namespaceDefinition = $namespaceDefinition ?? $this->getNamespaceDefinition();
453+
$namespaceDefinition = $this->getNamespaceDefinition();
454454

455455
// Use declarations can exist in either the global scope, or inside namespace declarations.
456456
// http://php.net/manual/en/language.namespaces.importing.php#language.namespaces.importing.scope

src/Node/Expression/EchoExpression.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
namespace Microsoft\PhpParser\Node\Expression;
88

99
use Microsoft\PhpParser\Node\Expression;
10+
use Microsoft\PhpParser\Node\DelimitedList\ExpressionList;
1011
use Microsoft\PhpParser\Token;
1112

1213
class EchoExpression extends Expression {
1314

1415
/** @var Token */
1516
public $echoKeyword;
1617

17-
/** @var Expression[] */
18+
/** @var ExpressionList */
1819
public $expressions;
1920

2021
const CHILD_NAMES = [

src/Node/NumericLiteral.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Microsoft\PhpParser\Token;
1010

1111
class NumericLiteral extends Expression {
12-
/** @var Token[] */
12+
/** @var Token */
1313
public $children;
1414

1515
const CHILD_NAMES = [

src/Node/QualifiedName.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public function getLastNamePart() {
157157
/**
158158
* @param ResolvedName[] $importTable
159159
* @param bool $isCaseSensitive
160-
* @return null
160+
* @return string|null
161161
*/
162162
private function tryResolveFromImportTable($importTable, bool $isCaseSensitive = false) {
163163
$content = $this->getFileContents();

src/Node/ReservedWord.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Microsoft\PhpParser\Token;
1010

1111
class ReservedWord extends Expression {
12-
/** @var Token[] */
12+
/** @var Token */
1313
public $children;
1414

1515
const CHILD_NAMES = [

src/Node/StringLiteral.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class StringLiteral extends Expression {
1313
/** @var Token */
1414
public $startQuote;
1515

16-
/** @var Token[] | Node[] */
16+
/** @var Token[]|Node[]|Token */
1717
public $children;
1818

1919
/** @var Token */

0 commit comments

Comments
 (0)