1 | <?php |
||
13 | abstract class AbstractMagentoStoreConfigCommand extends AbstractMagentoCommand |
||
14 | { |
||
15 | /** |
||
16 | * @var string |
||
17 | */ |
||
18 | const SCOPE_STORE_VIEW = 'store'; |
||
19 | |||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | const SCOPE_WEBSITE = 'website'; |
||
24 | |||
25 | /** |
||
26 | * @var string |
||
27 | */ |
||
28 | const SCOPE_GLOBAL = 'global'; |
||
29 | |||
30 | /** |
||
31 | * Store view or global by additional option |
||
32 | */ |
||
33 | const SCOPE_STORE_VIEW_GLOBAL = 'store_view_global'; |
||
34 | |||
35 | /** |
||
36 | * @var string |
||
37 | */ |
||
38 | protected $commandName = ''; |
||
39 | |||
40 | /** |
||
41 | * @var string |
||
42 | */ |
||
43 | protected $commandDescription = ''; |
||
44 | |||
45 | /** |
||
46 | * @var string |
||
47 | */ |
||
48 | protected $configPath = ''; |
||
49 | |||
50 | /** |
||
51 | * @var string |
||
52 | */ |
||
53 | protected $toggleComment = ''; |
||
54 | |||
55 | /** |
||
56 | * @var string |
||
57 | */ |
||
58 | protected $falseName = 'disabled'; |
||
59 | |||
60 | /** |
||
61 | * @var string |
||
62 | */ |
||
63 | protected $trueName = 'enabled'; |
||
64 | |||
65 | /** |
||
66 | * Add admin store to interactive prompt |
||
67 | * |
||
68 | * @var bool |
||
69 | */ |
||
70 | protected $withAdminStore = false; |
||
71 | |||
72 | /** |
||
73 | * @var string |
||
74 | */ |
||
75 | protected $scope = self::SCOPE_STORE_VIEW; |
||
76 | |||
77 | protected function configure() |
||
94 | |||
95 | /** |
||
96 | * @param InputInterface $input |
||
97 | * @param OutputInterface $output |
||
98 | * |
||
99 | * @return int|void |
||
100 | */ |
||
101 | protected function execute(InputInterface $input, OutputInterface $output) |
||
148 | |||
149 | /** |
||
150 | * Determine if a developer restriction is in place, and if we're enabling something that will use it |
||
151 | * then notify and ask if it needs to be changed from its current value. |
||
152 | * |
||
153 | * @param \Mage_Core_Model_Store $store |
||
154 | * @param bool $enabled |
||
155 | * @return void |
||
156 | */ |
||
157 | protected function detectAskAndSetDeveloperIp(\Mage_Core_Model_Store $store, $enabled) |
||
173 | |||
174 | /** |
||
175 | * Ask if the developer IP should be changed, and change it if required |
||
176 | * |
||
177 | * @param OutputInterface $output |
||
178 | * @param \Mage_Core_Model_Store $store |
||
179 | * @param string|null $devRestriction |
||
180 | * @return void |
||
181 | */ |
||
182 | protected function askAndSetDeveloperIp(OutputInterface $output, \Mage_Core_Model_Store $store, $devRestriction) |
||
205 | |||
206 | /** |
||
207 | * Set the restricted IP for developer access |
||
208 | * |
||
209 | * @param \Mage_Core_Model_Store $store |
||
210 | * @param string $newDeveloperIp |
||
211 | */ |
||
212 | protected function setDeveloperIp(\Mage_Core_Model_Store $store, $newDeveloperIp) |
||
217 | |||
218 | /** |
||
219 | * @param InputInterface $input |
||
220 | * @param OutputInterface $output |
||
221 | * |
||
222 | * @return mixed |
||
223 | */ |
||
224 | protected function _initStore(InputInterface $input, OutputInterface $output) |
||
231 | |||
232 | /** |
||
233 | * @param \Mage_Core_Model_Store $store |
||
234 | * @param bool $disabled |
||
235 | */ |
||
236 | protected function _beforeSave(\Mage_Core_Model_Store $store, $disabled) |
||
239 | |||
240 | /** |
||
241 | * @param \Mage_Core_Model_Store $store |
||
242 | * @param bool $disabled |
||
243 | */ |
||
244 | protected function _afterSave(\Mage_Core_Model_Store $store, $disabled) |
||
247 | } |
||
248 |
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: