From 10a90d227054037260d48d23025e9638e01d2f6e Mon Sep 17 00:00:00 2001 From: rightfold Date: Sat, 21 Apr 2018 22:01:10 +0200 Subject: [PATCH] Use less obscure method for checking a string against many other strings --- src/Psalm/Checker/MethodChecker.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Psalm/Checker/MethodChecker.php b/src/Psalm/Checker/MethodChecker.php index fee0ed716..a9cbbac26 100644 --- a/src/Psalm/Checker/MethodChecker.php +++ b/src/Psalm/Checker/MethodChecker.php @@ -663,6 +663,9 @@ class MethodChecker extends FunctionLikeChecker } /** + * Check that __clone, __construct, and __destruct do not have a return type + * hint in their signature. + * * @param MethodStorage $method_storage * @param CodeLocation $code_location * @return false|null @@ -676,10 +679,8 @@ class MethodChecker extends FunctionLikeChecker } $cased_method_name = $method_storage->cased_name; - switch ($cased_method_name) { - case '__clone': - case '__construct': - case '__destruct': + $methodsOfInterest = ['__clone', '__construct', '__destruct']; + if (in_array($cased_method_name, $methodsOfInterest)) { if (IssueBuffer::accepts( new MethodSignatureMustOmitReturnType( 'Method ' . $cased_method_name . ' must not declare a return type', @@ -688,8 +689,8 @@ class MethodChecker extends FunctionLikeChecker )) { return false; } - - return null; } + + return null; } }