From e869ee49a841cda3595fe1baea7f3c424be6037f Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Sun, 15 Mar 2026 12:49:27 +0800 Subject: [PATCH] =?UTF-8?q?test(aot):=20=E6=B7=BB=E5=8A=A0=E7=A9=BA?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E5=B1=9E=E6=80=A7=E6=B5=8B=E8=AF=95=E7=94=A8?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加了具有可空字符串类型的属性测试 - 实现了包含状态码短语常量的响应类 - 添加了获取原因方法的测试逻辑 - 验证了空合并操作符的功能 - 测试了不同状态码下的返回值情况 --- tests/aot/prop-002.phpt | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tests/aot/prop-002.phpt diff --git a/tests/aot/prop-002.phpt b/tests/aot/prop-002.phpt new file mode 100644 index 00000000..fd2739af --- /dev/null +++ b/tests/aot/prop-002.phpt @@ -0,0 +1,40 @@ +--TEST-- +Property with nullable type +--FILE-- + 'Continue', + 101 => 'Switching Protocols', + 102 => 'Processing', // WebDAV; RFC 2518 + 103 => 'Early Hints', // RFC 8297 + ]; + + public function __construct() { + + } + + public function getReason(int $status): string + { + $reason = $this->reason ?: self::PHRASES[$status] ?? 'unknown'; + return $reason; + } +} + +function main() { + $resp = new Response; + var_dump($resp->getReason(102)); + var_dump($resp->getReason(200)); + $resp->reason = 'OK'; + var_dump($resp->getReason(102)); + var_dump($resp->getReason(200)); +} +?> +--EXPECT-- +string(10) "Processing" +string(7) "unknown" +string(2) "OK" +string(2) "OK" \ No newline at end of file