Skip to content
Permalink
Browse files

Fix incorrect message when inheriting parent docblock

  • Loading branch information...
muglug committed May 9, 2019
1 parent 6a473f6 commit 629eeed3e68cbc9bc04b03e1d110a6eabdec602d
@@ -655,11 +655,12 @@ public static function checkReturnType(
$context->self
);
if (!TypeAnalyzer::isContainedBy(
$codebase,
$fleshed_out_return_type,
$fleshed_out_signature_type
)
if ((!$storage instanceof MethodStorage || !$storage->imported_return_type)
&& !TypeAnalyzer::isContainedBy(
$codebase,
$fleshed_out_return_type,
$fleshed_out_signature_type
)
) {
if ($codebase->alter_code
&& isset($project_analyzer->getIssuesToFix()['MismatchingDocblockReturnType'])
@@ -322,11 +322,13 @@ private function populateOverriddenMethods(
) {
if ($declaring_method_storage->signature_return_type) {
$method_storage->return_type = $declaring_method_storage->return_type;
$method_storage->imported_return_type = true;
} elseif (TypeAnalyzer::isSimplyContainedBy(
$declaring_method_storage->return_type,
$method_storage->signature_return_type
)) {
$method_storage->return_type = $declaring_method_storage->return_type;
$method_storage->imported_return_type = true;
}
}
}
@@ -59,4 +59,9 @@ class MethodStorage extends FunctionLikeStorage
* @var bool
*/
public $has_docblock_param_types = false;
/**
* @var bool
*/
public $imported_return_type = false;
}
@@ -967,6 +967,21 @@ public function doFoo(): array {
'$b' => 'array<array-key, int>',
]
],
'allowLessSpecificDocblockTypeOnParent' => [
'<?php
abstract class Foo {
/**
* @return array|string
*/
abstract public function getTargets();
}
class Bar extends Foo {
public function getTargets(): string {
return "baz";
}
}',
],
];
}

0 comments on commit 629eeed

Please sign in to comment.
You can’t perform that action at this time.