PHP Digest for Jan 28 – Feb 11, 2019
Updated on: | Categories: PHP |
Fresh compilation with links to news and materials. In this article: 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 entered in review phase.
- PSD-12 Extended Code Style — newly extended coding style standard which extends, expands and replaces PSR-2. Also, in the review phase.
- PHP 7.3.2
- PHP 7.2.15
- PHPUnit 8
PHP Internals
- The PHP-7.4 branch has been created, and “master” is now aimed at PHP 8.0 development. 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 JIT idea 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. There is currently no support for Windows, which causes disputes in discussion threads.
- Meantime, you can already try PHP + JIT using Docker images (thanks @dmitrybalabka).
- [RFC] Consistent type errors for internal functions — and another RFC from Nikita Popov. He proposed to make sure that all built-in functions in PHP 8 throw a TypeError when wrong type parameters are passed instead of warnings or null. So instead:
var_dump(strlen(new stdClass));
// Warning: strlen() expects parameter 1 to be string, object given
// NULL
It 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) — An attempt to tight RFC voting met a storm of criticism in the discussion threads. So much so that alternative proposals have appeared. Zeev Suraski promised to rework and take the criticism into account.
- [RFC] Weak References — a proposal to add the WeakReference class to implement weak references, which will allow the developer to save the link to the object without preventing it from being destroyed. This can be especially useful for all sorts of caches.
- [RFC] Allow void return type variance — The proposal to implement the ability to override void return type in inherited methods. Suggested in following signature change of the setUp() method and several others in PHPUnit 8.
class Foo {
function method1 (): void {}
function method2 () {}
}
class Bar extends Foo {
function method1 (): array { return []; }
function method2 (): array { return []; }
}
class Baz extends Foo {
function method1 () { return 42; }
function method2 () { return 42; }
}
- [RFC] Mixed typehint — here it is proposed to add mixed type hint. This will indicate that the function can get (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. Meantime, you can use a great annotations plugin in PhpStorm.
Tools
- mnapoli/bref v0.3 — A tool for creating serverless PHP applications on AWS Lambda. In the latest version, a bug was removed which allowed to launch it through NodeJS. Alternatively, you can use img2lambda.
- paragonie/ciphersweet — Fast encryption for PHP projects with the ability to search for data.
- phpdaily/php — Docker-images for PHP dev versions, including PHP 7.4 and PHP 8.
- immutablephp/immutable — truly immutable value objects for PHP.
- spatie/enum — another version of Strongly typed enums in PHP.
- krakjoe/pcov – a driver for quick calculation of code coverage.
- krakjoe/sandbox – An extension allows you to run an isolated environment in the sandbox.
- railt/railt – GraphQL implementation for PHP applications.
- SerafimArts/Properties – Implementing properties in PHP based on PHPDoc declarations.
Frameworks
- Files that Your Symfony Application Misses – ide-twig.json и .phpstorm.meta.php.
- The creator of Symfony Fabien Potencier answered the users’ questions about the framework, PHP, and more.
- brendt/aggregate.stitcher.io — A good example of a Laravel application.
- beyondcode/laravel-favicon — Generates a favicon based on environment settings, so as not to confuse dev and prod.
- Great Laravel Helper Functions that aren’t in Laravel.
Thanks for reading!