Skip to content

Commit cfe3c78

Browse files
TomasVotrubaondrejmirtes
authored andcommitted
Allow nodes to have custom attributes
1 parent 37a74df commit cfe3c78

Some content is hidden

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

44 files changed

+243
-0
lines changed

src/Ast/ConstExpr/ConstExprArrayItemNode.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22

33
namespace PHPStan\PhpDocParser\Ast\ConstExpr;
44

5+
use PHPStan\PhpDocParser\Ast\NodeAttributes;
6+
57
class ConstExprArrayItemNode implements ConstExprNode
68
{
79

10+
use NodeAttributes;
11+
812
/** @var ConstExprNode|null */
913
public $key;
1014

src/Ast/ConstExpr/ConstExprArrayNode.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22

33
namespace PHPStan\PhpDocParser\Ast\ConstExpr;
44

5+
use PHPStan\PhpDocParser\Ast\NodeAttributes;
6+
57
class ConstExprArrayNode implements ConstExprNode
68
{
79

10+
use NodeAttributes;
11+
812
/** @var ConstExprArrayItemNode[] */
913
public $items;
1014

src/Ast/ConstExpr/ConstExprFalseNode.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22

33
namespace PHPStan\PhpDocParser\Ast\ConstExpr;
44

5+
use PHPStan\PhpDocParser\Ast\NodeAttributes;
6+
57
class ConstExprFalseNode implements ConstExprNode
68
{
79

10+
use NodeAttributes;
11+
812
public function __toString(): string
913
{
1014
return 'false';

src/Ast/ConstExpr/ConstExprFloatNode.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22

33
namespace PHPStan\PhpDocParser\Ast\ConstExpr;
44

5+
use PHPStan\PhpDocParser\Ast\NodeAttributes;
6+
57
class ConstExprFloatNode implements ConstExprNode
68
{
79

10+
use NodeAttributes;
11+
812
/** @var string */
913
public $value;
1014

src/Ast/ConstExpr/ConstExprIntegerNode.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22

33
namespace PHPStan\PhpDocParser\Ast\ConstExpr;
44

5+
use PHPStan\PhpDocParser\Ast\NodeAttributes;
6+
57
class ConstExprIntegerNode implements ConstExprNode
68
{
79

10+
use NodeAttributes;
11+
812
/** @var string */
913
public $value;
1014

src/Ast/ConstExpr/ConstExprNullNode.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22

33
namespace PHPStan\PhpDocParser\Ast\ConstExpr;
44

5+
use PHPStan\PhpDocParser\Ast\NodeAttributes;
6+
57
class ConstExprNullNode implements ConstExprNode
68
{
79

10+
use NodeAttributes;
11+
812
public function __toString(): string
913
{
1014
return 'null';

src/Ast/ConstExpr/ConstExprStringNode.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22

33
namespace PHPStan\PhpDocParser\Ast\ConstExpr;
44

5+
use PHPStan\PhpDocParser\Ast\NodeAttributes;
6+
57
class ConstExprStringNode implements ConstExprNode
68
{
79

10+
use NodeAttributes;
11+
812
/** @var string */
913
public $value;
1014

src/Ast/ConstExpr/ConstExprTrueNode.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22

33
namespace PHPStan\PhpDocParser\Ast\ConstExpr;
44

5+
use PHPStan\PhpDocParser\Ast\NodeAttributes;
6+
57
class ConstExprTrueNode implements ConstExprNode
68
{
79

10+
use NodeAttributes;
11+
812
public function __toString(): string
913
{
1014
return 'true';

src/Ast/ConstExpr/ConstFetchNode.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22

33
namespace PHPStan\PhpDocParser\Ast\ConstExpr;
44

5+
use PHPStan\PhpDocParser\Ast\NodeAttributes;
6+
57
class ConstFetchNode implements ConstExprNode
68
{
79

10+
use NodeAttributes;
11+
812
/** @var string class name for class constants or empty string for non-class constants */
913
public $className;
1014

src/Ast/Node.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,18 @@ interface Node
77

88
public function __toString(): string;
99

10+
/**
11+
* @param string $key
12+
* @param mixed $value
13+
*/
14+
public function setAttribute(string $key, $value): void;
15+
16+
public function hasAttribute(string $key): bool;
17+
18+
/**
19+
* @param string $key
20+
* @return mixed
21+
*/
22+
public function getAttribute(string $key);
23+
1024
}

0 commit comments

Comments
 (0)