Skip to content

Annotation parsing issue #6859

@oojacoboo

Description

@oojacoboo

Bug Report

Subject Details
Rector version f068fd9

When running rector, the following exception is thrown. However, it's important to note that version 1.2.0 of phpstan does not produce any errors on this class. Also, a single quote ' doesn't fix the parsing issue.

Why is FROM being passed as a "token" to the phpdoc-parser TokenIterator? But even still, the parser isn't properly handling the syntax.

Fatal error: Uncaught PHPStan\PhpDocParser\Parser\ParserException: Unexpected token "FROM", expected ')' at offset 104 in phar:///./app/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/phpstan/phpdoc-parser/src/Parser/TokenIterator.php:141

The following annotation is added on a class declaration

/**
 * @MultiTenancy(filters={
 *      @MultiTenancy\Filter(
 *          filter="$this.unit_id IN(
 *              SELECT id
 *              FROM unit
 *              WHERE company_id = {companyId}
 *          ) OR $this.legal_entity_id IN(
 *              SELECT id
 *              FROM legal_entity
 *              WHERE company_id = {companyId}
 *          ) OR $this.payment_profile_id IN(
 *              SELECT id
 *              FROM payment_profile
 *              WHERE user_id = {userId}
 *          )"
 *      )
 * })
 */

Expected Behaviour

The parsing of the annotation is incorrect. The Filter property should be treated as a string.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions