PHP Digest # 204 (17 a 31 de maio de 2021)

Foto: Christian MĂŒnch .



Durante essas duas semanas do nĂșcleo, a equipe do PHP discutiu ativamente a proposta do Aplicativo de função parcial e, como alternativa, Nikita Popov sugeriu uma sintaxe mais simples para obter um link para qualquer função. TambĂ©m Ă© proposto adicionar propriedades estĂĄticas aos enums jĂĄ adotados no PHP 8.1.



Symfony 6 exigirå PHP 8.0, e o Doctrine 2.9 lançado suporta a especificação de metadados em atributos ao invés de PHPDoc.



TambĂ©m no lançamento estĂĄ um artigo legal sobre regexps e instruçÔes para usar o Deployer, bem como outros artigos Ășteis, um pacote de ferramentas, alguns vĂ­deos e podcasts.



Gostar de ler!





PHP Internals



  • [RFC] Sintaxe chamĂĄvel de primeira classe



    [RFC] Partial Function Application .



    //   
    $fn = Closure::fromCallable('strlen');
    $fn = Closure::fromCallable([$this, 'method']);
    $fn = Closure::fromCallable([Foo::class, 'method']);
    
    //   
    $fn = strlen(...);
    $fn = $this->method(...);
    $fn = Foo::method(...);
    
          
          







    , , callable



    . , :

    array_map(Something::toString(...), [1, 2, 3]);
    array_map(strval(...), [1, 2, 3]);
    
    // 
    array_map([Something::class, 'toString'], [1, 2, 3])
    array_map('strval', [1, 2, 3]);
    
          
          





  • [RFC] Disable autovivification on false



    PHP null



    false



    . false



    - Fatal error



    :

    $a = true;
    $a[] = 'value'; // Fatal error: Uncaught Error: Cannot use a scalar value as an array
    
    $a = null;
    $a[] = 'value'; // Ok
    
    $a = false;
    $a[] = 'value'; //   ,   
    
          
          



    3v4l.org/UucOC



  • [RFC] Allow static properties in enums



    PHP 8.1 . vĂ­deo PHP- php.watch.



    , .



    enum Environment {
        case DEV;
        case STAGE;
        case PROD;
    
        private static Environment $currentEnvironment;
    
        /**
         * Read the current environment from a file on disk, once.
         * This will affect various parts of the application.
         */
        public static function current(): Environment {
            if (!isset(self::$currentEnvironment)) {
                $info = json_decode(file_get_contents(__DIR__ . '/../../config.json'), true);
                self::$currentEnvironment = match($info['env']) {
                    'dev' => self::DEV,
                    'stage' => self::STAGE,
                    'prod' => self::PROD,
                };
            }
            return self::$currentEnvironment;
        }
        // Other methods can also access self::$currentEnvironment
    }
    printf("Current environment is %s\n", Environment::current()->name);
    
          
          





    . , .



    , PhpStorm 2021.2 enum



    , 2021.2 EAP.



  • [PR] HTTP Early Hint support



    , PHP . HTTP 1xx



    . , 103



    , Link, , , 200 OK



    .



    , : 103



    , , header()



    , — echo



    .



    , . - API Symfony HTTP.



  • Verifica [RFC] Add IntlDatePatternGenerator



    . PHP 8.1 IntlDatePatternGenerator



    . PHP Internals News #85 RFC.



  • [RFC] Final class constants



    .



  • Internals bugs.php.net



    issues GitHub. , . , . PHP, issue php/doc-en php/doc-ru. .










Symfony







Laravel













/







comunidade








Inscreva-se no canal PHP Digest Telegram .



Se vocĂȘ gostou do resumo, dĂȘ um acrĂ©scimo - Ă© muito motivador continuar fazendo isso.



VocĂȘ identificou um erro ou erro de digitação? Informe em um habr ou telegrama pessoal .



VocĂȘ pode enviar um link pelo formulĂĄrio ou simplesmente me escrevendo em um telegrama .

Pesquisar links em todos os resumos

← NĂșmero anterior: PHP-Digest # 203








All Articles