minor #17400 Use is_subclass_of instead of Reflection when possible (Ener-Getick)

This PR was merged into the 2.3 branch.

Discussion
----------

Use is_subclass_of instead of Reflection when possible

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT

For performance reason, I replaced a reflection instantiation by ``is_subclass_of``

Commits
-------

51e3652 Use is_subclass_of instead of Reflection when possible
This commit is contained in:
Fabien Potencier 2016-01-16 19:09:48 +01:00
commit 5c034adc5d

View File

@ -59,8 +59,6 @@ class CustomNormalizer extends SerializerAwareNormalizer implements NormalizerIn
*/
public function supportsDenormalization($data, $type, $format = null)
{
$class = new \ReflectionClass($type);
return $class->isSubclassOf('Symfony\Component\Serializer\Normalizer\DenormalizableInterface');
return is_subclass_of($type, 'Symfony\Component\Serializer\Normalizer\DenormalizableInterface');
}
}