| 1 | <?php |
||
| 10 | class EventTrap implements \Mleko\Event\Listener |
||
| 11 | { |
||
| 12 | |||
| 13 | /** @var object[] */ |
||
| 14 | private $trappedEvents; |
||
| 15 | |||
| 16 | /** @var boolean */ |
||
| 17 | private $oneTime; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * EventTrap constructor. |
||
| 21 | * @param bool $oneTime |
||
| 22 | */ |
||
| 23 | 2 | public function __construct($oneTime = true) |
|
| 28 | |||
| 29 | |||
| 30 | /** |
||
| 31 | * @param object $event |
||
| 32 | * @param \Mleko\Event\Meta $meta |
||
| 33 | */ |
||
| 34 | 2 | public function handle($event, \Mleko\Event\Meta $meta) |
|
| 41 | |||
| 42 | /** |
||
| 43 | * @return object[] |
||
| 44 | */ |
||
| 45 | 2 | public function getTrappedEvents() |
|
| 49 | |||
| 50 | /** |
||
| 51 | * @return null|object |
||
| 52 | */ |
||
| 53 | 1 | public function getFirstEvent() |
|
| 57 | |||
| 58 | } |
||
| 59 |
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.