The expression $hash of type string|null 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...
43
$this->redis->set($hash, $content);
44
$this->redis->expire($hash, 7 * 24 * 60 * 1000); // cache for a week
45
}
46
}
47
48
/**
49
* @param Widget $widget
50
*
51
* @return string
52
*/
53
protected function getHash(Widget $widget)
54
{
55
$hash = null;
56
if ($widget->getMode() == Widget::MODE_BUSINESS_ENTITY
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: