PHP Digest # 185 (July 20 - August 3, 2020)



Fresh selection with links to news and materials. In the release: PHP 8 Alpha 3, PhpStorm 2020.2, a new operator ?->, another discussion of attribute syntax and other PHP Internals news, an overview of the type system in PHP, a portion of useful tools, videos, streams and much more.



Enjoy reading!





News and releases





PHP Internals



  • [RFC] Shorter Attribute Syntax Change β€” PHP 8 . .



    : << >>, @@, .

    @@ , RFC . , #[ ] Rust, .



    , PHP 8.1, - 8.0 4 . PHP 8.0, << >>, #[], @@, PHP 8.1 .



    : @[Attribute], PHPDoc /** @@MyAttribute */, β€” @ @@, @ .







    , @@, - , T_PAAMAYIM_NEKUDOTAYIM , - β€” PHP 8 Alpha 3 .
  • check [RFC] Treat namespaced names as single token β€” PHP 8 . , , namespace app\function { class Foo {} } .



    , , :
    use /** Try comments */ \FullyQualified \ /* in this ugly way */ SometTotallyDifferentTrait /** also after */;
  • check [RFC] Saner string to number comparisons β€” .



    PHP 8, == , .



    0 == 'foobar' false.





    <=>, ==, !=, >, >=, < <=, switch, in_array(), sort() .
  • check [RFC] Nullsafe operator β€” PHP 8 nullsafe: ?->.

    C null.



    , :
    
    private function getUserCountry(): ?string
    {
        $session = $this->sessionStorage->getSession();
    
        if (null === $session) {
            return null;
        }
    
        $user = $session->getUser();
    
        if (null === $user) {
            return null;
        }
    
        if (null === $user->address) {
            return null;
        }
    
        return $user->address->country;
    }
    
    :
    $country = $this->sessionStorage->getSession()?->getUser()?->address?->country;


    (@).
  • check [RFC] Allow trailing comma in closure use lists β€” use PHP 8 , .
    
    $f = function (
        $longArgument,
        $longerArgument,
        $muchLongerArgument,
    ) use (
        $longVar1,
        $longerVar2,
        $muchLongerVar3, //      
    ) {
       ...
    };
    
  • check [RFC] Named Arguments β€” PHP 8 !

    , .

    htmlspecialchars($string, ENT_COMPAT | ENT_HTML401 , ini_get("default_charset"), false);
    :

    htmlspecialchars($string, double_encode: false);


    stitcher.io/blog/php-8-named-arguments.
  • [RFC] Renamed Parameters β€” . RFC.



    :
    
    function callBar(Foo $internalName:externalName) {
        $internalName->bar();
    }
    
    $x = new Foo();
    callBar(externalName: $x);
    


    - Swift. , @@NameAlias.
  • cross [RFC] Make constructors and destructors return void β€” .






Symfony





Laravel









/





Thank you for attention!



If you notice an error or inaccuracy, please let us know in a personal .

Questions and suggestions write to mail , twitter or telegram pronskiy...



More news and comments on the PHP Digest Telegram channel .



Send link

Search links in all digests

← Previous issue: PHP-Digest β„– 184




All Articles