Skip to content

Commit 5194589

Browse files
committed
TypeParserTest - test parsing string type representation again
1 parent f373259 commit 5194589

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests/PHPStan/Parser/TypeParserTest.php

+10
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
use PHPStan\PhpDocParser\Lexer\Lexer;
2929
use PHPUnit\Framework\TestCase;
3030
use function get_class;
31+
use function strpos;
3132
use const PHP_EOL;
3233

3334
class TypeParserTest extends TestCase
@@ -65,6 +66,15 @@ public function testParse(string $input, $expectedResult, int $nextTokenType = L
6566
$this->assertInstanceOf(get_class($expectedResult), $typeNode);
6667
$this->assertEquals($expectedResult, $typeNode);
6768
$this->assertSame($nextTokenType, $tokens->currentTokenType());
69+
70+
if (strpos((string) $expectedResult, '$ref') !== false) {
71+
// weird case with $ref inside double-quoted string - not really possible in PHP
72+
return;
73+
}
74+
75+
$typeNodeTokens = new TokenIterator($this->lexer->tokenize((string) $typeNode));
76+
$parsedAgainTypeNode = $this->typeParser->parse($typeNodeTokens);
77+
$this->assertSame((string) $typeNode, (string) $parsedAgainTypeNode);
6878
}
6979

7080

0 commit comments

Comments
 (0)