1 | <?php |
||
34 | class Point implements PointInterface, \ArrayAccess |
||
35 | { |
||
36 | protected $space; |
||
37 | protected $coordinates; |
||
38 | protected $distanceAlgo; |
||
39 | |||
40 | public function __construct(SpaceInterface $space, array $coordinates, DistanceAlgorithmInterface $algo = null) |
||
41 | { |
||
42 | $this->space = $space; |
||
43 | $this->coordinates = $coordinates; |
||
44 | $this->setDistanceAlgorithm($algo ?: new EuclidianDistance()); |
||
45 | } |
||
46 | |||
47 | public function setDistanceAlgorithm(DistanceAlgorithmInterface $algo): void |
||
48 | { |
||
49 | $this->distanceAlgo = $algo; |
||
50 | } |
||
51 | |||
52 | public function toArray(): array |
||
53 | { |
||
54 | return [ |
||
55 | 'coordinates' => $this->coordinates, |
||
56 | 'data' => isset($this->space[$this]) ? $this->space[$this] : null, |
||
57 | ]; |
||
58 | } |
||
59 | |||
60 | public function getDistanceWith(self $point): float |
||
61 | { |
||
62 | return $this->distanceAlgo->getDistanceBetween($this, $point); |
||
63 | } |
||
64 | |||
65 | public function getClosest(iterable $points): Point |
||
84 | |||
85 | public function belongsTo(Space $space): bool |
||
89 | |||
90 | public function getSpace(): Space |
||
94 | |||
95 | public function getCoordinates(): array |
||
99 | |||
100 | public function offsetExists($offset): bool |
||
104 | |||
105 | public function offsetGet($offset) |
||
109 | |||
110 | public function offsetSet($offset, $value): void |
||
114 | |||
115 | public function offsetUnset($offset): void |
||
119 | } |
||
120 |
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.