X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=vendor%2Fsymfony%2Fvalidator%2FMapping%2FFactory%2FLazyLoadingMetadataFactory.php;h=9d5da256f5dd52ed1de04832eaaa6ae08669d02a;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hp=82e1cf6bffd44794506cc7ec7e1712a80db89c79;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/vendor/symfony/validator/Mapping/Factory/LazyLoadingMetadataFactory.php b/vendor/symfony/validator/Mapping/Factory/LazyLoadingMetadataFactory.php index 82e1cf6bf..9d5da256f 100644 --- a/vendor/symfony/validator/Mapping/Factory/LazyLoadingMetadataFactory.php +++ b/vendor/symfony/validator/Mapping/Factory/LazyLoadingMetadataFactory.php @@ -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); } }