PHP Digest # 204 (17 al 31 de mayo de 2021)

Foto: Christian Münch .



Durante estas dos semanas del núcleo, el equipo de PHP discutió activamente la propuesta de Aplicación de función parcial y, como alternativa, Nikita Popov sugirió una sintaxis más simple para obtener un enlace a cualquier función. También se propone agregar propiedades estáticas a las enumeraciones ya adoptadas en PHP 8.1.



Symfony 6 requerirá PHP 8.0, y el Doctrine 2.9 publicado admite la especificación de metadatos en atributos en lugar de PHPDoc.



También en el lanzamiento hay un artículo interesante sobre expresiones regulares e instrucciones para usar Deployer, así como otros artículos útiles, un paquete de herramientas, algunos videos y podcasts.



¡Disfruta leyendo!





Internos de PHP



  • [RFC] Sintaxis invocable de primera clase



    [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 . video 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.



  • cheque [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













/







comunidad








Suscríbase al canal PHP Digest Telegram .



Si te gustó el resumen, dale un plus; esto es muy motivador para seguir haciéndolo.



¿Detectó un error o un error tipográfico? Informar en un habr personal o telegrama .



Puede enviar un enlace a través del formulario o simplemente escribiéndome en un telegrama .

Buscar enlaces en todos los resúmenes

Número anterior: PHP-Digest # 203








All Articles