From 25488bc236da108e0f11fbd19f00c3dd4f8ac3de Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Fri, 25 Apr 2025 10:49:38 -0300 Subject: [PATCH 1/4] PSR2/SwitchDeclaration: update doc as case indentation is not checked The sniff no longer checks `case` keyword indentation as of commit 4a39005, but the corresponding XML documentation was not updated. This commit aligns the documentation with the current sniff behavior by removing mentions of `case` indentation checks. --- .../SwitchDeclarationStandard.xml | 20 +------------------ 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/src/Standards/PSR2/Docs/ControlStructures/SwitchDeclarationStandard.xml b/src/Standards/PSR2/Docs/ControlStructures/SwitchDeclarationStandard.xml index 1d6d053dff..dd954c8e46 100644 --- a/src/Standards/PSR2/Docs/ControlStructures/SwitchDeclarationStandard.xml +++ b/src/Standards/PSR2/Docs/ControlStructures/SwitchDeclarationStandard.xml @@ -1,27 +1,9 @@ - - - case 'bar': - break; -} - ]]> - - - case 'bar': - break; -} - ]]> - - Date: Fri, 25 Apr 2025 11:08:51 -0300 Subject: [PATCH 2/4] PSR2/SwitchDeclaration: update doc as `case` body should be non-empty This commit updates the valid and invalid code examples in a `` block, as the `There must be a comment when fall-through is intentional in a non-empty case body` error is only triggered for non-empty `case` bodies. It also fixes the positioning of the `` tags in the modified code examples. --- .../Docs/ControlStructures/SwitchDeclarationStandard.xml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Standards/PSR2/Docs/ControlStructures/SwitchDeclarationStandard.xml b/src/Standards/PSR2/Docs/ControlStructures/SwitchDeclarationStandard.xml index dd954c8e46..6b8bc81ce7 100644 --- a/src/Standards/PSR2/Docs/ControlStructures/SwitchDeclarationStandard.xml +++ b/src/Standards/PSR2/Docs/ControlStructures/SwitchDeclarationStandard.xml @@ -67,8 +67,9 @@ switch ($foo) { // no break - default: + echo $foo; + // no break + default: break; } ]]> @@ -77,7 +78,8 @@ switch ($foo) { : + echo $foo; + default: break; } ]]> From d85e5b4e8e8bd4730cf0a22a4e7236fc53d0a624 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Fri, 25 Apr 2025 12:01:57 -0300 Subject: [PATCH 3/4] PSR2/SwitchDeclaration: improve XML documentation - Documentation title should match the sniff name. - Use different `` blocks for each error triggered by the sniff. - Minor changes to the text to make it more clear and consistent. --- .../SwitchDeclarationStandard.xml | 33 ++++++++++++++----- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/src/Standards/PSR2/Docs/ControlStructures/SwitchDeclarationStandard.xml b/src/Standards/PSR2/Docs/ControlStructures/SwitchDeclarationStandard.xml index 6b8bc81ce7..5d8dae4db6 100644 --- a/src/Standards/PSR2/Docs/ControlStructures/SwitchDeclarationStandard.xml +++ b/src/Standards/PSR2/Docs/ControlStructures/SwitchDeclarationStandard.xml @@ -1,11 +1,11 @@ - + - + 'bar': @@ -13,7 +13,7 @@ switch ($foo) { } ]]> - + 'bar': @@ -22,8 +22,13 @@ switch ($foo) { ]]> + + + - + : @@ -33,7 +38,7 @@ switch ($foo) { } ]]> - + : @@ -44,6 +49,11 @@ switch ($foo) { ]]> + + + - + + + + - + - + Date: Fri, 25 Apr 2025 12:39:12 -0300 Subject: [PATCH 4/4] PSR2/SwitchDeclaration: add missing errors to the XML documentation This commit adds four sniff errors not previously documented to the `PSR2.ControlStructures.SwitchDeclaration` sniff XML documentation. --- .../SwitchDeclarationStandard.xml | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/src/Standards/PSR2/Docs/ControlStructures/SwitchDeclarationStandard.xml b/src/Standards/PSR2/Docs/ControlStructures/SwitchDeclarationStandard.xml index 5d8dae4db6..fe4fe3b712 100644 --- a/src/Standards/PSR2/Docs/ControlStructures/SwitchDeclarationStandard.xml +++ b/src/Standards/PSR2/Docs/ControlStructures/SwitchDeclarationStandard.xml @@ -1,4 +1,31 @@ + + + + + + case 'bar': + break; + default: + break; +} + ]]> + + + CASE 'bar': + break; + Default: + break; +} + ]]> + + : break; +} + ]]> + + + + + + + + break; +} + ]]> + + + break; +} + ]]> + + + + + + + + return; +} + ]]> + + + echo $foo; return; } ]]> @@ -68,6 +141,34 @@ switch ($foo) { switch ($foo) { case 'bar': break; +} + ]]> + + + + + + + + : + break; + default: + break; +} + ]]> + + + ; + break; + default: { + break; + } } ]]>