diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 08db777..fc0d742 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,5 +51,12 @@ jobs: - name: Install composer dependencies run: composer install - - name: Run phpunit + # Work around https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/1286 + - name: Run phpunit (with coverage) + if: ${{ matrix.php == '8.4' }} run: vendor/bin/phpunit + + # Work around https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/1286 + - name: Run phpunit (no coverage) + if: ${{ matrix.php == '8.3' }} + run: vendor/bin/phpunit --no-coverage diff --git a/composer.json b/composer.json index 9bb545a..feeed47 100644 --- a/composer.json +++ b/composer.json @@ -10,10 +10,10 @@ ], "license": "MIT", "require": { - "mediawiki/mediawiki-codesniffer": "46.0.0", - "phpcsstandards/phpcsextra": "1.2.1", + "mediawiki/mediawiki-codesniffer": "51.0.1", + "phpcsstandards/phpcsextra": "1.5.0", "slevomat/coding-standard": "8.15.0", - "squizlabs/php_codesniffer": "3.11.3" + "squizlabs/php_codesniffer": "3.13.6" }, "require-dev": { "phpunit/phpunit": "^12.0", diff --git a/docs/rules.txt b/docs/rules.txt index 6422926..29d853e 100644 --- a/docs/rules.txt +++ b/docs/rules.txt @@ -1,11 +1,11 @@ -The DanielEScherzer standard contains 166 sniffs +The DanielEScherzer standard contains 168 sniffs CommonPhpcs (1 sniff) --------------------- CommonPhpcs.Attributes.AttributeAlignment -Generic (43 sniffs) +Generic (42 sniffs) ------------------- Generic.Arrays.DisallowLongArraySyntax Generic.Classes.DuplicateClassName @@ -28,7 +28,6 @@ Generic (43 sniffs) Generic.Formatting.MultipleStatementAlignment Generic.Formatting.SpaceAfterCast Generic.Formatting.SpaceAfterNot - Generic.Functions.CallTimePassByReference Generic.Functions.FunctionCallArgumentSpacing Generic.Functions.OpeningFunctionBraceKernighanRitchie Generic.NamingConventions.ConstructorName @@ -51,7 +50,7 @@ Generic (43 sniffs) Generic.WhiteSpace.ScopeIndent Generic.WhiteSpace.SpreadOperatorSpacingAfter -MediaWiki (58 sniffs) +MediaWiki (61 sniffs) --------------------- MediaWiki.AlternativeSyntax.LeadingZeroInFloat MediaWiki.AlternativeSyntax.UnicodeEscape @@ -60,7 +59,10 @@ MediaWiki (58 sniffs) MediaWiki.Classes.FullQualifiedClassName MediaWiki.Classes.UnsortedUseStatements MediaWiki.Classes.UnusedUseStatement + MediaWiki.Commenting.ClassAnnotations + MediaWiki.Commenting.ClassDocumentation MediaWiki.Commenting.ClassLevelLicense + MediaWiki.Commenting.CommentBeforeClass MediaWiki.Commenting.DocComment MediaWiki.Commenting.EmptyTag MediaWiki.Commenting.FunctionAnnotations @@ -68,6 +70,7 @@ MediaWiki (58 sniffs) MediaWiki.Commenting.IllegalSingleLineComment MediaWiki.Commenting.LicenseComment MediaWiki.Commenting.PhpunitAnnotations + MediaWiki.Commenting.PropertyAnnotations MediaWiki.Commenting.PropertyDocumentation MediaWiki.Commenting.RedundantVarName MediaWiki.Commenting.VariadicArgument @@ -75,6 +78,7 @@ MediaWiki (58 sniffs) MediaWiki.ExtraCharacters.ParenthesesAroundKeyword MediaWiki.Files.ClassMatchesFilename MediaWiki.NamingConventions.LowerCamelFunctionsName + MediaWiki.NamingConventions.NamespaceName MediaWiki.NamingConventions.PrefixedGlobalFunctions MediaWiki.NamingConventions.ValidGlobalName MediaWiki.PHPUnit.AssertCount @@ -89,12 +93,10 @@ MediaWiki (58 sniffs) MediaWiki.PHPUnit.SpecificAssertions MediaWiki.Usage.AssignmentInReturn MediaWiki.Usage.DirUsage - MediaWiki.Usage.FinalPrivate MediaWiki.Usage.ForbiddenFunctions MediaWiki.Usage.InArrayUsage MediaWiki.Usage.IsNull MediaWiki.Usage.MagicConstantClosure - MediaWiki.Usage.NestedFunctions MediaWiki.Usage.NestedInlineTernary MediaWiki.Usage.NullableType MediaWiki.Usage.PlusStringConcat @@ -159,10 +161,10 @@ Squiz (22 sniffs) Squiz.Classes.SelfMemberReference Squiz.Classes.ValidClassName Squiz.ControlStructures.ControlSignature - Squiz.CSS.SemicolonSpacing Squiz.Functions.FunctionDeclarationArgumentSpacing Squiz.Functions.FunctionDuplicateArgument Squiz.Operators.ValidLogicalOperators + Squiz.PHP.InnerFunctions Squiz.PHP.NonExecutableCode Squiz.Scope.MemberVarScope Squiz.Scope.MethodScope diff --git a/src/Tests/data/AttributeAlignment/wrong.php b/src/Tests/data/AttributeAlignment/wrong.php index ded6643..cee3fbe 100644 --- a/src/Tests/data/AttributeAlignment/wrong.php +++ b/src/Tests/data/AttributeAlignment/wrong.php @@ -68,3 +68,7 @@ function demo8() { // Not covered #[MyAttribute] function demo9() { } + +#[First] #[Second] +function demo10() { +} diff --git a/src/Tests/data/AttributeAlignment/wrong.php.fixed b/src/Tests/data/AttributeAlignment/wrong.php.fixed index 5f0c4e9..ac0527b 100644 --- a/src/Tests/data/AttributeAlignment/wrong.php.fixed +++ b/src/Tests/data/AttributeAlignment/wrong.php.fixed @@ -68,3 +68,7 @@ function demo8() { // Not covered #[MyAttribute] function demo9() { } + +#[First] #[Second] +function demo10() { +} diff --git a/src/Tests/data/AttributeAlignment/wrong.report b/src/Tests/data/AttributeAlignment/wrong.report index ffbfb85..39333f8 100644 --- a/src/Tests/data/AttributeAlignment/wrong.report +++ b/src/Tests/data/AttributeAlignment/wrong.report @@ -1,6 +1,6 @@ FILE: {dir}/data/AttributeAlignment/wrong.php -------------------------------------------------------------------------------- -FOUND 0 ERRORS AND 16 WARNINGS AFFECTING 16 LINES +FOUND 0 ERRORS AND 17 WARNINGS AFFECTING 17 LINES -------------------------------------------------------------------------------- 8 | WARNING | [x] Attributes should be aligned with their targets | | (CommonPhpcs.Attributes.AttributeAlignment.NotAligned) @@ -34,6 +34,8 @@ FOUND 0 ERRORS AND 16 WARNINGS AFFECTING 16 LINES | | (CommonPhpcs.Attributes.AttributeAlignment.NotAligned) 64 | WARNING | [ ] Attributes should be aligned with their targets | | (CommonPhpcs.Attributes.AttributeAlignment.NotAligned) + 72 | WARNING | [ ] Attributes should be aligned with their targets + | | (CommonPhpcs.Attributes.AttributeAlignment.NotAligned) -------------------------------------------------------------------------------- PHPCBF CAN FIX THE 14 MARKED SNIFF VIOLATIONS AUTOMATICALLY -------------------------------------------------------------------------------- diff --git a/src/Tests/data/ExtraSniffsApplied.php.fixed b/src/Tests/data/ExtraSniffsApplied.php.fixed index 958efa3..b0b6dcb 100644 --- a/src/Tests/data/ExtraSniffsApplied.php.fixed +++ b/src/Tests/data/ExtraSniffsApplied.php.fixed @@ -5,8 +5,7 @@ function usesDeprecated() { utf8_encode( "foo" ); } -#[FirstAttrib] -#[SecondAttrib] +#[FirstAttrib] #[SecondAttrib] function doNothing() { $a = true; } diff --git a/src/Tests/data/ExtraSniffsApplied.report b/src/Tests/data/ExtraSniffsApplied.report index 17f93e3..f7af4c3 100644 --- a/src/Tests/data/ExtraSniffsApplied.report +++ b/src/Tests/data/ExtraSniffsApplied.report @@ -1,11 +1,13 @@ FILE: {dir}/data/ExtraSniffsApplied.php -------------------------------------------------------------------------------- -FOUND 2 ERRORS AFFECTING 2 LINES --------------------------------------------------------------------------------- - 5 | ERROR | [ ] Function utf8_encode() has been deprecated - | | (Generic.PHP.DeprecatedFunctions.Deprecated) - 8 | ERROR | [x] 2 attributes are joined. - | | (SlevomatCodingStandard.Attributes.DisallowAttributesJoining.DisallowedAttributesJoining) +FOUND 2 ERRORS AND 1 WARNING AFFECTING 2 LINES +-------------------------------------------------------------------------------- + 5 | WARNING | [ ] utf8_encode should not be used + | | (MediaWiki.Usage.ForbiddenFunctions.utf8_encode) + 5 | ERROR | [ ] Function utf8_encode() has been deprecated + | | (Generic.PHP.DeprecatedFunctions.Deprecated) + 8 | ERROR | [x] 2 attributes are joined. + | | (SlevomatCodingStandard.Attributes.DisallowAttributesJoining.DisallowedAttributesJoining) -------------------------------------------------------------------------------- PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY -------------------------------------------------------------------------------- diff --git a/src/ruleset.xml b/src/ruleset.xml index d310f11..a8c0775 100644 --- a/src/ruleset.xml +++ b/src/ruleset.xml @@ -21,7 +21,7 @@ - + @@ -29,7 +29,7 @@ - +