Skip to content

Commit b24b96b

Browse files
committed
Fixed bug #497 : Generic InlineControlStructureSniff does not support alternative SWITCH syntax
1 parent 83622cb commit b24b96b

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

CodeSniffer/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.inc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,13 @@ if ($a)
7777
<div style="text-align: right;">
7878
<?php if ($model->scenario == 'simple') $widget->renderPager() ?>
7979
</div>
80+
81+
<?php
82+
switch ($this->error):
83+
case Shop_Customer :: ERROR_INVALID_GENDER: ?>
84+
Ung&uuml;ltiges Geschlecht!
85+
<?php break;
86+
case Shop_Customer :: ERROR_EMAIL_IN_USE: ?>
87+
Die eingetragene E-Mail-Adresse ist bereits registriert.
88+
<?php break;
89+
endswitch;

CodeSniffer/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.inc.fixed

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,13 @@ if ($a) {
7878
<div style="text-align: right;">
7979
<?php if ($model->scenario == 'simple') { $widget->renderPager(); } ?>
8080
</div>
81+
82+
<?php
83+
switch ($this->error):
84+
case Shop_Customer :: ERROR_INVALID_GENDER: ?>
85+
Ung&uuml;ltiges Geschlecht!
86+
<?php break;
87+
case Shop_Customer :: ERROR_EMAIL_IN_USE: ?>
88+
Die eingetragene E-Mail-Adresse ist bereits registriert.
89+
<?php break;
90+
endswitch;

CodeSniffer/Tokenizers/PHP.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,14 @@ class PHP_CodeSniffer_Tokenizers_PHP
199199
'with' => array(),
200200
),
201201
T_SWITCH => array(
202-
'start' => array(T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET),
203-
'end' => array(T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET),
202+
'start' => array(
203+
T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET,
204+
T_COLON => T_COLON,
205+
),
206+
'end' => array(
207+
T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET,
208+
T_ENDSWITCH => T_ENDSWITCH,
209+
),
204210
'strict' => true,
205211
'shared' => false,
206212
'with' => array(),

package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
5959
- Fixed bug #493 : PSR1_Sniffs_Methods_CamelCapsMethodNameSniff false positives for some magic method detection
6060
-- Thanks to Andreas Möller for the patch
6161
- Fixed bug #496 : Closures in PSR2 are not checked for a space after the function keyword
62+
- Fixed bug #497 : Generic InlineControlStructureSniff does not support alternative SWITCH syntax
6263
</notes>
6364
<contents>
6465
<dir name="/">

0 commit comments

Comments
 (0)