Side effects run out of order in echo lists and array literal keys
Maintainer thường phản hồi trong vòng 2 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 65/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- PHP
- Star
- 1.4k
- Fork
- 80
- Merge trung bình
- 1 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 25
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của swoole/typephp
-
NoExport by-defaultĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
swoole/typephp#151 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của swoole/typephp
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
maintenance
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
hawk-digital-environments/HAWKI#443 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100