mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
Fix implemented interface checks for self/static
This commit is contained in:
parent
e249c27308
commit
fdadcd3a70
@ -772,10 +772,24 @@ abstract class FunctionLikeChecker extends SourceChecker implements StatementsSo
|
|||||||
&& $implementer_method_storage->return_type
|
&& $implementer_method_storage->return_type
|
||||||
&& $implementer_classlike_storage->user_defined
|
&& $implementer_classlike_storage->user_defined
|
||||||
) {
|
) {
|
||||||
if (!TypeChecker::isContainedBy(
|
$implementer_method_storage_return_type = ExpressionChecker::fleshOutType(
|
||||||
$project_checker,
|
$project_checker,
|
||||||
$implementer_method_storage->return_type,
|
$implementer_method_storage->return_type,
|
||||||
|
$implementer_classlike_storage->name,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
|
$guide_method_storage_return_type = ExpressionChecker::fleshOutType(
|
||||||
|
$project_checker,
|
||||||
$guide_method_storage->return_type,
|
$guide_method_storage->return_type,
|
||||||
|
$guide_classlike_storage->name,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!TypeChecker::isContainedBy(
|
||||||
|
$project_checker,
|
||||||
|
$implementer_method_storage_return_type,
|
||||||
|
$guide_method_storage_return_type,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
$has_scalar_match,
|
$has_scalar_match,
|
||||||
|
@ -323,6 +323,21 @@ class InterfaceTest extends TestCase
|
|||||||
}
|
}
|
||||||
}',
|
}',
|
||||||
],
|
],
|
||||||
|
'implementStaticReturn' => [
|
||||||
|
'<?php
|
||||||
|
class A {}
|
||||||
|
interface I {
|
||||||
|
/** @return A */
|
||||||
|
public function foo();
|
||||||
|
}
|
||||||
|
|
||||||
|
class B extends A implements I {
|
||||||
|
/** @return static */
|
||||||
|
public function foo() {
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user