From 66fa08148805d4935218b9593885dd3e0af1394d Mon Sep 17 00:00:00 2001 From: Matthew Brown Date: Sun, 7 Jan 2018 18:06:31 -0500 Subject: [PATCH] Fix issue with nullable types going into docblock --- src/Psalm/Checker/FunctionLikeChecker.php | 4 ++-- .../FunctionDocblockManipulator.php | 1 - tests/FileManipulationTest.php | 18 +++++++++++++++++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/Psalm/Checker/FunctionLikeChecker.php b/src/Psalm/Checker/FunctionLikeChecker.php index 4dcaa873c..839580805 100644 --- a/src/Psalm/Checker/FunctionLikeChecker.php +++ b/src/Psalm/Checker/FunctionLikeChecker.php @@ -423,7 +423,7 @@ abstract class FunctionLikeChecker extends SourceChecker implements StatementsSo if ($project_checker->alter_code && isset($project_checker->getIssuesToFix()['MismatchingDocblockReturnType']) ) { - $this->addOrUpdateReturnType($project_checker, $storage->signature_return_type, true); + $this->addOrUpdateReturnType($project_checker, $storage->signature_return_type); return null; } @@ -1331,7 +1331,7 @@ abstract class FunctionLikeChecker extends SourceChecker implements StatementsSo && !$declared_return_type->isVoid() ) { if ($project_checker->alter_code - && isset($project_checker->getIssuesToFix()['UnexpectedNullableReturnType']) + && isset($project_checker->getIssuesToFix()['InvalidNullableReturnType']) ) { $this->addOrUpdateReturnType( $project_checker, diff --git a/src/Psalm/FileManipulation/FunctionDocblockManipulator.php b/src/Psalm/FileManipulation/FunctionDocblockManipulator.php index ac6ca854e..bcfd3a474 100644 --- a/src/Psalm/FileManipulation/FunctionDocblockManipulator.php +++ b/src/Psalm/FileManipulation/FunctionDocblockManipulator.php @@ -350,7 +350,6 @@ class FunctionDocblockManipulator } } elseif ($manipulator->return_typehint_colon_start && $manipulator->new_phpdoc_return_type - && !$manipulator->return_type_is_php_compatible && $manipulator->return_typehint_start && $manipulator->return_typehint_end ) { diff --git a/tests/FileManipulationTest.php b/tests/FileManipulationTest.php index 1b4cb493e..e49367f3e 100644 --- a/tests/FileManipulationTest.php +++ b/tests/FileManipulationTest.php @@ -449,7 +449,7 @@ class FileManipulationTest extends TestCase ['InvalidReturnType'], true, ], - 'fixInvalidIntReturnTypeThatIsNotPhpCompatible70' => [ + 'fixInvalidStringReturnTypeThatIsNotPhpCompatible70' => [ ' [ + ' [ '