diff --git a/src/Translator.php b/src/Translator.php index ce370f1e..e7c3838a 100644 --- a/src/Translator.php +++ b/src/Translator.php @@ -3242,6 +3242,7 @@ CODE; return $arg->typeCheck; } + $declaredClass = $arg->declaredClass ?: $arg->class; return match ($arg->type) { Type::INT => [['kind' => 'isInt']], Type::FLOAT => [['kind' => 'isFloat']], @@ -3249,8 +3250,8 @@ CODE; Type::STR => [['kind' => 'isString']], Type::ARRAY => [['kind' => 'isArray']], Type::RESOURCE => [['kind' => 'isResource']], - Type::OBJECT => $arg->declaredClass - ? [['kind' => 'instanceof', 'class' => $arg->declaredClass]] + Type::OBJECT => $declaredClass + ? [['kind' => 'instanceof', 'class' => $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 index acaec9e6..535212a7 100644 --- a/tests/compiler/namespace/interface-impl-param-type-cross-ns.phpt +++ b/tests/compiler/namespace/interface-impl-param-type-cross-ns.phpt @@ -1,8 +1,9 @@ --TEST-- -Cross-namespace interface implementation with an interface-typed parameter must not be reported as incompatible +Cross-namespace interface implementation parameter compatibility is declaration-order independent --FILE-- test(new \B\Impl1())); + var_dump($obj->testParent(new \B\Impl1())); echo "done\n"; } } ?> --EXPECT-- bool(true) +bool(true) done