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

Revert "replace squizlabs/php_codesniffer with phpcsstandards/php_codesniffer" #1646

Merged
merged 2 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions SlevomatCodingStandard/Sniffs/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use function strlen;
use function strpos;
use function substr;
use function version_compare;
use const PHP_EOL;

/**
Expand All @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions build/PHPStan/phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion build/phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Slevomat Coding Standard" xsi:noNamespaceSchemaLocation="../vendor/phpcsstandards/php_codesniffer/phpcs.xsd">
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Slevomat Coding Standard" xsi:noNamespaceSchemaLocation="../vendor/squizlabs/php_codesniffer/phpcs.xsd">
<config name="php_version" value="70100"/>
<arg name="extensions" value="php"/>
<arg name="tab-width" value="4"/>
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';