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
9 changes: 8 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
16 changes: 9 additions & 7 deletions docs/rules.txt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -60,21 +59,26 @@ 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
MediaWiki.Commenting.FunctionComment
MediaWiki.Commenting.IllegalSingleLineComment
MediaWiki.Commenting.LicenseComment
MediaWiki.Commenting.PhpunitAnnotations
MediaWiki.Commenting.PropertyAnnotations
MediaWiki.Commenting.PropertyDocumentation
MediaWiki.Commenting.RedundantVarName
MediaWiki.Commenting.VariadicArgument
MediaWiki.ControlStructures.MissingElseBetweenBrackets
MediaWiki.ExtraCharacters.ParenthesesAroundKeyword
MediaWiki.Files.ClassMatchesFilename
MediaWiki.NamingConventions.LowerCamelFunctionsName
MediaWiki.NamingConventions.NamespaceName
MediaWiki.NamingConventions.PrefixedGlobalFunctions
MediaWiki.NamingConventions.ValidGlobalName
MediaWiki.PHPUnit.AssertCount
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/Tests/data/AttributeAlignment/wrong.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,7 @@ function demo8() {
// Not covered
#[MyAttribute] function demo9() {
}

#[First] #[Second]
function demo10() {
}
4 changes: 4 additions & 0 deletions src/Tests/data/AttributeAlignment/wrong.php.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,7 @@ function demo8() {
// Not covered
#[MyAttribute] function demo9() {
}

#[First] #[Second]
function demo10() {
}
4 changes: 3 additions & 1 deletion src/Tests/data/AttributeAlignment/wrong.report
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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
--------------------------------------------------------------------------------
3 changes: 1 addition & 2 deletions src/Tests/data/ExtraSniffsApplied.php.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ function usesDeprecated() {
utf8_encode( "foo" );
}

#[FirstAttrib]
#[SecondAttrib]
#[FirstAttrib] #[SecondAttrib]
function doNothing() {
$a = true;
}
14 changes: 8 additions & 6 deletions src/Tests/data/ExtraSniffsApplied.report
Original file line number Diff line number Diff line change
@@ -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
--------------------------------------------------------------------------------
4 changes: 2 additions & 2 deletions src/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
<!-- With no prefixes configured, sniff will do nothing but be available
if I want to enable it for a project -->
<properties>
<property name="allowedPrefixes" type="array" value="" />
<property name="allowedPrefixes" type="array"/>
</properties>
</rule>

<rule ref="MediaWiki.NamingConventions.PrefixedGlobalFunctions">
<!-- With no prefixes configured, sniff will do nothing but be available
if I want to enable it for a project -->
<properties>
<property name="allowedPrefixes" type="array" value="" />
<property name="allowedPrefixes" type="array"/>
</properties>
</rule>

Expand Down
Loading