From 560ea466924c0a6db3e412f2e39ae63999c11c75 Mon Sep 17 00:00:00 2001 From: rango Date: Mon, 3 Aug 2026 21:34:05 +0800 Subject: [PATCH] add phpt tests --- .../static/late-static-class-return.phpt | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 tests/compiler/static/late-static-class-return.phpt diff --git a/tests/compiler/static/late-static-class-return.phpt b/tests/compiler/static/late-static-class-return.phpt new file mode 100644 index 00000000..9d7c45a6 --- /dev/null +++ b/tests/compiler/static/late-static-class-return.phpt @@ -0,0 +1,82 @@ +--TEST-- +static::class resolves to the called class through string-typed methods +--FILE-- +instanceClass()); + + // Late static binding through a static call. + var_dump(LsbChild::staticClass()); + var_dump(LsbGrandChild::staticClass()); + + // Late static binding through an inherited instance method. + var_dump((new LsbChild())->instanceClass()); + var_dump((new LsbGrandChild())->instanceClass()); + + // The result assigned to a local variable and returned. + var_dump(LsbChild::viaVar()); + + // static::class in a trait body resolves to the consuming class. + var_dump((new LsbChild())->traitClass()); + + // Untyped return keeps the runtime value intact. + var_dump(LsbGrandChild::untypedClass()); +} +?> +--EXPECT-- +string(7) "LsbBase" +string(7) "LsbBase" +string(8) "LsbChild" +string(13) "LsbGrandChild" +string(8) "LsbChild" +string(13) "LsbGrandChild" +string(8) "LsbChild" +string(8) "LsbChild" +string(13) "LsbGrandChild"