Skip to content

PrecisionAlignment: fix various bugs #1273

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

Merged
merged 4 commits into from
Jan 3, 2018

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Jan 3, 2018

Bug 1 - examine all lines

The PHP open tag may not be the first token in a file - think views starting with inline HTML -.

By starting the loop to examine all lines at the $stackPtr, inline HTML lines before the first PHP open tag were not being examined.

This fixes that.

Bug 2 - trigger on echo open tag

Files which do not contain a full PHP open tag <?php, but do contain short open echo tags <?= - i.e. views - were not being examined at all.

N.B.: this improvement will not work in PHPCS 2.x in combination with PHP 5.3 when the short_open_tag ini setting is turned off.
I deemed creating a work-around for that specific situation not worth the effort as PHPCS 2.x as well as PHP 5.3 support will be dropped this summer anyway.

Bug 3 - examine inline HTML at end of of file

The new line character is normally tokenized as T_WHITESPACE, however, not so when at the end of inline HTML, where it is tokenized as part of the T_INLINE_HTML token.

Bowing out of the sniff when no next token could be found, prevents the last line of inline HTML at the end of a file from being examined.

👉 The PR includes unit tests covered all three bugs.

jrfnl added 4 commits January 3, 2018 03:29
The PHP open tag may not be the first token in a file - think views starting with inline HTML.

By starting the loop to examine all lines at the `$stackPtr`, inline HTML lines before the first PHP open tag were not being examined.

This fixes that.
Files which do not contain a full PHP open tag `<?php`, but do contain short open echo tags `<?=` - i.e. views - were not being examined at all.
The new line character is normally tokenized as `T_WHITESPACE`, however, not so when at the end of inline HTML, where it is tokenized as part of the `T_INLINE_HTML` token.

Bowing out of the sniff when no next token could be found, prevent the last line of inline HTML at the end of a file from being examined.
@JDGrimes JDGrimes merged commit 1c11ca7 into develop Jan 3, 2018
@JDGrimes JDGrimes deleted the feature/bug-fix-precision-alignment branch January 3, 2018 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants