mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
Fix issue where documented self param confuses
This commit is contained in:
parent
407e4473f7
commit
9f16ab9cb5
@ -620,18 +620,32 @@ class MethodAnalyzer extends FunctionLikeAnalyzer
|
||||
&& $guide_param->type
|
||||
&& $implementer_param->type->getId() !== $guide_param->type->getId()
|
||||
) {
|
||||
if (!TypeAnalyzer::isContainedBy(
|
||||
$implementer_method_storage_param_type = ExpressionAnalyzer::fleshOutType(
|
||||
$codebase,
|
||||
$implementer_param->type,
|
||||
$implementer_classlike_storage->name,
|
||||
$implementer_classlike_storage->name
|
||||
);
|
||||
|
||||
$guide_method_storage_param_type = ExpressionAnalyzer::fleshOutType(
|
||||
$codebase,
|
||||
$guide_param->type,
|
||||
$implementer_param->type,
|
||||
$guide_classlike_storage->name,
|
||||
$guide_classlike_storage->name
|
||||
);
|
||||
|
||||
if (!TypeAnalyzer::isContainedBy(
|
||||
$codebase,
|
||||
$guide_method_storage_param_type,
|
||||
$implementer_method_storage_param_type,
|
||||
false,
|
||||
false
|
||||
)) {
|
||||
if (IssueBuffer::accepts(
|
||||
new MoreSpecificImplementedParamType(
|
||||
'Argument ' . ($i + 1) . ' of ' . $cased_implementer_method_id . ' has wrong type \'' .
|
||||
$implementer_param->type->getId() . '\', expecting \'' .
|
||||
$guide_param->type->getId() . '\' as defined by ' .
|
||||
$implementer_method_storage_param_type->getId() . '\', expecting \'' .
|
||||
$guide_method_storage_param_type->getId() . '\' as defined by ' .
|
||||
$cased_guide_method_id,
|
||||
$implementer_method_storage->params[$i]->location
|
||||
?: $code_location
|
||||
|
@ -335,6 +335,21 @@ class MethodSignatureTest extends TestCase
|
||||
}
|
||||
}',
|
||||
],
|
||||
'inheritDocumentedSelf' => [
|
||||
'<?php
|
||||
interface I {
|
||||
/**
|
||||
* @param self $f
|
||||
*/
|
||||
public function foo(self $f) : self;
|
||||
}
|
||||
|
||||
class C implements I {
|
||||
public function foo(I $i) : I {
|
||||
return new C();
|
||||
}
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user