Skip to content

Commit

Permalink
Merge branch 'feature/2565-generic-inlinecontrolstructure-bugfix' of h…
Browse files Browse the repository at this point in the history
  • Loading branch information
gsherwood committed Jul 25, 2019
2 parents 78124a0 + 9716919 commit 57ae79b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
<file baseinstalldir="PHP/CodeSniffer" name="InlineControlStructureUnitTest.4.inc" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="InlineControlStructureUnitTest.5.inc" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="InlineControlStructureUnitTest.6.inc" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="InlineControlStructureUnitTest.7.inc" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="InlineControlStructureUnitTest.js" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="InlineControlStructureUnitTest.js.fixed" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="InlineControlStructureUnitTest.php" role="test" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,16 @@ public function process(File $phpcsFile, $stackPtr)
return;
}

if ($tokens[$nextNonEmpty]['code'] === T_COLON) {
var_dump($tokens[$nextNonEmpty]);
// Alternative control structure.
// T_END... missing. Either live coding, parse error or end
// tag in short open tags and scan run with short_open_tag=Off.
// Bow out completely as any further detection will be unreliable
// and create incorrect fixes or cause fixer conflicts.
return ($phpcsFile->numTokens + 1);
}

unset($nextNonEmpty, $start);

// This is a control structure without an opening brace,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
// Issue #2565.
// Important note: this file intentionally does not have a ".fixed" version as
// when `short_open_tag=Off`, no fixes will be made, while when `short_open_tag=On`
// no fixes are necessary.
?>

<?php if (true) : ?>
<? endif ?>
<?php if (true) { ?>
<? } ?>

<? if (false) : ?>
<? endif ?>
<?php if (false) { ?>
<?php } ?>

0 comments on commit 57ae79b

Please sign in to comment.