Skip to content

Commit 178b33a

Browse files
committed
Backward compatibility - QuoteAwareConstExprStringNode should extend ConstExprStringNode
1 parent 5194589 commit 178b33a

File tree

4 files changed

+8
-13
lines changed

4 files changed

+8
-13
lines changed

src/Ast/ConstExpr/QuoteAwareConstExprStringNode.php

+2-5
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,14 @@
1313
use function strlen;
1414
use const STR_PAD_LEFT;
1515

16-
class QuoteAwareConstExprStringNode implements ConstExprNode
16+
class QuoteAwareConstExprStringNode extends ConstExprStringNode implements ConstExprNode
1717
{
1818

1919
public const SINGLE_QUOTED = 1;
2020
public const DOUBLE_QUOTED = 2;
2121

2222
use NodeAttributes;
2323

24-
/** @var string */
25-
public $value;
26-
2724
/** @var self::SINGLE_QUOTED|self::DOUBLE_QUOTED */
2825
public $quoteType;
2926

@@ -32,7 +29,7 @@ class QuoteAwareConstExprStringNode implements ConstExprNode
3229
*/
3330
public function __construct(string $value, int $quoteType)
3431
{
35-
$this->value = $value;
32+
parent::__construct($value);
3633
$this->quoteType = $quoteType;
3734
}
3835

src/Ast/Type/ArrayShapeItemNode.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprIntegerNode;
66
use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprStringNode;
7-
use PHPStan\PhpDocParser\Ast\ConstExpr\QuoteAwareConstExprStringNode;
87
use PHPStan\PhpDocParser\Ast\NodeAttributes;
98
use function sprintf;
109

@@ -13,7 +12,7 @@ class ArrayShapeItemNode implements TypeNode
1312

1413
use NodeAttributes;
1514

16-
/** @var ConstExprIntegerNode|QuoteAwareConstExprStringNode|ConstExprStringNode|IdentifierTypeNode|null */
15+
/** @var ConstExprIntegerNode|ConstExprStringNode|IdentifierTypeNode|null */
1716
public $keyName;
1817

1918
/** @var bool */
@@ -23,7 +22,7 @@ class ArrayShapeItemNode implements TypeNode
2322
public $valueType;
2423

2524
/**
26-
* @param ConstExprIntegerNode|QuoteAwareConstExprStringNode|ConstExprStringNode|IdentifierTypeNode|null $keyName
25+
* @param ConstExprIntegerNode|ConstExprStringNode|IdentifierTypeNode|null $keyName
2726
*/
2827
public function __construct($keyName, bool $optional, TypeNode $valueType)
2928
{

src/Ast/Type/ObjectShapeItemNode.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace PHPStan\PhpDocParser\Ast\Type;
44

55
use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprStringNode;
6-
use PHPStan\PhpDocParser\Ast\ConstExpr\QuoteAwareConstExprStringNode;
76
use PHPStan\PhpDocParser\Ast\NodeAttributes;
87
use function sprintf;
98

@@ -12,7 +11,7 @@ class ObjectShapeItemNode implements TypeNode
1211

1312
use NodeAttributes;
1413

15-
/** @var QuoteAwareConstExprStringNode|ConstExprStringNode|IdentifierTypeNode */
14+
/** @var ConstExprStringNode|IdentifierTypeNode */
1615
public $keyName;
1716

1817
/** @var bool */
@@ -22,7 +21,7 @@ class ObjectShapeItemNode implements TypeNode
2221
public $valueType;
2322

2423
/**
25-
* @param QuoteAwareConstExprStringNode|ConstExprStringNode|IdentifierTypeNode $keyName
24+
* @param ConstExprStringNode|IdentifierTypeNode $keyName
2625
*/
2726
public function __construct($keyName, bool $optional, TypeNode $valueType)
2827
{

src/Parser/TypeParser.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ private function parseArrayShapeItem(TokenIterator $tokens): Ast\Type\ArrayShape
566566

567567
/**
568568
* @phpstan-impure
569-
* @return Ast\ConstExpr\ConstExprIntegerNode|Ast\ConstExpr\QuoteAwareConstExprStringNode|Ast\ConstExpr\ConstExprStringNode|Ast\Type\IdentifierTypeNode
569+
* @return Ast\ConstExpr\ConstExprIntegerNode|Ast\ConstExpr\ConstExprStringNode|Ast\Type\IdentifierTypeNode
570570
*/
571571
private function parseArrayShapeKey(TokenIterator $tokens)
572572
{
@@ -639,7 +639,7 @@ private function parseObjectShapeItem(TokenIterator $tokens): Ast\Type\ObjectSha
639639

640640
/**
641641
* @phpstan-impure
642-
* @return Ast\ConstExpr\QuoteAwareConstExprStringNode|Ast\ConstExpr\ConstExprStringNode|Ast\Type\IdentifierTypeNode
642+
* @return Ast\ConstExpr\ConstExprStringNode|Ast\Type\IdentifierTypeNode
643643
*/
644644
private function parseObjectShapeKey(TokenIterator $tokens)
645645
{

0 commit comments

Comments
 (0)