These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * |
||
4 | */ |
||
5 | |||
6 | namespace Mvc5; |
||
7 | |||
8 | class Event |
||
9 | implements Event\Event |
||
10 | { |
||
11 | /** |
||
12 | * |
||
13 | */ |
||
14 | use Event\Model; |
||
15 | use Signal; |
||
16 | |||
17 | /** |
||
18 | * @var mixed |
||
19 | */ |
||
20 | protected $model; |
||
21 | |||
22 | /** |
||
23 | * @param string|null $event |
||
24 | * @param mixed $model |
||
25 | */ |
||
26 | 21 | function __construct($event = null, $model = null) |
|
0 ignored issues
–
show
|
|||
27 | { |
||
28 | 21 | $this->event = $event; |
|
29 | 21 | $this->model = $model; |
|
30 | 21 | } |
|
31 | |||
32 | /** |
||
33 | * @return array |
||
34 | */ |
||
35 | 2 | protected function args() |
|
36 | { |
||
37 | 2 | return array_filter([ |
|
38 | 2 | Arg::EVENT => $this, |
|
39 | 2 | Arg::MODEL => $this->model |
|
40 | ]); |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * @param callable $callable |
||
45 | * @param array $args |
||
46 | * @param callable $callback |
||
47 | * @return mixed |
||
48 | */ |
||
49 | 11 | function __invoke(callable $callable, array $args = [], callable $callback = null) |
|
0 ignored issues
–
show
|
|||
50 | { |
||
51 | 11 | $model = $this->signal($callable, !$args || !is_string(key($args)) ? $args : $this->args() + $args, $callback); |
|
0 ignored issues
–
show
The expression
$args of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using empty($expr) instead to make it clear that you intend to check for an array without elements.
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
Loading history...
|
|||
52 | |||
53 | 10 | null !== $model |
|
54 | 10 | && $this->model = $model; |
|
55 | |||
56 | 10 | return $model; |
|
57 | } |
||
58 | } |
||
59 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.