From d1ca607f5d670dde430d6127f56c3f633962058e Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Sun, 15 Sep 2024 15:01:37 +0200 Subject: [PATCH 1/2] Update to phpstan/phpdoc-parser 2.0 --- .../Helpers/PhpDocParserHelper.php | 29 ++++++++++++------- composer.json | 2 +- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/SlevomatCodingStandard/Helpers/PhpDocParserHelper.php b/SlevomatCodingStandard/Helpers/PhpDocParserHelper.php index 6cc06d61a..d78a307da 100644 --- a/SlevomatCodingStandard/Helpers/PhpDocParserHelper.php +++ b/SlevomatCodingStandard/Helpers/PhpDocParserHelper.php @@ -9,6 +9,7 @@ use PHPStan\PhpDocParser\Parser\ConstExprParser; use PHPStan\PhpDocParser\Parser\PhpDocParser; use PHPStan\PhpDocParser\Parser\TypeParser; +use PHPStan\PhpDocParser\ParserConfig; use PHPStan\PhpDocParser\Printer\Printer; /** @@ -22,7 +23,7 @@ public static function getLexer(): Lexer static $lexer; if ($lexer === null) { - $lexer = new Lexer(true); + $lexer = new Lexer(self::getConfig()); } return $lexer; @@ -33,17 +34,12 @@ public static function getParser(): PhpDocParser static $parser; if ($parser === null) { - $usedAttributes = ['lines' => true, 'indexes' => true]; - - $constantExpressionParser = new ConstExprParser(true, true, $usedAttributes); + $config = self::getConfig(); + $constantExpressionParser = new ConstExprParser($config); $parser = new PhpDocParser( - new TypeParser($constantExpressionParser, true, $usedAttributes), - $constantExpressionParser, - true, - true, - $usedAttributes, - true, - true + $config, + new TypeParser($config, $constantExpressionParser), + $constantExpressionParser ); } @@ -79,4 +75,15 @@ public static function cloneNode(Node $node): Node return $cloneNode; } + private static function getConfig(): ParserConfig + { + static $config; + + if ($config === null) { + $config = new ParserConfig(['lines' => true, 'indexes' => true]); + } + + return $config; + } + } diff --git a/composer.json b/composer.json index 2ac38f82b..d458c79e9 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "require": { "php": "^7.2 || ^8.0", "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7 || ^1.0", - "phpstan/phpdoc-parser": "^1.23.1", + "phpstan/phpdoc-parser": "^2.0", "squizlabs/php_codesniffer": "^3.9.0" }, "require-dev": { From 72fc744306de7792f970b68552d740c55826320f Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Thu, 7 Nov 2024 11:02:22 +0100 Subject: [PATCH 2/2] Drop PHP 7.2 and 7.3 --- .github/workflows/build.yml | 8 ++------ composer.json | 4 ++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 21821595f..cb7d13b5f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,8 +23,6 @@ jobs: dependencies: - "highest" php-version: - - "7.2" - - "7.3" - "7.4" - "8.0" - "8.1" @@ -45,7 +43,7 @@ jobs: ini-values: error_reporting=-1, display_errors=On, zend.assertions=1 - name: "Reset composer platform" - if: matrix.php-version == '7.2' || matrix.php-version == '7.3' || matrix.php-version == '7.4' + if: matrix.php-version == '7.4' run: "composer config --unset platform" - name: "Install dependencies" @@ -135,8 +133,6 @@ jobs: - "lowest" - "highest" php-version: - - "7.2" - - "7.3" - "7.4" - "8.0" - "8.1" @@ -159,7 +155,7 @@ jobs: ini-values: error_reporting=-1, display_errors=On, zend.assertions=1 - name: "Reset composer platform" - if: matrix.php-version == '7.2' || matrix.php-version == '7.3' || matrix.php-version == '7.4' || matrix.php-version == '8.0' + if: matrix.php-version == '7.4' || matrix.php-version == '8.0' run: "composer config --unset platform" - name: "Install dependencies" diff --git a/composer.json b/composer.json index d458c79e9..b1eb9a5df 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ } }, "require": { - "php": "^7.2 || ^8.0", + "php": "^7.4 || ^8.0", "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7 || ^1.0", "phpstan/phpdoc-parser": "^2.0", "squizlabs/php_codesniffer": "^3.9.0" @@ -28,7 +28,7 @@ "phpstan/phpstan-deprecation-rules": "1.1.4", "phpstan/phpstan-phpunit": "1.3.16", "phpstan/phpstan-strict-rules": "1.5.2", - "phpunit/phpunit": "8.5.21|9.6.8|10.5.11" + "phpunit/phpunit": "9.6.8|10.5.11" }, "autoload": { "psr-4": {