diff vendor/symfony/serializer/Normalizer/ObjectNormalizer.php @ 14:1fec387a4317

Update Drupal core to 8.5.2 via Composer
author Chris Cannam
date Mon, 23 Apr 2018 09:46:53 +0100
parents 4c8ae668cc8c
children 129ea1e6d783
line wrap: on
line diff
--- a/vendor/symfony/serializer/Normalizer/ObjectNormalizer.php	Mon Apr 23 09:33:26 2018 +0100
+++ b/vendor/symfony/serializer/Normalizer/ObjectNormalizer.php	Mon Apr 23 09:46:53 2018 +0100
@@ -15,6 +15,7 @@
 use Symfony\Component\PropertyAccess\PropertyAccess;
 use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
 use Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface;
+use Symfony\Component\Serializer\Exception\RuntimeException;
 use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface;
 use Symfony\Component\Serializer\NameConverter\NameConverterInterface;
 
@@ -25,13 +26,14 @@
  */
 class ObjectNormalizer extends AbstractObjectNormalizer
 {
-    /**
-     * @var PropertyAccessorInterface
-     */
     protected $propertyAccessor;
 
     public function __construct(ClassMetadataFactoryInterface $classMetadataFactory = null, NameConverterInterface $nameConverter = null, PropertyAccessorInterface $propertyAccessor = null, PropertyTypeExtractorInterface $propertyTypeExtractor = null)
     {
+        if (!\class_exists(PropertyAccess::class)) {
+            throw new RuntimeException('The ObjectNormalizer class requires the "PropertyAccess" component. Install "symfony/property-access" to use it.');
+        }
+
         parent::__construct($classMetadataFactory, $nameConverter, $propertyTypeExtractor);
 
         $this->propertyAccessor = $propertyAccessor ?: PropertyAccess::createPropertyAccessor();
@@ -49,7 +51,7 @@
         $reflClass = new \ReflectionClass($object);
         foreach ($reflClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $reflMethod) {
             if (
-                $reflMethod->getNumberOfRequiredParameters() !== 0 ||
+                0 !== $reflMethod->getNumberOfRequiredParameters() ||
                 $reflMethod->isStatic() ||
                 $reflMethod->isConstructor() ||
                 $reflMethod->isDestructor()
@@ -67,7 +69,7 @@
                 if (!$reflClass->hasProperty($attributeName)) {
                     $attributeName = lcfirst($attributeName);
                 }
-            } elseif (strpos($name, 'is') === 0) {
+            } elseif (0 === strpos($name, 'is')) {
                 // issers
                 $attributeName = substr($name, 2);