These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Maps; |
||
4 | |||
5 | use Maps\Elements\Line; |
||
6 | use Maps\Elements\Polygon; |
||
7 | |||
8 | /** |
||
9 | * ValueParser that parses the string representation of a polygon. |
||
10 | * |
||
11 | * @since 3.0 |
||
12 | * |
||
13 | * @licence GNU GPL v2+ |
||
14 | * @author Jeroen De Dauw < [email protected] > |
||
15 | */ |
||
16 | class PolygonParser extends LineParser { |
||
17 | |||
18 | protected function constructShapeFromLatLongValues( array $locations ) { |
||
19 | return new Polygon( $locations ); |
||
20 | } |
||
21 | |||
22 | protected function handleCommonParams( array &$params, Line &$line ) { |
||
23 | parent::handleCommonParams( $params, $line ); |
||
24 | $this->handlePolygonParams( $params, $line ); |
||
0 ignored issues
–
show
|
|||
25 | } |
||
26 | |||
27 | protected function handlePolygonParams( array &$params, Polygon &$polygon ) { |
||
28 | if ( $fillColor = array_shift( $params ) ) { |
||
29 | $polygon->setFillColor( $fillColor ); |
||
30 | } |
||
31 | |||
32 | if ( $fillOpacity = array_shift( $params ) ) { |
||
33 | $polygon->setFillOpacity( $fillOpacity ); |
||
34 | } |
||
35 | |||
36 | if ( $showOnlyOnHover = array_shift( $params ) ) { |
||
37 | $polygon->setOnlyVisibleOnHover( strtolower( trim( $showOnlyOnHover ) ) === 'on' ); |
||
38 | } |
||
39 | } |
||
40 | |||
41 | } |
||
42 |
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.