1
0
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:
Matthew Brown 2018-01-23 01:32:16 -05:00
parent e249c27308
commit fdadcd3a70
2 changed files with 30 additions and 1 deletions

View File

@ -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,

View File

@ -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;
}
}',
],
]; ];
} }