Skip to content

Commit

Permalink
Merge pull request #10 from CorpusPHP/donatj-patch-1
Browse files Browse the repository at this point in the history
Raise the slevomat coding standard floor
  • Loading branch information
donatj authored Nov 2, 2023
2 parents 467dd1c + f097536 commit d7e0565
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 38 deletions.
54 changes: 28 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Corpus Coding Standard for [PHP_CodeSniffer](https://github.com/squizlabs/PHP_Co

- **dealerdirect/phpcodesniffer-composer-installer**: *
- **squizlabs/php_codesniffer**: *
- **slevomat/coding-standard**: ^8.3
- **slevomat/coding-standard**: ^8.14
- **php**: >=7.4

## Installing
Expand Down Expand Up @@ -198,28 +198,30 @@ class MethodParameterFormattingSniff {
- [Squiz.Classes.LowercaseClassKeywords](https://github.com/squizlabs/PHP_CodeSniffer/blob/master/src/Standards/Squiz/Sniffs/Classes/LowercaseClassKeywordsSniff.php)
- [Squiz.Classes.SelfMemberReference](https://github.com/squizlabs/PHP_CodeSniffer/blob/master/src/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php)
- [Squiz.Scope.MethodScope](https://github.com/squizlabs/PHP_CodeSniffer/blob/master/src/Standards/Squiz/Sniffs/Scope/MethodScopeSniff.php)
- [SlevomatCodingStandard.Namespaces.UnusedUses](https://github.com/slevomat/coding-standard/blob/master/README.md#slevomatcodingstandardnamespacesunuseduses-)
- [SlevomatCodingStandard.Namespaces.DisallowGroupUse](https://github.com/slevomat/coding-standard/blob/master/README.md#slevomatcodingstandardnamespacesdisallowgroupuse)
- [SlevomatCodingStandard.Namespaces.MultipleUsesPerLine](https://github.com/slevomat/coding-standard/blob/master/README.md#slevomatcodingstandardnamespacesmultipleusesperline)
- [SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash](https://github.com/slevomat/coding-standard/blob/master/README.md#slevomatcodingstandardnamespacesusedoesnotstartwithbackslash-)
- [SlevomatCodingStandard.Classes.TraitUseDeclaration](https://github.com/slevomat/coding-standard/blob/master/README.md#slevomatcodingstandardclassestraitusedeclaration-)
- [SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure](https://github.com/slevomat/coding-standard/blob/master/README.md#slevomatcodingstandardfunctionsunusedinheritedvariablepassedtoclosure-)
- [SlevomatCodingStandard.Functions.UselessParameterDefaultValue](https://github.com/slevomat/coding-standard/blob/master/README.md#slevomatcodingstandardfunctionsuselessparameterdefaultvalue-)
- [SlevomatCodingStandard.Arrays.DisallowImplicitArrayCreation](https://github.com/slevomat/coding-standard/blob/master/README.md#slevomatcodingstandardarraysdisallowimplicitarraycreation)
- [SlevomatCodingStandard.ControlStructures.DisallowContinueWithoutIntegerOperandInSwitch](https://github.com/slevomat/coding-standard/blob/master/README.md#slevomatcodingstandardcontrolstructuresdisallowcontinuewithoutintegeroperandinswitch-)
- [SlevomatCodingStandard.Namespaces.UseFromSameNamespace](https://github.com/slevomat/coding-standard/blob/master/README.md#slevomatcodingstandardnamespacesusefromsamenamespace-)
- [SlevomatCodingStandard.Arrays.TrailingArrayComma](https://github.com/slevomat/coding-standard/blob/master/README.md#slevomatcodingstandardarraystrailingarraycomma-)
- [SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator](https://github.com/slevomat/coding-standard/blob/master/README.md#slevomatcodingstandardcontrolstructuresrequirenullcoalesceoperator-)
- [SlevomatCodingStandard.ControlStructures.RequireShortTernaryOperator](https://github.com/slevomat/coding-standard/blob/master/README.md#slevomatcodingstandardcontrolstructuresrequireshortternaryoperator-)
- [SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn](https://github.com/slevomat/coding-standard/blob/master/README.md#slevomatcodingstandardcontrolstructuresuselessifconditionwithreturn-)
- [SlevomatCodingStandard.ControlStructures.UselessTernaryOperator](https://github.com/slevomat/coding-standard/blob/master/README.md#slevomatcodingstandardcontrolstructuresuselessternaryoperator-)
- [SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses](https://github.com/slevomat/coding-standard/blob/master/README.md#slevomatcodingstandardnamespacesalphabeticallysorteduses-)
- [SlevomatCodingStandard.Namespaces.UselessAlias](https://github.com/slevomat/coding-standard/blob/master/README.md#slevomatcodingstandardnamespacesuselessalias-)
- [SlevomatCodingStandard.PHP.UselessSemicolon](https://github.com/slevomat/coding-standard/blob/master/README.md#slevomatcodingstandardphpuselesssemicolon-)
- [SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue](https://github.com/slevomat/coding-standard/blob/master/README.md#slevomatcodingstandardtypehintsnullabletypefornulldefaultvalue-)
- [SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces](https://github.com/slevomat/coding-standard/blob/master/README.md#slevomatcodingstandardclassesemptylinesaroundclassbraces-)
- [SlevomatCodingStandard.Variables.UselessVariable](https://github.com/slevomat/coding-standard/blob/master/README.md#slevomatcodingstandardvariablesuselessvariable-)
- [SlevomatCodingStandard.Operators.SpreadOperatorSpacing](https://github.com/slevomat/coding-standard/blob/master/README.md#slevomatcodingstandardoperatorsspreadoperatorspacing-)
- [SlevomatCodingStandard.Classes.ParentCallSpacing](https://github.com/slevomat/coding-standard/blob/master/README.md#slevomatcodingstandardclassesparentcallspacing-)
- [SlevomatCodingStandard.ControlStructures.NewWithoutParentheses](https://github.com/slevomat/coding-standard/blob/master/README.md#slevomatcodingstandardcontrolstructuresnewwithoutparentheses-)
- [SlevomatCodingStandard.Commenting.UselessFunctionDocComment](https://github.com/slevomat/coding-standard/blob/master/README.md#slevomatcodingstandardcommentinguselessfunctiondoccomment-)
- [SlevomatCodingStandard.Namespaces.UnusedUses](https://github.com/slevomat/coding-standard/blob/master/doc/namespaces.md#slevomatcodingstandardnamespacesunuseduses-)
- [SlevomatCodingStandard.Namespaces.DisallowGroupUse](https://github.com/slevomat/coding-standard/blob/master/doc/namespaces.md#slevomatcodingstandardnamespacesdisallowgroupuse)
- [SlevomatCodingStandard.Namespaces.MultipleUsesPerLine](https://github.com/slevomat/coding-standard/blob/master/doc/namespaces.md#slevomatcodingstandardnamespacesmultipleusesperline)
- [SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash](https://github.com/slevomat/coding-standard/blob/master/doc/namespaces.md#slevomatcodingstandardnamespacesusedoesnotstartwithbackslash-)
- [SlevomatCodingStandard.Classes.TraitUseDeclaration](https://github.com/slevomat/coding-standard/blob/master/doc/classes.md#slevomatcodingstandardclassestraitusedeclaration-)
- [SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure](https://github.com/slevomat/coding-standard/blob/master/doc/functions.md#slevomatcodingstandardfunctionsunusedinheritedvariablepassedtoclosure-)
- [SlevomatCodingStandard.Functions.UselessParameterDefaultValue](https://github.com/slevomat/coding-standard/blob/master/doc/functions.md#slevomatcodingstandardfunctionsuselessparameterdefaultvalue-)
- [SlevomatCodingStandard.Arrays.DisallowImplicitArrayCreation](https://github.com/slevomat/coding-standard/blob/master/doc/arrays.md#slevomatcodingstandardarraysdisallowimplicitarraycreation)
- [SlevomatCodingStandard.ControlStructures.DisallowContinueWithoutIntegerOperandInSwitch](https://github.com/slevomat/coding-standard/blob/master/doc/control-structures.md#slevomatcodingstandardcontrolstructuresdisallowcontinuewithoutintegeroperandinswitch-)
- [SlevomatCodingStandard.Namespaces.UseFromSameNamespace](https://github.com/slevomat/coding-standard/blob/master/doc/namespaces.md#slevomatcodingstandardnamespacesusefromsamenamespace-)
- [SlevomatCodingStandard.Arrays.TrailingArrayComma](https://github.com/slevomat/coding-standard/blob/master/doc/arrays.md#slevomatcodingstandardarraystrailingarraycomma-)
- [SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator](https://github.com/slevomat/coding-standard/blob/master/doc/control-structures.md#slevomatcodingstandardcontrolstructuresrequirenullcoalesceoperator-)
- [SlevomatCodingStandard.ControlStructures.RequireShortTernaryOperator](https://github.com/slevomat/coding-standard/blob/master/doc/control-structures.md#slevomatcodingstandardcontrolstructuresrequireshortternaryoperator-)
- [SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn](https://github.com/slevomat/coding-standard/blob/master/doc/control-structures.md#slevomatcodingstandardcontrolstructuresuselessifconditionwithreturn-)
- [SlevomatCodingStandard.ControlStructures.UselessTernaryOperator](https://github.com/slevomat/coding-standard/blob/master/doc/control-structures.md#slevomatcodingstandardcontrolstructuresuselessternaryoperator-)
- [SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses](https://github.com/slevomat/coding-standard/blob/master/doc/namespaces.md#slevomatcodingstandardnamespacesalphabeticallysorteduses-)
- [SlevomatCodingStandard.Namespaces.UselessAlias](https://github.com/slevomat/coding-standard/blob/master/doc/namespaces.md#slevomatcodingstandardnamespacesuselessalias-)
- [SlevomatCodingStandard.PHP.UselessSemicolon](https://github.com/slevomat/coding-standard/blob/master/doc/php.md#slevomatcodingstandardphpuselesssemicolon-)
- [SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue](https://github.com/slevomat/coding-standard/blob/master/doc/type-hints.md#slevomatcodingstandardtypehintsnullabletypefornulldefaultvalue-)
- [SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces](https://github.com/slevomat/coding-standard/blob/master/doc/classes.md#slevomatcodingstandardclassesemptylinesaroundclassbraces-)
- [SlevomatCodingStandard.Variables.UselessVariable](https://github.com/slevomat/coding-standard/blob/master/doc/variables.md#slevomatcodingstandardvariablesuselessvariable-)
- [SlevomatCodingStandard.Operators.SpreadOperatorSpacing](https://github.com/slevomat/coding-standard/blob/master/doc/operators.md#slevomatcodingstandardoperatorsspreadoperatorspacing-)
- [SlevomatCodingStandard.Classes.ParentCallSpacing](https://github.com/slevomat/coding-standard/blob/master/doc/classes.md#slevomatcodingstandardclassesparentcallspacing-)
- [SlevomatCodingStandard.ControlStructures.NewWithoutParentheses](https://github.com/slevomat/coding-standard/blob/master/doc/control-structures.md#slevomatcodingstandardcontrolstructuresnewwithoutparentheses-)
- [SlevomatCodingStandard.Commenting.UselessFunctionDocComment](https://github.com/slevomat/coding-standard/blob/master/doc/commenting.md#slevomatcodingstandardcommentinguselessfunctiondoccomment-)
- [SlevomatCodingStandard.Classes.RequireSelfReference](https://github.com/slevomat/coding-standard/blob/master/doc/classes.md#slevomatcodingstandardclassesrequireselfreference-)
- [SlevomatCodingStandard.ControlStructures.NewWithoutParentheses](https://github.com/slevomat/coding-standard/blob/master/doc/control-structures.md#slevomatcodingstandardcontrolstructuresnewwithoutparentheses-)
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
"require": {
"dealerdirect/phpcodesniffer-composer-installer": "*",
"squizlabs/php_codesniffer": "*",
"slevomat/coding-standard": "^8.3",
"slevomat/coding-standard": "^8.14",
"php": ">=7.4"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"donatj/drop": "^1.0",
"friendsofphp/php-cs-fixer": "^3.14"
"friendsofphp/php-cs-fixer": "^3.14",
"ext-dom": "*"
},
"authors": [
{
Expand Down
2 changes: 2 additions & 0 deletions src/Corpus/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,6 @@
<rule ref="SlevomatCodingStandard.Classes.ParentCallSpacing"/>
<rule ref="SlevomatCodingStandard.ControlStructures.NewWithoutParentheses"/>
<rule ref="SlevomatCodingStandard.Commenting.UselessFunctionDocComment"/>
<rule ref="SlevomatCodingStandard.Classes.RequireSelfReference"/>
<rule ref="SlevomatCodingStandard.ControlStructures.NewWithoutParentheses"/>
</ruleset>
15 changes: 5 additions & 10 deletions tools/inherited-rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

$rules = $ruleset->getElementsByTagName('rule');

$slevomatReadme = file_get_contents('https://github.com/slevomat/coding-standard/blob/master/README.md');
$slevomatReadme = file_get_contents('https://raw.githubusercontent.com/slevomat/coding-standard/master/README.md');

function makeRefLink( string $ref ) : string {
global $slevomatReadme;
Expand All @@ -19,14 +19,9 @@ function makeRefLink( string $ref ) : string {
}

if( $parts[0] === 'SlevomatCodingStandard' ) {
$anchor = strtolower($ref);
$anchor = preg_replace('/\W/', '', $anchor);
if( strpos($slevomatReadme, "#$anchor-\"") ) {
return "[{$ref}](https://github.com/slevomat/coding-standard/blob/master/README.md#{$anchor}-)";
}

if( strpos($slevomatReadme, "#$anchor\"") ) {
return "[{$ref}](https://github.com/slevomat/coding-standard/blob/master/README.md#{$anchor})";
preg_match('/\['.preg_quote($ref).'\]\(([^)]+)\)/im', $slevomatReadme, $matches);
if($matches) {
return "[{$ref}](https://github.com/slevomat/coding-standard/blob/master/{$matches[1]})";
}
}

Expand All @@ -37,4 +32,4 @@ function makeRefLink( string $ref ) : string {
foreach( $rules as $rule ) {
echo '- ' . makeRefLink($rule->attributes->getNamedItem('ref')->nodeValue);
echo "\n";
}
}

0 comments on commit d7e0565

Please sign in to comment.