The expression $this->canBeString($value) of type boolean|null is loosely compared to false; this is ambiguous if the boolean can be false. You might want to explicitly use !== null instead.
If an expression can have both false, and null as possible values. It
is generally a good practice to always use strict comparison to clearly
distinguish between those two values.
$a=canBeFalseAndNull();// Instead ofif(!$a){}// Better use one of the explicit versions:if($a!==null){}if($a!==false){}if($a!==null&&$a!==false){}
Loading history...
22
1
throw new InvalidArgumentException('You must supply a value.');
23
}
24
1
$this->value = (string) $value;
25
1
}
26
27
/**
28
* @return string
29
*/
30
1
public function getValue()
31
{
32
1
return parent::getValue();
33
}
34
35
/**
36
* @param $value
37
* @return bool
38
*/
39
1
private function canBeString($value)
40
{
41
1
switch(true) {
42
1
case is_object($value) && method_exists($value, '__toString'):
If an expression can have both
false
, andnull
as possible values. It is generally a good practice to always use strict comparison to clearly distinguish between those two values.