for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace JMGQ\AStar\Example\Graph;
use JMGQ\AStar\DomainLogicInterface;
class DomainLogic implements DomainLogicInterface
{
public function __construct(private Graph $graph)
$graph
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
public function __construct(/** @scrutinizer ignore-unused */ private Graph $graph)
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
}
/**
* @param Coordinate $node
* @return Coordinate[]
*/
public function getAdjacentNodes(mixed $node): iterable
return $this->graph->getDirectSuccessors($node);
graph
JMGQ\AStar\Example\Graph\DomainLogic
* @param Coordinate $adjacent
* @return float|int
public function calculateRealCost(mixed $node, mixed $adjacent): float | int
if (!$this->graph->hasLink($node, $adjacent)) {
throw new \DomainException('The provided nodes are not linked');
return $this->graph->getLink($node, $adjacent)->getDistance();
* @param Coordinate $fromNode
* @param Coordinate $toNode
public function calculateEstimatedCost(mixed $fromNode, mixed $toNode): float | int
return $this->euclideanDistance($fromNode, $toNode);
private function euclideanDistance(Coordinate $a, Coordinate $b): float
$xFactor = ($a->getX() - $b->getX()) ** 2;
$yFactor = ($a->getY() - $b->getY()) ** 2;
return sqrt($xFactor + $yFactor);
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.