diff --git a/README.md b/README.md index fff7b04cc..c13bde58a 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![Code coverage](https://codecov.io/gh/slevomat/coding-standard/branch/master/graph/badge.svg)](https://codecov.io/gh/slevomat/coding-standard) ![PHPStan](https://img.shields.io/badge/style-level%207-brightgreen.svg?&label=phpstan) -Slevomat Coding Standard for [PHP_CodeSniffer](https://github.com/phpcsstandards/PHP_CodeSniffer) provides sniffs that fall into three categories: +Slevomat Coding Standard for [PHP_CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer) provides sniffs that fall into three categories: * Functional - improving the safety and behaviour of code * Cleaning - detecting dead code @@ -249,7 +249,7 @@ However it is not a recommended way to use Slevomat Coding Standard, because you ## Fixing errors automatically -Sniffs in this standard marked by the 🔧 symbol support [automatic fixing of coding standard violations](https://github.com/phpcsstandards/PHP_CodeSniffer/wiki/Fixing-Errors-Automatically). To fix your code automatically, run phpcbf instead of phpcs: +Sniffs in this standard marked by the 🔧 symbol support [automatic fixing of coding standard violations](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Fixing-Errors-Automatically). To fix your code automatically, run phpcbf instead of phpcs: ``` vendor/bin/phpcbf --standard=ruleset.xml --extensions=php --tab-width=4 -sp src tests diff --git a/SlevomatCodingStandard/Sniffs/TestCase.php b/SlevomatCodingStandard/Sniffs/TestCase.php index 74d440f94..b418c788b 100644 --- a/SlevomatCodingStandard/Sniffs/TestCase.php +++ b/SlevomatCodingStandard/Sniffs/TestCase.php @@ -21,6 +21,7 @@ use function strlen; use function strpos; use function substr; +use function version_compare; use const PHP_EOL; /** @@ -44,6 +45,16 @@ protected static function checkFile(string $filePath, array $sniffProperties = [ $codeSniffer->init(); if (count($sniffProperties) > 0) { + /** @phpstan-ignore-next-line */ + if (version_compare(Config::VERSION, '3.8.0', '>=')) { + foreach ($sniffProperties as $name => $value) { + $sniffProperties[$name] = [ + 'value' => $value, + 'scope' => 'sniff', + ]; + } + } + $codeSniffer->ruleset->ruleset[self::getSniffName()]['properties'] = $sniffProperties; } diff --git a/build/PHPStan/phpstan.neon b/build/PHPStan/phpstan.neon index dae352a50..ef8b16809 100644 --- a/build/PHPStan/phpstan.neon +++ b/build/PHPStan/phpstan.neon @@ -12,8 +12,8 @@ parameters: - %currentWorkingDirectory%/SlevomatCodingStandard bootstrapFiles: - - %currentWorkingDirectory%/vendor/phpcsstandards/php_codesniffer/autoload.php - - %currentWorkingDirectory%/vendor/phpcsstandards/php_codesniffer/src/Util/Tokens.php + - %currentWorkingDirectory%/vendor/squizlabs/php_codesniffer/autoload.php + - %currentWorkingDirectory%/vendor/squizlabs/php_codesniffer/src/Util/Tokens.php excludePaths: - %currentWorkingDirectory%/tests/*/data/* ignoreErrors: diff --git a/build/phpcs.xml b/build/phpcs.xml index fc28a14b9..929551e3f 100644 --- a/build/phpcs.xml +++ b/build/phpcs.xml @@ -1,5 +1,5 @@ - + diff --git a/composer.json b/composer.json index a3dd1d08f..670f865e0 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "php": "^7.2 || ^8.0", "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7 || ^1.0", "phpstan/phpdoc-parser": "^1.23.1", - "phpcsstandards/php_codesniffer": "^3.7.1" + "squizlabs/php_codesniffer": "^3.7.1" }, "require-dev": { "phing/phing": "2.17.4", diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 009b1a557..d783176bd 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -3,4 +3,4 @@ error_reporting(E_ALL); require __DIR__ . '/../vendor/autoload.php'; -require __DIR__ . '/../vendor/phpcsstandards/php_codesniffer/autoload.php'; +require __DIR__ . '/../vendor/squizlabs/php_codesniffer/autoload.php';