The expression $method of type null|string is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.
In PHP, under loose comparison (like ==, or !=, or switch conditions),
values of different types might be equal.
For string values, the empty string '' is a special case, in particular
the following results might be unexpected:
''==false// true''==null// true'ab'==false// false'ab'==null// false// It is often better to use strict comparison''===false// false''===null// false
Loading history...
21
$this->$method($event, $domainMessage);
22
}
23
}
24
25
private function getHandleMethodName($event)
26
{
27
$classParts = explode('\\', get_class($event));
28
$methodName = 'apply' . end($classParts);
29
30
if (!method_exists($this, $methodName)) {
31
return null;
32
}
33
34
try {
35
$parameter = new \ReflectionParameter(array($this, $methodName), 0);
36
} catch (\ReflectionException $e) {
37
// No parameter for the method, so we ignore it.
38
return null;
39
}
40
41
$expectedClass = $parameter->getClass();
42
43
if ($expectedClass->getName() !== get_class($event)) {
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: