Skip to content

Commit f09f227

Browse files
committed
Declare namespacedName property
For historical reasons, this property is used by the NameResolver (in default mode). Declare it explicitly, rather than using a doc comment.
1 parent d4cb98a commit f09f227

File tree

5 files changed

+14
-12
lines changed

5 files changed

+14
-12
lines changed

lib/PhpParser/Node/Const_.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44

55
use PhpParser\NodeAbstract;
66

7-
/**
8-
* @property Name $namespacedName Namespaced name (for global constants, if using NameResolver)
9-
*/
107
class Const_ extends NodeAbstract
118
{
129
/** @var Identifier Name */
1310
public $name;
1411
/** @var Expr Value */
1512
public $value;
1613

14+
/** @var Name Namespaced name (if using NameResolver) */
15+
public $namespacedName;
16+
1717
/**
1818
* Constructs a const node for use in class const and const statements.
1919
*

lib/PhpParser/Node/Stmt/ClassLike.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
use PhpParser\Node;
66

7-
/**
8-
* @property Node\Name $namespacedName Namespaced name (if using NameResolver)
9-
*/
107
abstract class ClassLike extends Node\Stmt
118
{
129
/** @var Node\Identifier|null Name */
@@ -16,6 +13,9 @@ abstract class ClassLike extends Node\Stmt
1613
/** @var Node\AttributeGroup[] PHP attribute groups */
1714
public $attrGroups;
1815

16+
/** @var Node\Name Namespaced name (if using NameResolver) */
17+
public $namespacedName;
18+
1919
/**
2020
* @return TraitUse[]
2121
*/

lib/PhpParser/Node/Stmt/Function_.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
use PhpParser\Node;
66
use PhpParser\Node\FunctionLike;
77

8-
/**
9-
* @property Node\Name $namespacedName Namespaced name (if using NameResolver)
10-
*/
118
class Function_ extends Node\Stmt implements FunctionLike
129
{
1310
/** @var bool Whether function returns by reference */
@@ -23,6 +20,9 @@ class Function_ extends Node\Stmt implements FunctionLike
2320
/** @var Node\AttributeGroup[] PHP attribute groups */
2421
public $attrGroups;
2522

23+
/** @var Node\Name Namespaced name (if using NameResolver) */
24+
public $namespacedName;
25+
2626
/**
2727
* Constructs a function node.
2828
*

test/PhpParser/NodeAbstractTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ function functionName(&$a = 0, $b = 1.0) {
306306
}
307307
],
308308
"attrGroups": [],
309+
"namespacedName": null,
309310
"attributes": {
310311
"startLine": 4,
311312
"comments": [
@@ -454,7 +455,8 @@ function functionName(&$a = 0, $b = 1.0) {
454455
]
455456
}
456457
],
457-
"attrGroups": []
458+
"attrGroups": [],
459+
"namespacedName": null
458460
}
459461
]
460462
JSON;

test/PhpParser/NodeVisitor/NameResolverTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ public function testAddDeclarationNamespacedName() {
353353
$this->assertSame('NS\\C', (string) $stmts[0]->stmts[2]->namespacedName);
354354
$this->assertSame('NS\\D', (string) $stmts[0]->stmts[3]->consts[0]->namespacedName);
355355
$this->assertSame('NS\\E', (string) $stmts[0]->stmts[4]->namespacedName);
356-
$this->assertObjectNotHasAttribute('namespacedName', $stmts[0]->stmts[5]->class);
356+
$this->assertNull($stmts[0]->stmts[5]->class->namespacedName);
357357
$this->assertSame('NS\\F', (string) $stmts[0]->stmts[6]->namespacedName);
358358

359359
$stmts = $traverser->traverse([new Stmt\Namespace_(null, $nsStmts)]);
@@ -362,7 +362,7 @@ public function testAddDeclarationNamespacedName() {
362362
$this->assertSame('C', (string) $stmts[0]->stmts[2]->namespacedName);
363363
$this->assertSame('D', (string) $stmts[0]->stmts[3]->consts[0]->namespacedName);
364364
$this->assertSame('E', (string) $stmts[0]->stmts[4]->namespacedName);
365-
$this->assertObjectNotHasAttribute('namespacedName', $stmts[0]->stmts[5]->class);
365+
$this->assertNull($stmts[0]->stmts[5]->class->namespacedName);
366366
$this->assertSame('F', (string) $stmts[0]->stmts[6]->namespacedName);
367367
}
368368

0 commit comments

Comments
 (0)