Skip to content

Commit 7e2de10

Browse files
beberleidlsniper
authored andcommitted
Fix CS issues, removed global options
1 parent 3e7a28f commit 7e2de10

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
lines changed

Encoder/XmlEncoder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ private function selectNodeType($node, $val)
405405
*/
406406
private function getRealRootNodeName()
407407
{
408-
if ( ! $this->serializer) {
408+
if (!$this->serializer) {
409409
return $this->rootNodeName;
410410
}
411411

Serializer.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ class Serializer implements SerializerInterface, NormalizerInterface, Denormaliz
4242
protected $normalizers = array();
4343
protected $normalizerCache = array();
4444
protected $denormalizerCache = array();
45-
protected $options = array();
45+
protected $options;
4646

47-
public function __construct(array $normalizers = array(), array $encoders = array(), array $options = array())
47+
public function __construct(array $normalizers = array(), array $encoders = array())
4848
{
4949
foreach ($normalizers as $normalizer) {
5050
if ($normalizer instanceof SerializerAwareInterface) {
@@ -68,7 +68,6 @@ public function __construct(array $normalizers = array(), array $encoders = arra
6868
}
6969
$this->encoder = new ChainEncoder($realEncoders);
7070
$this->decoder = new ChainDecoder($decoders);
71-
$this->options = $options;
7271
}
7372

7473
/**
@@ -80,7 +79,7 @@ final public function serialize($data, $format, array $options = array())
8079
throw new UnexpectedValueException('Serialization for the format '.$format.' is not supported');
8180
}
8281

83-
$this->options = array_merge($this->options, $options);
82+
$this->options = $options;
8483

8584
if ($this->encoder->needsNormalization($format)) {
8685
$data = $this->normalize($data, $format);
@@ -98,7 +97,7 @@ final public function deserialize($data, $type, $format, array $options = array(
9897
throw new UnexpectedValueException('Deserialization for the format '.$format.' is not supported');
9998
}
10099

101-
$this->options = array_merge($this->options, $options);
100+
$this->options = $options;
102101

103102
$data = $this->decode($data, $format);
104103

SerializerInterface.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ interface SerializerInterface
2727
*
2828
* @return string
2929
*/
30-
function serialize($data, $format, array $options = array());
30+
public function serialize($data, $format, array $options = array());
3131

3232
/**
3333
* Deserializes data into the given type.
@@ -39,12 +39,12 @@ function serialize($data, $format, array $options = array());
3939
*
4040
* @return object
4141
*/
42-
function deserialize($data, $type, $format, array $options = array());
42+
public function deserialize($data, $type, $format, array $options = array());
4343

4444
/**
4545
* Get current options of the serializer
4646
*
4747
* @return array
4848
*/
49-
function getOptions();
49+
public function getOptions();
5050
}

Tests/Encoder/XmlEncoderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ public function testEncodeSerializerXmlRootNodeNameOption()
188188
{
189189
$options = array('xml_root_node_name' => 'test');
190190
$this->encoder = new XmlEncoder;
191-
$serializer = new Serializer(array(), array('xml' => new XmlEncoder()), $options);
191+
$serializer = new Serializer(array(), array('xml' => new XmlEncoder()));
192192
$this->encoder->setSerializer($serializer);
193193

194194
$array = array(
@@ -198,7 +198,7 @@ public function testEncodeSerializerXmlRootNodeNameOption()
198198
$expected = '<?xml version="1.0"?>'."\n".
199199
'<test><person gender="M">Peter</person></test>'."\n";
200200

201-
$this->assertEquals($expected, $this->encoder->encode($array, 'xml'));
201+
$this->assertEquals($expected, $serializer->serialize($array, 'xml', $options));
202202
}
203203

204204
public function testDecode()

0 commit comments

Comments
 (0)