From 72cbdc500a1805dda5180ef0e7c714d47afcba6a Mon Sep 17 00:00:00 2001 From: Yurun Date: Wed, 15 Jul 2026 19:20:57 +0800 Subject: [PATCH] =?UTF-8?q?fix(compiler):=20=E4=BF=AE=E5=A4=8D=E5=A3=B0?= =?UTF-8?q?=E6=98=8E=E5=85=88=E5=90=8E=E5=BD=B1=E5=93=8D=E8=B7=A8=E5=91=BD?= =?UTF-8?q?=E5=90=8D=E7=A9=BA=E9=97=B4=E6=8E=A5=E5=8F=A3=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Translator.php | 4 +- .../interface-impl-param-type-cross-ns.phpt | 48 +++++++++++++++++++ 2 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 tests/compiler/namespace/interface-impl-param-type-cross-ns.phpt diff --git a/src/Translator.php b/src/Translator.php index 676618a3..ce370f1e 100644 --- a/src/Translator.php +++ b/src/Translator.php @@ -3249,8 +3249,8 @@ CODE; Type::STR => [['kind' => 'isString']], Type::ARRAY => [['kind' => 'isArray']], Type::RESOURCE => [['kind' => 'isResource']], - Type::OBJECT => $arg->class - ? [['kind' => 'instanceof', 'class' => $arg->class]] + Type::OBJECT => $arg->declaredClass + ? [['kind' => 'instanceof', 'class' => $arg->declaredClass]] : [['kind' => 'isObject']], default => null, }; diff --git a/tests/compiler/namespace/interface-impl-param-type-cross-ns.phpt b/tests/compiler/namespace/interface-impl-param-type-cross-ns.phpt new file mode 100644 index 00000000..acaec9e6 --- /dev/null +++ b/tests/compiler/namespace/interface-impl-param-type-cross-ns.phpt @@ -0,0 +1,48 @@ +--TEST-- +Cross-namespace interface implementation with an interface-typed parameter must not be reported as incompatible +--FILE-- +test(new \B\Impl1())); + echo "done\n"; + } +} +?> +--EXPECT-- +bool(true) +done