Fix CS issues, removed global options
This commit is contained in:
parent
9c54a4b552
commit
8854b85abf
@ -405,7 +405,7 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec
|
||||
*/
|
||||
private function getRealRootNodeName()
|
||||
{
|
||||
if ( ! $this->serializer) {
|
||||
if (!$this->serializer) {
|
||||
return $this->rootNodeName;
|
||||
}
|
||||
|
||||
|
@ -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 @@ class Serializer implements SerializerInterface, NormalizerInterface, Denormaliz
|
||||
}
|
||||
$this->encoder = new ChainEncoder($realEncoders);
|
||||
$this->decoder = new ChainDecoder($decoders);
|
||||
$this->options = $options;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -80,7 +79,7 @@ class Serializer implements SerializerInterface, NormalizerInterface, Denormaliz
|
||||
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 @@ class Serializer implements SerializerInterface, NormalizerInterface, Denormaliz
|
||||
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);
|
||||
|
||||
|
@ -27,7 +27,7 @@ interface SerializerInterface
|
||||
*
|
||||
* @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 @@ interface SerializerInterface
|
||||
*
|
||||
* @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 @@ class XmlEncoderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$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 @@ class XmlEncoderTest extends \PHPUnit_Framework_TestCase
|
||||
$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()
|
||||
|
Reference in New Issue
Block a user