1 | <?php |
||
7 | class MissionsAleatoire { |
||
8 | |||
9 | |||
10 | |||
11 | //-------------------------- BUILDER ----------------------------------------------------------------------------// |
||
12 | public function __construct() { |
||
40 | //-------------------------- END BUILDER ----------------------------------------------------------------------------// |
||
41 | |||
42 | |||
43 | |||
44 | //-------------------------- GETTER ----------------------------------------------------------------------------// |
||
45 | /** |
||
46 | * fonction qui récupere tous les types de missions et les return dans un array |
||
47 | */ |
||
48 | private function getTypeMission() { |
||
51 | //-------------------------- END GETTER ----------------------------------------------------------------------------// |
||
52 | |||
53 | |||
54 | |||
55 | //-------------------------- SETTER ----------------------------------------------------------------------------// |
||
56 | /** |
||
57 | * fonction qui met a jour le last_ckeck_missions dans _bataille_base |
||
58 | * le met à la date du jour |
||
59 | */ |
||
60 | public function setUpdateLastCheckMissions() { |
||
68 | |||
69 | /** |
||
70 | * @param $type |
||
71 | * fonction qui recupere des missions aleatoirement de chaque type et qui les ajoute |
||
72 | * dans la table _bataille_mission_aleatoire |
||
73 | */ |
||
74 | private function setMissionsAleatoire() { |
||
99 | //-------------------------- END SETTER ----------------------------------------------------------------------------// |
||
100 | |||
101 | } |
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: