1 | <?php |
||
15 | abstract class AbstractMagentoStoreConfigCommand extends AbstractMagentoCommand |
||
16 | { |
||
17 | /** |
||
18 | * @var string |
||
19 | */ |
||
20 | const SCOPE_STORE_VIEW = 'store'; |
||
21 | |||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | const SCOPE_WEBSITE = 'website'; |
||
26 | |||
27 | /** |
||
28 | * @var string |
||
29 | */ |
||
30 | const SCOPE_GLOBAL = 'global'; |
||
31 | |||
32 | /** |
||
33 | * Store view or global by additional option |
||
34 | */ |
||
35 | const SCOPE_STORE_VIEW_GLOBAL = 'store_view_global'; |
||
36 | |||
37 | /** |
||
38 | * @var string |
||
39 | */ |
||
40 | protected $commandName = ''; |
||
41 | |||
42 | /** |
||
43 | * @var string |
||
44 | */ |
||
45 | protected $commandDescription = ''; |
||
46 | |||
47 | /** |
||
48 | * @var string |
||
49 | */ |
||
50 | protected $configPath = ''; |
||
51 | |||
52 | /** |
||
53 | * @var string |
||
54 | */ |
||
55 | protected $toggleComment = ''; |
||
56 | |||
57 | /** |
||
58 | * @var string |
||
59 | */ |
||
60 | protected $falseName = 'disabled'; |
||
61 | |||
62 | /** |
||
63 | * @var string |
||
64 | */ |
||
65 | protected $trueName = 'enabled'; |
||
66 | |||
67 | /** |
||
68 | * Add admin store to interactive prompt |
||
69 | * |
||
70 | * @var bool |
||
71 | */ |
||
72 | protected $withAdminStore = false; |
||
73 | |||
74 | /** |
||
75 | * @var string |
||
76 | */ |
||
77 | protected $scope = self::SCOPE_STORE_VIEW; |
||
78 | |||
79 | protected function configure() |
||
96 | |||
97 | /** |
||
98 | * @param InputInterface $input |
||
99 | * @param OutputInterface $output |
||
100 | * @return int|void |
||
101 | */ |
||
102 | protected function execute(InputInterface $input, OutputInterface $output) |
||
167 | |||
168 | /** |
||
169 | * @param InputInterface $input |
||
170 | * @param OutputInterface $output |
||
171 | * @return mixed |
||
172 | * @throws Exception |
||
173 | */ |
||
174 | protected function _initStore(InputInterface $input, OutputInterface $output) |
||
181 | |||
182 | /** |
||
183 | * @param \Magento\Store\Model\Store $store |
||
184 | * @param bool $disabled |
||
185 | */ |
||
186 | protected function _beforeSave(\Magento\Store\Model\Store $store, $disabled) |
||
189 | |||
190 | /** |
||
191 | * @param \Magento\Store\Model\Store $store |
||
192 | * @param bool $disabled |
||
193 | */ |
||
194 | protected function _afterSave(\Magento\Store\Model\Store $store, $disabled) |
||
197 | } |
||
198 |
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: