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

ID: 16283
Updated by: gsherwood@squiz.net
Reported By: mcaplan at labnet dot net
Summary: Zend switch spacing
Status: Open
Type: Bug
Package: PHP_CodeSniffer
Operating System: CentOS 5.3
Package Version: 1.2.0RC2
PHP Version: 5.2.9
Roadmap Versions:
New Comment:

The "Zend" standard that comes with PHP_CodeSniffer is not the "Zend
Framework" standard. It is just a collection of sniffs either
contributed by Zend or ZF developers.

If you are trying to test your code using the ZF coding standard, I
believe the ZF team has a standard that you can download and use,
although I have not seen it myself (only heard of it).


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

[2009-06-03 19:41:22] michaelcaplan

Description:
------------
I'm getting errors about switch statement formating using the zend
standard if I have it correctly formated (case 1) or formated the way CS
says I shoudl have it formated (case 2)

phpcs --standard=zend test.php

Test script:
---------------
Case 1:

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

switch ($res) {
case 3:
throw new Exception('key length was incorrect');
break;
case 4:
throw new Exception('memory allocation problem');
break;
default:
throw new Exception('unknown error');
}


case 2 (which is incorrect, but CS suggests that this should fix it):

switch ($res) {
case 3:
throw new Exception('key length was incorrect');
break;
case 4:
throw new Exception('memory allocation problem');
break;
default:
throw new Exception('unknown error');
}

Expected result:
----------------
Runs clean

Actual result:
--------------
Case 1:

--------------------------------------------------------------------------------
FOUND 1 ERROR(S) AND 0 WARNING(S) AFFECTING 1 LINE(S)
--------------------------------------------------------------------------------
11 | ERROR | Closing brace indented incorrectly; expected 4 spaces,
found 0
--------------------------------------------------------------------------------


case 2:

--------------------------------------------------------------------------------
FOUND 1 ERROR(S) AND 0 WARNING(S) AFFECTING 1 LINE(S)
--------------------------------------------------------------------------------
11 | ERROR | Closing brace indented incorrectly; expected 0 spaces,
found 4
--------------------------------------------------------------------------------

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

Search Discussions

  • Gsherwood at Jun 10, 2009 at 11:38 pm
    Edit report at http://pear.php.net/bugs/bug.php?id=16283&edit=1

    ID: 16283
    Updated by: gsherwood@squiz.net
    Reported By: mcaplan at labnet dot net
    Summary: Zend switch spacing
    -Status: Open
    +Status: Wont fix
    Type: Bug
    Package: PHP_CodeSniffer
    Operating System: CentOS 5.3
    Package Version: 1.2.0RC2
    PHP Version: 5.2.9
    -Assigned To:
    +Assigned To: squiz
    Roadmap Versions:
    New Comment:

    -Status: Open
    +Status: Wont fix
    -Assigned To:
    +Assigned To: squiz
    Marking as Wont Fix because I do not have the time to learn and support
    the ZF coding standard in PHP_CodeSniffer, esp considering others have
    already started.


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

    [2009-06-11 01:35:41] squiz

    The "Zend" standard that comes with PHP_CodeSniffer is not the "Zend
    Framework" standard. It is just a collection of sniffs either
    contributed by Zend or ZF developers.

    If you are trying to test your code using the ZF coding standard, I
    believe the ZF team has a standard that you can download and use,
    although I have not seen it myself (only heard of it).

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

    [2009-06-03 19:41:22] michaelcaplan

    Description:
    ------------
    I'm getting errors about switch statement formating using the zend
    standard if I have it correctly formated (case 1) or formated the way CS
    says I shoudl have it formated (case 2)

    phpcs --standard=zend test.php

    Test script:
    ---------------
    Case 1:

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

    switch ($res) {
    case 3:
    throw new Exception('key length was incorrect');
    break;
    case 4:
    throw new Exception('memory allocation problem');
    break;
    default:
    throw new Exception('unknown error');
    }


    case 2 (which is incorrect, but CS suggests that this should fix it):

    switch ($res) {
    case 3:
    throw new Exception('key length was incorrect');
    break;
    case 4:
    throw new Exception('memory allocation problem');
    break;
    default:
    throw new Exception('unknown error');
    }

    Expected result:
    ----------------
    Runs clean

    Actual result:
    --------------
    Case 1:

    --------------------------------------------------------------------------------
    FOUND 1 ERROR(S) AND 0 WARNING(S) AFFECTING 1 LINE(S)
    --------------------------------------------------------------------------------
    11 | ERROR | Closing brace indented incorrectly; expected 4 spaces,
    found 0
    --------------------------------------------------------------------------------


    case 2:

    --------------------------------------------------------------------------------
    FOUND 1 ERROR(S) AND 0 WARNING(S) AFFECTING 1 LINE(S)
    --------------------------------------------------------------------------------
    11 | ERROR | Closing brace indented incorrectly; expected 0 spaces,
    found 4
    --------------------------------------------------------------------------------

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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedJun 10, '09 at 11:37p
activeJun 10, '09 at 11:38p
posts2
users1
websitepear.php.net

1 user in discussion

Gsherwood: 2 posts

People

Translate

site design / logo © 2022 Grokbase