1 | <?php |
||
13 | class KeysMatcher extends AbstractMatcher |
||
14 | { |
||
15 | /** |
||
16 | * The verb used in the template. Uses "have" if the 'contain' flag is not used, otherwise |
||
17 | * "contain" is used. |
||
18 | * |
||
19 | * @var string |
||
20 | */ |
||
21 | protected $verb = 'have'; |
||
22 | |||
23 | /** |
||
24 | * {@inheritdoc} |
||
25 | * |
||
26 | * @return TemplateInterface |
||
27 | */ |
||
28 | public function getDefaultTemplate() |
||
43 | |||
44 | /** |
||
45 | * Assert that the actual value is an array or object with the expected keys. |
||
46 | * |
||
47 | * @param $actual |
||
48 | * @return mixed |
||
49 | */ |
||
50 | protected function doMatch($actual) |
||
60 | |||
61 | /** |
||
62 | * Normalize the actual value into an array, whether it is an object |
||
63 | * or an array. |
||
64 | * |
||
65 | * @param object|array $actual |
||
66 | */ |
||
67 | protected function getArrayValue($actual) |
||
79 | |||
80 | /** |
||
81 | * Returns a formatted string of expected keys. |
||
82 | * |
||
83 | * @return string keys |
||
84 | */ |
||
85 | protected function getKeyString() |
||
99 | |||
100 | /** |
||
101 | * Used when the 'contain' flag exists on the Assertion. Checks |
||
102 | * if the expected keys are included in the object or array. |
||
103 | * |
||
104 | * @param array $actual |
||
105 | * @return true |
||
106 | */ |
||
107 | protected function matchInclusion($actual) |
||
116 | } |
||
117 |
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.