10000 Updates according to feedback and style changes · symfony/symfony@0fe9da5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0fe9da5

Browse files
committed
Updates according to feedback and style changes
1 parent bb09437 commit 0fe9da5

25 files changed

+151
-164
lines changed

src/Symfony/Component/Serializer/Annotation/Exclude.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
<?php
22

3-
namespace Symfony\Component\Serializer\Annotation;
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
411

5-
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
12+
namespace Symfony\Component\Serializer\Annotation;
613

714
/**
815
* @Annotation

src/Symfony/Component/Serializer/Annotation/ExclusionPolicy.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Symfony\Component\Serializer\Annotation;
413

514
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
@@ -23,11 +32,11 @@ final class ExclusionPolicy
2332
public function __construct(array $data)
2433
{
2534
if (!isset($data['value']) || !$data['value']) {
26-
throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" cannot be empty.', get_class($this)));
35+
throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" cannot be empty.', \get_class($this)));
2736
}
2837

29-
if (!is_string($data['value'])) {
30-
throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" must be a string.', get_class($this)));
38+
if (!\is_string($data['value'])) {
39+
throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" must be a string.', \get_class($this)));
3140
}
3241

3342
$this->policy = strtoupper($data['value']);

src/Symfony/Component/Serializer/Annotation/Expose.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
<?php
22

3-
namespace Symfony\Component\Serializer\Annotation;
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
411

5-
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
12+
namespace Symfony\Component\Serializer\Annotation;
613

714
/**
815
* @Annotation

src/Symfony/Component/Serializer/Annotation/Methods.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Symfony\Component\Serializer\Annotation;
413

514
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
@@ -25,23 +34,23 @@ final class Methods
2534
public function __construct(array $data)
2635
{
2736
if (empty($data)) {
28-
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)));
2938
}
3039

3140
foreach (array('accessor', 'mutator') as $parameter) {
3241
if (!isset($data[$parameter]) || !$data[$parameter]) {
3342
continue;
3443
}
3544

36-
if (!is_string($data[$parameter])) {
37-
throw new InvalidArgumentException(sprintf('Parameter "%s" of annotation "%s" must be a string.', $parameter, get_class($this)));
45+
if (!\is_string($data[$parameter])) {
46+
throw new InvalidArgumentException(sprintf('Parameter "%s" of annotation "%s" must be a string.', $parameter, \get_class($this)));
3847
}
3948

4049
$this->$parameter = $data[$parameter];
4150
}
4251

4352
if (null === $this->accessor && null === $this->mutator) {
44-
throw new InvalidArgumentException(sprintf('Either option "getter" or "setter" must be given for annotation %s', get_class($this)));
53+
throw new InvalidArgumentException(sprintf('Either option "getter" or "setter" must be given for annotation %s', \get_class($this)));
4554
}
4655
}
4756

src/Symfony/Component/Serializer/Annotation/ReadOnly.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Symfony\Component\Serializer\Annotation;
413

514
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
@@ -25,8 +34,8 @@ public function __construct(array $data = array())
2534
return;
2635
}
2736

28-
if (!is_bool($data['value'])) {
29-
throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" must be a boolean.', get_class($this)));
37+
if (!\is_bool($data['value'])) {
38+
throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" must be a boolean.', \get_class($this)));
3039
}
3140

3241
$this->readOnly = $data['value'];

src/Symfony/Component/Serializer/Annotation/SerializedName.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Symfony\Component\Serializer\Annotation;
413

514
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
@@ -20,11 +29,11 @@ final class SerializedName
2029
public function __construct(array $data)
2130
{
2231
if (!isset($data['value']) || !$data['value']) {
23-
throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" cannot be empty.', get_class($this)));
32+
throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" cannot be empty.', \get_class($this)));
2433
}
2534

26-
if (!is_string($data['value'])) {
27-
throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" must be a string.', get_class($this)));
35+
if (!\is_string($data['value'])) {
36+
throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" must be a string.', \get_class($this)));
2837
}
2938

3039
$this->name = $data['value'];

src/Symfony/Component/Serializer/Annotation/Type.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Symfony\Component\Serializer\Annotation;
413

514
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
@@ -20,19 +29,19 @@ final class Type
2029
public function __construct(array $data)
2130
{
2231
if (!isset($data['value']) || !$data['value']) {
23-
throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" cannot be empty.', get_class($this)));
32+
throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" cannot be empty.', \get_class($this)));
2433
}
2534

26-
if (!is_string($data['value'])) {
27-
throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" must be a string.', get_class($this)));
35+
if (!\is_string($data['value'])) {
36+
throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" must be a string.', \get_class($this)));
2837
}
2938

3039
$type = $data['value'];
3140

3241
if (false !== $pos = strpos($type, '\\')) {
3342
// This is a referencet to a class
34-
if ($pos !== 0) {
35-
throw new InvalidArgumentException(sprintf('When referring to an class you you must begin the type with backslash (\\) you provided "%s" for annotation "%s".', $type, get_class($this)));
43+
if (0 !== $pos) {
44+
throw new InvalidArgumentException(sprintf('When referring to an class you you must begin the type with backslash (\\) you provided "%s" for annotation "%s".', $type, \get_class($this)));
3645
}
3746
}
3847

src/Symfony/Component/Serializer/Mapping/AttributeMetadata.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class AttributeMetadata implements AttributeMetadataInterface
3030
*
3131
* @internal This property is public in order to reduce the size of the
3232
* class' serialized representation. Do not access it. Use
33-
* {@link getGroups()} instead.
33+
* {@link getMethodsAccessor()} instead.
3434
*/
3535
public $methodsAccessor;
3636

@@ -39,7 +39,7 @@ class AttributeMetadata implements AttributeMetadataInterface
3939
*
4040
* @internal This property is public in order to reduce the size of the
4141
* class' serialized representation. Do not access it. Use
42-
* {@link getGroups()} instead.
42+
* {@link getMethodsMutator()} instead.
4343
*/
4444
public $methodsMutator;
4545

@@ -48,7 +48,7 @@ class AttributeMetadata implements AttributeMetadataInterface
4848
*
4949
* @internal This property is public in order to reduce the size of the
5050
* class' serialized representation. Do not access it. Use
51-
* {@link getGroups()} instead.
51+
* {@link getExclude()} instead.
5252
*/
5353
public $exclude;
5454

@@ -57,7 +57,7 @@ class AttributeMetadata implements AttributeMetadataInterface
5757
*
5858
* @internal This property is public in order to reduce the size of the
5959
* class' serialized representation. Do not access it. Use
60-
* {@link getGroups()} instead.
60+
* {@link getExpose()} instead.
6161
*/
6262
public $expose;
6363

@@ -82,7 +82,7 @@ class AttributeMetadata implements AttributeMetadataInterface
8282
*
8383
* @internal This property is public in order to reduce the size of the
8484
* class' serialized representation. Do not access it. Use
85-
* {@link getGroups()} instead.
85+
* {@link getReadOnly()} instead.
8686
*/
8787
public $readOnly;
8888

@@ -91,7 +91,7 @@ class AttributeMetadata implements AttributeMetadataInterface
9191
*
9292
* @internal This property is public in order to reduce the size of the
9393
* class' serialized representation. Do not access it. Use
94-
* {@link getGroups()} instead.
94+
* {@link getSerializedName()} instead.
9595
*/
9696
public $serializedName;
9797

@@ -100,7 +100,7 @@ class AttributeMetadata implements AttributeMetadataInterface
100100
*
101101
* @internal This property is public in order to reduce the size of the
102102
* class' serialized representation. Do not access it. Use
103-
* {@link getGroups()} instead.
103+
* {@link getType()} instead.
104104
*/
105105
public $type;
106106

src/Symfony/Component/Serializer/Mapping/ClassMetadata.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class ClassMetadata implements ClassMetadataInterface
3030
*
3131
* @internal This property is public in order to reduce the size of the
3232
* class' serialized representation. Do not access it. Use
33-
* {@link getName()} instead.
33+
* {@link getExclusionPolicy()} instead.
3434
*/
3535
public $exclusionPolicy;
3636

@@ -39,7 +39,7 @@ class ClassMetadata implements ClassMetadataInterface
3939
*
4040
* @internal This property is public in order to reduce the size of the
4141
* class' serialized representation. Do not access it. Use
42-
* {@link getName()} instead.
42+
* {@link getReadOnly()} instead.
4343
*/
4444
public $readOnly;
4545

src/Symfony/Component/Serializer/Mapping/Loader/BetterAnnotationLoader.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ class BetterAnnotationLoader implements LoaderInterface
2929
*/
3030
private $reader;
3131

32-
/**
33-
* @param Reader $reader
34-
*/
3532
public function __construct(Reader $reader)
3633
{
3734
$this->reader = $reader;

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,11 +288,10 @@ protected function isAllowedAttribute($classOrObject, $attribute, $format = null
288288
* the denormalization process.
289289
*
290290
* @param object|array $data
291-
* @param string $class
292291
*
293292
* @return array
294293
*/
295-
protected function prepareForDenormalization($data, $class)
294+
protected function prepareForDenormalization($data)
296295
{
297296
return (array) $data;
298297
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,8 @@ private function validateAndDenormalize(string $currentClass, string $attribute,
340340
throw new LogicException(sprintf('Cannot denormalize attribute "%s" for class "%s" because injected serializer is not a denormalizer', $attribute, $class));
341341
}
342342

343-
if (!is_array($data) && !$data instanceof \Traversable) {
344-
throw new LogicException(sprintf('Cannot denormalize attribute "%s" for class "%s" because the value is "%s", expected array', $attribute, $class, gettype($data)));
343+
if (!\is_array($data) && !$data instanceof \Traversable) {
344+
throw new LogicException(sprintf('Cannot denormalize attribute "%s" for class "%s" because the value is "%s", expected array', $attribute, $class, \gettype($data)));
345345
}
346346

347347
$denormalizedData = array();
@@ -418,6 +418,7 @@ private function getTypes(string $currentClass, string $attribute)
418418
* Sets an attribute and apply the name converter if necessary.
419419
*
420420
* @param mixed $attributeValue
421+
*
421422
* @internal
422423
*/
423424
protected function updateData(array $data, string $attribute, $attributeValue): array

0 commit comments

Comments
 (0)
0