It seems like the GitHub access token used for retrieving details about this repository from
GitHub became invalid. This might prevent certain types of inspections from being run (in
particular,
everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
This class seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate
the same code in three or more different places, we strongly encourage you to
look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
22
{
23
/**
24
* @var MarkerCollector
25
*/
26
private $markerCollector;
27
28
/**
29
* @param MarkerCollector $markerCollector
30
*/
31
public function __construct(MarkerCollector $markerCollector)
32
{
33
$this->setMarkerCollector($markerCollector);
34
}
35
36
/**
37
* @return MarkerCollector
38
*/
39
public function getMarkerCollector()
40
{
41
return $this->markerCollector;
42
}
43
44
/**
45
* @param MarkerCollector $markerCollector
46
*/
47
public function setMarkerCollector(MarkerCollector $markerCollector)
48
{
49
$this->markerCollector = $markerCollector;
50
}
51
52
/**
53
* @param Map $map
54
* @param MarkerShape[] $markerShapes
55
*
56
* @return MarkerShape[]
57
*/
58
public function collect(Map $map, array $markerShapes = [])
59
{
60
foreach ($this->markerCollector->collect($map) as $marker) {
It seems like $marker->getShape() can be null; however, collectValue() does not accept null, maybe add an additional type check?
Unless you are absolutely sure that the expression can never be null because of
other conditions, we strongly recommend to add an additional type check to your
code:
/** @return stdClass|null */functionmayReturnNull(){}functiondoesNotAcceptNull(stdClass$x){}// With potential error.functionwithoutCheck(){$x=mayReturnNull();doesNotAcceptNull($x);// Potential error here.}// Safe - Alternative 1functionwithCheck1(){$x=mayReturnNull();if(!$xinstanceofstdClass){thrownew\LogicException('$x must be defined.');}doesNotAcceptNull($x);}// Safe - Alternative 2functionwithCheck2(){$x=mayReturnNull();if($xinstanceofstdClass){doesNotAcceptNull($x);}}
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.