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 7.4: New NewPHPOpenTagEOF sniff #843

Merged
merged 1 commit into from
Jul 22, 2019

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Jul 21, 2019

<?php at the end of the file (without trailing newline) will now be interpreted as an opening PHP tag.
Previously it was interpreted either as <? php and resulted in a syntax error (with short_open_tag=1) or was interpreted as a literal <?php string (with short_open_tag=0).

Refs:

Related to #808

Implementation notes:

This sniff will not work on PHP 5.3 in combination with PHPCS < 2.6.0 with short_open_tag=On due to a tokenizer bug in PHPCS itself in those older versions.

Related: #835

The sniff needs different to sniff for different token codes to detect the issue depending on whether or not short_open_tags is enabled on the system running the sniffs.

By default, the Travis images have short_open_tag=Off.

To make sure that both situations are unit tested, two of the existing builds will now change the PHP ini config of the Travis image to ensure that the sniff is also tested with short_open_tag=On.

> `<?php` at the end of the file (without trailing newline) will now be interpreted as an opening PHP tag.
> Previously it was interpreted either as `<? php` and resulted in a syntax error (with short_open_tag=1) or was interpreted as a literal `<?php` string (with short_open_tag=0).

Refs:
* https://github.com/php/php-src/blob/30de357fa14480468132bbc22a272aeb91789ba8/UPGRADING#L37-L40
* php/php-src@c9acc90#diff-7748eb3bfdd3bf962553f6f9f2723c45

## Implementation notes:

This sniff will not work on PHP 5.3 in combination with PHPCS < 2.6.0 with `short_open_tag=On` due to a tokenizer bug in PHPCS itself in those older versions.

Related: 835

The sniff needs different code to detect the issue depending on whether or not `short_open_tag`s is enabled on the system running the sniffs.

By default, the Travis images have `short_open_tag=Off`.

To make sure that both situations are unit tested, two of the existing builds will now change the PHP ini config of the Travis image to ensure that the sniff is also tested with `short_open_tag=On`.
@jrfnl jrfnl force-pushed the php-7.4/new-newstandalonephpopentag-sniff branch from 65d48b9 to f49f31c Compare July 22, 2019 10:21
@wimg wimg merged commit 1b3add6 into master Jul 22, 2019
@delete-merged-branch delete-merged-branch bot deleted the php-7.4/new-newstandalonephpopentag-sniff branch July 22, 2019 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants