Closed peterbowey closed 9 years ago
I was thinking about this same issue last week how to reduce the clutter. I definitely approve of the change. I also want to work in a "relaxed" and "strict" mode so that people can go hog wild with PHP 7 changes if they like.
I am a bit occupied today with some outside work so I will look at this later.
@Alexia I discovered a good reason to run 'php7mar' under PHP 7:
Example, PHP7 will catch these types of syntax changes (unexpected 'new' (T_NEW)
):
$client = & new xmlrpc_client('/xml-rpc-server/','software.realtyna.com',80);
Under php7 (only), php7mar will now report:
#### /root/www-backup-23-june-prior-ereg-clean/virtual/gobuylocal.com.au/plugins/xmlrpc/magicupdaterpro.php
* syntax
* Line 154: ` { //PHP Parse error: syntax error, unexpected 'new' (T_NEW) on line 154`
Thus, we know to remove the '&' (via = & new
) and change the code to:
$client = new xmlrpc_client('/xml-rpc-server/','software.realtyna.com',80);
An earlier PHP (say 5.x) will ignore this unexpected 'new' (T_NEW)
state using php -l :)
@peterbowey It can be ran under both, but running it can be given a path to the PHP 7 binary with the --php switch for syntax checking.
--php="/path/to/php/binary/php"
@Alexia
Thanks for that alternative as a [PHP run-time option].
I can state my intention was a 'forewarning' to other users, of 'php7mar', to use PHP 7 as the final 'syntax check', thus no grief on the unexpected 'new' (T_NEW)
silence (using an older PHP).
Just had an idea. Then syntax check can warn if the version of PHP being used is not high enough.
@Alexia
"Absolutely" a great idea!
Notes: I am happy to state that your 'php7mar' (along with the new regex) has helped me to migrate 12 mixed older sites to using PHP 7. I see over a 120 hours saved...
Many thanks :)
I ended up extending @LawnGnome's regex he put up on Twitter back in May. The one I created and subsequently modifications to it still were not producing proper test results.
Fixed in commit: https://github.com/Alexia/php7mar/commit/357630aad78f9f7ae7526104bd3995095fd79062
I will work on the other things noted here this week.
@Alexia
New regex @ https://github.com/Alexia/php7mar/commit/357630aad78f9f7ae7526104bd3995095fd79062 looks good!
It will now spit out a warning in the report if something lower than PHP 7.0.0-dev was used for syntax checking. https://github.com/Alexia/php7mar/commit/1e26de191758454d92cfa9a3cedf145c5c170e39
At this time it looks like these issues are solved. Going to close this ticket.
@Alexia, A wonderful tool, it has saved a lot of time - for me!
A suggestion and a tested 'patch' to eliminate some of the "php7mar" report noise:
Change file php7mar/classes/tests/critical.php
Before Patch Report:
After Patch:
This simple change avoids a number of 'unneeded' reports on the PHP Uniform Variable Syntax changes. The main target being those changed “variable variable” syntax issues = $$foo['bar'], $foo->$bar['baz'], and Foo::$bar['baz'].