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