Skip to content

Commit

Permalink
Fix CS issues, removed global options
Browse files Browse the repository at this point in the history
  • Loading branch information
beberlei authored and dlsniper committed Jan 4, 2013
1 parent 3e7a28f commit 7e2de10
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Encoder/XmlEncoder.php
Expand Up @@ -405,7 +405,7 @@ private function selectNodeType($node, $val)
*/ */
private function getRealRootNodeName() private function getRealRootNodeName()
{ {
if ( ! $this->serializer) { if (!$this->serializer) {
return $this->rootNodeName; return $this->rootNodeName;
} }


Expand Down
9 changes: 4 additions & 5 deletions Serializer.php
Expand Up @@ -42,9 +42,9 @@ class Serializer implements SerializerInterface, NormalizerInterface, Denormaliz
protected $normalizers = array(); protected $normalizers = array();
protected $normalizerCache = array(); protected $normalizerCache = array();
protected $denormalizerCache = 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) { foreach ($normalizers as $normalizer) {
if ($normalizer instanceof SerializerAwareInterface) { if ($normalizer instanceof SerializerAwareInterface) {
Expand All @@ -68,7 +68,6 @@ public function __construct(array $normalizers = array(), array $encoders = arra
} }
$this->encoder = new ChainEncoder($realEncoders); $this->encoder = new ChainEncoder($realEncoders);
$this->decoder = new ChainDecoder($decoders); $this->decoder = new ChainDecoder($decoders);
$this->options = $options;
} }


/** /**
Expand All @@ -80,7 +79,7 @@ final public function serialize($data, $format, array $options = array())
throw new UnexpectedValueException('Serialization for the format '.$format.' is not supported'); 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)) { if ($this->encoder->needsNormalization($format)) {
$data = $this->normalize($data, $format); $data = $this->normalize($data, $format);
Expand All @@ -98,7 +97,7 @@ final public function deserialize($data, $type, $format, array $options = array(
throw new UnexpectedValueException('Deserialization for the format '.$format.' is not supported'); 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); $data = $this->decode($data, $format);


Expand Down
6 changes: 3 additions & 3 deletions SerializerInterface.php
Expand Up @@ -27,7 +27,7 @@ interface SerializerInterface
* *
* @return string * @return string
*/ */
function serialize($data, $format, array $options = array()); public function serialize($data, $format, array $options = array());


/** /**
* Deserializes data into the given type. * Deserializes data into the given type.
Expand All @@ -39,12 +39,12 @@ function serialize($data, $format, array $options = array());
* *
* @return object * @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 * Get current options of the serializer
* *
* @return array * @return array
*/ */
function getOptions(); public function getOptions();
} }
4 changes: 2 additions & 2 deletions Tests/Encoder/XmlEncoderTest.php
Expand Up @@ -188,7 +188,7 @@ public function testEncodeSerializerXmlRootNodeNameOption()
{ {
$options = array('xml_root_node_name' => 'test'); $options = array('xml_root_node_name' => 'test');
$this->encoder = new XmlEncoder; $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); $this->encoder->setSerializer($serializer);


$array = array( $array = array(
Expand All @@ -198,7 +198,7 @@ public function testEncodeSerializerXmlRootNodeNameOption()
$expected = '<?xml version="1.0"?>'."\n". $expected = '<?xml version="1.0"?>'."\n".
'<test><person gender="M">Peter</person></test>'."\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() public function testDecode()
Expand Down

0 comments on commit 7e2de10

Please sign in to comment.