Skip to content

single quote on doctrine got ParserException on v2 #260

@samsonasik

Description

@samsonasik

Given the following code:

/**
 * @\Doctrine\ORM\Mapping\Entity()
 * @\Doctrine\ORM\Mapping\Table('user', indexes={
 *  @\Doctrine\ORM\Mapping\Index(name="name_index", columns={"name"}),
 *  @\Doctrine\ORM\Mapping\Index(name="surname_index", columns={"surname"}),
 * })
 */
class SingleQuote
{
}

got error:

There was 1 error:

1) Rector\Tests\Issues\FqcnAnnotationToAttribute\FqcnAnnotationToAttributeTest::test with data set #2 ('/Users/samsonasik/www/rector-...hp.inc')
PHPStan\PhpDocParser\Parser\ParserException: Unexpected token "'user'", expected TOKEN_DOUBLE_QUOTED_STRING at offset 71 on line 3

/Users/samsonasik/www/rector-src/vendor/phpstan/phpdoc-parser/src/Parser/ConstExprParser.php:79
/Users/samsonasik/www/rector-src/vendor/phpstan/phpdoc-parser/src/Parser/PhpDocParser.php:684
/Users/samsonasik/www/rector-src/vendor/phpstan/phpdoc-parser/src/Parser/PhpDocParser.php:575
/Users/samsonasik/www/rector-src/vendor/phpstan/phpdoc-parser/src/Parser/PhpDocParser.php:553
/Users/samsonasik/www/rector-src/vendor/phpstan/phpdoc-parser/src/Parser/PhpDocParser.php:522
/Users/samsonasik/www/rector-src/vendor/phpstan/phpdoc-parser/src/Parser/PhpDocParser.php:148
/Users/samsonasik/www/rector-src/vendor/phpstan/phpdoc-parser/src/Parser/PhpDocParser.php:75

tracing it, it seems on

if ($tokens->isCurrentTokenType(Lexer::TOKEN_SINGLE_QUOTED_STRING)) {
throw new ParserException(
$tokens->currentTokenValue(),
$tokens->currentTokenType(),
$tokens->currentTokenOffset(),
Lexer::TOKEN_DOUBLE_QUOTED_STRING,
null,
$tokens->currentTokenLine(),
);

on phpdoc-parser v1, it is working as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions