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

    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 text
      var_dump(strlen(new stdClass));
      // Warning: strlen() expects parameter 1 to be string, object given// NULL

      Will be:

      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 signature setUp()and several others in PHPUnit 8.
      Hidden text
          functionmethod1(): void{}
          functionmethod1(): array{ return []; }
          functionmethod2(): array{ return []; }
          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 .





    Async php


    Study materials

    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

    Also popular now: