1 | <?php |
||
13 | class Migrate extends YarakCommand |
||
14 | { |
||
15 | /** |
||
16 | * Configure the command. |
||
17 | */ |
||
18 | protected function configure() |
||
30 | |||
31 | /** |
||
32 | * Add rollback option. |
||
33 | */ |
||
34 | protected function addRollback() |
||
43 | |||
44 | /** |
||
45 | * Add steps option. |
||
46 | */ |
||
47 | protected function addSteps() |
||
57 | |||
58 | /** |
||
59 | * Add reset option. |
||
60 | */ |
||
61 | protected function addReset() |
||
70 | |||
71 | /** |
||
72 | * Add refresh option. |
||
73 | */ |
||
74 | protected function addRefresh() |
||
83 | |||
84 | /** |
||
85 | * Add seed option. |
||
86 | */ |
||
87 | protected function addSeed() |
||
96 | |||
97 | protected function addSeedClass() |
||
107 | |||
108 | /** |
||
109 | * Execute the command. |
||
110 | * |
||
111 | * @param InputInterface $input |
||
112 | * @param OutputInterface $output |
||
113 | */ |
||
114 | protected function execute(InputInterface $input, OutputInterface $output) |
||
132 | |||
133 | /** |
||
134 | * Get an instance of the migrator. |
||
135 | * |
||
136 | * @return Migrator |
||
137 | */ |
||
138 | protected function getMigrator() |
||
150 | |||
151 | /** |
||
152 | * Get the name of the migrator class. |
||
153 | * |
||
154 | * @param Config $config |
||
155 | * |
||
156 | * @return string |
||
157 | */ |
||
158 | protected function getMigratorClassName(Config $config) |
||
165 | |||
166 | /** |
||
167 | * Get an instance of MigrationRepository. |
||
168 | * |
||
169 | * @param Config $config |
||
170 | * |
||
171 | * @return Yarak\Migrations\MigrationRepository |
||
172 | */ |
||
173 | protected function getRepository(Config $config) |
||
182 | |||
183 | /** |
||
184 | * Perform the database refresh. |
||
185 | * |
||
186 | * @param Migrator $migrator |
||
187 | * @param InputInterface $input |
||
188 | */ |
||
189 | protected function preformRefresh(Migrator $migrator, InputInterface $input) |
||
203 | } |
||
204 |
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: