Skip to content

Commit

Permalink
Return false in fewer places
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Jun 30, 2019
1 parent 220fa31 commit 0e8fa0e
Showing 1 changed file with 31 additions and 27 deletions.
58 changes: 31 additions & 27 deletions src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,7 @@ protected static function checkFunctionLikeArgumentsMatch(
$generic_params,
$template_types
) === false) {
return false;
return;
}
}

Expand Down Expand Up @@ -1206,7 +1206,7 @@ protected static function checkFunctionLikeArgumentsMatch(
),
$statements_analyzer->getSuppressedIssues()
)) {
return false;
// fall through
}
} elseif ($method_id === 'array_filter' && count($args) < 1) {
if (IssueBuffer::accepts(
Expand All @@ -1217,7 +1217,7 @@ protected static function checkFunctionLikeArgumentsMatch(
),
$statements_analyzer->getSuppressedIssues()
)) {
return false;
// fall through
}
}

Expand All @@ -1230,6 +1230,8 @@ protected static function checkFunctionLikeArgumentsMatch(
) {
return false;
}

return null;
}

if (!$is_variadic
Expand Down Expand Up @@ -1279,7 +1281,7 @@ protected static function checkFunctionLikeArgumentsMatch(
),
$statements_analyzer->getSuppressedIssues()
)) {
return false;
// fall through
}

break;
Expand Down Expand Up @@ -1442,10 +1444,10 @@ private static function handlePossiblyMatchingByRefParam(
),
$statements_analyzer->getSuppressedIssues()
)) {
return false;
// fall through
}

return;
return false;
}

if (!in_array(
Expand Down Expand Up @@ -1693,8 +1695,10 @@ private static function checkFunctionLikeTypeMatches(
),
$statements_analyzer->getSuppressedIssues()
)) {
return false;
// fall through
}

continue;
}
}

Expand Down Expand Up @@ -1848,7 +1852,7 @@ protected static function checkArrayFunctionArgumentsMatch(
}

foreach ($closure_arg_type->getTypes() as $closure_type) {
if (self::checkArrayFunctionClosureType(
self::checkArrayFunctionClosureType(
$statements_analyzer,
$method_id,
$closure_type,
Expand All @@ -1857,9 +1861,7 @@ protected static function checkArrayFunctionArgumentsMatch(
$max_closure_param_count,
$array_arg_types,
$check_functions
) === false) {
return false;
}
);
}
}
}
Expand All @@ -1870,7 +1872,7 @@ protected static function checkArrayFunctionArgumentsMatch(
* @param int $max_closure_param_count [description]
* @param (TArray|null)[] $array_arg_types
*
* @return false|null
* @return void
*/
private static function checkArrayFunctionClosureType(
StatementsAnalyzer $statements_analyzer,
Expand Down Expand Up @@ -2008,17 +2010,15 @@ private static function checkArrayFunctionClosureType(
continue;
}

if (self::checkArrayFunctionClosureTypeArgs(
self::checkArrayFunctionClosureTypeArgs(
$statements_analyzer,
$method_id,
$closure_type,
$closure_arg,
$min_closure_param_count,
$max_closure_param_count,
$array_arg_types
) === false) {
return false;
}
);
}
}

Expand All @@ -2029,7 +2029,7 @@ private static function checkArrayFunctionClosureType(
* @param int $max_closure_param_count
* @param (TArray|null)[] $array_arg_types
*
* @return false|null
* @return void
*/
private static function checkArrayFunctionClosureTypeArgs(
StatementsAnalyzer $statements_analyzer,
Expand Down Expand Up @@ -2068,8 +2068,10 @@ private static function checkArrayFunctionClosureTypeArgs(
),
$statements_analyzer->getSuppressedIssues()
)) {
return false;
// fall through
}

return;
} elseif ($required_param_count > $max_closure_param_count) {
$argument_text = $max_closure_param_count === 1 ? 'one argument' : $max_closure_param_count . ' arguments';

Expand All @@ -2082,8 +2084,10 @@ private static function checkArrayFunctionClosureTypeArgs(
),
$statements_analyzer->getSuppressedIssues()
)) {
return false;
// fall through
}

return;
}

// abandon attempt to validate closure params if we have an extra arg for ARRAY_FILTER
Expand Down Expand Up @@ -2196,7 +2200,7 @@ private static function checkArrayFunctionClosureTypeArgs(
),
$statements_analyzer->getSuppressedIssues()
)) {
return false;
// fall through
}
}

Expand Down Expand Up @@ -2313,7 +2317,7 @@ public static function checkFunctionArgumentType(
),
$statements_analyzer->getSuppressedIssues()
)) {
return false;
// fall through
}

return null;
Expand Down Expand Up @@ -2503,7 +2507,7 @@ public static function checkFunctionArgumentType(
$statements_analyzer->getSuppressedIssues()
) === false
) {
return false;
return;
}
} elseif ($param_type_part instanceof TArray
&& $input_expr instanceof PhpParser\Node\Expr\Array_
Expand All @@ -2519,7 +2523,7 @@ public static function checkFunctionArgumentType(
$statements_analyzer->getSuppressedIssues()
) === false
) {
return false;
return;
}
}
}
Expand Down Expand Up @@ -2567,7 +2571,7 @@ public static function checkFunctionArgumentType(
$statements_analyzer->getSuppressedIssues()
) === false
) {
return false;
return;
}

if (!$codebase->classOrInterfaceExists($callable_fq_class_name)) {
Expand All @@ -2591,7 +2595,7 @@ public static function checkFunctionArgumentType(
$statements_analyzer->getSuppressedIssues()
) === false
) {
return false;
return;
}
}
} else {
Expand All @@ -2602,7 +2606,7 @@ public static function checkFunctionArgumentType(
false
) === false
) {
return false;
return;
}
}
}
Expand All @@ -2621,7 +2625,7 @@ public static function checkFunctionArgumentType(
),
$statements_analyzer->getSuppressedIssues()
)) {
return false;
// fall through
}

return null;
Expand Down

0 comments on commit 0e8fa0e

Please sign in to comment.