Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / symfony / validator / Mapping / Factory / LazyLoadingMetadataFactory.php
index 82e1cf6bffd44794506cc7ec7e1712a80db89c79..9d5da256f5dd52ed1de04832eaaa6ae08669d02a 100644 (file)
@@ -14,8 +14,6 @@ namespace Symfony\Component\Validator\Mapping\Factory;
 use Symfony\Component\Validator\Exception\NoSuchMetadataException;
 use Symfony\Component\Validator\Mapping\Cache\CacheInterface;
 use Symfony\Component\Validator\Mapping\ClassMetadata;
-use Symfony\Component\Validator\Mapping\ClassMetadataInterface;
-use Symfony\Component\Validator\Mapping\Loader\LoaderChain;
 use Symfony\Component\Validator\Mapping\Loader\LoaderInterface;
 
 /**
@@ -40,18 +38,7 @@ use Symfony\Component\Validator\Mapping\Loader\LoaderInterface;
  */
 class LazyLoadingMetadataFactory implements MetadataFactoryInterface
 {
-    /**
-     * The loader for loading the class metadata.
-     *
-     * @var LoaderInterface|null
-     */
     protected $loader;
-
-    /**
-     * The cache for caching class metadata.
-     *
-     * @var CacheInterface|null
-     */
     protected $cache;
 
     /**
@@ -91,16 +78,20 @@ class LazyLoadingMetadataFactory implements MetadataFactoryInterface
      */
     public function getMetadataFor($value)
     {
-        if (!is_object($value) && !is_string($value)) {
-            throw new NoSuchMetadataException(sprintf('Cannot create metadata for non-objects. Got: %s', gettype($value)));
+        if (!\is_object($value) && !\is_string($value)) {
+            throw new NoSuchMetadataException(sprintf('Cannot create metadata for non-objects. Got: %s', \gettype($value)));
         }
 
-        $class = ltrim(is_object($value) ? get_class($value) : $value, '\\');
+        $class = ltrim(\is_object($value) ? \get_class($value) : $value, '\\');
 
         if (isset($this->loadedClasses[$class])) {
             return $this->loadedClasses[$class];
         }
 
+        if (!class_exists($class) && !interface_exists($class, false)) {
+            throw new NoSuchMetadataException(sprintf('The class or interface "%s" does not exist.', $class));
+        }
+
         if (null !== $this->cache && false !== ($metadata = $this->cache->read($class))) {
             // Include constraints from the parent class
             $this->mergeConstraints($metadata);
@@ -108,10 +99,6 @@ class LazyLoadingMetadataFactory implements MetadataFactoryInterface
             return $this->loadedClasses[$class] = $metadata;
         }
 
-        if (!class_exists($class) && !interface_exists($class)) {
-            throw new NoSuchMetadataException(sprintf('The class or interface "%s" does not exist.', $class));
-        }
-
         $metadata = new ClassMetadata($class);
 
         if (null !== $this->loader) {
@@ -167,16 +154,12 @@ class LazyLoadingMetadataFactory implements MetadataFactoryInterface
      */
     public function hasMetadataFor($value)
     {
-        if (!is_object($value) && !is_string($value)) {
+        if (!\is_object($value) && !\is_string($value)) {
             return false;
         }
 
-        $class = ltrim(is_object($value) ? get_class($value) : $value, '\\');
-
-        if (class_exists($class) || interface_exists($class)) {
-            return true;
-        }
+        $class = ltrim(\is_object($value) ? \get_class($value) : $value, '\\');
 
-        return false;
+        return class_exists($class) || interface_exists($class, false);
     }
 }