Skip to content

Commit 0b69ec9

Browse files
committed
Fix phpdoc and coding standards
This removes the unused use statements which were not catched by PHP-CS-Fixer because of string occurences. It also fixes some invalid phpdoc (scalar is not recognized as a valid type for instance).
1 parent 699c735 commit 0b69ec9

File tree

7 files changed

+33
-30
lines changed

7 files changed

+33
-30
lines changed

Encoder/DecoderInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ interface DecoderInterface
2121
/**
2222
* Decodes a string into PHP data.
2323
*
24-
* @param scalar $data Data to decode
24+
* @param string $data Data to decode
2525
* @param string $format Format name
2626
* @param array $context options that decoders have access to.
2727
*

Encoder/EncoderInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ interface EncoderInterface
2525
* @param string $format Format name
2626
* @param array $context options that normalizers/encoders have access to.
2727
*
28-
* @return scalar
28+
* @return string|bool|int|float|null
2929
*/
3030
public function encode($data, $format, array $context = array());
3131

Encoder/XmlEncoder.php

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
*/
2323
class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, DecoderInterface, NormalizationAwareInterface
2424
{
25+
/**
26+
* @var \DOMDocument
27+
*/
2528
private $dom;
2629
private $format;
2730
private $rootNodeName = 'response';
@@ -164,7 +167,7 @@ public function getRootNodeName()
164167
*
165168
* @return bool
166169
*/
167-
final protected function appendXMLString($node, $val)
170+
final protected function appendXMLString(\DOMNode $node, $val)
168171
{
169172
if (strlen($val) > 0) {
170173
$frag = $this->dom->createDocumentFragment();
@@ -178,12 +181,12 @@ final protected function appendXMLString($node, $val)
178181
}
179182

180183
/**
181-
* @param DOMNode $node
182-
* @param string $val
184+
* @param \DOMNode $node
185+
* @param string $val
183186
*
184187
* @return bool
185188
*/
186-
final protected function appendText($node, $val)
189+
final protected function appendText(\DOMNode $node, $val)
187190
{
188191
$nodeText = $this->dom->createTextNode($val);
189192
$node->appendChild($nodeText);
@@ -192,12 +195,12 @@ final protected function appendText($node, $val)
192195
}
193196

194197
/**
195-
* @param DOMNode $node
196-
* @param string $val
198+
* @param \DOMNode $node
199+
* @param string $val
197200
*
198201
* @return bool
199202
*/
200-
final protected function appendCData($node, $val)
203+
final protected function appendCData(\DOMNode $node, $val)
201204
{
202205
$nodeText = $this->dom->createCDATASection($val);
203206
$node->appendChild($nodeText);
@@ -206,12 +209,12 @@ final protected function appendCData($node, $val)
206209
}
207210

208211
/**
209-
* @param DOMNode $node
210-
* @param DOMDocumentFragment $fragment
212+
* @param \DOMNode $node
213+
* @param \DOMDocumentFragment $fragment
211214
*
212215
* @return bool
213216
*/
214-
final protected function appendDocumentFragment($node, $fragment)
217+
final protected function appendDocumentFragment(\DOMNode $node, $fragment)
215218
{
216219
if ($fragment instanceof \DOMDocumentFragment) {
217220
$node->appendChild($fragment);
@@ -239,11 +242,11 @@ final protected function isElementNameValid($name)
239242
/**
240243
* Parse the input SimpleXmlElement into an array.
241244
*
242-
* @param SimpleXmlElement $node xml to parse
245+
* @param \SimpleXmlElement $node xml to parse
243246
*
244247
* @return array
245248
*/
246-
private function parseXml($node)
249+
private function parseXml(\SimpleXMLElement $node)
247250
{
248251
$data = array();
249252
if ($node->attributes()) {
@@ -290,15 +293,15 @@ private function parseXml($node)
290293
/**
291294
* Parse the data and convert it to DOMElements.
292295
*
293-
* @param DOMNode $parentNode
296+
* @param \DOMElement $parentNode
294297
* @param array|object $data data
295298
* @param string $xmlRootNodeName
296299
*
297300
* @return bool
298301
*
299302
* @throws UnexpectedValueException
300303
*/
301-
private function buildXml($parentNode, $data, $xmlRootNodeName = null)
304+
private function buildXml(\DOMElement $parentNode, $data, $xmlRootNodeName = null)
302305
{
303306
$append = true;
304307

@@ -358,14 +361,14 @@ private function buildXml($parentNode, $data, $xmlRootNodeName = null)
358361
/**
359362
* Selects the type of node to create and appends it to the parent.
360363
*
361-
* @param DOMNode $parentNode
364+
* @param \DOMNode $parentNode
362365
* @param array|object $data
363366
* @param string $nodeName
364367
* @param string $key
365368
*
366369
* @return bool
367370
*/
368-
private function appendNode($parentNode, $data, $nodeName, $key = null)
371+
private function appendNode(\DOMNode $parentNode, $data, $nodeName, $key = null)
369372
{
370373
$node = $this->dom->createElement($nodeName);
371374
if (null !== $key) {
@@ -395,12 +398,12 @@ private function needsCdataWrapping($val)
395398
/**
396399
* Tests the value being passed and decide what sort of element to create.
397400
*
398-
* @param DOMNode $node
399-
* @param mixed $val
401+
* @param \DOMNode $node
402+
* @param mixed $val
400403
*
401404
* @return bool
402405
*/
403-
private function selectNodeType($node, $val)
406+
private function selectNodeType(\DOMNode $node, $val)
404407
{
405408
if (is_array($val)) {
406409
return $this->buildXml($node, $val);

Normalizer/DenormalizableInterface.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ interface DenormalizableInterface
2727
* It is important to understand that the denormalize() call should denormalize
2828
* recursively all child objects of the implementor.
2929
*
30-
* @param DenormalizerInterface $denormalizer The denormalizer is given so that you
31-
* can use it to denormalize objects contained within this object.
32-
* @param array|scalar $data The data from which to re-create the object.
33-
* @param string|null $format The format is optionally given to be able to denormalize differently
34-
* based on different input formats.
35-
* @param array $context options for denormalizing
30+
* @param DenormalizerInterface $denormalizer The denormalizer is given so that you
31+
* can use it to denormalize objects contained within this object.
32+
* @param array|string|bool|int|float|null $data The data from which to re-create the object.
33+
* @param string|null $format The format is optionally given to be able to denormalize differently
34+
* based on different input formats.
35+
* @param array $context options for denormalizing
3636
*/
3737
public function denormalize(DenormalizerInterface $denormalizer, $data, $format = null, array $context = array());
3838
}

Normalizer/NormalizableInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ interface NormalizableInterface
3333
* based on different output formats.
3434
* @param array $context Options for normalizing this object
3535
*
36-
* @return array|scalar
36+
* @return array|string|bool|int|float|null
3737
*/
3838
public function normalize(NormalizerInterface $normalizer, $format = null, array $context = array());
3939
}

Normalizer/NormalizerInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ interface NormalizerInterface
2525
* @param string $format format the normalization result will be encoded as
2626
* @param array $context Context options for the normalizer
2727
*
28-
* @return array|scalar
28+
* @return array|string|bool|int|float|null
2929
*/
3030
public function normalize($object, $format = null, array $context = array());
3131

Serializer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ final public function decode($data, $format, array $context = array())
218218
* @param string $format format name, present to give the option to normalizers to act differently based on formats
219219
* @param array $context The context data for this particular normalization
220220
*
221-
* @return array|scalar
221+
* @return array|string|bool|int|float|null
222222
*
223223
* @throws LogicException
224224
* @throws UnexpectedValueException

0 commit comments

Comments
 (0)