Skip to content

Commit 198155d

Browse files
committed
Check for advanced sniffer package.
1 parent 0a45310 commit 198155d

File tree

7 files changed

+39
-13
lines changed

7 files changed

+39
-13
lines changed

PSR2R/Sniffs/Commenting/DocBlockParamNoOpSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ public function process(File $phpCsFile, $stackPointer): void {
6464
continue;
6565
}
6666

67-
$error = 'Possible doc block error: `' . $content .
68-
'` as only param type does not seem right. Makes this a no-op.';
67+
$error = 'Possible doc block error: `' . $content
68+
. '` as only param type does not seem right. Makes this a no-op.';
6969
$phpCsFile->addWarning($error, $i, 'ParamNoOp');
7070
}
7171
}

PSR2R/Sniffs/Namespaces/NoInlineFullyQualifiedClassNameSniff.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,8 @@ protected function checkUseForExtends(File $phpcsFile, int $nextIndex): void {
243243
}
244244

245245
$className = $this->extractClassNameFromUseStatementAsString($extractedUseStatement['statement']);
246-
$error = 'Use statement ' . $extractedUseStatement['statement'] . ' for ' . $className .
247-
' should be in use block.';
246+
$error = 'Use statement ' . $extractedUseStatement['statement'] . ' for ' . $className
247+
. ' should be in use block.';
248248
$fix = $phpcsFile->addFixableError($error, $extractedUseStatement['start'], 'Extends');
249249
if (!$fix) {
250250
return;
@@ -442,8 +442,8 @@ protected function checkUseForImplements(File $phpcsFile, int $nextIndex): void
442442
}
443443

444444
$className = $this->extractClassNameFromUseStatementAsString($extractedUseStatement['statement']);
445-
$error = 'Use statement ' . $extractedUseStatement['statement'] . ' for ' . $className .
446-
' should be in use block.';
445+
$error = 'Use statement ' . $extractedUseStatement['statement'] . ' for ' . $className
446+
. ' should be in use block.';
447447
$fix = $phpcsFile->addFixableError($error, $extractedUseStatement['start'], 'Implements');
448448
if (!$fix) {
449449
continue;

PSR2R/Sniffs/WhiteSpace/UnaryOperatorSpacingSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ public function process(File $phpcsFile, $stackPtr) {
3838
return;
3939
}
4040

41-
$fix = $phpcsFile->addFixableError('No whitespace should be between ' . $tokens[$stackPtr]['content'] .
42-
' operator and variable.', $stackPtr, 'NoWhitespace');
41+
$fix = $phpcsFile->addFixableError('No whitespace should be between ' . $tokens[$stackPtr]['content']
42+
. ' operator and variable.', $stackPtr, 'NoWhitespace');
4343
if ($fix) {
4444
$phpcsFile->fixer->replaceToken($stackPtr + 1, '');
4545
}

PSR2R/Tools/Tokenizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function __construct(array $argv) {
4848
}
4949
$file = realpath($file);
5050

51-
$this->root = dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR;
51+
$this->root = dirname(__DIR__, 2) . DIRECTORY_SEPARATOR;
5252
$this->path = $file;
5353
$this->verbose = !empty($argv[2]) && in_array($argv[2], ['--verbose', '-v'], true);
5454
}

PSR2R/ruleset.xml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<exclude-pattern>\.txt</exclude-pattern>
1818
<exclude-pattern>\.json</exclude-pattern>
1919

20-
<config name="installed_paths" value="../../slevomat/coding-standard,../../php-collective/code-sniffer"/>
20+
<config name="installed_paths" value="../../slevomat/coding-standard,../../php-collective/code-sniffer,../../phpcsstandards/phpcsextra"/>
2121

2222
<arg name="tab-width" value="4"/>
2323

@@ -280,6 +280,15 @@
280280
<rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
281281
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/>
282282

283+
<rule ref="Generic.Arrays.ArrayIndent"/>
284+
<rule ref="Universal.Constants.LowercaseClassResolutionKeyword"/>
285+
<rule ref="Universal.Constants.UppercaseMagicConstants"/>
286+
<rule ref="Universal.WhiteSpace.PrecisionAlignment"/>
287+
<rule ref="Universal.Operators.ConcatPosition"/>
288+
<rule ref="Universal.UseStatements.NoUselessAliases"/>
289+
<rule ref="Modernize.FunctionCalls.Dirname"/>
290+
<rule ref="NormalizedArrays.Arrays.ArrayBraceSpacing"/>
291+
283292
<!-- PHP 8 specific, only relevant for those PHP 8.0+ -->
284293
<rule ref="SlevomatCodingStandard.TypeHints.DNFTypeHintFormat">
285294
<properties>

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
],
1414
"require": {
1515
"php": ">=8.1",
16-
"php-collective/code-sniffer": "^0.2.14",
16+
"php-collective/code-sniffer": "dev-next",
1717
"slevomat/coding-standard": "^8.16.0",
1818
"squizlabs/php_codesniffer": "^3.7.0"
1919
},

docs/sniffs.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# PSR2R Code Sniffer
22

3-
The PSR2R standard contains 190 sniffs
3+
The PSR2R standard contains 198 sniffs
44

5-
Generic (23 sniffs)
5+
Generic (24 sniffs)
66
-------------------
7+
- Generic.Arrays.ArrayIndent
78
- Generic.Arrays.DisallowLongArraySyntax
89
- Generic.CodeAnalysis.ForLoopShouldBeWhileLoop
910
- Generic.CodeAnalysis.ForLoopWithTestFunctionCall
@@ -28,6 +29,14 @@ Generic (23 sniffs)
2829
- Generic.WhiteSpace.LanguageConstructSpacing
2930
- Generic.WhiteSpace.ScopeIndent
3031

32+
Modernize (1 sniff)
33+
-------------------
34+
- Modernize.FunctionCalls.Dirname
35+
36+
NormalizedArrays (1 sniff)
37+
--------------------------
38+
- NormalizedArrays.Arrays.ArrayBraceSpacing
39+
3140
PEAR (3 sniffs)
3241
---------------
3342
- PEAR.ControlStructures.ControlSignature
@@ -218,6 +227,14 @@ Squiz (20 sniffs)
218227
- Squiz.WhiteSpace.SemicolonSpacing
219228
- Squiz.WhiteSpace.SuperfluousWhitespace
220229

230+
Universal (5 sniffs)
231+
--------------------
232+
- Universal.Constants.LowercaseClassResolutionKeyword
233+
- Universal.Constants.UppercaseMagicConstants
234+
- Universal.Operators.ConcatPosition
235+
- Universal.UseStatements.NoUselessAliases
236+
- Universal.WhiteSpace.PrecisionAlignment
237+
221238
Zend (1 sniff)
222239
--------------
223240
- Zend.Files.ClosingTag

0 commit comments

Comments
 (0)