longitude-one/doctrine-spatial

View on GitHub
lib/LongitudeOne/Spatial/PHP/Types/AbstractMultiPoint.php

Summary

Maintainability
A
0 mins
Test Coverage
A
100%

Avoid using LongitudeOne\Spatial\PHP\Types\count() function in for loops.
Open

        for ($i = 0; $i < count($this->points); ++$i) {
            $points[] = $this->getPoint($i);
        }

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

        // TODO throw an error when $this->points is empty

TODO found
Open

        // TODO throw an error when index is out of range

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

<?php

Possible parse error: class missing opening or closing brace
Open

abstract class AbstractMultiPoint extends AbstractGeometry

Possible parse error: class missing opening or closing brace
Open

abstract class AbstractMultiPoint extends AbstractGeometry

Line indented incorrectly; expected 0 spaces, found 4
Open

    protected array $points = [];

Line indented incorrectly; expected 0 spaces, found 4
Open

    public function addPoint(array|PointInterface $point): self

Line indented incorrectly; expected 0 spaces, found 4
Open

    }

Line indented incorrectly; expected 4 spaces, found 12
Open

            default => $this->points[$index],

Closing brace indented incorrectly; expected 4 spaces, found 0
Open

}

Line indented incorrectly; expected 0 spaces, found 4
Open

    public function getPoint(int $index): PointInterface

Line indented incorrectly; expected 0 spaces, found 4
Open

    }

Line indented incorrectly; expected 0 spaces, found 4
Open

    public function __construct(array $points, ?int $srid = null)

Space before opening parenthesis of function call prohibited
Open

        $point = match ($index) {

There are no issues that match your filters.

Category
Status