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

ID: 18160
Updated by: gsherwood@squiz.net
Reported By: spam at endstadium dot com
Summary: Massive notices about undefined offset
-Status: Open
+Status: Bogus
Type: Bug
Package: PHP_CodeSniffer
Operating System: Ubuntu 10.10
Package Version: 1.3.0RC1
PHP Version: 5.3.1
-Assigned To:
+Assigned To: squiz
Roadmap Versions:
New Comment:

-Status: Open
+Status: Bogus
-Assigned To:
+Assigned To: squiz
This code you are testing is obviously a template language based on PHP,
but is not the sort of code you would use PHPCS to check. Check pure PHP
classes and methods please.


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

[2010-12-29 20:10:49] seikilos

Description:
------------
I get a massive amount of undefined offset notices from phpcs.
Sometimes its offset -1 but sometimes on other files it is like 9456

Here is one output and a testfile for that


$ php -d memory_limit=512M phpcs -s -v
--standard=/home/code/sandburg/tools/codesniffer.xml /home/code


Processing _navigation.php [205 tokens in 12 lines]... PHP Notice:
Undefined offset: -1 in
/home/programs/PHP_CodeSniffer-1.3.0RC1/CodeSniffer/Standards/Squiz/Sniffs/Strings/EchoedStringsSniff.php
on line 70
PHP Stack trace:
PHP 1. {main}()
/home/programs/PHP_CodeSniffer-1.3.0RC1/scripts/phpcs:0
PHP 2. PHP_CodeSniffer_CLI->process()
/home/programs/PHP_CodeSniffer-1.3.0RC1/scripts/phpcs:38
PHP 3. PHP_CodeSniffer->process()
/home/programs/PHP_CodeSniffer-1.3.0RC1/CodeSniffer/CLI.php:494
PHP 4. PHP_CodeSniffer->processFiles()
/home/programs/PHP_CodeSniffer-1.3.0RC1/CodeSniffer.php:435
PHP 5. PHP_CodeSniffer->processFile()
/home/programs/PHP_CodeSniffer-1.3.0RC1/CodeSniffer.php:913
PHP 6. PHP_CodeSniffer->_processFile()
/home/programs/PHP_CodeSniffer-1.3.0RC1/CodeSniffer.php:1001
PHP 7. PHP_CodeSniffer_File->start()
/home/programs/PHP_CodeSniffer-1.3.0RC1/CodeSniffer.php:1087
PHP 8. Squiz_Sniffs_Strings_EchoedStringsSniff->process()
/home/programs/PHP_CodeSniffer-1.3.0RC1/CodeSniffer/File.php:445

Notice: Undefined offset: -1 in
/home/programs/PHP_CodeSniffer-1.3.0RC1/CodeSniffer/Standards/Squiz/Sniffs/Strings/EchoedStringsSniff.php
on line 70

Call Stack:
0.0004 324508 1. {main}()
/home/programs/PHP_CodeSniffer-1.3.0RC1/scripts/phpcs:0
0.0172 1339080 2. PHP_CodeSniffer_CLI->process()
/home/programs/PHP_CodeSniffer-1.3.0RC1/scripts/phpcs:38
0.0180 1343336 3. PHP_CodeSniffer->process()
/home/programs/PHP_CodeSniffer-1.3.0RC1/CodeSniffer/CLI.php:494
0.1488 4850188 4. PHP_CodeSniffer->processFiles()
/home/programs/PHP_CodeSniffer-1.3.0RC1/CodeSniffer.php:435
5.4279 12442504 5. PHP_CodeSniffer->processFile()
/home/programs/PHP_CodeSniffer-1.3.0RC1/CodeSniffer.php:913
5.4283 12443080 6. PHP_CodeSniffer->_processFile()
/home/programs/PHP_CodeSniffer-1.3.0RC1/CodeSniffer.php:1001
5.4284 12444660 7. PHP_CodeSniffer_File->start()
/home/programs/PHP_CodeSniffer-1.3.0RC1/CodeSniffer.php:1087
5.4681 12619632 8.
Squiz_Sniffs_Strings_EchoedStringsSniff->process()
/home/programs/PHP_CodeSniffer-1.3.0RC1/CodeSniffer/File.php:445

DONE in < 1 second (30 errors, 0 warnings)


File:_navigation.php

<?php if ($pager->haveToPaginate()): ?>
<div class="mnavigation">
<?php echo link_to('«',
sprintf('message/list?page=%s&view=%s',$pager->getFirstPage(),$view))
?>
<?php echo link_to('<',
sprintf('message/list?page=%s&view=%s',$pager->getPreviousPage(),$view))
?>
<?php $links = $pager->getLinks(); foreach ($links as $page): ?>
<?php echo ($page == $pager->getPage()) ? $page : link_to($page,
sprintf('message/list?page=%s&view=%s',$page,$view)) ?>
<?php if ($page != $pager->getCurrentMaxLink()): ?> - <?php endif
?>
<?php endforeach ?>
<?php echo link_to('>',
sprintf('message/list?page=%s&view=%s',$pager->getNextPage(),$view)) ?>
<?php echo link_to('»',
sprintf('message/list?page=%s&view=%s',$pager->getLastPage(),$view)) ?>
</div>
<?php endif ?>

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

Search Discussions

  • Spam at Dec 29, 2010 at 9:53 pm
    Edit report at http://pear.php.net/bugs/bug.php?id=18160&edit=1

    ID: 18160
    Updated by: spam@endstadium.com
    Reported By: spam at endstadium dot com
    Summary: Massive notices about undefined offset
    Status: Bogus
    Type: Bug
    Package: PHP_CodeSniffer
    Operating System: Ubuntu 10.10
    Package Version: 1.3.0RC1
    PHP Version: 5.3.1
    Assigned To: squiz
    Roadmap Versions:
    New Comment:

    Ok,
    this is an application developed with symfony php framework.
    A lot of code is not based on entire classes but consists of templates
    like that.

    I'll keep that in mind, although it reduces the tested codebase since
    either the classes are auto generated or they are template code.

    Thanks
    Sam


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

    [2010-12-29 22:44:41] squiz

    -Status: Open
    +Status: Bogus
    -Assigned To:
    +Assigned To: squiz
    This code you are testing is obviously a template language based on PHP,
    but is not the sort of code you would use PHPCS to check. Check pure PHP
    classes and methods please.

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

    [2010-12-29 20:10:49] seikilos

    Description:
    ------------
    I get a massive amount of undefined offset notices from phpcs.
    Sometimes its offset -1 but sometimes on other files it is like 9456

    Here is one output and a testfile for that


    $ php -d memory_limit=512M phpcs -s -v
    --standard=/home/code/sandburg/tools/codesniffer.xml /home/code


    Processing _navigation.php [205 tokens in 12 lines]... PHP Notice:
    Undefined offset: -1 in
    /home/programs/PHP_CodeSniffer-1.3.0RC1/CodeSniffer/Standards/Squiz/Sniffs/Strings/EchoedStringsSniff.php
    on line 70
    PHP Stack trace:
    PHP 1. {main}()
    /home/programs/PHP_CodeSniffer-1.3.0RC1/scripts/phpcs:0
    PHP 2. PHP_CodeSniffer_CLI->process()
    /home/programs/PHP_CodeSniffer-1.3.0RC1/scripts/phpcs:38
    PHP 3. PHP_CodeSniffer->process()
    /home/programs/PHP_CodeSniffer-1.3.0RC1/CodeSniffer/CLI.php:494
    PHP 4. PHP_CodeSniffer->processFiles()
    /home/programs/PHP_CodeSniffer-1.3.0RC1/CodeSniffer.php:435
    PHP 5. PHP_CodeSniffer->processFile()
    /home/programs/PHP_CodeSniffer-1.3.0RC1/CodeSniffer.php:913
    PHP 6. PHP_CodeSniffer->_processFile()
    /home/programs/PHP_CodeSniffer-1.3.0RC1/CodeSniffer.php:1001
    PHP 7. PHP_CodeSniffer_File->start()
    /home/programs/PHP_CodeSniffer-1.3.0RC1/CodeSniffer.php:1087
    PHP 8. Squiz_Sniffs_Strings_EchoedStringsSniff->process()
    /home/programs/PHP_CodeSniffer-1.3.0RC1/CodeSniffer/File.php:445

    Notice: Undefined offset: -1 in
    /home/programs/PHP_CodeSniffer-1.3.0RC1/CodeSniffer/Standards/Squiz/Sniffs/Strings/EchoedStringsSniff.php
    on line 70

    Call Stack:
    0.0004 324508 1. {main}()
    /home/programs/PHP_CodeSniffer-1.3.0RC1/scripts/phpcs:0
    0.0172 1339080 2. PHP_CodeSniffer_CLI->process()
    /home/programs/PHP_CodeSniffer-1.3.0RC1/scripts/phpcs:38
    0.0180 1343336 3. PHP_CodeSniffer->process()
    /home/programs/PHP_CodeSniffer-1.3.0RC1/CodeSniffer/CLI.php:494
    0.1488 4850188 4. PHP_CodeSniffer->processFiles()
    /home/programs/PHP_CodeSniffer-1.3.0RC1/CodeSniffer.php:435
    5.4279 12442504 5. PHP_CodeSniffer->processFile()
    /home/programs/PHP_CodeSniffer-1.3.0RC1/CodeSniffer.php:913
    5.4283 12443080 6. PHP_CodeSniffer->_processFile()
    /home/programs/PHP_CodeSniffer-1.3.0RC1/CodeSniffer.php:1001
    5.4284 12444660 7. PHP_CodeSniffer_File->start()
    /home/programs/PHP_CodeSniffer-1.3.0RC1/CodeSniffer.php:1087
    5.4681 12619632 8.
    Squiz_Sniffs_Strings_EchoedStringsSniff->process()
    /home/programs/PHP_CodeSniffer-1.3.0RC1/CodeSniffer/File.php:445

    DONE in < 1 second (30 errors, 0 warnings)


    File:_navigation.php

    <?php if ($pager->haveToPaginate()): ?>
    <div class="mnavigation">
    <?php echo link_to('«',
    sprintf('message/list?page=%s&view=%s',$pager->getFirstPage(),$view))
    ?>
    <?php echo link_to('<',
    sprintf('message/list?page=%s&view=%s',$pager->getPreviousPage(),$view))
    ?>
    <?php $links = $pager->getLinks(); foreach ($links as $page): ?>
    <?php echo ($page == $pager->getPage()) ? $page : link_to($page,
    sprintf('message/list?page=%s&view=%s',$page,$view)) ?>
    <?php if ($page != $pager->getCurrentMaxLink()): ?> - <?php endif
    ?>
    <?php endforeach ?>
    <?php echo link_to('>',
    sprintf('message/list?page=%s&view=%s',$pager->getNextPage(),$view)) ?>
    <?php echo link_to('»',
    sprintf('message/list?page=%s&view=%s',$pager->getLastPage(),$view)) ?>
    </div>
    <?php endif ?>

    ------------------------------------------------------------------------
  • Gsherwood at Dec 29, 2010 at 9:59 pm
    Edit report at http://pear.php.net/bugs/bug.php?id=18160&edit=1

    ID: 18160
    Updated by: gsherwood@squiz.net
    Reported By: spam at endstadium dot com
    Summary: Massive notices about undefined offset
    Status: Bogus
    Type: Bug
    Package: PHP_CodeSniffer
    Operating System: Ubuntu 10.10
    Package Version: 1.3.0RC1
    PHP Version: 5.3.1
    Assigned To: squiz
    Roadmap Versions:
    New Comment:

    When you have auto-generated code, you don't need to enforce styles on
    it.

    When you have template code where even basic statements are split into
    multiple parse PHP blocks, you'll have no chance of checking the coding
    standards because you're really checking HTML standards mixed in with a
    bit of PHP. And while you can write a custom tokenizer for PHPCS to
    check this format, it's a fair bit of effort.

    If you'd like to run over a directory of some complete PHP code blocks
    and some templates, or even in a file with some blocks and some template
    code within it, look into the special @codingStandardsIgnore tags you
    can put into your code:
    http://pear.php.net/manual/en/package.php.php-codesniffer.advanced-usage.php
    (Section: Ignoring parts of a file)


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

    [2010-12-29 22:55:35] seikilos

    Ok,
    this is an application developed with symfony php framework.
    A lot of code is not based on entire classes but consists of templates
    like that.

    I'll keep that in mind, although it reduces the tested codebase since
    either the classes are auto generated or they are template code.

    Thanks
    Sam

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

    [2010-12-29 22:44:41] squiz

    -Status: Open
    +Status: Bogus
    -Assigned To:
    +Assigned To: squiz
    This code you are testing is obviously a template language based on PHP,
    but is not the sort of code you would use PHPCS to check. Check pure PHP
    classes and methods please.

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

    [2010-12-29 20:10:49] seikilos

    Description:
    ------------
    I get a massive amount of undefined offset notices from phpcs.
    Sometimes its offset -1 but sometimes on other files it is like 9456

    Here is one output and a testfile for that


    $ php -d memory_limit=512M phpcs -s -v
    --standard=/home/code/sandburg/tools/codesniffer.xml /home/code


    Processing _navigation.php [205 tokens in 12 lines]... PHP Notice:
    Undefined offset: -1 in
    /home/programs/PHP_CodeSniffer-1.3.0RC1/CodeSniffer/Standards/Squiz/Sniffs/Strings/EchoedStringsSniff.php
    on line 70
    PHP Stack trace:
    PHP 1. {main}()
    /home/programs/PHP_CodeSniffer-1.3.0RC1/scripts/phpcs:0
    PHP 2. PHP_CodeSniffer_CLI->process()
    /home/programs/PHP_CodeSniffer-1.3.0RC1/scripts/phpcs:38
    PHP 3. PHP_CodeSniffer->process()
    /home/programs/PHP_CodeSniffer-1.3.0RC1/CodeSniffer/CLI.php:494
    PHP 4. PHP_CodeSniffer->processFiles()
    /home/programs/PHP_CodeSniffer-1.3.0RC1/CodeSniffer.php:435
    PHP 5. PHP_CodeSniffer->processFile()
    /home/programs/PHP_CodeSniffer-1.3.0RC1/CodeSniffer.php:913
    PHP 6. PHP_CodeSniffer->_processFile()
    /home/programs/PHP_CodeSniffer-1.3.0RC1/CodeSniffer.php:1001
    PHP 7. PHP_CodeSniffer_File->start()
    /home/programs/PHP_CodeSniffer-1.3.0RC1/CodeSniffer.php:1087
    PHP 8. Squiz_Sniffs_Strings_EchoedStringsSniff->process()
    /home/programs/PHP_CodeSniffer-1.3.0RC1/CodeSniffer/File.php:445

    Notice: Undefined offset: -1 in
    /home/programs/PHP_CodeSniffer-1.3.0RC1/CodeSniffer/Standards/Squiz/Sniffs/Strings/EchoedStringsSniff.php
    on line 70

    Call Stack:
    0.0004 324508 1. {main}()
    /home/programs/PHP_CodeSniffer-1.3.0RC1/scripts/phpcs:0
    0.0172 1339080 2. PHP_CodeSniffer_CLI->process()
    /home/programs/PHP_CodeSniffer-1.3.0RC1/scripts/phpcs:38
    0.0180 1343336 3. PHP_CodeSniffer->process()
    /home/programs/PHP_CodeSniffer-1.3.0RC1/CodeSniffer/CLI.php:494
    0.1488 4850188 4. PHP_CodeSniffer->processFiles()
    /home/programs/PHP_CodeSniffer-1.3.0RC1/CodeSniffer.php:435
    5.4279 12442504 5. PHP_CodeSniffer->processFile()
    /home/programs/PHP_CodeSniffer-1.3.0RC1/CodeSniffer.php:913
    5.4283 12443080 6. PHP_CodeSniffer->_processFile()
    /home/programs/PHP_CodeSniffer-1.3.0RC1/CodeSniffer.php:1001
    5.4284 12444660 7. PHP_CodeSniffer_File->start()
    /home/programs/PHP_CodeSniffer-1.3.0RC1/CodeSniffer.php:1087
    5.4681 12619632 8.
    Squiz_Sniffs_Strings_EchoedStringsSniff->process()
    /home/programs/PHP_CodeSniffer-1.3.0RC1/CodeSniffer/File.php:445

    DONE in < 1 second (30 errors, 0 warnings)


    File:_navigation.php

    <?php if ($pager->haveToPaginate()): ?>
    <div class="mnavigation">
    <?php echo link_to('«',
    sprintf('message/list?page=%s&view=%s',$pager->getFirstPage(),$view))
    ?>
    <?php echo link_to('<',
    sprintf('message/list?page=%s&view=%s',$pager->getPreviousPage(),$view))
    ?>
    <?php $links = $pager->getLinks(); foreach ($links as $page): ?>
    <?php echo ($page == $pager->getPage()) ? $page : link_to($page,
    sprintf('message/list?page=%s&view=%s',$page,$view)) ?>
    <?php if ($page != $pager->getCurrentMaxLink()): ?> - <?php endif
    ?>
    <?php endforeach ?>
    <?php echo link_to('>',
    sprintf('message/list?page=%s&view=%s',$pager->getNextPage(),$view)) ?>
    <?php echo link_to('»',
    sprintf('message/list?page=%s&view=%s',$pager->getLastPage(),$view)) ?>
    </div>
    <?php endif ?>

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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedDec 29, '10 at 9:43p
activeDec 29, '10 at 9:59p
posts3
users2
websitepear.php.net

2 users in discussion

Gsherwood: 2 posts Spam: 1 post

People

Translate

site design / logo © 2022 Grokbase