Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function getParent() {
* Gets first ancestor that is an instance of one of the provided classes.
* Returns null if there is no match.
*
* @param array ...$classNames
* @param string ...$classNames

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this needs to be string and not string[]? Could you point to docs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/phpDocumentor/fig-standards/pull/87#r37054459 is what an owner of phpDocumentor said

Doesn't seem to be part of PSR-5 yet, but haven't checked: https://youtrack.jetbrains.com/issue/WI-29429

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, not in PSR-5.

Also see https://github.com/phpDocumentor/ReflectionDocBlock/blob/14f9edf1ae14d6ce417afb05a9ed37d7b3cc341e/tests/unit/DocBlock/Tags/ParamTest.php#L152-L168 for how the phpdocumentor implementation works. It parses the individual element types as string from @param string ...$varName

* @return Node|null
*/
public function getFirstAncestor(...$classNames) {
Expand Down Expand Up @@ -139,7 +139,7 @@ public function getFirstDescendantNode(...$classNames) {

/**
* Gets root of the syntax tree (returns self if has no parents)
* @return Node
* @return SourceFileNode (expect root to be SourceFileNode unless the tree was manipulated)
*/
public function getRoot() : Node {
$node = $this;
Expand Down Expand Up @@ -450,7 +450,7 @@ public function __toString() {
* @throws \Exception
*/
public function getImportTablesForCurrentScope() {
$namespaceDefinition = $namespaceDefinition ?? $this->getNamespaceDefinition();
$namespaceDefinition = $this->getNamespaceDefinition();

// Use declarations can exist in either the global scope, or inside namespace declarations.
// http://php.net/manual/en/language.namespaces.importing.php#language.namespaces.importing.scope
Expand Down
3 changes: 2 additions & 1 deletion src/Node/Expression/EchoExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
namespace Microsoft\PhpParser\Node\Expression;

use Microsoft\PhpParser\Node\Expression;
use Microsoft\PhpParser\Node\DelimitedList\ExpressionList;
use Microsoft\PhpParser\Token;

class EchoExpression extends Expression {

/** @var Token */
public $echoKeyword;

/** @var Expression[] */
/** @var ExpressionList */
public $expressions;

const CHILD_NAMES = [
Expand Down
2 changes: 1 addition & 1 deletion src/Node/NumericLiteral.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Microsoft\PhpParser\Token;

class NumericLiteral extends Expression {
/** @var Token[] */
/** @var Token */
public $children;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird for this to be called children when it's only ever a single token.


const CHILD_NAMES = [
Expand Down
2 changes: 1 addition & 1 deletion src/Node/QualifiedName.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public function getLastNamePart() {
/**
* @param ResolvedName[] $importTable
* @param bool $isCaseSensitive
* @return null
* @return string|null
*/
private function tryResolveFromImportTable($importTable, bool $isCaseSensitive = false) {
$content = $this->getFileContents();
Expand Down
2 changes: 1 addition & 1 deletion src/Node/ReservedWord.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Microsoft\PhpParser\Token;

class ReservedWord extends Expression {
/** @var Token[] */
/** @var Token */
public $children;

const CHILD_NAMES = [
Expand Down
2 changes: 1 addition & 1 deletion src/Node/StringLiteral.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class StringLiteral extends Expression {
/** @var Token */
public $startQuote;

/** @var Token[] | Node[] */
/** @var Token[]|Node[]|Token */
public $children;

/** @var Token */
Expand Down