Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6d6cea2

Browse files
Merge branch '3.4' into 4.3
* 3.4: [VarDumper] Remove useless variable [Serializer] Fixed docblocks and parameter names.
2 parents 15cd8cf + 73dcf71 commit 6d6cea2

15 files changed

+35
-36
lines changed

src/Symfony/Component/Serializer/Mapping/Factory/ClassResolverTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ trait ClassResolverTrait
2525
/**
2626
* Gets a class name for a given class or instance.
2727
*
28-
* @param mixed $value
28+
* @param object|string $value
2929
*
3030
* @return string
3131
*

src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -316,18 +316,18 @@ public function supportsDenormalization($data, $type, $format = null)
316316
/**
317317
* {@inheritdoc}
318318
*/
319-
public function denormalize($data, $class, $format = null, array $context = [])
319+
public function denormalize($data, $type, $format = null, array $context = [])
320320
{
321321
if (!isset($context['cache_key'])) {
322322
$context['cache_key'] = $this->getCacheKey($format, $context);
323323
}
324324

325-
$allowedAttributes = $this->getAllowedAttributes($class, $context, true);
325+
$allowedAttributes = $this->getAllowedAttributes($type, $context, true);
326326
$normalizedData = $this->prepareForDenormalization($data);
327327
$extraAttributes = [];
328328

329-
$reflectionClass = new \ReflectionClass($class);
330-
$object = $this->instantiateObject($normalizedData, $class, $context, $reflectionClass, $allowedAttributes, $format);
329+
$reflectionClass = new \ReflectionClass($type);
330+
$object = $this->instantiateObject($normalizedData, $type, $context, $reflectionClass, $allowedAttributes, $format);
331331
$resolvedClass = $this->objectClassResolver ? ($this->objectClassResolver)($object) : \get_class($object);
332332

333333
foreach ($normalizedData as $attribute => $value) {
@@ -354,7 +354,7 @@ public function denormalize($data, $class, $format = null, array $context = [])
354354
try {
355355
$this->setAttributeValue($object, $attribute, $value, $format, $context);
356356
} catch (InvalidArgumentException $e) {
357-
throw new NotNormalizableValueException(sprintf('Failed to denormalize attribute "%s" value for class "%s": %s.', $attribute, $class, $e->getMessage()), $e->getCode(), $e);
357+
throw new NotNormalizableValueException(sprintf('Failed to denormalize attribute "%s" value for class "%s": %s.', $attribute, $type, $e->getMessage()), $e->getCode(), $e);
358358
}
359359
}
360360

src/Symfony/Component/Serializer/Normalizer/ArrayDenormalizer.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,28 +36,28 @@ class ArrayDenormalizer implements ContextAwareDenormalizerInterface, Serializer
3636
*
3737
* @throws NotNormalizableValueException
3838
*/
39-
public function denormalize($data, $class, $format = null, array $context = [])
39+
public function denormalize($data, $type, $format = null, array $context = [])
4040
{
4141
if (null === $this->serializer) {
4242
throw new BadMethodCallException('Please set a serializer before calling denormalize()!');
4343
}
4444
if (!\is_array($data)) {
4545
throw new InvalidArgumentException('Data expected to be an array, '.\gettype($data).' given.');
4646
}
47-
if ('[]' !== substr($class, -2)) {
48-
throw new InvalidArgumentException('Unsupported class: '.$class);
47+
if ('[]' !== substr($type, -2)) {
48+
throw new InvalidArgumentException('Unsupported class: '.$type);
4949
}
5050

5151
$serializer = $this->serializer;
52-
$class = substr($class, 0, -2);
52+
$type = substr($type, 0, -2);
5353

5454
$builtinType = isset($context['key_type']) ? $context['key_type']->getBuiltinType() : null;
5555
foreach ($data as $key => $value) {
5656
if (null !== $builtinType && !('is_'.$builtinType)($key)) {
5757
throw new NotNormalizableValueException(sprintf('The type of the key "%s" must be "%s" ("%s" given).', $key, $builtinType, \gettype($key)));
5858
}
5959

60-
$data[$key] = $serializer->denormalize($value, $class, $format, $context);
60+
$data[$key] = $serializer->denormalize($value, $type, $format, $context);
6161
}
6262

6363
return $data;

src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ public function normalize($object, $format = null, array $context = [])
3333
/**
3434
* {@inheritdoc}
3535
*/
36-
public function denormalize($data, $class, $format = null, array $context = [])
36+
public function denormalize($data, $type, $format = null, array $context = [])
3737
{
38-
$object = $this->extractObjectToPopulate($class, $context) ?: new $class();
38+
$object = $this->extractObjectToPopulate($type, $context) ?: new $type();
3939
$object->denormalize($this->serializer, $data, $format, $context);
4040

4141
return $object;

src/Symfony/Component/Serializer/Normalizer/DataUriNormalizer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,14 @@ public function supportsNormalization($data, $format = null)
103103
* @throws InvalidArgumentException
104104
* @throws NotNormalizableValueException
105105
*/
106-
public function denormalize($data, $class, $format = null, array $context = [])
106+
public function denormalize($data, $type, $format = null, array $context = [])
107107
{
108108
if (!preg_match('/^data:([a-z0-9][a-z0-9\!\#\$\&\-\^\_\+\.]{0,126}\/[a-z0-9][a-z0-9\!\#\$\&\-\^\_\+\.]{0,126}(;[a-z0-9\-]+\=[a-z0-9\-]+)?)?(;base64)?,[a-z0-9\!\$\&\\\'\,\(\)\*\+\,\;\=\-\.\_\~\:\@\/\?\%\s]*\s*$/i', $data)) {
109109
throw new NotNormalizableValueException('The provided "data:" URI is not valid.');
110110
}
111111

112112
try {
113-
switch ($class) {
113+
switch ($type) {
114114
case 'Symfony\Component\HttpFoundation\File\File':
115115
return new File($data, false);
116116

@@ -122,7 +122,7 @@ public function denormalize($data, $class, $format = null, array $context = [])
122122
throw new NotNormalizableValueException($exception->getMessage(), $exception->getCode(), $exception);
123123
}
124124

125-
throw new InvalidArgumentException(sprintf('The class parameter "%s" is not supported. It must be one of "SplFileInfo", "SplFileObject" or "Symfony\Component\HttpFoundation\File\File".', $class));
125+
throw new InvalidArgumentException(sprintf('The class parameter "%s" is not supported. It must be one of "SplFileInfo", "SplFileObject" or "Symfony\Component\HttpFoundation\File\File".', $type));
126126
}
127127

128128
/**

src/Symfony/Component/Serializer/Normalizer/DateIntervalNormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function hasCacheableSupportsMethod(): bool
7878
* @throws InvalidArgumentException
7979
* @throws UnexpectedValueException
8080
*/
81-
public function denormalize($data, $class, $format = null, array $context = [])
81+
public function denormalize($data, $type, $format = null, array $context = [])
8282
{
8383
if (!\is_string($data)) {
8484
throw new InvalidArgumentException(sprintf('Data expected to be a string, %s given.', \gettype($data)));

src/Symfony/Component/Serializer/Normalizer/DateTimeNormalizer.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function supportsNormalization($data, $format = null)
8888
*
8989
* @throws NotNormalizableValueException
9090
*/
91-
public function denormalize($data, $class, $format = null, array $context = [])
91+
public function denormalize($data, $type, $format = null, array $context = [])
9292
{
9393
$dateTimeFormat = $context[self::FORMAT_KEY] ?? null;
9494
$timezone = $this->getTimezone($context);
@@ -98,13 +98,13 @@ public function denormalize($data, $class, $format = null, array $context = [])
9898
}
9999

100100
if (null !== $dateTimeFormat) {
101-
$object = \DateTime::class === $class ? \DateTime::createFromFormat($dateTimeFormat, $data, $timezone) : \DateTimeImmutable::createFromFormat($dateTimeFormat, $data, $timezone);
101+
$object = \DateTime::class === $type ? \DateTime::createFromFormat($dateTimeFormat, $data, $timezone) : \DateTimeImmutable::createFromFormat($dateTimeFormat, $data, $timezone);
102102

103103
if (false !== $object) {
104104
return $object;
105105
}
106106

107-
$dateTimeErrors = \DateTime::class === $class ? \DateTime::getLastErrors() : \DateTimeImmutable::getLastErrors();
107+
$dateTimeErrors = \DateTime::class === $type ? \DateTime::getLastErrors() : \DateTimeImmutable::getLastErrors();
108108

109109
throw new NotNormalizableValueException(sprintf(
110110
'Parsing datetime string "%s" using format "%s" resulted in %d errors:'."\n".'%s',
@@ -116,7 +116,7 @@ public function denormalize($data, $class, $format = null, array $context = [])
116116
}
117117

118118
try {
119-
return \DateTime::class === $class ? new \DateTime($data, $timezone) : new \DateTimeImmutable($data, $timezone);
119+
return \DateTime::class === $type ? new \DateTime($data, $timezone) : new \DateTimeImmutable($data, $timezone);
120120
} catch (\Exception $e) {
121121
throw new NotNormalizableValueException($e->getMessage(), $e->getCode(), $e);
122122
}

src/Symfony/Component/Serializer/Normalizer/DateTimeZoneNormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function supportsNormalization($data, $format = null)
4848
*
4949
* @throws NotNormalizableValueException
5050
*/
51-
public function denormalize($data, $class, $format = null, array $context = [])
51+
public function denormalize($data, $type, $format = null, array $context = [])
5252
{
5353
if ('' === $data || null === $data) {
5454
throw new NotNormalizableValueException('The data is either an empty string or null, you should pass a string that can be parsed as a DateTimeZone.');

src/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ interface DenormalizerInterface
3030
* Denormalizes data back into an object of the given class.
3131
*
3232
* @param mixed $data Data to restore
33-
* @param string $class The expected class to instantiate
33+
* @param string $type The expected class to instantiate
3434
* @param string $format Format the given data was extracted from
3535
* @param array $context Options available to the denormalizer
3636
*
@@ -44,7 +44,7 @@ interface DenormalizerInterface
4444
* @throws RuntimeException Occurs if the class cannot be instantiated
4545
* @throws ExceptionInterface Occurs for all the other cases of errors
4646
*/
47-
public function denormalize($data, $class, $format = null, array $context = []);
47+
public function denormalize($data, $type, $format = null, array $context = []);
4848

4949
/**
5050
* Checks whether the given class is supported for denormalization by this normalizer.

src/Symfony/Component/Serializer/Normalizer/JsonSerializableNormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function supportsDenormalization($data, $type, $format = null)
6060
/**
6161
* {@inheritdoc}
6262
*/
63-
public function denormalize($data, $class, $format = null, array $context = [])
63+
public function denormalize($data, $type, $format = null, array $context = [])
6464
{
6565
throw new LogicException(sprintf('Cannot denormalize with "%s".', \JsonSerializable::class));
6666
}

src/Symfony/Component/Serializer/Normalizer/ObjectToPopulateTrait.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ trait ObjectToPopulateTrait
1717
* Extract the `object_to_populate` field from the context if it exists
1818
* and is an instance of the provided $class.
1919
*
20-
* @param string $class The class the object should be
21-
* @param $context The denormalization context
22-
* @param string $key They in which to look for the object to populate.
23-
* Keeps backwards compatibility with `AbstractNormalizer`.
20+
* @param string $class The class the object should be
21+
* @param string|null $key They in which to look for the object to populate.
22+
* Keeps backwards compatibility with `AbstractNormalizer`.
2423
*
2524
* @return object|null an object if things check out, null otherwise
2625
*/

src/Symfony/Component/Serializer/Tests/Fixtures/AbstractNormalizerDummy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function supportsNormalization($data, $format = null)
4646
/**
4747
* {@inheritdoc}
4848
*/
49-
public function denormalize($data, $class, $format = null, array $context = [])
49+
public function denormalize($data, $type, $format = null, array $context = [])
5050
{
5151
}
5252

src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,13 +346,13 @@ class ArrayDenormalizerDummy implements DenormalizerInterface, SerializerAwareIn
346346
*
347347
* @throws NotNormalizableValueException
348348
*/
349-
public function denormalize($data, $class, $format = null, array $context = [])
349+
public function denormalize($data, $type, $format = null, array $context = [])
350350
{
351351
$serializer = $this->serializer;
352-
$class = substr($class, 0, -2);
352+
$type = substr($type, 0, -2);
353353

354354
foreach ($data as $key => $value) {
355-
$data[$key] = $serializer->denormalize($value, $class, $format, $context);
355+
$data[$key] = $serializer->denormalize($value, $type, $format, $context);
356356
}
357357

358358
return $data;

src/Symfony/Component/Serializer/Tests/Normalizer/TestDenormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class TestDenormalizer implements DenormalizerInterface
2323
/**
2424
* {@inheritdoc}
2525
*/
26-
public function denormalize($data, $class, $format = null, array $context = [])
26+
public function denormalize($data, $type, $format = null, array $context = [])
2727
{
2828
}
2929

src/Symfony/Component/VarDumper/Tests/Dumper/FunctionsTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function testDumpReturnsFirstArg()
2626

2727
ob_start();
2828
$return = dump($var1);
29-
$out = ob_get_clean();
29+
ob_end_clean();
3030

3131
$this->assertEquals($var1, $return);
3232
}
@@ -41,7 +41,7 @@ public function testDumpReturnsAllArgsInArray()
4141

4242
ob_start();
4343
$return = dump($var1, $var2, $var3);
44-
$out = ob_get_clean();
44+
ob_end_clean();
4545

4646
$this->assertEquals([$var1, $var2, $var3], $return);
4747
}

0 commit comments

Comments
 (0)