1 | <?php |
||
5 | abstract class AbstractCommand implements CommandInterface |
||
6 | { |
||
7 | /** |
||
8 | * @var array |
||
9 | */ |
||
10 | private $options = []; |
||
11 | |||
12 | /** |
||
13 | * @inheritDoc |
||
14 | */ |
||
15 | 3 | public function options() |
|
16 | { |
||
17 | 3 | $required = $this->requiredOptions(); |
|
18 | |||
19 | 3 | if ($required) { |
|
|
|||
20 | 2 | foreach ($required as $key) { |
|
21 | 2 | if (!isset($this->options[$key])) { |
|
22 | 1 | throw CommandException::missingOption($key); |
|
23 | } |
||
24 | 1 | } |
|
25 | 2 | } |
|
26 | |||
27 | 2 | return $this->options; |
|
28 | } |
||
29 | |||
30 | /** |
||
31 | * @inheritDoc |
||
32 | */ |
||
33 | 3 | public function withOptions(array $options) |
|
40 | |||
41 | /** |
||
42 | * @inheritDoc |
||
43 | */ |
||
44 | 1 | public function addOptions(array $options) |
|
51 | |||
52 | /** |
||
53 | * @inheritDoc |
||
54 | */ |
||
55 | 1 | public function hasOption($name) |
|
59 | } |
||
60 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.