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

Skip to content

Commit 1a21a75

Browse files
bug #36921 [OptionsResolver][Serializer] Remove calls to deprecated ReflectionParameter::getClass() (derrabus)
This PR was merged into the 4.4 branch. Discussion ---------- [OptionsResolver][Serializer] Remove calls to deprecated ReflectionParameter::getClass() | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | #36872 | License | MIT | Doc PR | N/A Following #36891, this PR removes the remaining calls to `ReflectionParameter::getClass()` from the 4.4 branch. Commits ------- 1575d85 Remove calls to deprecated ReflectionParameter::getClass().
2 parents ae49c3c + 1575d85 commit 1a21a75

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

src/Symfony/Component/OptionsResolver/OptionsResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ public function setDefault($option, $value)
201201
return $this;
202202
}
203203

204-
if (isset($params[0]) && null !== ($class = $params[0]->getClass()) && self::class === $class->name && (!isset($params[1]) || (null !== ($class = $params[1]->getClass()) && Options::class === $class->name))) {
204+
if (isset($params[0]) && null !== ($type = $params[0]->getType()) && self::class === $type->getName() && (!isset($params[1]) || (null !== ($type = $params[1]->getType()) && Options::class === $type->getName()))) {
205205
// Store closure for later evaluation
206206
$this->nested[$option][] = $value;
207207
$this->defaults[$option] = [];

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -522,9 +522,7 @@ protected function instantiateObject(array &$data, $class, array &$context, \Ref
522522
protected function denormalizeParameter(\ReflectionClass $class, \ReflectionParameter $parameter, $parameterName, $parameterData, array $context, $format = null)
523523
{
524524
try {
525-
if (\PHP_VERSION_ID < 70100 && null !== $parameterClass = $parameter->getClass()) {
526-
$parameterClass = $parameterClass->name;
527-
} elseif (\PHP_VERSION_ID >= 70100 && $parameter->hasType() && ($parameterType = $parameter->getType()) && !$parameterType->isBuiltin()) {
525+
if ($parameter->hasType() && ($parameterType = $parameter->getType()) && !$parameterType->isBuiltin()) {
528526
$parameterClass = $parameterType->getName();
529527
new \ReflectionClass($parameterClass); // throws a \ReflectionException if the class doesn't exist
530528
} else {

0 commit comments

Comments
 (0)