Side effects run out of order in echo lists and array literal keys
I maintainer di solito rispondono entro 2 giorni
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 65/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- PHP
- Stelle
- 1.4k
- Fork
- 80
- Merge medio
- 1g 9h
- PR unite (30g)
- 25
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di swoole/typephp
-
NoExport by-defaultAperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
swoole/typephp#151 · 2 commenti ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di swoole/typephp
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
maintenance
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
hawk-digital-environments/HAWKI#443 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100