On 4/24/2019 4:28 AM, G. P. B. wrote:
Hello Internal,
The two weeks of voting have now ended.
The results are 38 for and 18 against (total 56) for the primary vote to
deprecate PHP's short open tag in PHP 7.4.
This passes in favor with 68%.
The results are 42 for and 15 against (total 57) for the secondary vote to
remove PHP's short open tag in PHP 8.
This passes in favor with 74%.
Thanks for everyone who voted on this issue.
Best regards
George P. Banyard
Since this has passed, I would like to discuss official tool
recommendations when 7.4 and 8 are published. Because users are going
to want that.
sed-based solutions do NOT work. PHP is a complex language and it
requires using the tokenizer to properly replace short open tags. The
PHP-CS-Fixer FullOpeningTag fixer is also completely broken software -
it actually misses common use-cases and it intentionally damages code
and then attempts (and in some cases fails) to revert the damage in the
process. Neither of the two recommended options to date on this list
are valid recommendations for serious software deployment managers.
I also looked at a number of other tools that have popped up on my radar
and found nothing that met my basic criteria of:
- Total control over the transformation process, favoring analysis over
modification.
- Zero regexes and relying solely on token_get_all().
- Does exactly one thing and does it well in as little code as possible
so it can be easily vetted by others.
So I built a tool that meets the above minimum criteria and have already
run it against a fairly extensive codebase (and have shared the tool
with a few concerned folks - you've already seen its output here on-list):
https://github.com/cubiclesoft/php-short-open-tag-finder/
The included test suite (test.php), while a mere 14 lines, presents
suitably difficult scenarios to correctly handle both situations of
having (pre-PHP 8) and not having (post-PHP 8) short open tag support.
The tool correctly parses the test suite in both modes without using any
regexes.
The only downside to the tool is that the 'Y' key on a keyboard might
get broken in the optional '-ask' mode. I did experience a bit of
fatigue with using the tool to modify several thousand files with short
open tags but the transformation was otherwise flawless (i.e. no false
positives or false negatives) and was end-user transparent (i.e. didn't
break anything in production) other than having to go back and do
git-commits on all of the 70+ affected projects afterwards.
I recommend having a short list of vetted, verified tools that meet
specific criteria. Tools that just walk down a directory tree and bulk
modify by default, those that rely on regexes, and those that require
short tags to be enabled to function should all be rejected from
consideration. Recommended tools should also be able to be run by a
wide range of users, including hosting providers who might want to
inform their customers that use short open tags when they plan on
upgrading the host to PHP 8 that they have code on their website that
will probably break.
In summary, I went ahead and wrote a tool, ran it against 9.4 million
lines of real production code, then ran it in '-ask' mode and let it
carefully modify a few thousand files by mashing my 'Y' key a bunch of
times pausing briefly to look at interesting changes (which really only
took a couple of hours and probably lowered the lifespan of that key on
the keyboard a bit). I hope others can benefit from the tool too.
--
Thomas Hruska
CubicleSoft President
I've got great, time saving software that you will find useful.
http://cubiclesoft.com/
And once you find my software useful:
http://cubiclesoft.com/donate/
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php