The State of PHP 8

PHP 8.0 is currently being discussed and developed.
This means that many things in this post will still change a lot over time. For each field
of interest I'll leave a subheading and as discussions move further inside php community
they'll be properly updated.

It should be clear that I won't be able to post every single update in real time as there
are many things happening every day. If you're looking for a fresh up-to-date list, please
refer to the UPGRADING file in the official repo.

When will PHP 8.0 be released?

PHP 8.0 will be released on December 2020. At least this is where the official schedule is
pointing to.

The WeakMap class

Status: Confirmed.

Category: Standard Library.

Votes: 25 yes. 0 no.

The WeakMap class RFC creates a new class
called WeakMap which looks a bit like SplObjectStorage.

The main idea is that you can create a object -> value map in it, without
preventing this object from being garbage collected. Thus the Weak name, stating
there's a weak reference between the key object and the map itself.

Garbage collecting an object used as key in such map will cause its removal, meaning
the value will be removed. Like the following:

Optimize function/constants lookup

Whenever you're in a namespaced code and tries to fetch a globally scoped
function or constant without prefixing it with a backslash (\), PHP
will first try to find it on the current namespace and then bubble up
to the global namespace.

By adding a disable_ambiguous_element_lookup=1 directive, PHP will directly
go to the global namespace. Here's an example (from the RFC):

disable_ambiguous_element_lookup was zero on the above example,
PHP would attempt to find MyNS\PHP_VERSION and MyNS\version_compare
first, understand they don't exist (hopefully) and only then attempt the
\PHP_VERSION and \version_compare.

When disable_ambiguous_element_lookup equals one, this extra lookup
is no longer necessary and PHP will go directly to the global scope, fetching
\PHP_VERSION and \version_compare.

Strict Operators directive

Status: POC implemented. Under Discussion.

Category: Syntax.

The strict operators RFC would
add a new directive called strict_operators. When switched on a couple of
comparisons would then behave differently.

Changes are much wider than this example and are out of the scope of this single
post. Check the RFC for more, or ping me on twitter if you'd like to see a blog
post about this one! 😉

The RFCs below are still under discussion and most of them have something related
to past versions of PHP, not being able to get released in time or something
similar. I won't describe them in detail just yet, as I don't quite feel they
have big changes to be integrated to the language.

I will, of course, follow up on them to make sure I'm hopefully wrong.