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

ID: 19493
Updated by: gsherwood@squiz.net
Reported By: giadiireg@gmail.com
Summary: Sniff paths are incorrectly resolved in Windows
-Status: Open
+Status: Feedback
Type: Bug
Package: PHP_CodeSniffer
Operating System: Windows (7)
Package Version: 1.3.4
PHP Version: 5.3.10
-Assigned To:
+Assigned To: squiz
Roadmap Versions:
New Comment:

-Status: Open
+Status: Feedback
-Assigned To:
+Assigned To: squiz
Can you please try running PHPCS from a git clone. Instruction are here:

https://github.com/squizlabs/PHP_CodeSniffer#installation

Ive fixed a lot of Windows issues in the git repo and I think this was
one of them.


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

[2012-07-02 11:18:55] nevvermind

Description:
------------
When using a custom ruleset, the resolving of different sniffs refs
(i.e. "Generic.Functions.FunctionCallArgumentSpacing") uses the forward
slash, but when searching for Sniff files, the DIRECTORY_SEPARATOR
constant is used, which in Windows is a backslash, the result being that
no sniffs get registered.

Test script:
---------------
Change PHP_CodeSniffer::_expandRulesetReference(), line 833:

$path = $parts[0].'/Sniffs/'.$parts[1].'/'.$parts[2].'Sniff.php';

to

$path = sprintf('%s%sSniffs%s%s%s%sSniff.php', $parts[0],
DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, $parts[1],
DIRECTORY_SEPARATOR, $parts[2]);

and it should work on Windows systems.

Expected result:
----------------
Registering sniffs in SomeCustomStandard standard... DONE (17 sniffs
registered)
Creating file list... DONE (1 files in queue)
Changing into directory
D:\wamp\www\mage\app\code\local\Project\ProductState\Model
Processing Observer.php [447 tokens in 87 lines]... DONE in < 1 second
(3 errors, 8 warnings)

FILE: ...es\mage\app\code\local\Project\ProductState\Model\Observer.php
--------------------------------------------------------------------------------
FOUND 3 ERROR(S) AND 8 WARNING(S) AFFECTING 11 LINE(S)
--------------------------------------------------------------------------------
1 | ERROR | End of line character is invalid; expected "\n" but
found
"\r\n"
22 | WARNING | Line exceeds 80 characters; contains 83 characters
26 | WARNING | Line exceeds 80 characters; contains 114 characters
27 | WARNING | Line exceeds 80 characters; contains 108 characters
30 | WARNING | Line exceeds 80 characters; contains 119 characters
31 | ERROR | Line exceeds maximum limit of 120 characters; contains
121
characters
45 | WARNING | Line exceeds 80 characters; contains 82 characters
49 | WARNING | Line exceeds 80 characters; contains 84 characters
66 | WARNING | Line exceeds 80 characters; contains 82 characters
67 | ERROR | Line exceeds maximum limit of 120 characters; contains
139
characters
78 | WARNING | Line exceeds 80 characters; contains 81 characters
--------------------------------------------------------------------------------

Actual result:
--------------
Registering sniffs in SomeCustomStandard standard... DONE (0 sniffs
registered)
Creating file list... DONE (1 files in queue)
Changing into directory
D:\wamp\www\mage\app\code\local\Project\ProductState\Model
Processing Observer.php [447 tokens in 87 lines]... DONE in < 1 second
(0 errors, 0 warnings)

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

Search Discussions

  • Rico Sonntag at Jul 11, 2012 at 7:58 am
    Edit report at https://pear.php.net/bugs/bug.php?id=19493&edit=1

    ID: 19493
    Comment by: rico.sonntag@netresearch.de
    Reported By: giadiireg@gmail.com
    Summary: Sniff paths are incorrectly resolved in Windows
    Status: Feedback
    Type: Bug
    Package: PHP_CodeSniffer
    Operating System: Windows (7)
    Package Version: 1.3.4
    PHP Version: 5.3.10
    Assigned To: squiz
    Roadmap Versions:
    New Comment:

    We also had issues on windows with exclude pattern paths and sniffs that
    were not correctly excluded. The git version of PHP_CodeSniffer fixes
    all of them for us.


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

    [2012-07-04 08:01:55] squiz

    -Status: Open
    +Status: Feedback
    -Assigned To:
    +Assigned To: squiz
    Can you please try running PHPCS from a git clone. Instruction are here:

    https://github.com/squizlabs/PHP_CodeSniffer#installation

    Ive fixed a lot of Windows issues in the git repo and I think this was
    one of them.

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

    [2012-07-02 11:18:55] nevvermind

    Description:
    ------------
    When using a custom ruleset, the resolving of different sniffs refs
    (i.e. "Generic.Functions.FunctionCallArgumentSpacing") uses the forward
    slash, but when searching for Sniff files, the DIRECTORY_SEPARATOR
    constant is used, which in Windows is a backslash, the result being that
    no sniffs get registered.

    Test script:
    ---------------
    Change PHP_CodeSniffer::_expandRulesetReference(), line 833:

    $path = $parts[0].'/Sniffs/'.$parts[1].'/'.$parts[2].'Sniff.php';

    to

    $path = sprintf('%s%sSniffs%s%s%s%sSniff.php', $parts[0],
    DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, $parts[1],
    DIRECTORY_SEPARATOR, $parts[2]);

    and it should work on Windows systems.

    Expected result:
    ----------------
    Registering sniffs in SomeCustomStandard standard... DONE (17 sniffs
    registered)
    Creating file list... DONE (1 files in queue)
    Changing into directory
    D:\wamp\www\mage\app\code\local\Project\ProductState\Model
    Processing Observer.php [447 tokens in 87 lines]... DONE in < 1 second
    (3 errors, 8 warnings)

    FILE: ...es\mage\app\code\local\Project\ProductState\Model\Observer.php
    --------------------------------------------------------------------------------
    FOUND 3 ERROR(S) AND 8 WARNING(S) AFFECTING 11 LINE(S)
    --------------------------------------------------------------------------------
    1 | ERROR | End of line character is invalid; expected "\n" but
    found
    "\r\n"
    22 | WARNING | Line exceeds 80 characters; contains 83 characters
    26 | WARNING | Line exceeds 80 characters; contains 114 characters
    27 | WARNING | Line exceeds 80 characters; contains 108 characters
    30 | WARNING | Line exceeds 80 characters; contains 119 characters
    31 | ERROR | Line exceeds maximum limit of 120 characters; contains
    121
    characters
    45 | WARNING | Line exceeds 80 characters; contains 82 characters
    49 | WARNING | Line exceeds 80 characters; contains 84 characters
    66 | WARNING | Line exceeds 80 characters; contains 82 characters
    67 | ERROR | Line exceeds maximum limit of 120 characters; contains
    139
    characters
    78 | WARNING | Line exceeds 80 characters; contains 81 characters
    --------------------------------------------------------------------------------

    Actual result:
    --------------
    Registering sniffs in SomeCustomStandard standard... DONE (0 sniffs
    registered)
    Creating file list... DONE (1 files in queue)
    Changing into directory
    D:\wamp\www\mage\app\code\local\Project\ProductState\Model
    Processing Observer.php [447 tokens in 87 lines]... DONE in < 1 second
    (0 errors, 0 warnings)

    ------------------------------------------------------------------------
  • Gsherwood at Jul 11, 2012 at 8:20 am
    Edit report at https://pear.php.net/bugs/bug.php?id=19493&edit=1

    ID: 19493
    Updated by: gsherwood@squiz.net
    Reported By: giadiireg@gmail.com
    Summary: Sniff paths are incorrectly resolved in Windows
    Status: Feedback
    Type: Bug
    Package: PHP_CodeSniffer
    Operating System: Windows (7)
    Package Version: 1.3.4
    PHP Version: 5.3.10
    Assigned To: squiz
    Roadmap Versions:
    New Comment:

    Thanks for that feedback Rico. I think the git version is just about
    ready to release
    now.


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

    [2012-07-11 10:04:11] ricson

    We also had issues on windows with exclude pattern paths and sniffs that
    were not correctly excluded. The git version of PHP_CodeSniffer fixes
    all of them for us.

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

    [2012-07-04 08:01:55] squiz

    -Status: Open
    +Status: Feedback
    -Assigned To:
    +Assigned To: squiz
    Can you please try running PHPCS from a git clone. Instruction are here:

    https://github.com/squizlabs/PHP_CodeSniffer#installation

    Ive fixed a lot of Windows issues in the git repo and I think this was
    one of them.

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

    [2012-07-02 11:18:55] nevvermind

    Description:
    ------------
    When using a custom ruleset, the resolving of different sniffs refs
    (i.e. "Generic.Functions.FunctionCallArgumentSpacing") uses the forward
    slash, but when searching for Sniff files, the DIRECTORY_SEPARATOR
    constant is used, which in Windows is a backslash, the result being that
    no sniffs get registered.

    Test script:
    ---------------
    Change PHP_CodeSniffer::_expandRulesetReference(), line 833:

    $path = $parts[0].'/Sniffs/'.$parts[1].'/'.$parts[2].'Sniff.php';

    to

    $path = sprintf('%s%sSniffs%s%s%s%sSniff.php', $parts[0],
    DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, $parts[1],
    DIRECTORY_SEPARATOR, $parts[2]);

    and it should work on Windows systems.

    Expected result:
    ----------------
    Registering sniffs in SomeCustomStandard standard... DONE (17 sniffs
    registered)
    Creating file list... DONE (1 files in queue)
    Changing into directory
    D:\wamp\www\mage\app\code\local\Project\ProductState\Model
    Processing Observer.php [447 tokens in 87 lines]... DONE in < 1 second
    (3 errors, 8 warnings)

    FILE: ...es\mage\app\code\local\Project\ProductState\Model\Observer.php
    --------------------------------------------------------------------------------
    FOUND 3 ERROR(S) AND 8 WARNING(S) AFFECTING 11 LINE(S)
    --------------------------------------------------------------------------------
    1 | ERROR | End of line character is invalid; expected "\n" but
    found
    "\r\n"
    22 | WARNING | Line exceeds 80 characters; contains 83 characters
    26 | WARNING | Line exceeds 80 characters; contains 114 characters
    27 | WARNING | Line exceeds 80 characters; contains 108 characters
    30 | WARNING | Line exceeds 80 characters; contains 119 characters
    31 | ERROR | Line exceeds maximum limit of 120 characters; contains
    121
    characters
    45 | WARNING | Line exceeds 80 characters; contains 82 characters
    49 | WARNING | Line exceeds 80 characters; contains 84 characters
    66 | WARNING | Line exceeds 80 characters; contains 82 characters
    67 | ERROR | Line exceeds maximum limit of 120 characters; contains
    139
    characters
    78 | WARNING | Line exceeds 80 characters; contains 81 characters
    --------------------------------------------------------------------------------

    Actual result:
    --------------
    Registering sniffs in SomeCustomStandard standard... DONE (0 sniffs
    registered)
    Creating file list... DONE (1 files in queue)
    Changing into directory
    D:\wamp\www\mage\app\code\local\Project\ProductState\Model
    Processing Observer.php [447 tokens in 87 lines]... DONE in < 1 second
    (0 errors, 0 warnings)

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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedJul 4, '12 at 5:56a
activeJul 11, '12 at 8:20a
posts3
users2
websitepear.php.net

2 users in discussion

Gsherwood: 2 posts Rico Sonntag: 1 post

People

Translate

site design / logo © 2022 Grokbase