1 | <?php |
||
7 | final class FallbackHydratorContainer implements HydratorContainerInterface |
||
8 | { |
||
9 | private $handlers = array(); |
||
10 | private $interfaces = array(); |
||
11 | private $aliases = array(); |
||
12 | |||
13 | 13 | public function add($class, $handler) |
|
14 | { |
||
15 | 13 | if(false === is_callable($handler)) { |
|
16 | 1 | throw new \RuntimeException(sprintf('Invalid handler for class %s!', $class)); |
|
17 | } |
||
18 | |||
19 | 12 | if(class_exists($class)) { |
|
20 | 9 | $this->aliases[$class] = $class; |
|
21 | 9 | $this->handlers[$class] = $handler; |
|
22 | 12 | } elseif(interface_exists($class)) { |
|
23 | 2 | $this->aliases[$class] = $class; |
|
24 | 2 | $this->interfaces[$class] = $handler; |
|
25 | 2 | } else { |
|
26 | 1 | throw new \RuntimeException(sprintf('Given value %s is neither class nor interface name!', $class)); |
|
27 | } |
||
28 | 11 | } |
|
29 | |||
30 | 2 | public function addAlias($alias, $class) |
|
41 | |||
42 | 10 | public function getHandler($class) |
|
64 | |||
65 | 1 | public function hydrate($class, array $data) |
|
69 | } |
||
70 |
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.