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

PHP open/close tags on new lines should not apply for PHP inside HTML #423

Closed
aik099 opened this issue Jan 6, 2015 · 2 comments
Closed

Comments

@aik099
Copy link
Contributor

aik099 commented Jan 6, 2015

Code:

<?php
// something
?>
<table>
    <tr><td>Usage: <strong><?php echo round($bin_packer->percentsUsed(), 2) . '%'; ?></strong></td><td><a href="<?php echo $this->getLink('up'); ?>">UP</a></td><td>Zoom: <strong><?php echo $this->sizeCoefficient; ?></strong></td></tr>
    <tr><td><a href="<?php echo $this->getLink('left'); ?>">LEFT</a></td><td><img style="border: 1px solid black; padding: 2px;" src="<?php echo $base_url . '/system/object.png'; ?>" alt=""/></td><td><a href="<?php echo $this->getLink('right'); ?>">RIGHT</a></td></tr>
    <tr><td>&nbsp;</td><td><a href="<?php echo $this->getLink('down'); ?>">DOWN</a></td><td>&nbsp;</td></tr>
</table>

For code above I'm getting following errors:

  • The opening PHP tag must be the first content in the file (Generic.PHP.CharacterBeforePHPOpeningTag.Found)
  • Each PHP statement must be on a line by itself (Generic.Formatting.DisallowMultipleStatements.SameLine)

I'm not 100% sure, but for cases, when <?php and ?> are located on same line at least 1st error (Generic.PHP.CharacterBeforePHPOpeningTag.Found) should not be reported/fixed.

gsherwood added a commit that referenced this issue Jan 6, 2015
gsherwood added a commit that referenced this issue Jan 6, 2015
@gsherwood
Copy link
Member

Both those sniffs were written to disallow the sample code you've provided, but I agree that they work better when they allow that code instead. I've made 2 commits to let this sample code pass.

@aik099
Copy link
Contributor Author

aik099 commented Jan 6, 2015

Great. Thanks.

jrfnl added a commit to jrfnl/PHP_CodeSniffer that referenced this issue Jul 29, 2024
…peclosingbrace-fix-fixer-conflict

PEAR/ScopeClosingBrace: prevent fixer conflict with itself
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

2 participants