Page MenuHomePhabricator

Upgrade Support Infrastructure to Minimum PHP Version 5.5
Open, WishlistPublic

Description

See T13488. Previously, see T7408.

I'm changing the minimum required version of PHP to PHP 5.5. A few things should be changed or updated as a result.

The syntax id(new X())->setY() can now be simplified into (new X())->setY(). I don't think we have any existing lint guidance on this. We could bulk-remove all id(new ...) in the codebase, but this is very low priority. This is also easy to undo if necessary (the new allowed syntax is a parse error under older PHP) so I think there's no reason to continue using id(...). I have no plans to ever use id() as some sort of on-object-construction hook. The new syntax still requires (...) so it isn't much better.

  • D20049 added some code which could be simplified with PHP_QUERY_RFC3986.
  • We should add static analysis support for traits (T4725) before using them.
  • T7408#99040 notes a few other things, although not all of them are worth pursuing.
  • We can use finally, which simplifies various code hacking around the lack of finally.

Event Timeline

epriestley triaged this task as Wishlist priority.Feb 17 2020, 6:58 PM
epriestley created this task.

XHPAST currently can not parse $x = yield $y;. I suspect this was added to the PHP grammar after XHPAST diverged. I'm hopeful the fix is straightforward.

The full yield syntax is a bit zany:

$data = (yield $key => $value);

This is entangled with T9753.

  • macOS ships with Bison 2.3.
  • Under Bison 3, with -Wall, the grammar for Bison 2.3 emits a bunch of warnings. The -Wall flag was added in D13970 and the warnings were fixed in D13974.

These Bison 3 fixes are not backward-compatible. Since the only goal of those changes was to improve tidiness, I'm just going to revert them. I think building more easily on macOS is generally a more important goal than building more cleanly on Bison 3.

A future change could do version detection, or require Bison 3 (if this serves some other goal) and version-detect that Bison is too old.

XHPAST currently can not parse $x = yield $y;.

A complication here is that PHP can't either, until PHP7. In PHP 5.5, only $x = (yield $y); is valid.

So this change is somewhat moot. Once xhpast can parse this construction, the linter needs to emit a message forbidding it.

See also T13588. Using static::class to work around changes to the scope of static in PHP 8.1 is also possible now that PHP 5.5 is the minimum version, and some uses of get_class($this) might be replaceable. There's no strong motivator for this, it's just a little cleaner.