Side effects run out of order in echo lists and array literal keys
Los mantenedores suelen responder en 2 días
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 65/100
Línea de trabajo
Reproduce the PHP and TypePHP outputs from the issue, then trace the pre-statement temporary materialization for nested calls in echo operands and array key/value evaluation. Add regression coverage for the three examples and verify that side effects, output, and exceptions occur in PHP's order without changing the already-correct constructs.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
A call nested inside an expression can be materialized into a pre-statement temporary. In two constructs this moves side effects (output, mutations, exceptions) ahead of work PHP performs first.
<?php
function f(string $s): string { echo "[$s]"; return $s; }
function boom(): string { throw new RuntimeException('boom'); }
function main(): void
{
echo "A", var_export(f("1"), true), "\n";
try { echo "E-", var_export(boom(), true), "\n"; } catch (RuntimeException $e) { echo "| caught\n"; }
$a = [f("k1") => strtoupper(f("v1")), f("k2") => f("v2")];
echo "\n";
}
| PHP | TypePHP master | |
|---|---|---|
echo "A", var_export(f("1"), true) |
A[1]'1' |
[1]A'1' |
echo "E-", var_export(boom(), true) |
E- then the exception |
the exception, E- is never printed |
[f("k1") => strtoupper(f("v1")), f("k2") => f("v2")] |
[k1][v1][k2][v2] |
[v1][k1][v2][k2] |
echo prints each operand before evaluating the next, and PHP evaluates an array key before its value. Function arguments, concatenation, binary operators and plain array values keep the right order (checked the same way).
Found with a differential fuzzer. Environment: PHP 8.4.26 ZTS + embed, GCC 11, Linux x64, master.
- Lenguaje dominante
- PHP
- Estrellas
- 1.4k
- Forks
- 80
- Merge medio
- 1 d 9 h
- PR fusionados (30 d)
- 25
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de swoole/typephp
-
NoExport by-defaultAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
swoole/typephp#151 · 2 comentarios ·
Los mantenedores suelen responder en 2 días
Todos los issues de swoole/typephp
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
-
Made by AI module: MCP type: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
-
maintenance
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
hawk-digital-environments/HAWKI#443 ·
Los mantenedores suelen responder en 1 día