PHP Annotated Monthly – February 2019

PHP Annotated Monthly

Greetings everyone,

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!

⚡️ News & Releases

🐘 PHP Internals

  • 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] RFC Workflow & Voting (2019 update) — There were some rants about the proposed changes to RFC process, and even an alternative proposal raised. Zeev Suraski promised to work on it and take the feedback into account.
  • [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] Allow void return type variance — A proposal to allow overriding void return type of a method in a subclass.
  • [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.
  • [RFC] Annotations 2.0 — A draft proposal for annotations. There have been attempts before to add annotations via attributes and simple annotations. For now, you can use annotations and get full support for them in PhpStorm with the php-annotations plugin.

🛠 Tools

  • 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.
  • paragonie/ciphersweet — Fast, searchable field-level encryption for PHP projects. More details in the blog post.
  • akondas/php-grandmaster — A chess engine, written in PHP and deployed to AWS Lambda.
  • krakjoe/pcov — Fast code coverage driver delivered as an extension. More in the blog post.
  • krakjoe/sandbox — This extension allows running a closure in a sandbox environment. Read more in the blog post.
  • spatie/enum — Strongly typed enums in PHP supporting autocompletion and refactoring
  • railt/railt — An interesting (but WIP) PHP GraphQL Framework.

Symfony

Laravel

Yii

🌀 Async PHP

💡 Misc

🎥 Video

Thanks for reading!

If you have any interesting or useful links to share via PHP Annotated Monthly, leave a comment or drop me a message on Twitter.

Subscribe to PHP Annotated

Your JetBrains PhpStorm Team
The Drive to Develop

This entry was posted in PHP Annotated Monthly. Bookmark the permalink.
  • https://stackoverflow.com/users/1262820/felipsmartins Felipe Martins

    The video links is gold 😀