updated core and modules
This commit is contained in:
+1
-1
@@ -59,7 +59,7 @@ class ChainDecoder implements DecoderInterface
|
||||
*
|
||||
* @return DecoderInterface
|
||||
*
|
||||
* @throws RuntimeException if no decoder is found
|
||||
* @throws RuntimeException If no decoder is found.
|
||||
*/
|
||||
private function getDecoder($format)
|
||||
{
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ interface DecoderInterface
|
||||
*
|
||||
* @param string $data Data to decode
|
||||
* @param string $format Format name
|
||||
* @param array $context options that decoders have access to.
|
||||
* @param array $context options that decoders have access to
|
||||
*
|
||||
* The format parameter specifies which format the data is in; valid values
|
||||
* depend on the specific implementation. Authors implementing this interface
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ interface EncoderInterface
|
||||
*
|
||||
* @param mixed $data Data to encode
|
||||
* @param string $format Format name
|
||||
* @param array $context options that normalizers/encoders have access to.
|
||||
* @param array $context options that normalizers/encoders have access to
|
||||
*
|
||||
* @return scalar
|
||||
*
|
||||
|
||||
+8
-3
@@ -369,7 +369,10 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec
|
||||
if (is_array($data) || ($data instanceof \Traversable && !$this->serializer->supportsNormalization($data, $this->format))) {
|
||||
foreach ($data as $key => $data) {
|
||||
//Ah this is the magic @ attribute types.
|
||||
if (0 === strpos($key, '@') && is_scalar($data) && $this->isElementNameValid($attributeName = substr($key, 1))) {
|
||||
if (0 === strpos($key, '@') && $this->isElementNameValid($attributeName = substr($key, 1))) {
|
||||
if (!is_scalar($data)) {
|
||||
$data = $this->serializer->normalize($data, $this->format, $this->context);
|
||||
}
|
||||
$parentNode->setAttribute($attributeName, $data);
|
||||
} elseif ($key === '#') {
|
||||
$append = $this->selectNodeType($parentNode, $data);
|
||||
@@ -461,6 +464,8 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec
|
||||
* @param mixed $val
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws UnexpectedValueException
|
||||
*/
|
||||
private function selectNodeType(\DOMNode $node, $val)
|
||||
{
|
||||
@@ -472,7 +477,7 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec
|
||||
} elseif ($val instanceof \Traversable) {
|
||||
$this->buildXml($node, $val);
|
||||
} elseif (is_object($val)) {
|
||||
return $this->buildXml($node, $this->serializer->normalize($val, $this->format, $this->context));
|
||||
return $this->selectNodeType($node, $this->serializer->normalize($val, $this->format, $this->context));
|
||||
} elseif (is_numeric($val)) {
|
||||
return $this->appendText($node, (string) $val);
|
||||
} elseif (is_string($val) && $this->needsCdataWrapping($val)) {
|
||||
@@ -506,7 +511,7 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec
|
||||
/**
|
||||
* Create a DOM document, taking serializer options into account.
|
||||
*
|
||||
* @param array $context options that the encoder has access to.
|
||||
* @param array $context options that the encoder has access to
|
||||
*
|
||||
* @return \DOMDocument
|
||||
*/
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2004-2016 Fabien Potencier
|
||||
Copyright (c) 2004-2017 Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -27,7 +27,7 @@ interface ClassMetadataInterface
|
||||
/**
|
||||
* Returns the name of the backing PHP class.
|
||||
*
|
||||
* @return string The name of the backing class.
|
||||
* @return string The name of the backing class
|
||||
*/
|
||||
public function getName();
|
||||
|
||||
|
||||
+23
-23
@@ -60,39 +60,39 @@ class YamlFileLoader extends FileLoader
|
||||
$this->classes = $classes;
|
||||
}
|
||||
|
||||
if (isset($this->classes[$classMetadata->getName()])) {
|
||||
$yaml = $this->classes[$classMetadata->getName()];
|
||||
if (!isset($this->classes[$classMetadata->getName()])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isset($yaml['attributes']) && is_array($yaml['attributes'])) {
|
||||
$attributesMetadata = $classMetadata->getAttributesMetadata();
|
||||
$yaml = $this->classes[$classMetadata->getName()];
|
||||
|
||||
foreach ($yaml['attributes'] as $attribute => $data) {
|
||||
if (isset($attributesMetadata[$attribute])) {
|
||||
$attributeMetadata = $attributesMetadata[$attribute];
|
||||
} else {
|
||||
$attributeMetadata = new AttributeMetadata($attribute);
|
||||
$classMetadata->addAttributeMetadata($attributeMetadata);
|
||||
if (isset($yaml['attributes']) && is_array($yaml['attributes'])) {
|
||||
$attributesMetadata = $classMetadata->getAttributesMetadata();
|
||||
|
||||
foreach ($yaml['attributes'] as $attribute => $data) {
|
||||
if (isset($attributesMetadata[$attribute])) {
|
||||
$attributeMetadata = $attributesMetadata[$attribute];
|
||||
} else {
|
||||
$attributeMetadata = new AttributeMetadata($attribute);
|
||||
$classMetadata->addAttributeMetadata($attributeMetadata);
|
||||
}
|
||||
|
||||
if (isset($data['groups'])) {
|
||||
if (!is_array($data['groups'])) {
|
||||
throw new MappingException(sprintf('The "groups" key must be an array of strings in "%s" for the attribute "%s" of the class "%s".', $this->file, $attribute, $classMetadata->getName()));
|
||||
}
|
||||
|
||||
if (isset($data['groups'])) {
|
||||
if (!is_array($data['groups'])) {
|
||||
throw new MappingException('The "groups" key must be an array of strings in "%s" for the attribute "%s" of the class "%s".', $this->file, $attribute, $classMetadata->getName());
|
||||
foreach ($data['groups'] as $group) {
|
||||
if (!is_string($group)) {
|
||||
throw new MappingException(sprintf('Group names must be strings in "%s" for the attribute "%s" of the class "%s".', $this->file, $attribute, $classMetadata->getName()));
|
||||
}
|
||||
|
||||
foreach ($data['groups'] as $group) {
|
||||
if (!is_string($group)) {
|
||||
throw new MappingException('Group names must be strings in "%s" for the attribute "%s" of the class "%s".', $this->file, $attribute, $classMetadata->getName());
|
||||
}
|
||||
|
||||
$attributeMetadata->addGroup($group);
|
||||
}
|
||||
$attributeMetadata->addGroup($group);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+8
-7
@@ -29,8 +29,8 @@ class CamelCaseToSnakeCaseNameConverter implements NameConverterInterface
|
||||
private $lowerCamelCase;
|
||||
|
||||
/**
|
||||
* @param null|array $attributes The list of attributes to rename or null for all attributes.
|
||||
* @param bool $lowerCamelCase Use lowerCamelCase style.
|
||||
* @param null|array $attributes The list of attributes to rename or null for all attributes
|
||||
* @param bool $lowerCamelCase Use lowerCamelCase style
|
||||
*/
|
||||
public function __construct(array $attributes = null, $lowerCamelCase = true)
|
||||
{
|
||||
@@ -44,14 +44,15 @@ class CamelCaseToSnakeCaseNameConverter implements NameConverterInterface
|
||||
public function normalize($propertyName)
|
||||
{
|
||||
if (null === $this->attributes || in_array($propertyName, $this->attributes)) {
|
||||
$lcPropertyName = lcfirst($propertyName);
|
||||
$snakeCasedName = '';
|
||||
|
||||
$len = strlen($propertyName);
|
||||
$len = strlen($lcPropertyName);
|
||||
for ($i = 0; $i < $len; ++$i) {
|
||||
if (ctype_upper($propertyName[$i])) {
|
||||
$snakeCasedName .= '_'.strtolower($propertyName[$i]);
|
||||
if (ctype_upper($lcPropertyName[$i])) {
|
||||
$snakeCasedName .= '_'.strtolower($lcPropertyName[$i]);
|
||||
} else {
|
||||
$snakeCasedName .= strtolower($propertyName[$i]);
|
||||
$snakeCasedName .= strtolower($lcPropertyName[$i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +76,7 @@ class CamelCaseToSnakeCaseNameConverter implements NameConverterInterface
|
||||
}
|
||||
|
||||
if (null === $this->attributes || in_array($camelCasedName, $this->attributes)) {
|
||||
return $this->lowerCamelCase ? lcfirst($camelCasedName) : $camelCasedName;
|
||||
return $camelCasedName;
|
||||
}
|
||||
|
||||
return $propertyName;
|
||||
|
||||
@@ -38,8 +38,8 @@ class CustomNormalizer extends SerializerAwareNormalizer implements NormalizerIn
|
||||
/**
|
||||
* Checks if the given class implements the NormalizableInterface.
|
||||
*
|
||||
* @param mixed $data Data to normalize.
|
||||
* @param string $format The format being (de-)serialized from or into.
|
||||
* @param mixed $data Data to normalize
|
||||
* @param string $format The format being (de-)serialized from or into
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@@ -51,9 +51,9 @@ class CustomNormalizer extends SerializerAwareNormalizer implements NormalizerIn
|
||||
/**
|
||||
* Checks if the given class implements the NormalizableInterface.
|
||||
*
|
||||
* @param mixed $data Data to denormalize from.
|
||||
* @param string $type The class to which the data should be denormalized.
|
||||
* @param string $format The format being deserialized from.
|
||||
* @param mixed $data Data to denormalize from
|
||||
* @param string $type The class to which the data should be denormalized
|
||||
* @param string $format The format being deserialized from
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
@@ -29,10 +29,12 @@ interface DenormalizableInterface
|
||||
*
|
||||
* @param DenormalizerInterface $denormalizer The denormalizer is given so that you
|
||||
* can use it to denormalize objects contained within this object
|
||||
* @param array|scalar $data The data from which to re-create the object.
|
||||
* @param array|scalar $data The data from which to re-create the object
|
||||
* @param string|null $format The format is optionally given to be able to denormalize differently
|
||||
* based on different input formats
|
||||
* @param array $context options for denormalizing
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function denormalize(DenormalizerInterface $denormalizer, $data, $format = null, array $context = array());
|
||||
}
|
||||
|
||||
@@ -33,9 +33,9 @@ interface DenormalizerInterface
|
||||
/**
|
||||
* Checks whether the given class is supported for denormalization by this normalizer.
|
||||
*
|
||||
* @param mixed $data Data to denormalize from.
|
||||
* @param string $type The class to which the data should be denormalized.
|
||||
* @param string $format The format being deserialized from.
|
||||
* @param mixed $data Data to denormalize from
|
||||
* @param string $type The class to which the data should be denormalized
|
||||
* @param string $format The format being deserialized from
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
@@ -164,7 +164,7 @@ class GetSetMethodNormalizer extends AbstractNormalizer
|
||||
*
|
||||
* @param \ReflectionMethod $method the method to check
|
||||
*
|
||||
* @return bool whether the method is a getter or boolean getter.
|
||||
* @return bool whether the method is a getter or boolean getter
|
||||
*/
|
||||
private function isGetMethod(\ReflectionMethod $method)
|
||||
{
|
||||
|
||||
@@ -33,7 +33,7 @@ interface NormalizableInterface
|
||||
* based on different output formats.
|
||||
* @param array $context Options for normalizing this object
|
||||
*
|
||||
* @return array|string|bool|int|float|null
|
||||
* @return array|scalar
|
||||
*/
|
||||
public function normalize(NormalizerInterface $normalizer, $format = null, array $context = array());
|
||||
}
|
||||
|
||||
@@ -25,15 +25,15 @@ interface NormalizerInterface
|
||||
* @param string $format format the normalization result will be encoded as
|
||||
* @param array $context Context options for the normalizer
|
||||
*
|
||||
* @return array|string|bool|int|float|null
|
||||
* @return array|scalar
|
||||
*/
|
||||
public function normalize($object, $format = null, array $context = array());
|
||||
|
||||
/**
|
||||
* Checks whether the given class is supported for normalization by this normalizer.
|
||||
*
|
||||
* @param mixed $data Data to normalize.
|
||||
* @param string $format The format being (de-)serialized from or into.
|
||||
* @param mixed $data Data to normalize
|
||||
* @param string $format The format being (de-)serialized from or into
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
-9
@@ -250,15 +250,6 @@ class Serializer implements SerializerInterface, NormalizerInterface, Denormaliz
|
||||
return $normalizer->denormalize($data, $class, $format, $context);
|
||||
}
|
||||
|
||||
foreach ($this->normalizers as $normalizer) {
|
||||
if (
|
||||
$normalizer instanceof DenormalizerInterface &&
|
||||
$normalizer->supportsDenormalization($data, $class, $format)
|
||||
) {
|
||||
return $normalizer->denormalize($data, $class, $format, $context);
|
||||
}
|
||||
}
|
||||
|
||||
throw new UnexpectedValueException(sprintf('Could not denormalize object of type %s, no supporting normalizer found.', $class));
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
"symfony/polyfill-php55": "~1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/yaml": "~2.0,>=2.0.5|~3.0.0",
|
||||
"symfony/yaml": "^2.0.5|~3.0.0",
|
||||
"symfony/config": "~2.2|~3.0.0",
|
||||
"symfony/property-access": "~2.3|~3.0.0",
|
||||
"doctrine/annotations": "~1.0",
|
||||
|
||||
Reference in New Issue
Block a user