1 | <?php |
||
26 | class XmlResponseFormatter extends Component implements ResponseFormatterInterface |
||
27 | { |
||
28 | /** |
||
29 | * @var string the Content-Type header for the response |
||
30 | */ |
||
31 | public $contentType = 'application/xml'; |
||
32 | /** |
||
33 | * @var string the XML version |
||
34 | */ |
||
35 | public $version = '1.0'; |
||
36 | /** |
||
37 | * @var string the XML encoding. If not set, it will use the value of [[Response::charset]]. |
||
38 | */ |
||
39 | public $encoding; |
||
40 | /** |
||
41 | * @var string the name of the root element. If set to false, null or is empty then no root tag should be added. |
||
42 | */ |
||
43 | public $rootTag = 'response'; |
||
44 | /** |
||
45 | * @var string the name of the elements that represent the array elements with numeric keys. |
||
46 | */ |
||
47 | public $itemTag = 'item'; |
||
48 | /** |
||
49 | * @var bool whether to interpret objects implementing the [[\Traversable]] interface as arrays. |
||
50 | * Defaults to `true`. |
||
51 | * @since 2.0.7 |
||
52 | */ |
||
53 | public $useTraversableAsArray = true; |
||
54 | /** |
||
55 | * @var bool if object tags should be added |
||
56 | * @since 2.0.11 |
||
57 | */ |
||
58 | public $useObjectTags = true; |
||
59 | |||
60 | |||
61 | /** |
||
62 | * Formats the specified response. |
||
63 | * @param Response $response the response to be formatted. |
||
64 | */ |
||
65 | 20 | public function format($response) |
|
84 | |||
85 | /** |
||
86 | * @param DOMElement $element |
||
87 | * @param mixed $data |
||
88 | */ |
||
89 | 19 | protected function buildXml($element, $data) |
|
127 | |||
128 | /** |
||
129 | * Formats scalar value to use in XML text node |
||
130 | * |
||
131 | * @param int|string|bool $value |
||
132 | * @return string |
||
133 | * @since 2.0.11 |
||
134 | */ |
||
135 | 18 | protected function formatScalarValue($value) |
|
147 | |||
148 | /** |
||
149 | * Returns element name ready to be used in DOMElement if |
||
150 | * name is not empty, is not int and is valid. |
||
151 | * |
||
152 | * Falls back to [[itemTag]] otherwise. |
||
153 | * |
||
154 | * @param mixed $name |
||
155 | * @return string |
||
156 | * @since 2.0.12 |
||
157 | */ |
||
158 | 11 | protected function getValidXmlElementName($name) |
|
165 | |||
166 | /** |
||
167 | * Checks if name is valid to be used in XML |
||
168 | * |
||
169 | * @param mixed $name |
||
170 | * @return bool |
||
171 | * @see http://stackoverflow.com/questions/2519845/how-to-check-if-string-is-a-valid-xml-element-name/2519943#2519943 |
||
172 | * @since 2.0.12 |
||
173 | */ |
||
174 | 9 | protected function isValidXmlName($name) |
|
183 | } |
||
184 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: