Skip to content

Commit 5bfa8bb

Browse files
authored
Merge pull request microsoft#174 from TysonAndre/normalize-space
Normalize spaces in union types in comments ("A | B" -> "A|B")
2 parents c26f732 + 2858366 commit 5bfa8bb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+104
-99
lines changed

src/DiagnosticsProvider.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
use Microsoft\PhpParser\Node;
1010

1111
class DiagnosticsProvider {
12-
/**
13-
* Traverses AST to generate diagnostics.
14-
* @param \Microsoft\PhpParser\Node $node
15-
* @return \Generator | Diagnostic[]
16-
*/
1712

1813
private static $tokenKindToText;
1914

15+
/**
16+
* Returns the diagnostic for $node, or null.
17+
* @param \Microsoft\PhpParser\Node $node
18+
* @return Diagnostic|null
19+
*/
2020
public static function checkDiagnostics($node) {
2121
if (!isset(self::$tokenKindToText)) {
2222
self::$tokenKindToText = \array_flip(\array_merge(
@@ -88,6 +88,11 @@ public static function checkDiagnostics($node) {
8888
return null;
8989
}
9090

91+
/**
92+
* Traverses AST to generate diagnostics.
93+
* @param \Microsoft\PhpParser\Node $n
94+
* @return Diagnostic[]
95+
*/
9196
public static function getDiagnostics(Node $n) : array {
9297
$diagnostics = [];
9398

src/Node.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ abstract class Node implements \JsonSerializable {
1616
/** @var array[] Map from node class to array of child keys */
1717
private static $childNames = [];
1818

19-
/** @var Node | null */
19+
/** @var Node|null */
2020
public $parent;
2121

2222
public function getNodeKindName() : string {
@@ -187,7 +187,7 @@ public function getDescendantNodes(callable $shouldDescendIntoChildrenFn = null)
187187
/**
188188
* Gets generator containing all descendant Tokens.
189189
* @param callable|null $shouldDescendIntoChildrenFn
190-
* @return \Generator | Token[]
190+
* @return \Generator|Token[]
191191
*/
192192
public function getDescendantTokens(callable $shouldDescendIntoChildrenFn = null) {
193193
foreach ($this->getChildNodesAndTokens() as $child) {
@@ -205,7 +205,7 @@ public function getDescendantTokens(callable $shouldDescendIntoChildrenFn = null
205205
* Gets generator containing all child Nodes and Tokens (direct descendants).
206206
* Does not return null elements.
207207
*
208-
* @return \Generator | Token[] | Node[]
208+
* @return \Generator|Token[]|Node[]
209209
*/
210210
public function getChildNodesAndTokens() : \Generator {
211211
foreach ($this::CHILD_NAMES as $name) {
@@ -227,7 +227,7 @@ public function getChildNodesAndTokens() : \Generator {
227227

228228
/**
229229
* Gets generator containing all child Nodes (direct descendants)
230-
* @return \Generator | Node[]
230+
* @return \Generator|Node[]
231231
*/
232232
public function getChildNodes() : \Generator {
233233
foreach ($this::CHILD_NAMES as $name) {
@@ -425,7 +425,7 @@ private function containsPosition(int $pos): bool {
425425
* Returns last doc comment in leading comment / whitespace trivia,
426426
* and returns null if there is no preceding doc comment.
427427
*
428-
* @return string | null
428+
* @return string|null
429429
*/
430430
public function getDocCommentText() {
431431
$leadingTriviaText = $this->getLeadingCommentAndWhitespaceText();
@@ -446,7 +446,7 @@ public function __toString() {
446446
}
447447

448448
/**
449-
* @return array | ResolvedName[][]
449+
* @return array|ResolvedName[][]
450450
* @throws \Exception
451451
*/
452452
public function getImportTablesForCurrentScope() {
@@ -547,7 +547,7 @@ public function getImportTablesForCurrentScope() {
547547
/**
548548
* Gets corresponding NamespaceDefinition for Node. Returns null if in global namespace.
549549
*
550-
* @return NamespaceDefinition | null
550+
* @return NamespaceDefinition|null
551551
*/
552552
public function getNamespaceDefinition() {
553553
$namespaceDefinition = $this instanceof NamespaceDefinition

src/Node/ArrayElement.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111

1212
class ArrayElement extends Node {
1313

14-
/** @var Expression | null */
14+
/** @var Expression|null */
1515
public $elementKey;
1616

17-
/** @var Token | null */
17+
/** @var Token|null */
1818
public $arrowToken;
1919

20-
/** @var Token | null */
20+
/** @var Token|null */
2121
public $byRef;
2222

2323
/** @var Expression */

src/Node/ClassInterfaceClause.php

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

16-
/** @var DelimitedList\QualifiedNameList | null */
16+
/** @var DelimitedList\QualifiedNameList|null */
1717
public $interfaceNameList;
1818

1919
const CHILD_NAMES = [

src/Node/ElseClauseNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class ElseClauseNode extends Node {
1414
public $elseKeyword;
1515
/** @var Token */
1616
public $colon;
17-
/** @var StatementNode | StatementNode[] */
17+
/** @var StatementNode|StatementNode[] */
1818
public $statements;
1919

2020
const CHILD_NAMES = [

src/Node/ElseIfClauseNode.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ class ElseIfClauseNode extends Node {
1818
public $expression;
1919
/** @var Token */
2020
public $closeParen;
21-
/** @var Token | null */
21+
/** @var Token|null */
2222
public $colon;
23-
/** @var StatementNode | StatementNode[] */
23+
/** @var StatementNode|StatementNode[] */
2424
public $statements;
2525

2626
const CHILD_NAMES = [

src/Node/Expression/AnonymousFunctionCreationExpression.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use Microsoft\PhpParser\Token;
1616

1717
class AnonymousFunctionCreationExpression extends Expression implements FunctionLike {
18-
/** @var Token | null */
18+
/** @var Token|null */
1919
public $staticModifier;
2020

2121
use FunctionHeader, FunctionUseClause, FunctionReturnType, FunctionBody;

src/Node/Expression/ArgumentExpression.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
use Microsoft\PhpParser\Token;
1111

1212
class ArgumentExpression extends Expression {
13-
/** @var Token | null */
13+
/** @var Token|null */
1414
public $byRefToken; // TODO removed in newer versions of PHP. Also only accept variable, not expression if byRef
1515

16-
/** @var Token | null */
16+
/** @var Token|null */
1717
public $dotDotDotToken;
1818

1919
/** @var Expression */

src/Node/Expression/ArrayCreationExpression.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
class ArrayCreationExpression extends Expression {
1414

15-
/** @var Token | null */
15+
/** @var Token|null */
1616
public $arrayKeyword;
1717

1818
/** @var Token */

src/Node/Expression/CallExpression.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class CallExpression extends Expression {
1717
/** @var Token */
1818
public $openParen;
1919

20-
/** @var DelimitedList\ArgumentExpressionList | null */
20+
/** @var DelimitedList\ArgumentExpressionList|null */
2121
public $argumentExpressionList;
2222

2323
/** @var Token */

0 commit comments

Comments
 (0)