Please welcome February edition PHP Annotated Monthly, with all the latest news and notable materials coming from the world of PHP. Read all about the PHP 8 development that’s underway, JIT in PHP, PSR-14 and PSR-12 in review, a bunch of new RFCs from PHP Internals, Laravel, Yii, Symfony, async PHP stuff, useful tools, and a whole lot more!
PSR-12 Extended Code Style — The new code style standard to replace PSR-2 is also in the review stage now. Read more about PHP-FIG news in the latest recap.
PhpStorm 2019.1 EAP — Another reminder that we’ve started an Early Access Program for the next PhpStorm version. Join it and be one of the first to preview the newest features, including support for debugging Twig templates, multiple new intentions for juggling strings, improved autocompletion for function arguments, code cleanup for PHP, and container lifecycle management for Docker Compose, to name just a few.
PHP-7.4 has been branched, and the master now targets PHP 8.0. Branching usually meant a feature freeze for the version, but this time it was done so that both PHP 8 and PHP 7.4 could be developed in parallel. Lots of deprecated stuff is already removed from PHP 8. You may try both PHP 8 and PHP 7.4 using Docker images phpdaily/php.
[RFC] JIT — Finally proposed by Dmitry Stogov. JIT is implemented as an almost independent part of OPcache and may be enabled/disabled at PHP compile time and at run-time. The target is PHP 8, but there is an ongoing discussion about whether to include it in PHP 7.4 as an experimental feature. As benchmarked by Nikita Popov, JIT gives a 30% boost for PHP-Parser and ~5% for amphp/http-server. There are some concerns about Windows support. You may try PHP+JIT with this Docker image. Check out also a nice write up on what is JIT for PHP.
[RFC] Weak References — It is proposed to add a WeakReference class, that will allow keeping a reference to an object without preventing it for being deleted with garbage collector. For example, this could be useful for implementing caches.
[RFC] Null Coalescing Assignment Operator — The RFC was accepted more than 2 years ago, and now Nikita has delivered an implementation for the new operator ??=. While it seemed like a simple task, it turned out anything but. So: $a ??= $b is equivalent to $a ?? ($a = $b). In case $a[foo()] ??= bar() then foo() function will be called exactly once, and bar() will be called, if $a[foo()] equals null (or unset). Read more about shorthand comparisons in PHP.
[RFC] New custom object serialization mechanism — In this one, Nikita proposes a new serialization mechanism for objects by introducing a couple of magic methods:// Returns array containing all the necessary state of the object. This change is meant to fix problems of Serializable interface. Unfortunately, it is not possible to fix the interface itself, but if the proposal is accepted there will be a working alternative.
[RFC] Consistent type errors for internal functions — Another proposal by Nikita Popov to make internal functions always throw TypeError (in PHP 8) when parameters with incorrect types are passed, instead of warning and returning null. Removes an internal/user-defined inconsistency, and unblocks specifying param types for Reflection.
[RFC] Mixed typehint — Here it is proposed to add a mixed typehint. This would allow explicitly specifing that a function may accept or return values of different types.
mnapoli/bref v0.3 — A tool for making serverless PHP apps on AWS Lambda. In the latest version, the Nodejs hack is removed and custom runtime feature is used instead. You may also use img2lambda as an alternative.
leocavalcante/siler — A microframework based on plain functions and no classes. May be used with Swoole
mgp25/Instagram-API — The package allows using Instagram features that are not available in the official API.
bmitch/churn-php — The tool will help will find candidates for refactoring – files that have been modified most according to the Git log and those with the greatest cyclomatic complexity.