Comments for "PHP_CodeSniffer"

» Submit Your Comment
Comments are only accepted during the "Proposal" phase. This proposal is currently in the "Finished" phase.
» Comments
  • Daniel O'Connor  [2006-07-20 05:13 UTC]

    Any chance of killing off some of the E_NOTICE errors?

    With XDebug and E_NOTICE on, this code gives my poor machine a hammering!

    Notice: Undefined index: scope_closer in c:\php\PEAR\PHP\CodeSniffer\Standards\
    PEAR\Sniffs\WhiteSpace\ScopeIndentSniff.php on line 219

    Call Stack:
    0.0016 1. {main}() C:\php\PEAR\phpcs.php:0
    0.1139 2. PHP_CodeSniffer->process() C:\php\PEAR\phpcs.php:126
    0.2773 3. PHP_CodeSniffer->_processFile() c:\php\PEAR\PHP\CodeSniffer.php:
    149
    1.0437 4. PHP_CodeSniffer_File->start() c:\php\PEAR\PHP\CodeSniffer.php:34
    8
    1.0440 5. PHP_CodeSniffer_Sniffs_PEAR_Whitespace_ScopeIndentSniff->process
    () c:\php\PEAR\PHP\CodeSniffer\File.php:378
  • Daniel O'Connor  [2006-07-20 05:23 UTC]

    Fatal error: Access to undeclared static property: PHP_CodeSniffer_Sniffs_Squiz
    _PHP_ForbiddenFunctionSniff::$forbiddenFns in c:\php\PEAR\PHP\CodeSniffer\Standa
    rds\Squiz\Sniffs\PHP\ForbiddenFunctionSniff.php on line 98


    ... should be $_forbiddenFns
  • Christian Weiske  [2006-07-20 05:28 UTC]

    The idea of the package is great.
    Unfortunately, I can't install it on *nix because the package.xml lowercases the "standard" directory. Could you please fix this?
  • Arnaud Limbourg  [2006-07-20 06:49 UTC]

    Very interesting !

    Links to the source files would be much appreciated (sorry if I missed the links on the website)
  • Greg Sherwood  [2006-07-20 07:17 UTC]

    I've posted an updated version of the code (redownload, pear uninstall, pear install again to get it). It includes the Standards dir case fix (reported by Christian Weiske).

    There is also a fix for the scope map that fixes errors similar to the one reported by Daniel O'Connor, but I'm not sure it will fix the actual reported error. Try and see :)
  • Christian Weiske  [2006-07-20 08:18 UTC]

    - I would reverse the order of parameters. The files should be at the end of the param list, multiple files should be allowed.
    - There should be an option to list all available coding standards
    - Abilitity to set a default CS is needed
    - Show the line in which the errors occured (if enabled by parameter)


    cweiske:/data/php-gtk/two/Dev_Inspector> /data/cvs/php/php5install/bin/phpcs --help
    PHP Warning: substr_compare(): The start position cannot exceed initial string length in /data/cvs/php/php5cli/share/pear/PHP/CodeSniffer.php on line 799
    PHP Warning: substr_compare(): The start position cannot exceed initial string length in /data/cvs/php/php5cli/share/pear/PHP/CodeSniffer.php on line 799
    Usage: /data/cvs/php/php5install/bin/phpcs <file>|<dir> --standard=<standard>
    <file> : a specific file to check


    cweiske:/data/php-gtk/two/Dev_Inspector> /data/cvs/php/php5install/bin/phpcs . --standard=PEAR
    PHP Warning: substr_compare(): The start position cannot exceed initial string length in /data/cvs/php/php5cli/share/pear/PHP/CodeSniffer.php on line 799
    PHP Strict Standards: Assigning the return value of new by reference is deprecated in /data/cvs/php/php5cli/share/pear/MIME/Type.php on line 102
    PHP Strict Standards: Assigning the return value of new by reference is deprecated in /data/cvs/php/php5cli/share/pear/MIME/Type.php on line 298
    PHP Strict Standards: Assigning the return value of new by reference is deprecated in /data/cvs/php/php5cli/share/pear/PEAR.php on line 563
    PHP Strict Standards: Assigning the return value of new by reference is deprecated in /data/cvs/php/php5cli/share/pear/PEAR.php on line 566
    PHP Strict Standards: Non-static method PEAR::getStaticProperty() should not be called statically, assuming $this from incompatible context in /data/cvs/php/php5cli/share/pear/MIME/Type.php on line 23
  • Christian Weiske  [2006-07-20 08:26 UTC]

    Sorry for the second message dump, this is PEAR and MIME package.

    However, could you constrain the "-----------------" lines to standard 80 chars (as normal terminals have?)
  • Christian Weiske  [2006-07-20 08:30 UTC]

    <?php
    class A
    {
    function b()
    {
    echo "a";
    }
    }
    ?>

    gives:
    [LINE 8] Line not indented correctly. Expected 4 spaces but found 0.
    What is wrong with this?
  • Christian Weiske  [2006-07-20 08:31 UTC]

    sorry that the code isn't indented here:
    http://phpfi.com/133354
  • David Coallier  [2006-07-23 04:22 UTC]

    Haven't tried it yet, but this is defenatly a good idea. I don't know if it should just be implemented at the C level (php-ext) but this is great (if it works fine). I mean, that'll be something beautiful! Good idea, looking forward to test.
  • Laurent Laville  [2006-07-25 08:00 UTC]

    As Christian already said, and i agree with him, idea of the package is great.

    Unfortunately, on my platform (Windows XP), i've no script ".bat" included to have a chance to test it.

    Of course i've tried to run it directly with the PHP cli interpreter. But it will be better with a windows.bat that process also the include_path with a pear installation

    Something like "pear.bat"
  • Laurent Laville  [2006-07-25 08:26 UTC]

    Another comment related to Windows Platform.

    I've run version 0.0.2 on command line with :

    C:\wamp\php>php -d include_path=".;c:\wamp\php\pear" -f phpcs C:\php\pear\HTML_P
    rogress2

    and i got lot of lines like on this file

    FILE: C:\php\pear\HTML_Progress2\examples\circle\circle.php
    --------------------------------------------------------------------------------
    FOUND 4 ERROR(S) AND 0 WARNING(S) AFFECTING 4 LINE(S)
    --------------------------------------------------------------------------------
    [LINE 26] ERROR: Format error: expected "\n" found "
    \n"
    [LINE 29] ERROR: Format error: expected "\n" found "
    \n"
    [LINE 31] ERROR: Format error: expected "\n" found "
    \n"
    [LINE 35] ERROR: Format error: expected "\n" found "
    \n"

    I think it could be a windows CR not manage.
    Perharps it should be into file
    PHP\CodeSniffer\Standards\AbstractPatternSniff.php

    method : processViolation

    Tell me if i'm wrong (bad usage) or if i'm right (windows platform problem).
  • Laurent Laville  [2006-07-26 07:36 UTC]

    First, i would thanks Marc McIntyre for offline answer about file ending line.

    My problem on Windows platform and CR.

    I don't have read carefully the PEAR docs (Coding Standard) :-)

    Here is the link it can help to all other windows users, in case or.
    http://pear.php.net/manual/en/standards.file.php

    NOW, my new test attempt on a source file converted from windows CRLF to unix LF.
    CompatInfo.php
    http://cvs.php.net/viewvc.cgi/pear/PHP_CompatInfo/CompatInfo.php?annotate=1.24

    give me, i think a serious error that need to be fix, about line ident.

    [LINE 181] ERROR: Line indented incorrectly. Expected atleast 93 spaces, but found 20.
    [LINE 185] ERROR: Line indented incorrectly. Expected atleast 93 spaces, but found 24.
    [LINE 186] ERROR: Line indented incorrectly. Expected atleast 93 spaces, but found 20.

    Same problem can be find later

    [LINE 288] ERROR: Line indented incorrectly. Expected atleast 81 spaces, but found 20.
    [LINE 292] ERROR: Line indented incorrectly. Expected atleast 81 spaces, but found 24.
    [LINE 293] ERROR: Line indented incorrectly. Expected atleast 81 spaces, but found 20.


    Related to if-condition on two lines
    Lines 179-180
    Lines 286-287
  • Laurent Laville  [2006-07-26 08:46 UTC]

    Another case of strange error indentation

    here are a bit of code analysed:

    <pre>
    </head>
    <body>
    <?php
    if ($form->validate()) {
    $safe = $form->getSubmitValues();
    //...
    }
    </pre>

    Line 212 is the form->validate call

    I get this result with CodeSniffer 0.0.2

    [LINE 213] ERROR: Line indented incorrectly. Expected atleast 27 spaces, but found 4.
  • Laurent Laville  [2006-08-07 15:12 UTC]

    While i added phpdoc tags to PEAR_PackageFileManager files and check with CodeSniffer 0.0.2, i've found another piece of code that raise errors.

    With a simply script as below and comments on lines 2,4,6 i got theses results :

    [LINE 2] ERROR: Format error: expected "\n" found " "
    [LINE 4] ERROR: Format error: expected "\n" found " "

    I think , after reading PEAR CS again, that it should be accepted, (comment on same line of code, even on if-condition) isn't it ?

    <pre>
    <?php
    if ($cond == $val) { // comment 1
    continue;
    } else { // comment 2
    continue;
    } // comment 3
    $c = 1; // comment 4
    print 'hello';
    ?>
    </pre>
  • Laurent Laville  [2006-08-23 18:56 UTC]

    I run codeSniffer 0.0.3 again and i'm surprised to see such kind of error :

    ERROR: Public method name PHP_CompatInfo::_tokenize is invalid.

    a method name beginning with _ is private (by pear naming standard) with PHP 4.

    BTW a script for windows users to run on command box, will be greatly appreciated.
    I hope to see it on next release !

    regards
  • Greg Sherwood  [2006-08-28 06:32 UTC]

    New version 0.0.4 fixes error submitted by Laurent Laville (ERROR: Public method name PHP_CompatInfo::_tokenize is invalid) and a few others. More testing has been done on existing PEAR code so it should perform better.