PHP Digest # 185 (20 de julio - 3 de agosto de 2020)



Nueva selección con enlaces a noticias y materiales. En el lanzamiento: PHP 8 Alpha 3, PhpStorm 2020.2, un nuevo operador ?->, nuevamente una discusión de la sintaxis de atributos y otras noticias de PHP Internals, una descripción general del sistema de tipos en PHP, una parte de herramientas útiles, videos, transmisiones y mucho más.



¡Disfruta leyendo!





Noticias y comunicados





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 .
  • cheque [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 */;
  • cheque [RFC] Saner string to number comparisons — .



    PHP 8, == , .



    0 == 'foobar' false.





    <=>, ==, !=, >, >=, < <=, switch, in_array(), sort() .
  • cheque [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;


    (@).
  • cheque [RFC] Allow trailing comma in closure use lists — use PHP 8 , .
    
    $f = function (
        $longArgument,
        $longerArgument,
        $muchLongerArgument,
    ) use (
        $longVar1,
        $longerVar2,
        $muchLongerVar3, //      
    ) {
       ...
    };
    
  • cheque [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.
  • cruzar [RFC] Make constructors and destructors return void — .






Symfony





Laravel









/





¡Gracias por su atención!



Si nota algún error o inexactitud, háganoslo saber personalmente .

Preguntas y sugerencias escríbanos a mail , twitter o telegram pronskiy...



Más noticias y comentarios en el canal PHP Digest Telegram .



Enviar enlace

Buscar enlaces en todos los resúmenes

Número anterior: PHP-Digest № 184




All Articles