| 1 | <?php |
||
| 27 | class LoadGroupData extends AbstractFixture implements OrderedFixtureInterface |
||
| 28 | { |
||
| 29 | private $datas = [ |
||
| 30 | ['admin', 'ROLE_SUPER_ADMIN'], |
||
| 31 | ['assistant','ROLE_ADMIN'], |
||
| 32 | ['user', 'ROLE_USER'] |
||
| 33 | ]; |
||
| 34 | |||
| 35 | public function load(ObjectManager $manager) |
||
| 48 | |||
| 49 | public function getOrder() |
||
| 53 | } |
||
| 54 |
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: