Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105430 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 24029 invoked from network); 25 Apr 2019 10:10:56 -0000 Received: from unknown (HELO 28.ip-149-56-142.net) (149.56.142.28) by pb1.pair.com with SMTP; 25 Apr 2019 10:10:56 -0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: thruska@cubiclesoft.com) with ESMTPSA id 6AC6B3E877 To: "G. P. B." , PHP internals References: <0ec42fa9-77d1-a203-8425-e72fdd5071f3@korulczyk.pl> <06473788-a34b-f041-36e6-31d19d8dda4c@cubiclesoft.com> <59cafbfb-2bb0-468c-458f-74bcac780e0f@korulczyk.pl> <004c01d4f09f$880ac320$98204960$@roze.lv> Message-ID: Date: Thu, 25 Apr 2019 00:11:42 -0700 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:11.0) Gecko/20120327 Thunderbird/11.0.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] [VOTE] Deprecate PHP's short open tags From: thruska@cubiclesoft.com (Thomas Hruska) 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/