PHP Digest # 197 (11 al 25 de enero de 2021)



Nueva selección con enlaces a noticias y materiales. En el lanzamiento: objetos como claves de matriz y otras propuestas de RFC para PHP 8.1, ejecutando WebAssembly en PHP, sobre colisiones en matrices, una parte de herramientas útiles, artículos, videos, PHP Live Digest .



¡Disfruta leyendo!









Noticias y comunicados





PHP Internals



  • [RFC] Object keys in arrays

    .



    $obj1 = new stdClass;
    $obj2 = new stdClass;
    
    $array = [];
    $array[$obj1] = 1;
    $array[$obj2] = 2;
    
    var_dump($array[$obj1]); // int(1)
    var_dump($array[$obj2]); // int(2)
    
          
          





    SplObjectStorage



    WeakMap



    , . . , array_*



    .



    , , , .



    , RFC Enumerations . . .
  • [RFC] Object scoped RNG Implementations

    rand()



    mt_rand()



    (seed) srand()



    . - .



    API , .

    $seed = 1234;
    $rng = new RNG\MT19937($seed);
    $array = [1, 2, 3, 4, 5];
    
    shuffle($array, $rng); //   
    
          
          



    , , , : random_bytes() random_int().

  • [RFC] var_representation(): readable alternative to var_export()

    var_export()



    , , . RFC array( )



    [ ]



    .



    var_representation($value, int $flags=0) :string



    , var_export()



    .



    brick/varexporter.
  • [RFC] Change Default mysqli Error Mode

    mysqli ( PHPLive#3 ) : . : mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);







    mysqli CodeIgniter WordPress.
  • [RFC] Dump results of expressions in `php -a`php -a



    .
  • PHP 8.1: What's New and Changed — php.watch , PHP 8.1. RFC - .




  • fabpot/local-php-security-checker — composer.json . FriendsOfPHP/security-advisories.



    GitHub action Docker- oxcom.

  • funivan/PhpClean — PhpStorm, , , , , . .
  • wasmerio/wasmer-php — WebAssembly PHP. wasm- PHP. Rust, wasm PHP. . .
  • temporalio/sdk-php — PHP-SDK temporal.io – , , , , -.



    .. - :
    #[Workflow\WorkflowInterface]
    class LoopWorkflow
    {
        private array $values = [];
        private array $result = [];
        private $simple;
    
        public function __construct()
        {
            $this->simple = Workflow::newActivityStub(
                SimpleActivity::class,
                ActivityOptions::new()->withStartToCloseTimeout(5)
            );
        }
    
        #[SignalMethod]
        public function addValue(
            string $value
        ) {
            $this->values[] = $value;
        }
    
        #[WorkflowMethod(name: 'LoopWorkflow')]
        public function run(
            int $count
        ) {
            while (true) {
                yield Workflow::await(fn() => $this->values !== []);
                $value = array_shift($this->values);
    
                $this->result[] = yield $this->simple->echo($value);
    
                if (count($this->result) === $count) {
                    break;
                }
            }
    
            return $this->result;
        }
    }
          
          





    RoadRunner, reactphp/promise, PHP 8. , .


Symfony





Laravel





Yii





Async PHP









/







  • habr -, PHP.
  • PHP 8 @jrf_nl, , PHP 8 .

    , PHP 1997-2017.





    Brent Roose , , .



    . . , , PHP 8.0 TypeError



    :



    var_dump(round("foo"));
          
          



    3v4l.org/pU0LD



    , , :
    $sub = substr('abcdef', 4, -4);
    if ($sub === false) {
        echo 'fail';
    } else {
        echo 'do something with $sub';
    }
    
    // PHP 5-7 > 'fail'
    // PHP 8   > 'do something with $sub'
    
          
          



    3v4l.org/Ln9g3



    : understandlegacycode.com.
  • Cómo se vería PHP si dependiera de mí : una selección de características deseables de Brent Roose: final y nulo por defecto, sin mezcla, los parámetros y propiedades deben escribirse, genéricos, dónde podemos ir sin ellos, enams, objetos para escalares .













Hoy habrá el cuarto flujo basado en PHP Digest. Análisis de noticias y enlaces del número con detalles y detalles interesantes que no se incluyen en la edición de texto. Invitado Anton Titov con una historia sobre un nuevo instrumento. Así como los resultados del dibujo y un nuevo concurso con elefantes.

A partir de las 20:00 Moscú, Minsk / 19:00 Kiev.






Si observa un error o inexactitud, háganoslo saber en un habr personal o telegrama .





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 № 196




All Articles