lib/LongitudeOne/Spatial/PHP/Types/AbstractMultiPoint.php
Avoid using LongitudeOne\Spatial\PHP\Types\count() function in for loops. Open
Open
for ($i = 0; $i < count($this->points); ++$i) {
$points[] = $this->getPoint($i);
}
- Read upRead up
- Exclude checks
CountInLoopExpression
Since: 2.7.0
Using count/sizeof in loops expressions is considered bad practice and is a potential source of many bugs, especially when the loop manipulates an array, as count happens on each iteration.
Example
class Foo {
public function bar()
{
$array = array();
for ($i = 0; count($array); $i++) {
// ...
}
}
}
Source https://phpmd.org/rules/design.html#countinloopexpression
TODO found Open
Open
// TODO throw an error when $this->points is empty
- Exclude checks
TODO found Open
Open
// TODO throw an error when index is out of range
- Exclude checks
A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 41 and the first side effect is on line 26. Open
Open
<?php
- Exclude checks
Possible parse error: class missing opening or closing brace Open
Open
abstract class AbstractMultiPoint extends AbstractGeometry
- Exclude checks
Possible parse error: class missing opening or closing brace Open
Open
abstract class AbstractMultiPoint extends AbstractGeometry
- Exclude checks
Line indented incorrectly; expected 0 spaces, found 4 Open
Open
protected array $points = [];
- Exclude checks
Line indented incorrectly; expected 0 spaces, found 4 Open
Open
public function addPoint(array|PointInterface $point): self
- Exclude checks
Line indented incorrectly; expected 0 spaces, found 4 Open
Open
}
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 12 Open
Open
default => $this->points[$index],
- Exclude checks
Closing brace indented incorrectly; expected 4 spaces, found 0 Open
Open
}
- Exclude checks
Line indented incorrectly; expected 0 spaces, found 4 Open
Open
public function getPoint(int $index): PointInterface
- Exclude checks
Line indented incorrectly; expected 0 spaces, found 4 Open
Open
}
- Exclude checks
Line indented incorrectly; expected 0 spaces, found 4 Open
Open
public function __construct(array $points, ?int $srid = null)
- Exclude checks
Space before opening parenthesis of function call prohibited Open
Open
$point = match ($index) {
- Exclude checks