diff --git a/config.xsd b/config.xsd
index 54da4b56d..4e640aa79 100644
--- a/config.xsd
+++ b/config.xsd
@@ -22,6 +22,7 @@
+
diff --git a/src/Psalm/Checker/FunctionLikeChecker.php b/src/Psalm/Checker/FunctionLikeChecker.php
index 3f7c03e14..782853180 100644
--- a/src/Psalm/Checker/FunctionLikeChecker.php
+++ b/src/Psalm/Checker/FunctionLikeChecker.php
@@ -824,7 +824,7 @@ abstract class FunctionLikeChecker extends SourceChecker implements StatementsSo
if ($this->function instanceof Closure) {
if (IssueBuffer::accepts(
new MissingClosureReturnType(
- 'Closure does not have a return type',
+ 'Closure does not have a return type, expecting ' . $inferred_return_type,
new CodeLocation($this, $this->function, true)
),
$this->suppressed_issues
@@ -837,7 +837,7 @@ abstract class FunctionLikeChecker extends SourceChecker implements StatementsSo
if (IssueBuffer::accepts(
new MissingReturnType(
- 'Method ' . $cased_method_id . ' does not have a return type',
+ 'Method ' . $cased_method_id . ' does not have a return type, expecting ' . $inferred_return_type,
new CodeLocation($this, $this->function, true)
),
$this->suppressed_issues
@@ -848,23 +848,6 @@ abstract class FunctionLikeChecker extends SourceChecker implements StatementsSo
return null;
}
- $inferred_yield_types = [];
- $inferred_return_types = EffectsAnalyser::getReturnTypes(
- $this->function->getStmts(),
- $inferred_yield_types,
- true
- );
-
- $inferred_return_type = $inferred_return_types ? Type::combineTypes($inferred_return_types) : Type::getVoid();
- $inferred_yield_type = $inferred_yield_types ? Type::combineTypes($inferred_yield_types) : null;
-
- $inferred_generator_return_type = null;
-
- if ($inferred_yield_type) {
- $inferred_generator_return_type = $inferred_return_type;
- $inferred_return_type = $inferred_yield_type;
- }
-
if ($is_to_string) {
if (!$inferred_return_type->isMixed() && (string)$inferred_return_type !== 'string') {
if (IssueBuffer::accepts(
@@ -956,16 +939,6 @@ abstract class FunctionLikeChecker extends SourceChecker implements StatementsSo
return null;
}
- $inferred_return_type = TypeChecker::simplifyUnionType(
- ExpressionChecker::fleshOutTypes(
- $inferred_return_type,
- [],
- $this->source->getFQCLN(),
- ''
- ),
- $this->getFileChecker()
- );
-
$return_types_different = false;
if (!TypeChecker::isContainedBy($inferred_return_type, $declared_return_type, $this->getFileChecker())) {
diff --git a/src/Psalm/Config.php b/src/Psalm/Config.php
index 015805f45..b1c24cff3 100644
--- a/src/Psalm/Config.php
+++ b/src/Psalm/Config.php
@@ -141,6 +141,9 @@ class Config
/** @var bool */
public $strict_binary_operands = false;
+ /** @var bool */
+ public $add_void_docblocks = true;
+
/**
* Psalm plugins
*
@@ -275,6 +278,11 @@ class Config
$config->strict_binary_operands = $attribute_text === 'true' || $attribute_text === '1';
}
+ if (isset($config_xml['addVoidDocblockReturnType'])) {
+ $attribute_text = (string) $config_xml['addVoidDocblockReturnType'];
+ $config->add_void_docblocks = $attribute_text === 'true' || $attribute_text === '1';
+ }
+
if (isset($config_xml->projectFiles)) {
$config->project_files = ProjectFileFilter::loadFromXMLElement($config_xml->projectFiles, $config, true);
}
diff --git a/tests/JsonOutputTest.php b/tests/JsonOutputTest.php
index d4b2b47bf..fe835c381 100644
--- a/tests/JsonOutputTest.php
+++ b/tests/JsonOutputTest.php
@@ -146,7 +146,7 @@ class JsonOutputTest extends PHPUnit_Framework_TestCase
$issue_data = IssueBuffer::getIssueData()[0];
$this->assertSame('somefile.php', $issue_data['file_path']);
$this->assertSame('error', $issue_data['type']);
- $this->assertSame('Method fooFoo does not have a return type', $issue_data['message']);
+ $this->assertSame('Method fooFoo does not have a return type, expecting string', $issue_data['message']);
$this->assertSame(2, $issue_data['line_number']);
$this->assertSame(
'function fooFoo() {',