From 9ed73be36ff7ba7f9c1cdb752f73c45089e37400 Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Thu, 23 Apr 2026 13:04:32 +0800 Subject: [PATCH] =?UTF-8?q?refactor(examples):=20=E6=9B=B4=E6=96=B0PHP?= =?UTF-8?q?=E7=A4=BA=E4=BE=8B=E4=B8=AD=E7=9A=84=E7=B1=BB=E5=9E=8B=E5=A3=B0?= =?UTF-8?q?=E6=98=8E=E5=92=8C=E4=BB=A3=E7=A0=81=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 为Foo类的属性$b添加int类型声明 - 为read_prop和write_prop方法的参数$n添加int类型声明 - 移除python/sys.php文件开头的注释和无用函数定义 - 重新组织sys.php文件中的代码顺序,将main函数移到合适位置 - 保持原有的系统API调用功能不变 --- examples/micro_bench.php | 6 +++--- examples/python/sys.php | 18 +++++++----------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/examples/micro_bench.php b/examples/micro_bench.php index 50be6743..223d5860 100644 --- a/examples/micro_bench.php +++ b/examples/micro_bench.php @@ -33,7 +33,7 @@ function simpleicall(int $n) class Foo { static $a = 12; - public $b = 0; + public int $b = 0; const TEST = 23; static function read_static($n) { @@ -69,13 +69,13 @@ class Foo { } } - function read_prop($n) { + function read_prop(int $n) { for ($i = 0; $i < $n; ++$i) { $x = $this->b; } } - function write_prop($n) { + function write_prop(int $n) { for ($i = 0; $i < $n; ++$i) { $this->b = 0; } diff --git a/examples/python/sys.php b/examples/python/sys.php index 6f01698f..295a00a5 100644 --- a/examples/python/sys.php +++ b/examples/python/sys.php @@ -1,8 +1,13 @@ full_version); +} function main() { @@ -13,15 +18,6 @@ function main() -use numpy as np; - -function np() -{ - print(np::$module); - print(np::version->full_version); -} - - $array["hello"] = $a; $array["world"] = $b;