1 | <?php |
||
19 | class Client |
||
20 | { |
||
21 | /** |
||
22 | * An ordered list of metrics yet to be sent |
||
23 | * |
||
24 | * @var MetricInterface[] |
||
25 | */ |
||
26 | protected $queue = []; |
||
27 | |||
28 | /** |
||
29 | * @var Socket |
||
30 | */ |
||
31 | protected $socket; |
||
32 | |||
33 | /** |
||
34 | * @var FactoryInterface |
||
35 | */ |
||
36 | protected $factory; |
||
37 | |||
38 | /** |
||
39 | * Client constructor |
||
40 | * |
||
41 | * @param Socket $socket |
||
42 | * @param FactoryInterface $factory |
||
43 | */ |
||
44 | 3 | public function __construct(Socket $socket, FactoryInterface $factory) |
|
49 | |||
50 | /** |
||
51 | * Forward methods to the factory |
||
52 | * |
||
53 | * @param string $name |
||
54 | * @param array $arguments |
||
55 | * @return Metric |
||
56 | */ |
||
57 | 2 | public function __call($name, $arguments) |
|
58 | { |
||
59 | 2 | if (method_exists($this->factory, $name)) { |
|
60 | 1 | $metric = call_user_func_array([$this->factory, $name], $arguments); |
|
61 | 1 | $this->add($metric); |
|
62 | 1 | return $metric; |
|
63 | } |
||
64 | |||
65 | 1 | throw new \BadMethodCallException('No such StatsD factory method: ' . $name); |
|
66 | } |
||
67 | |||
68 | /** |
||
69 | * Enqueues a metric to be sent on the next flush |
||
70 | * |
||
71 | * @param MetricInterface $metric |
||
72 | */ |
||
73 | 1 | public function add(MetricInterface $metric) |
|
77 | |||
78 | /** |
||
79 | * Flushes the queued metrics |
||
80 | */ |
||
81 | 1 | public function flush() |
|
98 | |||
99 | /** |
||
100 | * Splits an array of pieces of data into combined pieces no larger than the given max |
||
101 | * |
||
102 | * @param String[] $data |
||
103 | * @return array<array<int,string>> |
||
104 | */ |
||
105 | 2 | protected function fillPackets(array $data) |
|
133 | } |
||
134 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.