Skip to content
Permalink
Browse files

Fix #2348 - ensure all functions and methods return some type

  • Loading branch information
muglug committed Nov 14, 2019
1 parent b3a15e8 commit 5e17a9af104de39321c47f73b253cece9df1cf2c
@@ -918,6 +918,10 @@ function (array $_) : bool {
}
}
if (!isset($stmt->inferredType)) {
$stmt->inferredType = Type::getMixed();
}
return null;
}
}
@@ -1126,5 +1126,9 @@ function (Assertion $assertion) use ($generic_params) : Assertion {
if (!$config->remember_property_assignments_after_call && !$context->collect_initializations) {
$context->removeAllObjectVars();
}
if (!isset($stmt->inferredType)) {
$stmt->inferredType = Type::getMixed();
}
}
}
@@ -1172,6 +1172,45 @@ function strtr_wrapper($str, array $replace_pairs) {
array_intersect_key([], [], [], [], []);',
'assertions' => [],
],
'arrayIntersectKeyNoReturnType' => [
'<?php
/**
* @psalm-suppress MissingReturnType
*/
function unknown() {
return ["x" => "hello"];
}
class C {
/**
* @psalm-suppress MissingReturnType
*/
public static function unknownStatic() {
return ["x" => "hello"];
}
/**
* @psalm-suppress MissingReturnType
*/
public static function unknownInstance() {
return ["x" => "hello"];
}
}
/**
* @psalm-suppress MixedArgument
*/
function sdn(array $s) : void {
$r = array_intersect_key(unknown(), array_filter($s));
if (empty($r)) {}
$r = array_intersect_key(C::unknownStatic(), array_filter($s));
if (empty($r)) {}
$r = array_intersect_key((new C)->unknownInstance(), array_filter($s));
if (empty($r)) {}
}',
],
'arrayReduce' => [
'<?php
$arr = [2, 3, 4, 5];

0 comments on commit 5e17a9a

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