Skip to content

Endless loop whilst parsing mixture of control structure styles #512

@asgrim

Description

@asgrim

I can successfully reproduce an endless loop state whilst parsing our legacy codebase, which has a mixture of if/else styles.

Steps to reproduce:

  • Create test.php (with content below)
  • composer require squizlabs/php_codesniffer (installs 2.3.0)
  • vendor/bin/phpcs --standard=psr2 test.php

This is the file content that causes the state:

<?php foreach ($blah as $boo) : ?> <?php if ($foo): ?> <?php if ($bar) { } else { } ?> <?php endif; ?> <?php endforeach; ?>

Versions

$ vendor/bin/phpcs --version PHP_CodeSniffer version 2.3.0 (stable) by Squiz (http://www.squiz.net) $ php -v PHP 5.5.18-1+deb.sury.org~precise+1 (cli) (built: Oct 17 2014 15:11:34) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans $ cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=14.04 DISTRIB_CODENAME=trusty DISTRIB_DESCRIPTION="Ubuntu 14.04.2 LTS"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions