Skip to content
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 PSR2R/Sniffs/Commenting/DocBlockParamNoOpSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ public function process(File $phpCsFile, $stackPointer): void {
continue;
}

$error = 'Possible doc block error: `' . $content .
'` as only param type does not seem right. Makes this a no-op.';
$error = 'Possible doc block error: `' . $content
. '` as only param type does not seem right. Makes this a no-op.';
$phpCsFile->addWarning($error, $i, 'ParamNoOp');
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ protected function checkUseForExtends(File $phpcsFile, int $nextIndex): void {
}

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

$className = $this->extractClassNameFromUseStatementAsString($extractedUseStatement['statement']);
$error = 'Use statement ' . $extractedUseStatement['statement'] . ' for ' . $className .
' should be in use block.';
$error = 'Use statement ' . $extractedUseStatement['statement'] . ' for ' . $className
. ' should be in use block.';
$fix = $phpcsFile->addFixableError($error, $extractedUseStatement['start'], 'Implements');
if (!$fix) {
continue;
Expand Down
4 changes: 2 additions & 2 deletions PSR2R/Sniffs/WhiteSpace/UnaryOperatorSpacingSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public function process(File $phpcsFile, $stackPtr) {
return;
}

$fix = $phpcsFile->addFixableError('No whitespace should be between ' . $tokens[$stackPtr]['content'] .
' operator and variable.', $stackPtr, 'NoWhitespace');
$fix = $phpcsFile->addFixableError('No whitespace should be between ' . $tokens[$stackPtr]['content']
. ' operator and variable.', $stackPtr, 'NoWhitespace');
if ($fix) {
$phpcsFile->fixer->replaceToken($stackPtr + 1, '');
}
Expand Down
2 changes: 1 addition & 1 deletion PSR2R/Tools/Tokenizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function __construct(array $argv) {
}
$file = realpath($file);

$this->root = dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR;
$this->root = dirname(__DIR__, 2) . DIRECTORY_SEPARATOR;
$this->path = $file;
$this->verbose = !empty($argv[2]) && in_array($argv[2], ['--verbose', '-v'], true);
}
Expand Down
11 changes: 10 additions & 1 deletion PSR2R/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<exclude-pattern>\.txt</exclude-pattern>
<exclude-pattern>\.json</exclude-pattern>

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

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

Expand Down Expand Up @@ -280,6 +280,15 @@
<rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/>

<rule ref="Generic.Arrays.ArrayIndent"/>
<rule ref="Universal.Constants.LowercaseClassResolutionKeyword"/>
<rule ref="Universal.Constants.UppercaseMagicConstants"/>
<rule ref="Universal.WhiteSpace.PrecisionAlignment"/>
<rule ref="Universal.Operators.ConcatPosition"/>
<rule ref="Universal.UseStatements.NoUselessAliases"/>
<rule ref="Modernize.FunctionCalls.Dirname"/>
<rule ref="NormalizedArrays.Arrays.ArrayBraceSpacing"/>

<!-- PHP 8 specific, only relevant for those PHP 8.0+ -->
<rule ref="SlevomatCodingStandard.TypeHints.DNFTypeHintFormat">
<properties>
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
],
"require": {
"php": ">=8.1",
"php-collective/code-sniffer": "^0.2.14",
"php-collective/code-sniffer": "dev-next",
"slevomat/coding-standard": "^8.16.0",
"squizlabs/php_codesniffer": "^3.7.0"
},
Expand Down
21 changes: 19 additions & 2 deletions docs/sniffs.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# PSR2R Code Sniffer

The PSR2R standard contains 190 sniffs
The PSR2R standard contains 198 sniffs

Generic (23 sniffs)
Generic (24 sniffs)
-------------------
- Generic.Arrays.ArrayIndent
- Generic.Arrays.DisallowLongArraySyntax
- Generic.CodeAnalysis.ForLoopShouldBeWhileLoop
- Generic.CodeAnalysis.ForLoopWithTestFunctionCall
Expand All @@ -28,6 +29,14 @@ Generic (23 sniffs)
- Generic.WhiteSpace.LanguageConstructSpacing
- Generic.WhiteSpace.ScopeIndent

Modernize (1 sniff)
-------------------
- Modernize.FunctionCalls.Dirname

NormalizedArrays (1 sniff)
--------------------------
- NormalizedArrays.Arrays.ArrayBraceSpacing

PEAR (3 sniffs)
---------------
- PEAR.ControlStructures.ControlSignature
Expand Down Expand Up @@ -218,6 +227,14 @@ Squiz (20 sniffs)
- Squiz.WhiteSpace.SemicolonSpacing
- Squiz.WhiteSpace.SuperfluousWhitespace

Universal (5 sniffs)
--------------------
- Universal.Constants.LowercaseClassResolutionKeyword
- Universal.Constants.UppercaseMagicConstants
- Universal.Operators.ConcatPosition
- Universal.UseStatements.NoUselessAliases
- Universal.WhiteSpace.PrecisionAlignment

Zend (1 sniff)
--------------
- Zend.Files.ClosingTag