1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Use less obscure method for checking a string against many other strings

This commit is contained in:
rightfold 2018-04-21 22:01:10 +02:00 committed by Matthew Brown
parent e6d9854883
commit 10a90d2270

View File

@ -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;
}
}
}