1 | <?php |
||
9 | class ArrayToXml |
||
10 | { |
||
11 | /** |
||
12 | * The root DOM Document. |
||
13 | * |
||
14 | * @var \DOMDocument |
||
15 | */ |
||
16 | protected $document; |
||
17 | |||
18 | /** |
||
19 | * Set to enable replacing space with underscore. |
||
20 | * |
||
21 | * @var bool |
||
22 | */ |
||
23 | protected $replaceSpacesByUnderScoresInKeyNames = true; |
||
24 | |||
25 | /** |
||
26 | * Construct a new instance. |
||
27 | * |
||
28 | * @param string[] $array |
||
29 | * @param string $rootElementName |
||
30 | * @param bool $replaceSpacesByUnderScoresInKeyNames |
||
|
|||
31 | * |
||
32 | * @throws DOMException |
||
33 | */ |
||
34 | public function __construct(array $array, $rootElementName = '', $options = []) |
||
56 | |||
57 | /** |
||
58 | * Convert the given array to an xml string. |
||
59 | * |
||
60 | * @param string[] $array |
||
61 | * @param string $rootElementName |
||
62 | * @param bool $replaceSpacesByUnderScoresInKeyNames |
||
63 | * |
||
64 | * @return type |
||
65 | */ |
||
66 | public static function convert(array $array, $rootElementName = '', $options = []) |
||
72 | |||
73 | /** |
||
74 | * Return as XML. |
||
75 | * |
||
76 | * @return string |
||
77 | */ |
||
78 | public function toXml() |
||
82 | |||
83 | /** |
||
84 | * Parse individual element. |
||
85 | * |
||
86 | * @param \DOMElement $element |
||
87 | * @param string|string[] $value |
||
88 | */ |
||
89 | private function convertElement(DOMElement $element, $value) |
||
115 | |||
116 | /** |
||
117 | * Add node. |
||
118 | * |
||
119 | * @param \DOMElement $element |
||
120 | * @param string $key |
||
121 | * @param string|string[] $value |
||
122 | */ |
||
123 | protected function addNode(DOMElement $element, $key, $value) |
||
133 | |||
134 | /** |
||
135 | * Add collection node. |
||
136 | * |
||
137 | * @param \DOMElement $element |
||
138 | * @param string|string[] $value |
||
139 | * |
||
140 | * @internal param string $key |
||
141 | */ |
||
142 | protected function addCollectionNode(DOMElement $element, $value) |
||
154 | |||
155 | /** |
||
156 | * Add sequential node. |
||
157 | * |
||
158 | * @param \DOMElement $element |
||
159 | * @param string|string[] $value |
||
160 | * |
||
161 | * @internal param string $key |
||
162 | */ |
||
163 | protected function addSequentialNode(DOMElement $element, $value) |
||
175 | |||
176 | /** |
||
177 | * Check if array are all sequential. |
||
178 | * |
||
179 | * @param array|string $value |
||
180 | * |
||
181 | * @return bool |
||
182 | */ |
||
183 | protected function isArrayAllKeySequential($value) |
||
195 | |||
196 | /** |
||
197 | * Add attributes. |
||
198 | * |
||
199 | * @param \DOMElement $element |
||
200 | * @param string[] $data |
||
201 | */ |
||
202 | protected function addAttributes($element, $data) |
||
208 | } |
||
209 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.