PHP Annotated Monthly – March 2019

PHP Annotated Monthly

Greetings everyone,

Welcome to the March edition of PHP Annotated Monthly, with all the latest news and notable materials from the world of PHP. In today’s issue read all about the PHP updates, and 5 new and 3 accepted RFCs from PHP Internals. There is also news from Laravel, Symfony, some async PHP stuff, useful tools, and a whole lot more!

⚡️ News & Releases

  • PHP 7.3.3
  • PHP 7.2.16
  • PHP 7.1.27
  • Xdebug 2.7.0 — With long-awaited PHP 7.3 support.
  • ircmaxell/php-compiler — This compiler for PHP from Anthony Ferrara gets a breath of fresh air with FFI in the upcoming PHP 7.4. The compiler can generate native machine code, and output it to an executable that runs without a VM. So far, it’s a PoC that supports a very limited subset of PHP, but it looks promising.

🐘 PHP Internals

  • The proposal to abolish 50% threshold on voting is accepted and from now on all RFCs require at least 2/3 of the votes to pass.
  • A great overview of the unaccepted RFCs — Read why generics, method overloading, and annotations, etc. are still not implemented and what the forecast is for them.
  • [RFC] Consistent type errors for internal functions — The RFC is accepted, which means that in PHP 8 all the built-in functions will be throwing a TypeError if a wrong type argument is atorspassed.
  • [RFC] Weak References — The proposal is accepted. In PHP 7.4 there will be a new WeakReference class, which will allow you to keep a reference to an object without preventing the object from being destroyed with a garbage collector.
  • [RFC] Saner string to number comparisons — In this RFC Nikita Popov proposes changing the behavior of comparison operators to make them less error-prone. Particularly, comparing numbers is to be used only when the string to compare is indeed a number. Otherwise, the number is converted into a string and a string comparison is performed.


    This proposal entails changing the behavior of the operators <=>==!=>>=<, and <=, the switch construction, functions like in_array() and sort(), and others.

    In response, there were ideas of varying degrees of radicalism: from adding a special flag declare('strict_comparison=1'), which would convert all == to ===, up to deprecate == at all.

    Meanwhile, in PHP 7.4, you'll get a Warning if the result of a comparison differs from the one expected in PHP 8.

  • [RFC] Permit trailing whitespace in numeric strings — One more proposal to improve consistency, but at the cost of losing rules. Basically, it is proposed that "123 " == " 123" and all other operations would behave the same as for strings with leading whitespaces.
  • [RFC] Locked Classes — This one is about adding a new keyword locked for classes. Such classes will be closed for dynamic usage of properties, i.e. you could only use properties that were declared explicitly:
        locked class TestClass {
            public $definedProp;
        $t = new testClass();
        $t->definedProp = "OK";
        echo $t->definedProp;
        echo $t->nonExistentProp; // Error
        $t->nonExistentProp = "Not OK"; // Error
        unset($t->definedProp); // Error
  • Allow throwing from __toString()PR from Nikita to fix one of the oldest PHP sadnesses.
  • [RFC] Arrow Functions 2.0 — The third attempt to bring short closures to PHP. This time Nikita, Bob, and Levi propose the following syntax:
        fn($x, $y) => $x * $y.

    Variables from the outer scope will be implicitly bound by-value and there is no need to add use():

        $y = 1;
        $fn1 = fn($x) => $x + $y;

    In the future the same syntax might be used for methods as well:

        class Test {
            private $foo;
            fn getFoo() => $this->foo;

    We hope this time it will be accepted!

  • [RFC] Generator comprehensions — This is a draft RFC with the PoC implementation on adding list comprehension for PHP. It looks really nice:
        $a = [1, 2, 3];
        $mul = 3;
        $c = [ for $a as $v yield $mul * $v ];
  • 🔈 PHP Internals News: Episode 1 — The new podcast from Xdebug author Derick Rethans. The first episode is a talk with Nikita Popov.

🛠 Tools



🌀 Async PHP

🚨 Security

💡 Misc

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

image description