FAQ
Edit report at https://pear.php.net/bugs/bug.php?id=19892&edit=1

ID: 19892
Updated by: gsherwood@squiz.net
Reported By: sanjayr at aspl dot in
-Summary: Incorrect error massage on Switch Case breaking
statement indented incorrec
+Summary: ELSE with no braces causes incorrect SWITCH break
statement indentation error
Status: Open
Type: Bug
Package: PHP_CodeSniffer
Operating System: Linux Fedora core 12
Package Version: 1.4.5
PHP Version: 5.3.3
-Assigned To:
+Assigned To: squiz
Roadmap Versions:
New Comment:

-Summary: Incorrect error massage on Switch Case
breaking statement indented incorrec
+Summary: ELSE with no braces causes incorrect SWITCH
break statement indentation error
-Assigned To:
+Assigned To: squiz



Previous Comments:
------------------------------------------------------------------------

[2013-04-10 13:02:51] sanjayr

Description:
------------
- Please check Test Script code sample.
- Switch case break statement already indent properly with 8 space in
case 'A'

- Its give error message, ERROR | Case breaking statement indented
incorrectly; expected 8 spaces found 12

- Working properly for case 'B'

Test script:
---------------
<?php

switch($case_name)
{
case 'A':
if($cond_a == 1)
return 1;
else
return 0;
break;
case 'B':
if($cond_b == 1)
{
return 1;
}
else
{
return 0;
}
break;
}

Expected result:
----------------
Its shouldn't return error on case 'A'.

------------------------------------------------------------------------

Search Discussions

  • Gsherwood at Apr 12, 2013 at 12:10 am
    Edit report at https://pear.php.net/bugs/bug.php?id=19892&edit=1

    ID: 19892
    Updated by: gsherwood@squiz.net
    Reported By: sanjayr at aspl dot in
    Summary: ELSE with no braces causes incorrect SWITCH break
    statement indentation error
    Status: Assigned
    Type: Bug
    Package: PHP_CodeSniffer
    Operating System: Linux Fedora core 12
    Package Version: 1.4.5
    PHP Version: 5.3.3
    Assigned To: squiz
    Roadmap Versions:
    New Comment:

    Fix committed to github repo:
    https://github.com/squizlabs/PHP_CodeSniffer/commit/c275359a3f4f9ebc09b8b7cfe69
    e79052ddf3ec6

    This was caused by the ELSE statement having to braces inside the first
    CASE. PHPCS
    was using the "return 0" as the breaking statement on the CASE
    statement, which is
    obviously incorrect.


    Previous Comments:
    ------------------------------------------------------------------------

    [2013-04-12 02:10:10] squiz

    -Summary: Incorrect error massage on Switch Case
    breaking statement indented incorrec
    +Summary: ELSE with no braces causes incorrect SWITCH
    break statement indentation error
    -Assigned To:
    +Assigned To: squiz


    ------------------------------------------------------------------------

    [2013-04-10 13:02:51] sanjayr

    Description:
    ------------
    - Please check Test Script code sample.
    - Switch case break statement already indent properly with 8 space in
    case 'A'

    - Its give error message, ERROR | Case breaking statement indented
    incorrectly; expected 8 spaces found 12

    - Working properly for case 'B'

    Test script:
    ---------------
    <?php

    switch($case_name)
    {
    case 'A':
    if($cond_a == 1)
    return 1;
    else
    return 0;
    break;
    case 'B':
    if($cond_b == 1)
    {
    return 1;
    }
    else
    {
    return 0;
    }
    break;
    }

    Expected result:
    ----------------
    Its shouldn't return error on case 'A'.

    ------------------------------------------------------------------------
  • Gsherwood at Apr 12, 2013 at 12:10 am
    Edit report at https://pear.php.net/bugs/bug.php?id=19892&edit=1

    ID: 19892
    Updated by: gsherwood@squiz.net
    Reported By: sanjayr at aspl dot in
    Summary: ELSE with no braces causes incorrect SWITCH break
    statement indentation error
    -Status: Assigned
    +Status: Closed
    Type: Bug
    Package: PHP_CodeSniffer
    Operating System: Linux Fedora core 12
    Package Version: 1.4.5
    PHP Version: 5.3.3
    Assigned To: squiz
    Roadmap Versions:
    New Comment:

    -Status: Assigned
    +Status: Closed



    Previous Comments:
    ------------------------------------------------------------------------

    [2013-04-12 02:11:59] squiz

    Fix committed to github repo:
    https://github.com/squizlabs/PHP_CodeSniffer/commit/c275359a3f4f9ebc09b8b7cfe69
    e79052ddf3ec6

    This was caused by the ELSE statement having to braces inside the first
    CASE. PHPCS
    was using the "return 0" as the breaking statement on the CASE
    statement, which is
    obviously incorrect.

    ------------------------------------------------------------------------

    [2013-04-12 02:10:10] squiz

    -Summary: Incorrect error massage on Switch Case
    breaking statement indented incorrec
    +Summary: ELSE with no braces causes incorrect SWITCH
    break statement indentation error
    -Assigned To:
    +Assigned To: squiz


    ------------------------------------------------------------------------

    [2013-04-10 13:02:51] sanjayr

    Description:
    ------------
    - Please check Test Script code sample.
    - Switch case break statement already indent properly with 8 space in
    case 'A'

    - Its give error message, ERROR | Case breaking statement indented
    incorrectly; expected 8 spaces found 12

    - Working properly for case 'B'

    Test script:
    ---------------
    <?php

    switch($case_name)
    {
    case 'A':
    if($cond_a == 1)
    return 1;
    else
    return 0;
    break;
    case 'B':
    if($cond_b == 1)
    {
    return 1;
    }
    else
    {
    return 0;
    }
    break;
    }

    Expected result:
    ----------------
    Its shouldn't return error on case 'A'.

    ------------------------------------------------------------------------

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedApr 12, '13 at 12:09a
activeApr 12, '13 at 12:10a
posts3
users1
websitepear.php.net

1 user in discussion

Gsherwood: 3 posts

People

Translate

site design / logo © 2022 Grokbase