From 4b0241e06ad025bae477bfdf587e61b8383ab305 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 13 Dec 2025 14:38:57 +0000 Subject: [PATCH 1/2] Sniffs: add custom parameter tests for 10 more sniffs Add custom tests for sniff options: - SlevomatCodingStandard.Variables.UnusedVariable - SlevomatCodingStandard.Classes.TraitUseSpacing - SlevomatCodingStandard.Classes.ParentCallSpacing - SlevomatCodingStandard.Commenting.DocCommentSpacing - SlevomatCodingStandard.Namespaces.NamespaceSpacing - SlevomatCodingStandard.Operators.SpreadOperatorSpacing - SlevomatCodingStandard.PHP.ReferenceSpacing - SlevomatCodingStandard.Functions.ArrowFunctionDeclaration - SlevomatCodingStandard.Classes.ModernClassNameReference - SlevomatCodingStandard.ControlStructures.RequireNullCoalesceEqualOperator --- .../ModernClassNameReference/custom1.php | 21 +++++++++++ .../custom1.ruleset.xml | 8 +++++ .../custom1.snapshot.json | 13 +++++++ .../ModernClassNameReference/custom2.php | 21 +++++++++++ .../custom2.ruleset.xml | 8 +++++ .../custom2.snapshot.json | 13 +++++++ .../ParentCallSpacing/custom1.php | 25 +++++++++++++ .../ParentCallSpacing/custom1.ruleset.xml | 9 +++++ .../ParentCallSpacing/custom1.snapshot.json | 13 +++++++ .../ParentCallSpacing/custom2.php | 29 +++++++++++++++ .../ParentCallSpacing/custom2.ruleset.xml | 9 +++++ .../ParentCallSpacing/custom2.snapshot.json | 13 +++++++ .../TraitUseSpacing/custom1.php | 16 +++++++++ .../TraitUseSpacing/custom1.ruleset.xml | 10 ++++++ .../TraitUseSpacing/custom1.snapshot.json | 13 +++++++ .../TraitUseSpacing/custom2.php | 35 +++++++++++++++++++ .../TraitUseSpacing/custom2.ruleset.xml | 10 ++++++ .../TraitUseSpacing/custom2.snapshot.json | 13 +++++++ .../DocCommentSpacing/custom1.php | 19 ++++++++++ .../DocCommentSpacing/custom1.ruleset.xml | 8 +++++ .../DocCommentSpacing/custom1.snapshot.json | 13 +++++++ .../DocCommentSpacing/custom2.php | 22 ++++++++++++ .../DocCommentSpacing/custom2.ruleset.xml | 9 +++++ .../DocCommentSpacing/custom2.snapshot.json | 13 +++++++ .../custom1.php | 19 ++++++++++ .../custom1.ruleset.xml | 8 +++++ .../custom1.snapshot.json | 13 +++++++ .../custom2.php | 21 +++++++++++ .../custom2.ruleset.xml | 8 +++++ .../custom2.snapshot.json | 13 +++++++ .../ArrowFunctionDeclaration/custom1.php | 16 +++++++++ .../custom1.ruleset.xml | 10 ++++++ .../custom1.snapshot.json | 13 +++++++ .../ArrowFunctionDeclaration/custom2.php | 18 ++++++++++ .../custom2.ruleset.xml | 8 +++++ .../custom2.snapshot.json | 13 +++++++ .../NamespaceSpacing/custom1.php | 8 +++++ .../NamespaceSpacing/custom1.ruleset.xml | 9 +++++ .../NamespaceSpacing/custom1.snapshot.json | 13 +++++++ .../NamespaceSpacing/custom2.php | 12 +++++++ .../NamespaceSpacing/custom2.ruleset.xml | 9 +++++ .../NamespaceSpacing/custom2.snapshot.json | 13 +++++++ .../SpreadOperatorSpacing/custom1.php | 21 +++++++++++ .../SpreadOperatorSpacing/custom1.ruleset.xml | 8 +++++ .../custom1.snapshot.json | 13 +++++++ .../SpreadOperatorSpacing/custom2.php | 21 +++++++++++ .../SpreadOperatorSpacing/custom2.ruleset.xml | 8 +++++ .../custom2.snapshot.json | 13 +++++++ .../ReferenceSpacing/custom1.php | 19 ++++++++++ .../ReferenceSpacing/custom1.ruleset.xml | 8 +++++ .../ReferenceSpacing/custom1.snapshot.json | 13 +++++++ .../ReferenceSpacing/custom2.php | 19 ++++++++++ .../ReferenceSpacing/custom2.ruleset.xml | 8 +++++ .../ReferenceSpacing/custom2.snapshot.json | 13 +++++++ .../UnusedVariable/custom1.php | 16 +++++++++ .../UnusedVariable/custom1.ruleset.xml | 8 +++++ .../UnusedVariable/custom1.snapshot.json | 13 +++++++ .../UnusedVariable/custom2.php | 16 +++++++++ .../UnusedVariable/custom2.ruleset.xml | 8 +++++ .../UnusedVariable/custom2.snapshot.json | 21 +++++++++++ 60 files changed, 833 insertions(+) create mode 100644 tests/Sniffs/SlevomatCodingStandard.Classes/ModernClassNameReference/custom1.php create mode 100644 tests/Sniffs/SlevomatCodingStandard.Classes/ModernClassNameReference/custom1.ruleset.xml create mode 100644 tests/Sniffs/SlevomatCodingStandard.Classes/ModernClassNameReference/custom1.snapshot.json create mode 100644 tests/Sniffs/SlevomatCodingStandard.Classes/ModernClassNameReference/custom2.php create mode 100644 tests/Sniffs/SlevomatCodingStandard.Classes/ModernClassNameReference/custom2.ruleset.xml create mode 100644 tests/Sniffs/SlevomatCodingStandard.Classes/ModernClassNameReference/custom2.snapshot.json create mode 100644 tests/Sniffs/SlevomatCodingStandard.Classes/ParentCallSpacing/custom1.php create mode 100644 tests/Sniffs/SlevomatCodingStandard.Classes/ParentCallSpacing/custom1.ruleset.xml create mode 100644 tests/Sniffs/SlevomatCodingStandard.Classes/ParentCallSpacing/custom1.snapshot.json create mode 100644 tests/Sniffs/SlevomatCodingStandard.Classes/ParentCallSpacing/custom2.php create mode 100644 tests/Sniffs/SlevomatCodingStandard.Classes/ParentCallSpacing/custom2.ruleset.xml create mode 100644 tests/Sniffs/SlevomatCodingStandard.Classes/ParentCallSpacing/custom2.snapshot.json create mode 100644 tests/Sniffs/SlevomatCodingStandard.Classes/TraitUseSpacing/custom1.php create mode 100644 tests/Sniffs/SlevomatCodingStandard.Classes/TraitUseSpacing/custom1.ruleset.xml create mode 100644 tests/Sniffs/SlevomatCodingStandard.Classes/TraitUseSpacing/custom1.snapshot.json create mode 100644 tests/Sniffs/SlevomatCodingStandard.Classes/TraitUseSpacing/custom2.php create mode 100644 tests/Sniffs/SlevomatCodingStandard.Classes/TraitUseSpacing/custom2.ruleset.xml create mode 100644 tests/Sniffs/SlevomatCodingStandard.Classes/TraitUseSpacing/custom2.snapshot.json create mode 100644 tests/Sniffs/SlevomatCodingStandard.Commenting/DocCommentSpacing/custom1.php create mode 100644 tests/Sniffs/SlevomatCodingStandard.Commenting/DocCommentSpacing/custom1.ruleset.xml create mode 100644 tests/Sniffs/SlevomatCodingStandard.Commenting/DocCommentSpacing/custom1.snapshot.json create mode 100644 tests/Sniffs/SlevomatCodingStandard.Commenting/DocCommentSpacing/custom2.php create mode 100644 tests/Sniffs/SlevomatCodingStandard.Commenting/DocCommentSpacing/custom2.ruleset.xml create mode 100644 tests/Sniffs/SlevomatCodingStandard.Commenting/DocCommentSpacing/custom2.snapshot.json create mode 100644 tests/Sniffs/SlevomatCodingStandard.ControlStructures/RequireNullCoalesceEqualOperator/custom1.php create mode 100644 tests/Sniffs/SlevomatCodingStandard.ControlStructures/RequireNullCoalesceEqualOperator/custom1.ruleset.xml create mode 100644 tests/Sniffs/SlevomatCodingStandard.ControlStructures/RequireNullCoalesceEqualOperator/custom1.snapshot.json create mode 100644 tests/Sniffs/SlevomatCodingStandard.ControlStructures/RequireNullCoalesceEqualOperator/custom2.php create mode 100644 tests/Sniffs/SlevomatCodingStandard.ControlStructures/RequireNullCoalesceEqualOperator/custom2.ruleset.xml create mode 100644 tests/Sniffs/SlevomatCodingStandard.ControlStructures/RequireNullCoalesceEqualOperator/custom2.snapshot.json create mode 100644 tests/Sniffs/SlevomatCodingStandard.Functions/ArrowFunctionDeclaration/custom1.php create mode 100644 tests/Sniffs/SlevomatCodingStandard.Functions/ArrowFunctionDeclaration/custom1.ruleset.xml create mode 100644 tests/Sniffs/SlevomatCodingStandard.Functions/ArrowFunctionDeclaration/custom1.snapshot.json create mode 100644 tests/Sniffs/SlevomatCodingStandard.Functions/ArrowFunctionDeclaration/custom2.php create mode 100644 tests/Sniffs/SlevomatCodingStandard.Functions/ArrowFunctionDeclaration/custom2.ruleset.xml create mode 100644 tests/Sniffs/SlevomatCodingStandard.Functions/ArrowFunctionDeclaration/custom2.snapshot.json create mode 100644 tests/Sniffs/SlevomatCodingStandard.Namespaces/NamespaceSpacing/custom1.php create mode 100644 tests/Sniffs/SlevomatCodingStandard.Namespaces/NamespaceSpacing/custom1.ruleset.xml create mode 100644 tests/Sniffs/SlevomatCodingStandard.Namespaces/NamespaceSpacing/custom1.snapshot.json create mode 100644 tests/Sniffs/SlevomatCodingStandard.Namespaces/NamespaceSpacing/custom2.php create mode 100644 tests/Sniffs/SlevomatCodingStandard.Namespaces/NamespaceSpacing/custom2.ruleset.xml create mode 100644 tests/Sniffs/SlevomatCodingStandard.Namespaces/NamespaceSpacing/custom2.snapshot.json create mode 100644 tests/Sniffs/SlevomatCodingStandard.Operators/SpreadOperatorSpacing/custom1.php create mode 100644 tests/Sniffs/SlevomatCodingStandard.Operators/SpreadOperatorSpacing/custom1.ruleset.xml create mode 100644 tests/Sniffs/SlevomatCodingStandard.Operators/SpreadOperatorSpacing/custom1.snapshot.json create mode 100644 tests/Sniffs/SlevomatCodingStandard.Operators/SpreadOperatorSpacing/custom2.php create mode 100644 tests/Sniffs/SlevomatCodingStandard.Operators/SpreadOperatorSpacing/custom2.ruleset.xml create mode 100644 tests/Sniffs/SlevomatCodingStandard.Operators/SpreadOperatorSpacing/custom2.snapshot.json create mode 100644 tests/Sniffs/SlevomatCodingStandard.PHP/ReferenceSpacing/custom1.php create mode 100644 tests/Sniffs/SlevomatCodingStandard.PHP/ReferenceSpacing/custom1.ruleset.xml create mode 100644 tests/Sniffs/SlevomatCodingStandard.PHP/ReferenceSpacing/custom1.snapshot.json create mode 100644 tests/Sniffs/SlevomatCodingStandard.PHP/ReferenceSpacing/custom2.php create mode 100644 tests/Sniffs/SlevomatCodingStandard.PHP/ReferenceSpacing/custom2.ruleset.xml create mode 100644 tests/Sniffs/SlevomatCodingStandard.PHP/ReferenceSpacing/custom2.snapshot.json create mode 100644 tests/Sniffs/SlevomatCodingStandard.Variables/UnusedVariable/custom1.php create mode 100644 tests/Sniffs/SlevomatCodingStandard.Variables/UnusedVariable/custom1.ruleset.xml create mode 100644 tests/Sniffs/SlevomatCodingStandard.Variables/UnusedVariable/custom1.snapshot.json create mode 100644 tests/Sniffs/SlevomatCodingStandard.Variables/UnusedVariable/custom2.php create mode 100644 tests/Sniffs/SlevomatCodingStandard.Variables/UnusedVariable/custom2.ruleset.xml create mode 100644 tests/Sniffs/SlevomatCodingStandard.Variables/UnusedVariable/custom2.snapshot.json diff --git a/tests/Sniffs/SlevomatCodingStandard.Classes/ModernClassNameReference/custom1.php b/tests/Sniffs/SlevomatCodingStandard.Classes/ModernClassNameReference/custom1.php new file mode 100644 index 0000000..72ecf57 --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.Classes/ModernClassNameReference/custom1.php @@ -0,0 +1,21 @@ + + + + + + + + diff --git a/tests/Sniffs/SlevomatCodingStandard.Classes/ModernClassNameReference/custom1.snapshot.json b/tests/Sniffs/SlevomatCodingStandard.Classes/ModernClassNameReference/custom1.snapshot.json new file mode 100644 index 0000000..c66e2fa --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.Classes/ModernClassNameReference/custom1.snapshot.json @@ -0,0 +1,13 @@ +{ + "totals": { + "errors": 0, + "warnings": 0 + }, + "files": { + "custom1.php": { + "errors": 0, + "warnings": 0, + "messages": [] + } + } +} diff --git a/tests/Sniffs/SlevomatCodingStandard.Classes/ModernClassNameReference/custom2.php b/tests/Sniffs/SlevomatCodingStandard.Classes/ModernClassNameReference/custom2.php new file mode 100644 index 0000000..6a2f7b6 --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.Classes/ModernClassNameReference/custom2.php @@ -0,0 +1,21 @@ + + + + + + + + diff --git a/tests/Sniffs/SlevomatCodingStandard.Classes/ModernClassNameReference/custom2.snapshot.json b/tests/Sniffs/SlevomatCodingStandard.Classes/ModernClassNameReference/custom2.snapshot.json new file mode 100644 index 0000000..6e75177 --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.Classes/ModernClassNameReference/custom2.snapshot.json @@ -0,0 +1,13 @@ +{ + "totals": { + "errors": 0, + "warnings": 0 + }, + "files": { + "custom2.php": { + "errors": 0, + "warnings": 0, + "messages": [] + } + } +} diff --git a/tests/Sniffs/SlevomatCodingStandard.Classes/ParentCallSpacing/custom1.php b/tests/Sniffs/SlevomatCodingStandard.Classes/ParentCallSpacing/custom1.php new file mode 100644 index 0000000..8a5116b --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.Classes/ParentCallSpacing/custom1.php @@ -0,0 +1,25 @@ + + + + + + + + + diff --git a/tests/Sniffs/SlevomatCodingStandard.Classes/ParentCallSpacing/custom1.snapshot.json b/tests/Sniffs/SlevomatCodingStandard.Classes/ParentCallSpacing/custom1.snapshot.json new file mode 100644 index 0000000..c66e2fa --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.Classes/ParentCallSpacing/custom1.snapshot.json @@ -0,0 +1,13 @@ +{ + "totals": { + "errors": 0, + "warnings": 0 + }, + "files": { + "custom1.php": { + "errors": 0, + "warnings": 0, + "messages": [] + } + } +} diff --git a/tests/Sniffs/SlevomatCodingStandard.Classes/ParentCallSpacing/custom2.php b/tests/Sniffs/SlevomatCodingStandard.Classes/ParentCallSpacing/custom2.php new file mode 100644 index 0000000..58b282b --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.Classes/ParentCallSpacing/custom2.php @@ -0,0 +1,29 @@ + + + + + + + + + diff --git a/tests/Sniffs/SlevomatCodingStandard.Classes/ParentCallSpacing/custom2.snapshot.json b/tests/Sniffs/SlevomatCodingStandard.Classes/ParentCallSpacing/custom2.snapshot.json new file mode 100644 index 0000000..6e75177 --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.Classes/ParentCallSpacing/custom2.snapshot.json @@ -0,0 +1,13 @@ +{ + "totals": { + "errors": 0, + "warnings": 0 + }, + "files": { + "custom2.php": { + "errors": 0, + "warnings": 0, + "messages": [] + } + } +} diff --git a/tests/Sniffs/SlevomatCodingStandard.Classes/TraitUseSpacing/custom1.php b/tests/Sniffs/SlevomatCodingStandard.Classes/TraitUseSpacing/custom1.php new file mode 100644 index 0000000..0940770 --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.Classes/TraitUseSpacing/custom1.php @@ -0,0 +1,16 @@ + + + + + + + + + + diff --git a/tests/Sniffs/SlevomatCodingStandard.Classes/TraitUseSpacing/custom1.snapshot.json b/tests/Sniffs/SlevomatCodingStandard.Classes/TraitUseSpacing/custom1.snapshot.json new file mode 100644 index 0000000..c66e2fa --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.Classes/TraitUseSpacing/custom1.snapshot.json @@ -0,0 +1,13 @@ +{ + "totals": { + "errors": 0, + "warnings": 0 + }, + "files": { + "custom1.php": { + "errors": 0, + "warnings": 0, + "messages": [] + } + } +} diff --git a/tests/Sniffs/SlevomatCodingStandard.Classes/TraitUseSpacing/custom2.php b/tests/Sniffs/SlevomatCodingStandard.Classes/TraitUseSpacing/custom2.php new file mode 100644 index 0000000..1d50ce8 --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.Classes/TraitUseSpacing/custom2.php @@ -0,0 +1,35 @@ + + + + + + + + + + diff --git a/tests/Sniffs/SlevomatCodingStandard.Classes/TraitUseSpacing/custom2.snapshot.json b/tests/Sniffs/SlevomatCodingStandard.Classes/TraitUseSpacing/custom2.snapshot.json new file mode 100644 index 0000000..6e75177 --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.Classes/TraitUseSpacing/custom2.snapshot.json @@ -0,0 +1,13 @@ +{ + "totals": { + "errors": 0, + "warnings": 0 + }, + "files": { + "custom2.php": { + "errors": 0, + "warnings": 0, + "messages": [] + } + } +} diff --git a/tests/Sniffs/SlevomatCodingStandard.Commenting/DocCommentSpacing/custom1.php b/tests/Sniffs/SlevomatCodingStandard.Commenting/DocCommentSpacing/custom1.php new file mode 100644 index 0000000..f27ade8 --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.Commenting/DocCommentSpacing/custom1.php @@ -0,0 +1,19 @@ + + + + + + + + diff --git a/tests/Sniffs/SlevomatCodingStandard.Commenting/DocCommentSpacing/custom1.snapshot.json b/tests/Sniffs/SlevomatCodingStandard.Commenting/DocCommentSpacing/custom1.snapshot.json new file mode 100644 index 0000000..c66e2fa --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.Commenting/DocCommentSpacing/custom1.snapshot.json @@ -0,0 +1,13 @@ +{ + "totals": { + "errors": 0, + "warnings": 0 + }, + "files": { + "custom1.php": { + "errors": 0, + "warnings": 0, + "messages": [] + } + } +} diff --git a/tests/Sniffs/SlevomatCodingStandard.Commenting/DocCommentSpacing/custom2.php b/tests/Sniffs/SlevomatCodingStandard.Commenting/DocCommentSpacing/custom2.php new file mode 100644 index 0000000..2ed9fc3 --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.Commenting/DocCommentSpacing/custom2.php @@ -0,0 +1,22 @@ + + + + + + + + + diff --git a/tests/Sniffs/SlevomatCodingStandard.Commenting/DocCommentSpacing/custom2.snapshot.json b/tests/Sniffs/SlevomatCodingStandard.Commenting/DocCommentSpacing/custom2.snapshot.json new file mode 100644 index 0000000..6e75177 --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.Commenting/DocCommentSpacing/custom2.snapshot.json @@ -0,0 +1,13 @@ +{ + "totals": { + "errors": 0, + "warnings": 0 + }, + "files": { + "custom2.php": { + "errors": 0, + "warnings": 0, + "messages": [] + } + } +} diff --git a/tests/Sniffs/SlevomatCodingStandard.ControlStructures/RequireNullCoalesceEqualOperator/custom1.php b/tests/Sniffs/SlevomatCodingStandard.ControlStructures/RequireNullCoalesceEqualOperator/custom1.php new file mode 100644 index 0000000..16a36ac --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.ControlStructures/RequireNullCoalesceEqualOperator/custom1.php @@ -0,0 +1,19 @@ + + + + + + + + diff --git a/tests/Sniffs/SlevomatCodingStandard.ControlStructures/RequireNullCoalesceEqualOperator/custom1.snapshot.json b/tests/Sniffs/SlevomatCodingStandard.ControlStructures/RequireNullCoalesceEqualOperator/custom1.snapshot.json new file mode 100644 index 0000000..c66e2fa --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.ControlStructures/RequireNullCoalesceEqualOperator/custom1.snapshot.json @@ -0,0 +1,13 @@ +{ + "totals": { + "errors": 0, + "warnings": 0 + }, + "files": { + "custom1.php": { + "errors": 0, + "warnings": 0, + "messages": [] + } + } +} diff --git a/tests/Sniffs/SlevomatCodingStandard.ControlStructures/RequireNullCoalesceEqualOperator/custom2.php b/tests/Sniffs/SlevomatCodingStandard.ControlStructures/RequireNullCoalesceEqualOperator/custom2.php new file mode 100644 index 0000000..1ad8090 --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.ControlStructures/RequireNullCoalesceEqualOperator/custom2.php @@ -0,0 +1,21 @@ + + + + + + + + diff --git a/tests/Sniffs/SlevomatCodingStandard.ControlStructures/RequireNullCoalesceEqualOperator/custom2.snapshot.json b/tests/Sniffs/SlevomatCodingStandard.ControlStructures/RequireNullCoalesceEqualOperator/custom2.snapshot.json new file mode 100644 index 0000000..6e75177 --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.ControlStructures/RequireNullCoalesceEqualOperator/custom2.snapshot.json @@ -0,0 +1,13 @@ +{ + "totals": { + "errors": 0, + "warnings": 0 + }, + "files": { + "custom2.php": { + "errors": 0, + "warnings": 0, + "messages": [] + } + } +} diff --git a/tests/Sniffs/SlevomatCodingStandard.Functions/ArrowFunctionDeclaration/custom1.php b/tests/Sniffs/SlevomatCodingStandard.Functions/ArrowFunctionDeclaration/custom1.php new file mode 100644 index 0000000..35545e2 --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.Functions/ArrowFunctionDeclaration/custom1.php @@ -0,0 +1,16 @@ +$x * 2; + + $add = fn(int $a, int $b): int=>$a + $b; + } + +} diff --git a/tests/Sniffs/SlevomatCodingStandard.Functions/ArrowFunctionDeclaration/custom1.ruleset.xml b/tests/Sniffs/SlevomatCodingStandard.Functions/ArrowFunctionDeclaration/custom1.ruleset.xml new file mode 100644 index 0000000..b356d67 --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.Functions/ArrowFunctionDeclaration/custom1.ruleset.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/tests/Sniffs/SlevomatCodingStandard.Functions/ArrowFunctionDeclaration/custom1.snapshot.json b/tests/Sniffs/SlevomatCodingStandard.Functions/ArrowFunctionDeclaration/custom1.snapshot.json new file mode 100644 index 0000000..c66e2fa --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.Functions/ArrowFunctionDeclaration/custom1.snapshot.json @@ -0,0 +1,13 @@ +{ + "totals": { + "errors": 0, + "warnings": 0 + }, + "files": { + "custom1.php": { + "errors": 0, + "warnings": 0, + "messages": [] + } + } +} diff --git a/tests/Sniffs/SlevomatCodingStandard.Functions/ArrowFunctionDeclaration/custom2.php b/tests/Sniffs/SlevomatCodingStandard.Functions/ArrowFunctionDeclaration/custom2.php new file mode 100644 index 0000000..57432e9 --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.Functions/ArrowFunctionDeclaration/custom2.php @@ -0,0 +1,18 @@ + + $x * 2; + + $complexFn = fn (int $a, int $b, int $c): int => + $a + $b + $c; + } + +} diff --git a/tests/Sniffs/SlevomatCodingStandard.Functions/ArrowFunctionDeclaration/custom2.ruleset.xml b/tests/Sniffs/SlevomatCodingStandard.Functions/ArrowFunctionDeclaration/custom2.ruleset.xml new file mode 100644 index 0000000..7d3e23b --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.Functions/ArrowFunctionDeclaration/custom2.ruleset.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/tests/Sniffs/SlevomatCodingStandard.Functions/ArrowFunctionDeclaration/custom2.snapshot.json b/tests/Sniffs/SlevomatCodingStandard.Functions/ArrowFunctionDeclaration/custom2.snapshot.json new file mode 100644 index 0000000..6e75177 --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.Functions/ArrowFunctionDeclaration/custom2.snapshot.json @@ -0,0 +1,13 @@ +{ + "totals": { + "errors": 0, + "warnings": 0 + }, + "files": { + "custom2.php": { + "errors": 0, + "warnings": 0, + "messages": [] + } + } +} diff --git a/tests/Sniffs/SlevomatCodingStandard.Namespaces/NamespaceSpacing/custom1.php b/tests/Sniffs/SlevomatCodingStandard.Namespaces/NamespaceSpacing/custom1.php new file mode 100644 index 0000000..cb9138c --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.Namespaces/NamespaceSpacing/custom1.php @@ -0,0 +1,8 @@ + + + + + + + + + diff --git a/tests/Sniffs/SlevomatCodingStandard.Namespaces/NamespaceSpacing/custom1.snapshot.json b/tests/Sniffs/SlevomatCodingStandard.Namespaces/NamespaceSpacing/custom1.snapshot.json new file mode 100644 index 0000000..c66e2fa --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.Namespaces/NamespaceSpacing/custom1.snapshot.json @@ -0,0 +1,13 @@ +{ + "totals": { + "errors": 0, + "warnings": 0 + }, + "files": { + "custom1.php": { + "errors": 0, + "warnings": 0, + "messages": [] + } + } +} diff --git a/tests/Sniffs/SlevomatCodingStandard.Namespaces/NamespaceSpacing/custom2.php b/tests/Sniffs/SlevomatCodingStandard.Namespaces/NamespaceSpacing/custom2.php new file mode 100644 index 0000000..af5ab06 --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.Namespaces/NamespaceSpacing/custom2.php @@ -0,0 +1,12 @@ + + + + + + + + + diff --git a/tests/Sniffs/SlevomatCodingStandard.Namespaces/NamespaceSpacing/custom2.snapshot.json b/tests/Sniffs/SlevomatCodingStandard.Namespaces/NamespaceSpacing/custom2.snapshot.json new file mode 100644 index 0000000..6e75177 --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.Namespaces/NamespaceSpacing/custom2.snapshot.json @@ -0,0 +1,13 @@ +{ + "totals": { + "errors": 0, + "warnings": 0 + }, + "files": { + "custom2.php": { + "errors": 0, + "warnings": 0, + "messages": [] + } + } +} diff --git a/tests/Sniffs/SlevomatCodingStandard.Operators/SpreadOperatorSpacing/custom1.php b/tests/Sniffs/SlevomatCodingStandard.Operators/SpreadOperatorSpacing/custom1.php new file mode 100644 index 0000000..28222bb --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.Operators/SpreadOperatorSpacing/custom1.php @@ -0,0 +1,21 @@ +call(... $numbers); + } + + private function call(int ... $args): void + { + } + +} diff --git a/tests/Sniffs/SlevomatCodingStandard.Operators/SpreadOperatorSpacing/custom1.ruleset.xml b/tests/Sniffs/SlevomatCodingStandard.Operators/SpreadOperatorSpacing/custom1.ruleset.xml new file mode 100644 index 0000000..96a605a --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.Operators/SpreadOperatorSpacing/custom1.ruleset.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/tests/Sniffs/SlevomatCodingStandard.Operators/SpreadOperatorSpacing/custom1.snapshot.json b/tests/Sniffs/SlevomatCodingStandard.Operators/SpreadOperatorSpacing/custom1.snapshot.json new file mode 100644 index 0000000..c66e2fa --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.Operators/SpreadOperatorSpacing/custom1.snapshot.json @@ -0,0 +1,13 @@ +{ + "totals": { + "errors": 0, + "warnings": 0 + }, + "files": { + "custom1.php": { + "errors": 0, + "warnings": 0, + "messages": [] + } + } +} diff --git a/tests/Sniffs/SlevomatCodingStandard.Operators/SpreadOperatorSpacing/custom2.php b/tests/Sniffs/SlevomatCodingStandard.Operators/SpreadOperatorSpacing/custom2.php new file mode 100644 index 0000000..374eb64 --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.Operators/SpreadOperatorSpacing/custom2.php @@ -0,0 +1,21 @@ +call(...$numbers); + } + + private function call(int ...$args): void + { + } + +} diff --git a/tests/Sniffs/SlevomatCodingStandard.Operators/SpreadOperatorSpacing/custom2.ruleset.xml b/tests/Sniffs/SlevomatCodingStandard.Operators/SpreadOperatorSpacing/custom2.ruleset.xml new file mode 100644 index 0000000..05ea8d5 --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.Operators/SpreadOperatorSpacing/custom2.ruleset.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/tests/Sniffs/SlevomatCodingStandard.Operators/SpreadOperatorSpacing/custom2.snapshot.json b/tests/Sniffs/SlevomatCodingStandard.Operators/SpreadOperatorSpacing/custom2.snapshot.json new file mode 100644 index 0000000..6e75177 --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.Operators/SpreadOperatorSpacing/custom2.snapshot.json @@ -0,0 +1,13 @@ +{ + "totals": { + "errors": 0, + "warnings": 0 + }, + "files": { + "custom2.php": { + "errors": 0, + "warnings": 0, + "messages": [] + } + } +} diff --git a/tests/Sniffs/SlevomatCodingStandard.PHP/ReferenceSpacing/custom1.php b/tests/Sniffs/SlevomatCodingStandard.PHP/ReferenceSpacing/custom1.php new file mode 100644 index 0000000..e521c9c --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.PHP/ReferenceSpacing/custom1.php @@ -0,0 +1,19 @@ + + + + + + + + diff --git a/tests/Sniffs/SlevomatCodingStandard.PHP/ReferenceSpacing/custom1.snapshot.json b/tests/Sniffs/SlevomatCodingStandard.PHP/ReferenceSpacing/custom1.snapshot.json new file mode 100644 index 0000000..c66e2fa --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.PHP/ReferenceSpacing/custom1.snapshot.json @@ -0,0 +1,13 @@ +{ + "totals": { + "errors": 0, + "warnings": 0 + }, + "files": { + "custom1.php": { + "errors": 0, + "warnings": 0, + "messages": [] + } + } +} diff --git a/tests/Sniffs/SlevomatCodingStandard.PHP/ReferenceSpacing/custom2.php b/tests/Sniffs/SlevomatCodingStandard.PHP/ReferenceSpacing/custom2.php new file mode 100644 index 0000000..347743b --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.PHP/ReferenceSpacing/custom2.php @@ -0,0 +1,19 @@ + + + + + + + + diff --git a/tests/Sniffs/SlevomatCodingStandard.PHP/ReferenceSpacing/custom2.snapshot.json b/tests/Sniffs/SlevomatCodingStandard.PHP/ReferenceSpacing/custom2.snapshot.json new file mode 100644 index 0000000..6e75177 --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.PHP/ReferenceSpacing/custom2.snapshot.json @@ -0,0 +1,13 @@ +{ + "totals": { + "errors": 0, + "warnings": 0 + }, + "files": { + "custom2.php": { + "errors": 0, + "warnings": 0, + "messages": [] + } + } +} diff --git a/tests/Sniffs/SlevomatCodingStandard.Variables/UnusedVariable/custom1.php b/tests/Sniffs/SlevomatCodingStandard.Variables/UnusedVariable/custom1.php new file mode 100644 index 0000000..a3cf8c6 --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.Variables/UnusedVariable/custom1.php @@ -0,0 +1,16 @@ + 1, 'b' => 2]; + + foreach ($data as $key => $value) { + echo $key; + } + } + +} diff --git a/tests/Sniffs/SlevomatCodingStandard.Variables/UnusedVariable/custom1.ruleset.xml b/tests/Sniffs/SlevomatCodingStandard.Variables/UnusedVariable/custom1.ruleset.xml new file mode 100644 index 0000000..f6d92af --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.Variables/UnusedVariable/custom1.ruleset.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/tests/Sniffs/SlevomatCodingStandard.Variables/UnusedVariable/custom1.snapshot.json b/tests/Sniffs/SlevomatCodingStandard.Variables/UnusedVariable/custom1.snapshot.json new file mode 100644 index 0000000..c66e2fa --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.Variables/UnusedVariable/custom1.snapshot.json @@ -0,0 +1,13 @@ +{ + "totals": { + "errors": 0, + "warnings": 0 + }, + "files": { + "custom1.php": { + "errors": 0, + "warnings": 0, + "messages": [] + } + } +} diff --git a/tests/Sniffs/SlevomatCodingStandard.Variables/UnusedVariable/custom2.php b/tests/Sniffs/SlevomatCodingStandard.Variables/UnusedVariable/custom2.php new file mode 100644 index 0000000..5a8c49a --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.Variables/UnusedVariable/custom2.php @@ -0,0 +1,16 @@ + 1, 'b' => 2]; + + foreach ($data as $key => $value) { + echo $key; + } + } + +} diff --git a/tests/Sniffs/SlevomatCodingStandard.Variables/UnusedVariable/custom2.ruleset.xml b/tests/Sniffs/SlevomatCodingStandard.Variables/UnusedVariable/custom2.ruleset.xml new file mode 100644 index 0000000..980a126 --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.Variables/UnusedVariable/custom2.ruleset.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/tests/Sniffs/SlevomatCodingStandard.Variables/UnusedVariable/custom2.snapshot.json b/tests/Sniffs/SlevomatCodingStandard.Variables/UnusedVariable/custom2.snapshot.json new file mode 100644 index 0000000..98a1a7f --- /dev/null +++ b/tests/Sniffs/SlevomatCodingStandard.Variables/UnusedVariable/custom2.snapshot.json @@ -0,0 +1,21 @@ +{ + "totals": { + "errors": 1, + "warnings": 0 + }, + "files": { + "custom2.php": { + "errors": 1, + "warnings": 0, + "messages": [ + { + "line": 11, + "column": 29, + "type": "ERROR", + "source": "SlevomatCodingStandard.Variables.UnusedVariable.UnusedVariable", + "message": "Unused variable $value." + } + ] + } + } +} From 6ea91a5448073c86e09c883e64a824e3f6021d75 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 13 Dec 2025 14:49:56 +0000 Subject: [PATCH 2/2] Sniffs: fix ClassConstantTypeHint test for PHP 8.2 compatibility Add php_version=80300 config to ensure the sniff correctly detects missing native type hints on class constants regardless of the PHP version running the tests. Native class constant type hints require PHP 8.3+. --- tests/Sniffs/TypeHints/ClassConstantTypeHint/bad.ruleset.xml | 1 + tests/Sniffs/TypeHints/ClassConstantTypeHint/good.ruleset.xml | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/Sniffs/TypeHints/ClassConstantTypeHint/bad.ruleset.xml b/tests/Sniffs/TypeHints/ClassConstantTypeHint/bad.ruleset.xml index 5a4783d..1956e67 100644 --- a/tests/Sniffs/TypeHints/ClassConstantTypeHint/bad.ruleset.xml +++ b/tests/Sniffs/TypeHints/ClassConstantTypeHint/bad.ruleset.xml @@ -1,4 +1,5 @@ + diff --git a/tests/Sniffs/TypeHints/ClassConstantTypeHint/good.ruleset.xml b/tests/Sniffs/TypeHints/ClassConstantTypeHint/good.ruleset.xml index 5a4783d..1956e67 100644 --- a/tests/Sniffs/TypeHints/ClassConstantTypeHint/good.ruleset.xml +++ b/tests/Sniffs/TypeHints/ClassConstantTypeHint/good.ruleset.xml @@ -1,4 +1,5 @@ +