Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d10be79

Browse filesBrowse files
committed
cs
1 parent d9be208 commit d10be79
Copy full SHA for d10be79

File tree

1 file changed

+14
-19
lines changed
Filter options

1 file changed

+14
-19
lines changed

‎src/Symfony/Component/Serializer/Builder/NormalizerBuilder.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Builder/NormalizerBuilder.php
+14-19Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@
1313

1414
use PhpParser\Builder\Class_;
1515
use PhpParser\Builder\Namespace_;
16+
use PhpParser\BuilderFactory;
17+
use PhpParser\Node;
1618
use PhpParser\Node\Expr;
1719
use PhpParser\ParserFactory;
20+
use PhpParser\PrettyPrinter;
1821
use Symfony\Component\Serializer\Exception\DenormalizingUnionFailedException;
1922
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
2023
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
2124
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
2225
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
23-
use PhpParser\BuilderFactory;
24-
use PhpParser\PrettyPrinter;
25-
use PhpParser\Node;
2626

2727
/**
2828
* The main class to create a new Normalizer from a ClassDefinition.
@@ -42,7 +42,7 @@ public function __construct()
4242
throw new \LogicException(sprintf('You cannot use "%s" as the "nikic/php-parser" package is not installed. Try running "composer require nikic/php-parser".', static::class));
4343
}
4444

45-
$this->factory = new BuilderFactory;
45+
$this->factory = new BuilderFactory();
4646
$this->printer = new PrettyPrinter\Standard();
4747
}
4848

@@ -99,7 +99,6 @@ private function generateNormalizeChildMethod(Namespace_ $namespace, Class_ $cla
9999
)
100100
);
101101

102-
103102
// private function normalizeChild(mixed $object, ?string $format, array $context, bool $canBeIterable): mixed;
104103
$class->addStmt($this->factory->method('normalizeChild')
105104
->makePrivate()
@@ -151,7 +150,7 @@ private function generateNormalizeChildMethod(Namespace_ $namespace, Class_ $cla
151150
new Node\Arg(new Node\Expr\Variable('context')),
152151
new Node\Arg(new Node\Expr\ConstFetch(new Node\Name('true'))),
153152
]
154-
)
153+
),
155154
])
156155
),
157156
new Node\Arg(new Node\Expr\Variable('object')),
@@ -205,7 +204,6 @@ private function generateDenormalizeChildMethod(Namespace_ $namespace, Class_ $c
205204
)
206205
);
207206

208-
209207
// private function denormalizeChild(mixed $data, string $type, ?string $format, array $context, bool $canBeIterable): mixed;
210208
$class->addStmt($this->factory->method('denormalizeChild')
211209
->makePrivate()
@@ -259,7 +257,7 @@ private function generateDenormalizeChildMethod(Namespace_ $namespace, Class_ $c
259257
new Node\Arg(new Node\Expr\Variable('context')),
260258
new Node\Arg(new Node\Expr\ConstFetch(new Node\Name('true'))),
261259
]
262-
)
260+
),
263261
])
264262
),
265263
new Node\Arg(new Node\Expr\Variable('data')),
@@ -359,7 +357,7 @@ private function addDenormailizeMethod(ClassDefinition $definition, Namespace_ $
359357
[new Node\Arg(new Node\Expr\ClassConstFetch(new Node\Name($definition->getSourceClassName()), 'class'))]
360358
),
361359
'newInstanceWithoutConstructor'
362-
)));
360+
)));
363361
} else {
364362
$constructorArguments = [];
365363

@@ -369,10 +367,10 @@ private function addDenormailizeMethod(ClassDefinition $definition, Namespace_ $
369367
$canBeIterable = $propertyDefinition->isCollection();
370368

371369
$defaultValue = $propertyDefinition->getConstructorDefaultValue();
372-
if (is_object($defaultValue)) {
370+
if (\is_object($defaultValue)) {
373371
// public function __construct($foo = new \stdClass());
374372
// There is no support for parameters to the object.
375-
$defaultValue = new Expr\New_(new Node\Name\FullyQualified(get_class($defaultValue)));
373+
$defaultValue = new Expr\New_(new Node\Name\FullyQualified($defaultValue::class));
376374
} else {
377375
$defaultValue = $this->factory->val($defaultValue);
378376
}
@@ -427,7 +425,7 @@ private function addDenormailizeMethod(ClassDefinition $definition, Namespace_ $
427425
$defaultValue
428426
)),
429427
],
430-
'else' => new Node\Stmt\Else_($variableOutput)
428+
'else' => new Node\Stmt\Else_($variableOutput),
431429
]
432430
)];
433431
}
@@ -486,11 +484,9 @@ private function addDenormailizeMethod(ClassDefinition $definition, Namespace_ $
486484
),
487485
];
488486
}
489-
490-
491487
}
492488

493-
$result = $tempVariableName === null ? $variable : new Node\Expr\Variable($tempVariableName);
489+
$result = null === $tempVariableName ? $variable : new Node\Expr\Variable($tempVariableName);
494490
if (null !== $method = $propertyDefinition->getSetterName()) {
495491
$variableOutput[] = new Node\Stmt\Expression(new Node\Expr\MethodCall(
496492
new Node\Expr\Variable('output'),
@@ -567,7 +563,7 @@ private function addNormailizeMethod(ClassDefinition $definition, Namespace_ $na
567563
->addParam($this->factory->param('format')->setType('string')->setDefault(null))
568564
->addParam($this->factory->param('context')->setType('array')->setDefault([]))
569565
->setReturnType('array|string|int|float|bool|\ArrayObject|null')
570-
->setDocComment(sprintf('/**'.PHP_EOL.'* @param %s $object'.PHP_EOL.'*/', $definition->getSourceClassName()))
566+
->setDocComment(sprintf('/**'.\PHP_EOL.'* @param %s $object'.\PHP_EOL.'*/', $definition->getSourceClassName()))
571567
->addStmt(new Node\Stmt\Return_(new Node\Expr\Array_($bodyArrayItems))));
572568

573569
if ($needsChildNormalizer) {
@@ -644,7 +640,7 @@ private function generateCodeToDeserializeMultiplePossibleClasses(array $targetC
644640
new Node\Expr\ArrayDimFetch(new Node\Expr\Variable('exceptions')),
645641
new Node\Expr\Variable('e')
646642
)
647-
)
643+
),
648644
]
649645
),
650646
],
@@ -666,11 +662,10 @@ private function generateCodeToDeserializeMultiplePossibleClasses(array $targetC
666662
]
667663
)
668664
),
669-
)
665+
),
670666
],
671667
]
672668
),
673669
];
674-
675670
}
676671
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.