Skip to content

Commit bffa7c0

Browse files
committed
Update sniffs to PHPCS v4.
1 parent 69709cc commit bffa7c0

File tree

7 files changed

+12
-10
lines changed

7 files changed

+12
-10
lines changed

PSR2R/Sniffs/Commenting/DocBlockParamSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ private function getMethodSignature(File $phpCsFile, int $stackPtr): array {
145145
while ($nextVariableIndex = $phpCsFile->findNext(T_VARIABLE, $i + 1, $endIndex)) {
146146
$typehint = $default = null;
147147
$possibleTypeHint =
148-
$phpCsFile->findPrevious([T_ARRAY_HINT, T_CALLABLE], $nextVariableIndex - 1, $nextVariableIndex - 3);
148+
$phpCsFile->findPrevious([T_ARRAY, T_CALLABLE], $nextVariableIndex - 1, $nextVariableIndex - 3);
149149
if ($possibleTypeHint) {
150150
$typehint = $possibleTypeHint;
151151
}

PSR2R/Sniffs/Methods/MethodDeclarationSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop
5151
$tokens = $phpcsFile->getTokens();
5252

5353
$methodName = $phpcsFile->getDeclarationName($stackPtr);
54-
if ($methodName === null) {
54+
if (!$methodName) {
5555
// Ignore closures.
5656
return;
5757
}

PSR2R/Sniffs/Namespaces/NoInlineFullyQualifiedClassNameSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ protected function checkUseForReturnTypeHint(File $phpcsFile, int $stackPtr): vo
772772
$extractedUseStatement = '';
773773
$lastSeparatorIndex = null;
774774
while (true) {
775-
if (!$this->isGivenKind([T_NS_SEPARATOR, T_STRING, T_RETURN_TYPE], $tokens[$j])) {
775+
if (!$this->isGivenKind([T_NS_SEPARATOR, T_STRING], $tokens[$j])) {
776776
break;
777777
}
778778

PSR2R/Tools/Traits/SignatureTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ protected function getMethodSignature(File $phpCsFile, int $stackPtr): array {
2525
$i = $startIndex;
2626
while ($nextVariableIndex = $phpCsFile->findNext(T_VARIABLE, $i + 1, $endIndex)) {
2727
$typehintIndex = $defaultIndex = $default = null;
28-
$possibleTypeHint = $phpCsFile->findPrevious([T_ARRAY_HINT, T_CALLABLE], $nextVariableIndex - 1, $nextVariableIndex - 3);
28+
$possibleTypeHint = $phpCsFile->findPrevious([T_ARRAY, T_CALLABLE], $nextVariableIndex - 1, $nextVariableIndex - 3);
2929
if ($possibleTypeHint) {
3030
$typehintIndex = $possibleTypeHint;
3131
}

PSR2R/ruleset.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<exclude-pattern>\.json</exclude-pattern>
1919

2020
<config name="installed_paths" value="../../slevomat/coding-standard,../../php-collective/code-sniffer,../../phpcsstandards/phpcsextra"/>
21+
<config name="php_version" value="80100"/>
2122

2223
<arg name="tab-width" value="4"/>
2324

composer.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313
],
1414
"require": {
1515
"php": ">=8.1",
16-
"php-collective/code-sniffer": "^0.3.0",
17-
"slevomat/coding-standard": "^8.16.0",
18-
"squizlabs/php_codesniffer": "^3.7.0"
16+
"php-collective/code-sniffer": "dev-next",
17+
"slevomat/coding-standard": "dev-phpcs4",
18+
"squizlabs/php_codesniffer": "^4.0.0"
1919
},
2020
"require-dev": {
2121
"phpunit/phpunit": "^10.3 || ^11.5 || ^12.0",
22-
"phpstan/phpstan": "^2.1.0"
22+
"phpstan/phpstan": "^2.1.0",
23+
"dealerdirect/phpcodesniffer-composer-installer": "^1.0"
2324
},
2425
"autoload": {
2526
"psr-4": {
@@ -32,7 +33,7 @@
3233
}
3334
},
3435
"prefer-stable": true,
35-
"minimum-stability": "stable",
36+
"minimum-stability": "dev",
3637
"bin": [
3738
"bin/tokenize",
3839
"bin/sniff"

phpcs.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0"?>
22
<ruleset name="code-sniffer">
3-
<config name="installed_paths" value="../../fig-r/psr2r-sniffer"/>
3+
<config name="installed_paths" value="vendor/slevomat/coding-standard,vendor/php-collective/code-sniffer,vendor/phpcsstandards/phpcsextra,vendor/phpcsstandards/phpcsutils"/>
44

55
<arg value="nps"/>
66

0 commit comments

Comments
 (0)