From 1978edad3f1ebc5cd3d0c49cad7b1bc9b39a6ac0 Mon Sep 17 00:00:00 2001 From: Farhad Safarov Date: Tue, 13 Oct 2020 16:52:11 +0300 Subject: [PATCH] static analysis plugin itself with lowest & highest deps (#94) * static analysis plugin itself with lowest & highest deps * no message * no message * no message * no message * no message --- .github/workflows/integrate.yaml | 6 ++++++ composer.json | 2 +- src/Handler/DoctrineRepositoryHandler.php | 12 +++--------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/integrate.yaml b/.github/workflows/integrate.yaml index 2b61c9f8..e10775c1 100644 --- a/.github/workflows/integrate.yaml +++ b/.github/workflows/integrate.yaml @@ -18,9 +18,11 @@ jobs: matrix: php-version: - 7.4 + - 7.3 dependencies: - highest + - lowest steps: - name: "Checkout" @@ -43,6 +45,10 @@ jobs: key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.json') }} restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- + - name: "Install lowest dependencies from composer.json" + if: matrix.dependencies == 'lowest' + run: composer update --no-interaction --no-progress --no-suggest --prefer-lowest + - name: "Install highest dependencies from composer.json" if: matrix.dependencies == 'highest' run: composer install --no-interaction --no-progress --no-suggest diff --git a/composer.json b/composer.json index 68ee8d59..9e0f619b 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "php": "^7.1", "ext-simplexml": "*", "symfony/framework-bundle": "^3.0 || ^4.0 || ^5.0", - "vimeo/psalm": "^3.13" + "vimeo/psalm": "^3.16 <3.17" }, "require-dev": { "doctrine/orm": "^2.7", diff --git a/src/Handler/DoctrineRepositoryHandler.php b/src/Handler/DoctrineRepositoryHandler.php index ec9870f4..cf35e2fa 100644 --- a/src/Handler/DoctrineRepositoryHandler.php +++ b/src/Handler/DoctrineRepositoryHandler.php @@ -4,7 +4,6 @@ use Doctrine\Common\Annotations\AnnotationReader; use Doctrine\ORM\Mapping\Entity as EntityAnnotation; -use function GuzzleHttp\Psr7\parse_query; use PhpParser\Node\Expr; use PhpParser\Node\Scalar\String_; use PhpParser\Node\Stmt\ClassLike; @@ -75,14 +74,9 @@ public static function afterClassLikeVisit( $docblock = $stmt->getDocComment(); if ($docblock && false !== strpos((string) $docblock, 'repositoryClass')) { try { - /** @psalm-suppress DeprecatedMethod */ - $parsedComment = DocComment::parse( - (string) $docblock->getReformattedText() - ); - if (isset($parsedComment['specials']['Entity'][0])) { - $entitySpecial = trim($parsedComment['specials']['Entity'][0], '()'); - /** @psalm-suppress MixedArgument */ - $repositoryClassName = trim(parse_query($entitySpecial)['repositoryClass'], '"'); + $parsedComment = DocComment::parsePreservingLength($docblock); + if (isset($parsedComment->tags['Entity'])) { + $repositoryClassName = str_replace(['"', '(', ')', 'repositoryClass', '\'', '='], '', array_values($parsedComment->tags['Entity'])[0]); $file_path = $statements_source->getFilePath(); $file_storage = $codebase->file_storage_provider->get($file_path);