From 6d7e68a9fffe761fd9cdf6b0131fd5e6478ffa7c Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Thu, 6 Aug 2026 21:19:33 +0800 Subject: [PATCH] chore(deps): update swoole/phpx dependency and add magic method tests - Updated swoole/phpx from ~2.4.3 to ~2.4.5 in composer.json - Added new test case for static::class runtime called scope behavior - Added new test case for magic method indirect property update using __get by reference - Extended existing magic method tests with isset true scenario that skips reading --- composer.json | 2 +- tests/compiler/class/get-called-class.phpt | 27 ++++++++++++ .../magic_methods/indirect-update.phpt | 41 +++++++++++++++++++ .../magic_methods/read-skips-isset.phpt | 22 ++++++++++ 4 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 tests/compiler/class/get-called-class.phpt create mode 100644 tests/compiler/magic_methods/indirect-update.phpt diff --git a/composer.json b/composer.json index 9ec26205..90f92013 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "marcj/topsort": "^2.0", "symfony/var-dumper": "^8.0", "symfony/yaml": "^8.0", - "swoole/phpx": "~2.4.3", + "swoole/phpx": "~2.4.5", "ajaxray/ansikit": "^0.3.1" }, "require-dev": { diff --git a/tests/compiler/class/get-called-class.phpt b/tests/compiler/class/get-called-class.phpt new file mode 100644 index 00000000..0665b9b3 --- /dev/null +++ b/tests/compiler/class/get-called-class.phpt @@ -0,0 +1,27 @@ +--TEST-- +static::class uses the runtime called scope +--FILE-- + +--EXPECT-- +string(17) "CalledClassParent" +string(16) "CalledClassChild" diff --git a/tests/compiler/magic_methods/indirect-update.phpt b/tests/compiler/magic_methods/indirect-update.phpt new file mode 100644 index 00000000..5c96bab9 --- /dev/null +++ b/tests/compiler/magic_methods/indirect-update.phpt @@ -0,0 +1,41 @@ +--TEST-- +Magic Methods - indirect property update uses __get by reference +--FILE-- +values[$name]; + } + + public function value(string $name): mixed + { + return $this->values[$name] ?? null; + } +} + +function main(): void +{ + $probe = new MagicUpdateTest(); + $probe->value[] = 42; + var_dump($probe->value('value')); +} +?> +--EXPECT-- +__get(value) +array(1) { + [0]=> + int(42) +} diff --git a/tests/compiler/magic_methods/read-skips-isset.phpt b/tests/compiler/magic_methods/read-skips-isset.phpt index 291f5b3e..7dba37ee 100644 --- a/tests/compiler/magic_methods/read-skips-isset.phpt +++ b/tests/compiler/magic_methods/read-skips-isset.phpt @@ -21,6 +21,21 @@ class MagicReadTest } } +class MagicIssetTrueTest +{ + public function __isset(string $name): bool + { + echo "__isset($name)\n"; + return true; + } + + public function __get(string $name) + { + echo "__get($name)\n"; + return null; + } +} + function main(): void { $obj = new MagicReadTest(); @@ -33,6 +48,10 @@ function main(): void echo "--- empty ---\n"; var_dump(empty($obj->aaa)); + + echo "--- isset true does not read ---\n"; + $issetTrue = new MagicIssetTrueTest(); + var_dump(isset($issetTrue->value)); } ?> --EXPECTF-- @@ -45,3 +64,6 @@ bool(false) --- empty --- __isset(aaa) bool(true) +--- isset true does not read --- +__isset(value) +bool(true)