1 | <?php |
||
16 | class AbstractCommand extends AbstractMagentoCommand |
||
17 | { |
||
18 | /** |
||
19 | * @var Mage_Core_Model_Config |
||
20 | */ |
||
21 | protected $config; |
||
22 | |||
23 | /** |
||
24 | * @var string |
||
25 | */ |
||
26 | protected $modulesDir; |
||
27 | |||
28 | /** |
||
29 | * @var string |
||
30 | */ |
||
31 | protected $commandName; |
||
32 | |||
33 | /** |
||
34 | * Setup |
||
35 | * |
||
36 | * @return void |
||
37 | */ |
||
38 | protected function configure() |
||
39 | { |
||
40 | $this |
||
41 | ->setName('dev:module:' . $this->commandName) |
||
42 | ->addArgument('moduleName', InputArgument::OPTIONAL, 'Name of module to ' . $this->commandName) |
||
43 | ->addOption('codepool', null, InputOption::VALUE_OPTIONAL, 'Name of codePool to ' . $this->commandName) |
||
44 | ->setDescription(ucwords($this->commandName) . ' a module or all modules in codePool'); |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * Execute command |
||
49 | * |
||
50 | * @param InputInterface $input |
||
51 | * @param OutputInterface $output |
||
52 | * |
||
53 | * @return void |
||
54 | * |
||
55 | * @throws InvalidArgumentException |
||
56 | */ |
||
57 | protected function execute(InputInterface $input, OutputInterface $output) |
||
75 | |||
76 | /** |
||
77 | * Search a code pool for modules and enable them |
||
78 | * |
||
79 | * @param string $codePool |
||
80 | * @param OutputInterface $output |
||
81 | * |
||
82 | * @return int|void |
||
83 | */ |
||
84 | protected function enableCodePool($codePool, OutputInterface $output) |
||
93 | |||
94 | /** |
||
95 | * Enable a single module |
||
96 | * |
||
97 | * @param string $module |
||
98 | * @param OutputInterface $output |
||
99 | * |
||
100 | * @return int|void |
||
101 | */ |
||
102 | protected function enableModule($module, OutputInterface $output) |
||
135 | |||
136 | /** |
||
137 | * Load module files in the opposite order to core Magento, so that we find the last loaded declaration |
||
138 | * of a module first. |
||
139 | * |
||
140 | * @return array |
||
141 | */ |
||
142 | protected function getDeclaredModuleFiles() |
||
169 | } |
||
170 |
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: