1 | <?php |
||
15 | class Importer implements ImportInterface |
||
16 | { |
||
17 | public static $map = [ |
||
18 | 'animate' => ['animation', ['attributeName', 'from', 'to', 'dur']], |
||
19 | 'mpath' => ['animation', []], |
||
20 | 'animateMotion' => ['animation', []], |
||
21 | 'set' => ['animation', []], |
||
22 | 'svg' => ['container', []], |
||
23 | 'a' => ['container', []], |
||
24 | 'defs' => ['container', []], |
||
25 | 'g' => ['container', []], |
||
26 | 'marker' => ['container', []], |
||
27 | 'mask' => ['container', []], |
||
28 | 'pattern' => ['container', []], |
||
29 | 'switch' => ['container', []], |
||
30 | 'symbol' => ['container', []], |
||
31 | 'desc' => ['desc', ['nodeValue']], |
||
32 | 'metadata' => ['desc', ['nodeValue']], |
||
33 | 'title' => ['desc', ['nodeValue']], |
||
34 | 'filter' => ['filter', []], |
||
35 | 'feBlend' => ['filter', []], |
||
36 | 'feColorMatrix' => ['filter', []], |
||
37 | 'feComponentTransfer' => ['filter', []], |
||
38 | 'feComposite' => ['filter', []], |
||
39 | 'feConvolveMatrix' => ['filter', []], |
||
40 | 'feDiffuseLighting' => ['filter', []], |
||
41 | 'feDisplacementMap' => ['filter', []], |
||
42 | 'feFlood' => ['filter', []], |
||
43 | 'feFuncA' => ['filter', []], |
||
44 | 'feFuncB' => ['filter', []], |
||
45 | 'feFuncG' => ['filter', []], |
||
46 | 'feFuncR' => ['filter', []], |
||
47 | 'feGaussianBlur' => ['filter', []], |
||
48 | 'image' => ['filter', []], |
||
49 | 'feMerge' => ['filter', []], |
||
50 | 'feMergeNode' => ['filter', []], |
||
51 | 'feMorphology' => ['filter', []], |
||
52 | 'feOffset' => ['filter', []], |
||
53 | 'feSpecularLighting' => ['filter', []], |
||
54 | 'feTile' => ['filter', []], |
||
55 | 'feTurbulence' => ['filter', []], |
||
56 | 'font' => ['font', []], |
||
57 | 'font-face' => ['font', []], |
||
58 | 'font-face-format' => ['font', []], |
||
59 | 'font-face-name' => ['font', []], |
||
60 | 'font-face-src' => ['font', []], |
||
61 | 'font-face-uri' => ['font', []], |
||
62 | 'glyph' => ['font', []], |
||
63 | 'missing-glyph' => ['font', []], |
||
64 | 'hkern' => ['font', []], |
||
65 | 'vkern' => ['font', []], |
||
66 | 'linearGradient' => ['gradient', []], |
||
67 | 'radialGradient' => ['gradient', []], |
||
68 | 'stop' => ['gradient', []], |
||
69 | 'feDistantLight' => ['light', []], |
||
70 | 'fePointLight' => ['light', []], |
||
71 | 'feSpotLight' => ['light', []], |
||
72 | 'circle' => ['shape', ['cx', 'cy', 'r']], |
||
73 | 'ellipse' => ['shape', ['cx', 'cy', 'rx', 'ry']], |
||
74 | 'line' => ['shape', ['x1', 'y1', 'x2', 'y2']], |
||
75 | 'path' => ['shape', ['x', 'y']], |
||
76 | 'polygon' => ['shape', []], |
||
77 | 'polyline' => ['shape', []], |
||
78 | 'rect' => ['shape', ['height', 'width', 'x', 'y']], |
||
79 | 'altGlyph' => ['text', []], |
||
80 | 'altGlyphDef' => ['text', []], |
||
81 | 'altGlyphItem' => ['text', []], |
||
82 | 'glyphRef' => ['text', []], |
||
83 | 'text' => ['text', ['nodeValue']], |
||
84 | 'textPath' => ['text', []], |
||
85 | 'tref' => ['text', []], |
||
86 | 'tspan' => ['text', []], |
||
87 | ]; |
||
88 | |||
89 | 3 | public function fromString($svgString) |
|
108 | |||
109 | /** |
||
110 | * @param \DOMElement $element |
||
111 | * |
||
112 | * @param $parent |
||
113 | * |
||
114 | * @return ElementInterface |
||
115 | */ |
||
116 | 2 | private function toObject($element, $parent) |
|
136 | |||
137 | 2 | private function getObjectCtor(\DOMElement $element) |
|
147 | |||
148 | /** |
||
149 | * @param \DOMElement $element |
||
150 | * |
||
151 | * @param array $attrs |
||
152 | * |
||
153 | * @return array |
||
154 | */ |
||
155 | 1 | private function getAttrs(\DOMElement $element, array $attrs) |
|
174 | |||
175 | 2 | private function buildObjectTree(\DOMElement $element, ElementInterface $obj) |
|
186 | } |
||
187 |
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.