PHP Digest No. 151 (February 25 - March 11, 2019)


    Fresh selection with links to news and materials. In release: updates of PHP, Laravel 5.8, Xdebug 2.7 and other releases, 3 fresh RFC, 2 accepted, and the concept from PHP Internals, a portion of useful tools, and much more.

    Enjoy reading!



    News and Releases



    PHP internals


    • [RFC] Saner string to number comparisons - In her recent RFC, Nikita Popov suggests changing behavior ==and making lax comparisons less error prone. In particular, comparison of numbers is proposed to be used only if the string being compared is actually a numeric one. Otherwise, the number is converted to a string, and the string is compared.

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

      In response, ideas of varying degrees of radicalism were received: from the introduction of a special flag declare('strict_comparison=1');that would turn everything ==into ===, to the proposal to cancel == in general .

      In the meantime, in 7.4, Warning will probably be thrown if the result of the comparison differs from what is expected in PHP 8.
    • [RFC] Permit trailing whitespace in numeric strings - Another suggestion designed to improve consistency, but by weakening. It is proposed to allow whitespace at the end of numeric lines, that is, so that "123 " == " 123"all other operations work, as well as for lines with leading spaces.
    • [RFC] Consistent type errors for internal functions - The proposal has been accepted, which means that in PHP 8, built-in functions will throw a TypeError if parameters of the wrong type are passed and, accordingly, will not return null.
    • [RFC] Weak References - Proposal for implementing weak links accepted.
    • [RFC] Locked Classes - It is proposed to introduce a new keyword lockedfor classes. Such classes will be closed for the dynamic use of properties, that is, you cannot access undeclared properties:
      Hidden text
      locked class TestClass {
          public $definedProp;
      }
      $t = new testClass();
      $t->definedProp = "OK";
      echo $t->definedProp;
      unset($t->definedProp);
      echo $t->nonExistentProp; // Error
      $t->nonExistentProp = "Not OK"; // Error
      unset($t->definedProp); // Error
      
    • videoPHP Internals News: Episode 1 - New podcast from author Xdebug Derick Rethans. In the first issue, a conversation with Nikita Popov.
    • Allow throwing from __toString () - PR from Nikita with a fix for one of the old PHP problems - inability to throw exceptions to __toString.
    • List comprehension - A concept from Sarah Goleman with the implementation of list comprehension for PHP. The syntax is less elegant than in Python, but it looks interesting:
      $a = [1, 2, 3];
      $mul = 3;
      $c = [ for $a as $v yield $mul * $v use ($mul) ];
      

    Instruments



    Symfony



    Laravel



    Yii



    Async php



    Learning Materials



    Thanks for attention!

    If you notice a mistake or inaccuracy - please inform me in PM .
    Questions and suggestions write to mail or twitter .

    More news and comments on the PHP Digest Telegram Channel .

    Send link
    Search links for all digests
    Previous release: PHP Digest No. 150


    Also popular now: