1 | <?php |
||
7 | class Guard |
||
8 | { |
||
9 | /** |
||
10 | * return collection of (guard_name) property if exist on class or object |
||
11 | * otherwise will return collection of guards names that exists in config/auth.php. |
||
12 | * @param $model |
||
13 | * @return Collection |
||
14 | */ |
||
15 | public static function getNames($model): Collection |
||
48 | |||
49 | public static function getDefaultName($class): string |
||
55 | } |
||
56 |
If you define a variable conditionally, it can happen that it is not defined for all execution paths.
Let’s take a look at an example:
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.
Available Fixes
Check for existence of the variable explicitly:
Define a default value for the variable:
Add a value for the missing path: