Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scope indent check can go into infinite loop due to some parse errors #667

Closed
rasmusbe opened this issue Aug 3, 2015 · 3 comments
Closed

Comments

@rasmusbe
Copy link

rasmusbe commented Aug 3, 2015

This code gives an infinite loop in File.php and prints out this notices over and over again:

PHP Notice: Undefined index: in php_codesniffer/CodeSniffer/File.php on line 3479
PHP Notice: Undefined index: in php_codesniffer/CodeSniffer/File.php on line 3491

(its because of a ; instead of : in the end of the foreach, but it doesn't warn about it correctly)

<?php for ( $year = $first_year; $year <= $current_year; $year++ ): ?>
    <?php foreach ( $events as $event ); ?>
        <li class="item item-press">
        <strong class="item-date"><?php echo get_the_date( 'j M', $event ); ?></strong>
        <a href="<?php echo get_permalink( $event );?>"><?php echo $event->post_title;?></a>
        <span class="item-city"><?php the_papi_field( 'papi_city' ); ?></span>
        </li>
    <?php endforeach; ?>
<?php endfor; ?>
@aik099
Copy link
Contributor

aik099 commented Aug 3, 2015

Which PHP_CodeSniffer version are you using?

@gsherwood
Copy link
Member

PHPCS doesn't check syntax unless you have a custom standard that includes a sniff to do it (there is one in the Generic standard) so you're not going to get syntax errors reported if you are using the built-in standards.

Fixing the parse error is the way to work around this of course, but I'll see if I can get PHPCS to stop throwing errors as well.

@rasmusbe
Copy link
Author

rasmusbe commented Aug 4, 2015

@aik099 PHP_CodeSniffer version 2.3.3 (and using Wordpress Coding Standards)

@gsherwood Thanks!

@gsherwood gsherwood changed the title Inifinite loop in File.php Scope indent check can go into infinite loop due to some parse errors Aug 13, 2015
gsherwood added a commit that referenced this issue Aug 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants