From 4708ae796fdc4a6190ec8fc38f03cd5d3ef009ed Mon Sep 17 00:00:00 2001 From: Jesse Donat Date: Wed, 1 Nov 2023 16:35:24 -0500 Subject: [PATCH 1/4] Raise the slevomat coding standard floor --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ff3a843..92284c3 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ "require": { "dealerdirect/phpcodesniffer-composer-installer": "*", "squizlabs/php_codesniffer": "*", - "slevomat/coding-standard": "^8.3", + "slevomat/coding-standard": "^8.14", "php": ">=7.4" }, "require-dev": { From 215c44d2e01132c0de7cf7d95b730fb0734963cd Mon Sep 17 00:00:00 2001 From: Jesse Donat Date: Thu, 2 Nov 2023 10:37:44 -0500 Subject: [PATCH 2/4] Add a couple slevomat rules --- src/Corpus/ruleset.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Corpus/ruleset.xml b/src/Corpus/ruleset.xml index 270d7e8..1dcb079 100644 --- a/src/Corpus/ruleset.xml +++ b/src/Corpus/ruleset.xml @@ -56,4 +56,6 @@ + + From 6c4b648e9248dca1c5655f5e0ba148e0c41fd4aa Mon Sep 17 00:00:00 2001 From: Jesse Donat Date: Thu, 2 Nov 2023 14:12:46 -0500 Subject: [PATCH 3/4] Fix slevomat link generation --- tools/inherited-rules.php | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/tools/inherited-rules.php b/tools/inherited-rules.php index 4c0dd2f..3f606a5 100644 --- a/tools/inherited-rules.php +++ b/tools/inherited-rules.php @@ -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; @@ -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]})"; } } @@ -37,4 +32,4 @@ function makeRefLink( string $ref ) : string { foreach( $rules as $rule ) { echo '- ' . makeRefLink($rule->attributes->getNamedItem('ref')->nodeValue); echo "\n"; -} \ No newline at end of file +} From f09753610ce64f3435fc6c565dbcd0b9fd21da97 Mon Sep 17 00:00:00 2001 From: Jesse Donat Date: Thu, 2 Nov 2023 14:13:06 -0500 Subject: [PATCH 4/4] Update README --- README.md | 54 ++++++++++++++++++++++++++------------------------- composer.json | 3 ++- 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index fc58dd3..765d500 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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-) \ No newline at end of file +- [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-) \ No newline at end of file diff --git a/composer.json b/composer.json index 92284c3..c7c4ba0 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,8 @@ "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": [ {