Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

single quote on doctrine got ParserException on v2 #260

Closed
samsonasik opened this issue Nov 19, 2024 · 2 comments
Closed

single quote on doctrine got ParserException on v2 #260

samsonasik opened this issue Nov 19, 2024 · 2 comments

Comments

@samsonasik
Copy link

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.

@ondrejmirtes
Copy link
Member

This isn't valid Doctrine annotation, When I try it in a Doctrine project with annotations, this mapping exception is thrown:

[Syntax Error] Expected PlainValue, got ''' at position 16 in class PHPStan\Rules\Doctrine\ORM\Team.

Please note that phpdoc-parser v2 fully supports Doctrine annotations. You don't need to parse them manually anymore. See the UPGRADING guide for details: https://github.com/phpstan/phpdoc-parser/blob/2.0.x/UPGRADING.md

Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants