PHP Digest number 149 (January 28 - February 11, 2019)

Fresh selection with links to news and materials. In the release: PHPUnit 8 and other releases, PSR-14 and PSR-12 in the review stage, JIT for PHP, work started on PHP 8, a pack of fresh RFCs from PHP Internals, a portion of useful tools, and much more.
Enjoy reading!
News and Releases
- PSR-14 Event Dispatcher - officially moved to the review stage .
- PSD-12 Extended Code Style - New coding style standard extends and complements PSR-2 and is intended to replace it. Also under review.
- PHP 7.3.2
- PHP 7.2.15
- PHPUnit 8
Php internals
- The PHP-7.4 branch has been created , and the PHP master repository is now aimed at PHP 8.0. This means that work on PHP 8.0 has already started, and PHP 7.4 will be developed in parallel. So, in PHP 8, a whole bunch of obsolete features have been removed .
- [RFC] JIT - An old idea with JIT in PHP has finally been realized through the efforts of Dmitry Stogov. JIT is implemented as an independent part of OPcache, and can be turned on / off even at runtime. PHP 8 is considered as the target version, but it is possible to enable it in PHP 7.4 as an experimental disabled feature by default. According to Nikita Popov's benchmarks, JIT gives an increase of 30% for PHP-Parser and about 5% for amphp / http-server . At the moment there is no support for Windows, which causes controversy in the Internals.
In the meantime, you can already try PHP + JIT using Docker images (thanks @dmitrybalabka ). Also in the topic is a great post about what JIT means for PHP users . - [RFC] Consistent type errors for internal functions - Another RFC from Nikita Popov. It is proposed to make sure that in PHP 8 all built-in functions throw a TypeError when the parameters of the wrong type are passed instead of Vorning and return
null.Hidden textInstead:var_dump(strlen(new stdClass)); // Warning: strlen() expects parameter 1 to be string, object given// NULL
Will be:declare(strict_types=1); var_dump(strlen(new stdClass)); // TypeError: strlen() expects parameter 1 to be string, object given - [RFC] RFC Workflow & Voting (2019 update) - Attempting to somewhat tighten the RFC vote and bureaucratize the process met a storm of criticism in the Internals. So much so that alternative offers have appeared . Zeev Suraski, his own version, promised to rework and take into account the criticism.
- [RFC] Weak References - It is proposed to add a class
WeakReferenceto implement weak links, which will allow the developer to save a link to an object without preventing it from being deleted by the garbage collector. This can be especially useful for all sorts of caches. - [RFC] Allow void return type variance - Offer to implement the ability to override the return type
voidin inheritor methods. Appeared in the wake of changing the method signaturesetUp()and several others in PHPUnit 8.Hidden textclassFoo{ functionmethod1(): void{} functionmethod2(){} } classBarextendsFoo{ functionmethod1(): array{ return []; } functionmethod2(): array{ return []; } } classBazextendsFoo{ functionmethod1(){ return42; } functionmethod2(){ return42; } } - [RFC] Mixed typehint - And here it is proposed to add a tayphint
mixed. This will indicate that the function can take (or return) values โโof different types. - [RFC] Annotations 2.0 - A draft proposal for full annotations. Earlier there were attempts to implement simple annotations and attributes . In the meantime, you can use a great plugin for annotations in PhpStorm .
Instruments
- mnapoli / bref v0.3 - A tool for creating serverless PHP applications on AWS Lambda. In the fresh version, the hack was removed with the launch through NodeJS. Alternatively, you can use img2lambda .
- paragonie / ciphersweet - Fast encryption for PHP projects with the ability to search by data. More details in the post .
- phpdaily / php - Docker images of PHP versions, including PHP 7.4 and PHP 8.
- immutablephp / immutable - Immutable value objects. Introductory blogpost .
- spatie / enum - Another implementation of the enum type for PHP.
- krakjoe / pcov - Driver for quick calculation of code coverage. More in the post .
- krakjoe / sandbox - An extension allows you to run a short circuit in the sandbox. More details on the blogpost .
- akondas / php-grandmaster - PHP chess engine, with an example of deployment on AWS Lambda.
- railt / railt - GraphQL implementation for PHP applications.
- SerafimArts / Properties - Implementing properties in PHP based on PHPDoc declarations.
Symfony
- Symfony Week # 632 (February 4-10, 2019)
- Symfony Week # 631 (January 28 - February 3, 2019)
- A couple of files your symfony application lacks: ide-twig.json and .phpstorm.meta.php.
- The creator of Symfony Fabien Potencier answered questions from users about the framework, PHP, and so on.
Database serialization
Laravel
- brendt / aggregate.stitcher.io - A good example of an application on Laravel.
- beyondcode / laravel-favicon - Generates a favicon based on environment settings, so as not to confuse virgins and prod.
- 11 helper functions for Laravel
Podcast from Taylor's Laravel Snippet # 4 and # 5
Videos Laracon EU 2018
Yii
Yii 2.0.16- Yii development notes # 26
- iiifx-production / yii2-autocomplete-helper - IDE autocompletions for custom components Yii 2.
Unobvious RabbitMQ in Yii2 or why RabbitMQ writes to all queues at once.
Async php
- reactphp / event-loop v1.1.0 - Added support for libuv (ext-uv), PCNTL signal processing, use
hrtime()in PHP 7.3+. - shuchkin / react-smtp-client - Asynchronous SMTP client for sending mail using ReactPHP.
Fast web scraping on ReactPHP # 3: Download images
CMS
Study materials
- Detecting bugs with @template - About generic support in vimeo / psalm , and phan static analyzers .
- Context managers in PHP - An interesting idea is to implement an analog context managers from Python using generators in PHP.
- Go back to PHP

Video Recording Onliner PHP Meetup # 3
PHP for beginners. Session
Composer for the smallest
What to read in PHP in Russian?
BotMan acquaintance
Interactor Pattern (Interactor, Operation)
Liveprof will show when and why the performance of your PHP application has changed.
Thanks for attention!
If you notice an error or inaccuracy - please inform the PM .
Write questions and suggestions by mail or twitter .
More news and comments on the PHP Digest Telegram channel .
Send link
Search links for all digests
โ Previous release: PHP Digest number 148