Skip to content

Commit

Permalink
bug #36921 [OptionsResolver][Serializer] Remove calls to deprecated R…
Browse files Browse the repository at this point in the history
…eflectionParameter::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().
  • Loading branch information
nicolas-grekas committed May 23, 2020
2 parents ae49c3c + 1575d85 commit 1a21a75
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Symfony/Component/OptionsResolver/OptionsResolver.php
Expand Up @@ -201,7 +201,7 @@ public function setDefault($option, $value)
return $this;
}

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))) {
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()))) {
// Store closure for later evaluation
$this->nested[$option][] = $value;
$this->defaults[$option] = [];
Expand Down
Expand Up @@ -522,9 +522,7 @@ protected function instantiateObject(array &$data, $class, array &$context, \Ref
protected function denormalizeParameter(\ReflectionClass $class, \ReflectionParameter $parameter, $parameterName, $parameterData, array $context, $format = null)
{
try {
if (\PHP_VERSION_ID < 70100 && null !== $parameterClass = $parameter->getClass()) {
$parameterClass = $parameterClass->name;
} elseif (\PHP_VERSION_ID >= 70100 && $parameter->hasType() && ($parameterType = $parameter->getType()) && !$parameterType->isBuiltin()) {
if ($parameter->hasType() && ($parameterType = $parameter->getType()) && !$parameterType->isBuiltin()) {
$parameterClass = $parameterType->getName();
new \ReflectionClass($parameterClass); // throws a \ReflectionException if the class doesn't exist
} else {
Expand Down

0 comments on commit 1a21a75

Please sign in to comment.