Skip to content
Permalink
Browse files

Fix #1622 - don’t update return types in docblocks when overridden el…

…sewhere
  • Loading branch information...
muglug committed May 13, 2019
1 parent 9b4d841 commit f8b4b12ec28127a6823742f1cf3b5562136a0a4e
@@ -344,13 +344,20 @@ public static function verifyReturnType(
return null;
}
if ($codebase->alter_code && isset($project_analyzer->getIssuesToFix()['InvalidReturnType'])) {
if ($codebase->alter_code
&& isset($project_analyzer->getIssuesToFix()['InvalidReturnType'])
&& !in_array('InvalidReturnType', $suppressed_issues)
) {
self::addOrUpdateReturnType(
$function,
$project_analyzer,
Type::getVoid(),
$source,
$function_like_analyzer
$function_like_analyzer,
$compatible_method_ids
|| (($project_analyzer->only_replace_php_types_with_non_docblock_types
|| $unsafe_return_type)
&& $inferred_return_type->from_docblock)
);
return null;
@@ -1037,6 +1037,101 @@ public function getC(): self {
['LessSpecificReturnType'],
true,
],
'addMissingReturnTypeWhenParentHasNone' => [
'<?php
class A {
/** @psalm-suppress MissingReturnType */
public function foo() {
return;
}
}
class B extends A {
public function foo() {
return;
}
}',
'<?php
class A {
/** @psalm-suppress MissingReturnType */
public function foo() {
return;
}
}
class B extends A {
/**
* @return void
*/
public function foo() {
return;
}
}',
'7.1',
['MissingReturnType'],
false,
],
'dontAddMissingReturnTypeWhenChildHasNone' => [
'<?php
class A {
public function foo() {}
}
class B extends A {
/** @psalm-suppress MissingReturnType */
public function foo() {}
}',
'<?php
class A {
/**
* @return void
*/
public function foo() {}
}
class B extends A {
/** @psalm-suppress MissingReturnType */
public function foo() {}
}',
'7.1',
['MissingReturnType'],
false,
],
'fixInvalidIntReturnTypeJustInPhpDoc' => [
'<?php
class A {
/**
* @return int
* @psalm-suppress InvalidReturnType
*/
protected function foo() {}
}
class B extends A {
/**
* @return int
*/
protected function foo() {}
}',
'<?php
class A {
/**
* @return int
* @psalm-suppress InvalidReturnType
*/
protected function foo() {}
}
class B extends A {
/**
* @return void
*/
protected function foo() {}
}',
'7.3',
['InvalidReturnType'],
false,
],
];
}
}

0 comments on commit f8b4b12

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