Skip to content

Commit 11bea1a

Browse files
Merge branch '2.8' into 3.4
* 2.8: [Serializer] optims and cleanup fix accessing request values [Form] Add translations for Tagalog
2 parents 9a17f12 + c3cfcfc commit 11bea1a

File tree

10 files changed

+58
-58
lines changed

10 files changed

+58
-58
lines changed

Annotation/Groups.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ class Groups
3434
public function __construct(array $data)
3535
{
3636
if (!isset($data['value']) || !$data['value']) {
37-
throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" cannot be empty.', get_class($this)));
37+
throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" cannot be empty.', \get_class($this)));
3838
}
3939

4040
$value = (array) $data['value'];
4141
foreach ($value as $group) {
42-
if (!is_string($group)) {
43-
throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" must be a string or an array of strings.', get_class($this)));
42+
if (!\is_string($group)) {
43+
throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" must be a string or an array of strings.', \get_class($this)));
4444
}
4545
}
4646

Encoder/XmlEncoder.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public function getRootNodeName()
184184
*/
185185
final protected function appendXMLString(\DOMNode $node, $val)
186186
{
187-
if (strlen($val) > 0) {
187+
if (\strlen($val) > 0) {
188188
$frag = $this->dom->createDocumentFragment();
189189
$frag->appendXML($val);
190190
$node->appendChild($frag);
@@ -265,17 +265,17 @@ private function parseXml(\DOMNode $node, array $context = array())
265265

266266
$value = $this->parseXmlValue($node, $context);
267267

268-
if (!count($data)) {
268+
if (!\count($data)) {
269269
return $value;
270270
}
271271

272-
if (!is_array($value)) {
272+
if (!\is_array($value)) {
273273
$data['#'] = $value;
274274

275275
return $data;
276276
}
277277

278-
if (1 === count($value) && key($value)) {
278+
if (1 === \count($value) && key($value)) {
279279
$data[key($value)] = current($value);
280280

281281
return $data;
@@ -332,7 +332,7 @@ private function parseXmlValue(\DOMNode $node, array $context = array())
332332
return $node->nodeValue;
333333
}
334334

335-
if (1 === $node->childNodes->length && in_array($node->firstChild->nodeType, array(XML_TEXT_NODE, XML_CDATA_SECTION_NODE))) {
335+
if (1 === $node->childNodes->length && \in_array($node->firstChild->nodeType, array(XML_TEXT_NODE, XML_CDATA_SECTION_NODE))) {
336336
return $node->firstChild->nodeValue;
337337
}
338338

@@ -357,7 +357,7 @@ private function parseXmlValue(\DOMNode $node, array $context = array())
357357
}
358358

359359
foreach ($value as $key => $val) {
360-
if (is_array($val) && 1 === count($val)) {
360+
if (\is_array($val) && 1 === \count($val)) {
361361
$value[$key] = current($val);
362362
}
363363
}
@@ -380,7 +380,7 @@ private function buildXml(\DOMNode $parentNode, $data, $xmlRootNodeName = null)
380380
{
381381
$append = true;
382382

383-
if (is_array($data) || ($data instanceof \Traversable && !$this->serializer->supportsNormalization($data, $this->format))) {
383+
if (\is_array($data) || ($data instanceof \Traversable && !$this->serializer->supportsNormalization($data, $this->format))) {
384384
foreach ($data as $key => $data) {
385385
//Ah this is the magic @ attribute types.
386386
if (0 === strpos($key, '@') && $this->isElementNameValid($attributeName = substr($key, 1))) {
@@ -390,7 +390,7 @@ private function buildXml(\DOMNode $parentNode, $data, $xmlRootNodeName = null)
390390
$parentNode->setAttribute($attributeName, $data);
391391
} elseif ('#' === $key) {
392392
$append = $this->selectNodeType($parentNode, $data);
393-
} elseif (is_array($data) && false === is_numeric($key)) {
393+
} elseif (\is_array($data) && false === is_numeric($key)) {
394394
// Is this array fully numeric keys?
395395
if (ctype_digit(implode('', array_keys($data)))) {
396396
/*
@@ -414,7 +414,7 @@ private function buildXml(\DOMNode $parentNode, $data, $xmlRootNodeName = null)
414414
return $append;
415415
}
416416

417-
if (is_object($data)) {
417+
if (\is_object($data)) {
418418
$data = $this->serializer->normalize($data, $this->format, $this->context);
419419
if (null !== $data && !is_scalar($data)) {
420420
return $this->buildXml($parentNode, $data, $xmlRootNodeName);
@@ -483,22 +483,22 @@ private function needsCdataWrapping($val)
483483
*/
484484
private function selectNodeType(\DOMNode $node, $val)
485485
{
486-
if (is_array($val)) {
486+
if (\is_array($val)) {
487487
return $this->buildXml($node, $val);
488488
} elseif ($val instanceof \SimpleXMLElement) {
489489
$child = $this->dom->importNode(dom_import_simplexml($val), true);
490490
$node->appendChild($child);
491491
} elseif ($val instanceof \Traversable) {
492492
$this->buildXml($node, $val);
493-
} elseif (is_object($val)) {
493+
} elseif (\is_object($val)) {
494494
return $this->selectNodeType($node, $this->serializer->normalize($val, $this->format, $this->context));
495495
} elseif (is_numeric($val)) {
496496
return $this->appendText($node, (string) $val);
497-
} elseif (is_string($val) && $this->needsCdataWrapping($val)) {
497+
} elseif (\is_string($val) && $this->needsCdataWrapping($val)) {
498498
return $this->appendCData($node, $val);
499-
} elseif (is_string($val)) {
499+
} elseif (\is_string($val)) {
500500
return $this->appendText($node, $val);
501-
} elseif (is_bool($val)) {
501+
} elseif (\is_bool($val)) {
502502
return $this->appendText($node, (int) $val);
503503
} elseif ($val instanceof \DOMNode) {
504504
$child = $this->dom->importNode($val, true);

Mapping/AttributeMetadata.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function getName()
6464
*/
6565
public function addGroup($group)
6666
{
67-
if (!in_array($group, $this->groups)) {
67+
if (!\in_array($group, $this->groups)) {
6868
$this->groups[] = $group;
6969
}
7070
}

Mapping/Loader/LoaderChain.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function __construct(array $loaders)
4040
{
4141
foreach ($loaders as $loader) {
4242
if (!$loader instanceof LoaderInterface) {
43-
throw new MappingException(sprintf('Class %s is expected to implement LoaderInterface', get_class($loader)));
43+
throw new MappingException(sprintf('Class %s is expected to implement LoaderInterface', \get_class($loader)));
4444
}
4545
}
4646

Mapping/Loader/YamlFileLoader.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class YamlFileLoader extends FileLoader
3030
*
3131
* @var array
3232
*/
33-
private $classes = null;
33+
private $classes;
3434

3535
/**
3636
* {@inheritdoc}
@@ -51,7 +51,7 @@ public function loadClassMetadata(ClassMetadataInterface $classMetadata)
5151

5252
$yaml = $this->classes[$classMetadata->getName()];
5353

54-
if (isset($yaml['attributes']) && is_array($yaml['attributes'])) {
54+
if (isset($yaml['attributes']) && \is_array($yaml['attributes'])) {
5555
$attributesMetadata = $classMetadata->getAttributesMetadata();
5656

5757
foreach ($yaml['attributes'] as $attribute => $data) {
@@ -63,12 +63,12 @@ public function loadClassMetadata(ClassMetadataInterface $classMetadata)
6363
}
6464

6565
if (isset($data['groups'])) {
66-
if (!is_array($data['groups'])) {
66+
if (!\is_array($data['groups'])) {
6767
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()));
6868
}
6969

7070
foreach ($data['groups'] as $group) {
71-
if (!is_string($group)) {
71+
if (!\is_string($group)) {
7272
throw new MappingException(sprintf('Group names must be strings in "%s" for the attribute "%s" of the class "%s".', $this->file, $attribute, $classMetadata->getName()));
7373
}
7474

@@ -119,7 +119,7 @@ private function getClassesFromYaml()
119119
return array();
120120
}
121121

122-
if (!is_array($classes)) {
122+
if (!\is_array($classes)) {
123123
throw new MappingException(sprintf('The file "%s" must contain a YAML array.', $this->file));
124124
}
125125

NameConverter/CamelCaseToSnakeCaseNameConverter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __construct(array $attributes = null, $lowerCamelCase = true)
3636
*/
3737
public function normalize($propertyName)
3838
{
39-
if (null === $this->attributes || in_array($propertyName, $this->attributes)) {
39+
if (null === $this->attributes || \in_array($propertyName, $this->attributes)) {
4040
return strtolower(preg_replace('/[A-Z]/', '_\\0', lcfirst($propertyName)));
4141
}
4242

@@ -56,7 +56,7 @@ public function denormalize($propertyName)
5656
$camelCasedName = lcfirst($camelCasedName);
5757
}
5858

59-
if (null === $this->attributes || in_array($camelCasedName, $this->attributes)) {
59+
if (null === $this->attributes || \in_array($camelCasedName, $this->attributes)) {
6060
return $camelCasedName;
6161
}
6262

Normalizer/AbstractNormalizer.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public function setCircularReferenceHandler(callable $circularReferenceHandler)
119119
public function setCallbacks(array $callbacks)
120120
{
121121
foreach ($callbacks as $attribute => $callback) {
122-
if (!is_callable($callback)) {
122+
if (!\is_callable($callback)) {
123123
throw new InvalidArgumentException(sprintf(
124124
'The given callback for attribute "%s" is not callable.',
125125
$attribute
@@ -187,10 +187,10 @@ protected function isCircularReference($object, &$context)
187187
protected function handleCircularReference($object)
188188
{
189189
if ($this->circularReferenceHandler) {
190-
return call_user_func($this->circularReferenceHandler, $object);
190+
return \call_user_func($this->circularReferenceHandler, $object);
191191
}
192192

193-
throw new CircularReferenceException(sprintf('A circular reference has been detected when serializing the object of class "%s" (configured limit: %d)', get_class($object), $this->circularReferenceLimit));
193+
throw new CircularReferenceException(sprintf('A circular reference has been detected when serializing the object of class "%s" (configured limit: %d)', \get_class($object), $this->circularReferenceLimit));
194194
}
195195

196196
/**
@@ -209,7 +209,7 @@ protected function getAllowedAttributes($classOrObject, array $context, $attribu
209209
}
210210

211211
$groups = false;
212-
if (isset($context[static::GROUPS]) && is_array($context[static::GROUPS])) {
212+
if (isset($context[static::GROUPS]) && \is_array($context[static::GROUPS])) {
213213
$groups = $context[static::GROUPS];
214214
} elseif (!isset($context[static::ALLOW_EXTRA_ATTRIBUTES]) || $context[static::ALLOW_EXTRA_ATTRIBUTES]) {
215215
return false;
@@ -220,7 +220,7 @@ protected function getAllowedAttributes($classOrObject, array $context, $attribu
220220
$name = $attributeMetadata->getName();
221221

222222
if (
223-
(false === $groups || count(array_intersect($attributeMetadata->getGroups(), $groups))) &&
223+
(false === $groups || array_intersect($attributeMetadata->getGroups(), $groups)) &&
224224
$this->isAllowedAttribute($classOrObject, $name, null, $context)
225225
) {
226226
$allowedAttributes[] = $attributesAsString ? $name : $attributeMetadata;
@@ -309,10 +309,10 @@ protected function getConstructor(array &$data, $class, array &$context, \Reflec
309309
*/
310310
protected function instantiateObject(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes/*, string $format = null*/)
311311
{
312-
if (func_num_args() >= 6) {
313-
$format = func_get_arg(5);
312+
if (\func_num_args() >= 6) {
313+
$format = \func_get_arg(5);
314314
} else {
315-
if (__CLASS__ !== get_class($this)) {
315+
if (__CLASS__ !== \get_class($this)) {
316316
$r = new \ReflectionMethod($this, __FUNCTION__);
317317
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
318318
@trigger_error(sprintf('Method %s::%s() will have a 6th `string $format = null` argument in version 4.0. Not defining it is deprecated since Symfony 3.2.', get_class($this), __FUNCTION__), E_USER_DEPRECATED);
@@ -337,11 +337,11 @@ protected function instantiateObject(array &$data, $class, array &$context, \Ref
337337
$paramName = $constructorParameter->name;
338338
$key = $this->nameConverter ? $this->nameConverter->normalize($paramName) : $paramName;
339339

340-
$allowed = false === $allowedAttributes || in_array($paramName, $allowedAttributes);
340+
$allowed = false === $allowedAttributes || \in_array($paramName, $allowedAttributes);
341341
$ignored = !$this->isAllowedAttribute($class, $paramName, $format, $context);
342342
if (method_exists($constructorParameter, 'isVariadic') && $constructorParameter->isVariadic()) {
343343
if ($allowed && !$ignored && (isset($data[$key]) || array_key_exists($key, $data))) {
344-
if (!is_array($data[$paramName])) {
344+
if (!\is_array($data[$paramName])) {
345345
throw new RuntimeException(sprintf('Cannot create an instance of %s from serialized data because the variadic parameter %s can only accept an array.', $class, $constructorParameter->name));
346346
}
347347

Normalizer/GetSetMethodNormalizer.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ private function supports($class)
8080
*/
8181
private function isGetMethod(\ReflectionMethod $method)
8282
{
83-
$methodLength = strlen($method->name);
83+
$methodLength = \strlen($method->name);
8484

8585
return
8686
!$method->isStatic() &&
@@ -125,17 +125,17 @@ protected function getAttributeValue($object, $attribute, $format = null, array
125125
$ucfirsted = ucfirst($attribute);
126126

127127
$getter = 'get'.$ucfirsted;
128-
if (is_callable(array($object, $getter))) {
128+
if (\is_callable(array($object, $getter))) {
129129
return $object->$getter();
130130
}
131131

132132
$isser = 'is'.$ucfirsted;
133-
if (is_callable(array($object, $isser))) {
133+
if (\is_callable(array($object, $isser))) {
134134
return $object->$isser();
135135
}
136136

137137
$haser = 'has'.$ucfirsted;
138-
if (is_callable(array($object, $haser))) {
138+
if (\is_callable(array($object, $haser))) {
139139
return $object->$haser();
140140
}
141141
}
@@ -146,10 +146,10 @@ protected function getAttributeValue($object, $attribute, $format = null, array
146146
protected function setAttributeValue($object, $attribute, $value, $format = null, array $context = array())
147147
{
148148
$setter = 'set'.ucfirst($attribute);
149-
$key = get_class($object).':'.$setter;
149+
$key = \get_class($object).':'.$setter;
150150

151151
if (!isset(self::$setterAccessibleCache[$key])) {
152-
self::$setterAccessibleCache[$key] = is_callable(array($object, $setter)) && !(new \ReflectionMethod($object, $setter))->isStatic();
152+
self::$setterAccessibleCache[$key] = \is_callable(array($object, $setter)) && !(new \ReflectionMethod($object, $setter))->isStatic();
153153
}
154154

155155
if (self::$setterAccessibleCache[$key]) {

Normalizer/ObjectNormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class ObjectNormalizer extends AbstractObjectNormalizer
3030

3131
public function __construct(ClassMetadataFactoryInterface $classMetadataFactory = null, NameConverterInterface $nameConverter = null, PropertyAccessorInterface $propertyAccessor = null, PropertyTypeExtractorInterface $propertyTypeExtractor = null)
3232
{
33-
if (!class_exists('Symfony\Component\PropertyAccess\PropertyAccess')) {
33+
if (!\class_exists(PropertyAccess::class)) {
3434
throw new RuntimeException('The ObjectNormalizer class requires the "PropertyAccess" component. Install "symfony/property-access" to use it.');
3535
}
3636

Serializer.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public function normalize($data, $format = null, array $context = array())
147147
return $data;
148148
}
149149

150-
if (is_array($data) || $data instanceof \Traversable) {
150+
if (\is_array($data) || $data instanceof \Traversable) {
151151
$normalized = array();
152152
foreach ($data as $key => $val) {
153153
$normalized[$key] = $this->normalize($val, $format, $context);
@@ -156,12 +156,12 @@ public function normalize($data, $format = null, array $context = array())
156156
return $normalized;
157157
}
158158

159-
if (is_object($data)) {
159+
if (\is_object($data)) {
160160
if (!$this->normalizers) {
161161
throw new LogicException('You must register at least one normalizer to be able to normalize objects.');
162162
}
163163

164-
throw new NotNormalizableValueException(sprintf('Could not normalize object of type %s, no supporting normalizer found.', get_class($data)));
164+
throw new NotNormalizableValueException(sprintf('Could not normalize object of type %s, no supporting normalizer found.', \get_class($data)));
165165
}
166166

167167
throw new NotNormalizableValueException(sprintf('An unexpected value could not be normalized: %s', var_export($data, true)));
@@ -190,10 +190,10 @@ public function denormalize($data, $type, $format = null, array $context = array
190190
*/
191191
public function supportsNormalization($data, $format = null/*, array $context = array()*/)
192192
{
193-
if (func_num_args() > 2) {
194-
$context = func_get_arg(2);
193+
if (\func_num_args() > 2) {
194+
$context = \func_get_arg(2);
195195
} else {
196-
if (__CLASS__ !== get_class($this)) {
196+
if (__CLASS__ !== \get_class($this)) {
197197
$r = new \ReflectionMethod($this, __FUNCTION__);
198198
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
199199
@trigger_error(sprintf('Method %s() will have a third `$context = array()` argument in version 4.0. Not defining it is deprecated since Symfony 3.3.', __METHOD__), E_USER_DEPRECATED);
@@ -211,10 +211,10 @@ public function supportsNormalization($data, $format = null/*, array $context =
211211
*/
212212
public function supportsDenormalization($data, $type, $format = null/*, array $context = array()*/)
213213
{
214-
if (func_num_args() > 3) {
215-
$context = func_get_arg(3);
214+
if (\func_num_args() > 3) {
215+
$context = \func_get_arg(3);
216216
} else {
217-
if (__CLASS__ !== get_class($this)) {
217+
if (__CLASS__ !== \get_class($this)) {
218218
$r = new \ReflectionMethod($this, __FUNCTION__);
219219
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
220220
@trigger_error(sprintf('Method %s() will have a fourth `$context = array()` argument in version 4.0. Not defining it is deprecated since Symfony 3.3.', __METHOD__), E_USER_DEPRECATED);
@@ -285,10 +285,10 @@ final public function decode($data, $format, array $context = array())
285285
*/
286286
public function supportsEncoding($format/*, array $context = array()*/)
287287
{
288-
if (func_num_args() > 1) {
289-
$context = func_get_arg(1);
288+
if (\func_num_args() > 1) {
289+
$context = \func_get_arg(1);
290290
} else {
291-
if (__CLASS__ !== get_class($this)) {
291+
if (__CLASS__ !== \get_class($this)) {
292292
$r = new \ReflectionMethod($this, __FUNCTION__);
293293
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
294294
@trigger_error(sprintf('Method %s() will have a second `$context = array()` argument in version 4.0. Not defining it is deprecated since Symfony 3.3.', __METHOD__), E_USER_DEPRECATED);
@@ -306,10 +306,10 @@ public function supportsEncoding($format/*, array $context = array()*/)
306306
*/
307307
public function supportsDecoding($format/*, array $context = array()*/)
308308
{
309-
if (func_num_args() > 1) {
310-
$context = func_get_arg(1);
309+
if (\func_num_args() > 1) {
310+
$context = \func_get_arg(1);
311311
} else {
312-
if (__CLASS__ !== get_class($this)) {
312+
if (__CLASS__ !== \get_class($this)) {
313313
$r = new \ReflectionMethod($this, __FUNCTION__);
314314
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
315315
@trigger_error(sprintf('Method %s() will have a second `$context = array()` argument in version 4.0. Not defining it is deprecated since Symfony 3.3.', __METHOD__), E_USER_DEPRECATED);

0 commit comments

Comments
 (0)