The expression $page of type string|null is loosely compared to false; 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...
26
$page = 'posts';
27
}
28
29
$path = $this->module->find($page);
30
31
if ($path === null) {
32
throw new NotFoundHttpException(Yii::t('yii', 'Page not found.'));
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: