Permalink
Browse files

Fix CS issues, removed global options

  • Loading branch information...
1 parent 3e7a28f commit 7e2de10dbb6ae47606761765600b6544e80f9926 @beberlei beberlei committed with dlsniper Jul 17, 2012
Showing with 10 additions and 11 deletions.
  1. +1 −1 Encoder/XmlEncoder.php
  2. +4 −5 Serializer.php
  3. +3 −3 SerializerInterface.php
  4. +2 −2 Tests/Encoder/XmlEncoderTest.php
View
@@ -405,7 +405,7 @@ private function selectNodeType($node, $val)
*/
private function getRealRootNodeName()
{
- if ( ! $this->serializer) {
+ if (!$this->serializer) {
return $this->rootNodeName;
}
View
@@ -42,9 +42,9 @@ class Serializer implements SerializerInterface, NormalizerInterface, Denormaliz
protected $normalizers = array();
protected $normalizerCache = array();
protected $denormalizerCache = array();
- protected $options = array();
+ protected $options;
- public function __construct(array $normalizers = array(), array $encoders = array(), array $options = array())
+ public function __construct(array $normalizers = array(), array $encoders = array())
{
foreach ($normalizers as $normalizer) {
if ($normalizer instanceof SerializerAwareInterface) {
@@ -68,7 +68,6 @@ public function __construct(array $normalizers = array(), array $encoders = arra
}
$this->encoder = new ChainEncoder($realEncoders);
$this->decoder = new ChainDecoder($decoders);
- $this->options = $options;
}
/**
@@ -80,7 +79,7 @@ public function __construct(array $normalizers = array(), array $encoders = arra
throw new UnexpectedValueException('Serialization for the format '.$format.' is not supported');
}
- $this->options = array_merge($this->options, $options);
+ $this->options = $options;
if ($this->encoder->needsNormalization($format)) {
$data = $this->normalize($data, $format);
@@ -98,7 +97,7 @@ public function __construct(array $normalizers = array(), array $encoders = arra
throw new UnexpectedValueException('Deserialization for the format '.$format.' is not supported');
}
- $this->options = array_merge($this->options, $options);
+ $this->options = $options;
$data = $this->decode($data, $format);
View
@@ -27,7 +27,7 @@
*
* @return string
*/
- function serialize($data, $format, array $options = array());
+ public function serialize($data, $format, array $options = array());
/**
* Deserializes data into the given type.
@@ -39,12 +39,12 @@ function serialize($data, $format, array $options = array());
*
* @return object
*/
- function deserialize($data, $type, $format, array $options = array());
+ public function deserialize($data, $type, $format, array $options = array());
/**
* Get current options of the serializer
*
* @return array
*/
- function getOptions();
+ public function getOptions();
}
@@ -188,7 +188,7 @@ public function testEncodeSerializerXmlRootNodeNameOption()
{
$options = array('xml_root_node_name' => 'test');
$this->encoder = new XmlEncoder;
- $serializer = new Serializer(array(), array('xml' => new XmlEncoder()), $options);
+ $serializer = new Serializer(array(), array('xml' => new XmlEncoder()));
$this->encoder->setSerializer($serializer);
$array = array(
@@ -198,7 +198,7 @@ public function testEncodeSerializerXmlRootNodeNameOption()
$expected = '<?xml version="1.0"?>'."\n".
'<test><person gender="M">Peter</person></test>'."\n";
- $this->assertEquals($expected, $this->encoder->encode($array, 'xml'));
+ $this->assertEquals($expected, $serializer->serialize($array, 'xml', $options));
}
public function testDecode()

0 comments on commit 7e2de10

Please sign in to comment.