Initial Drupal 11 with DDEV setup
This commit is contained in:
		
							
								
								
									
										62
									
								
								vendor/symfony/serializer/Mapping/Factory/CacheClassMetadataFactory.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								vendor/symfony/serializer/Mapping/Factory/CacheClassMetadataFactory.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,62 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the Symfony package.
 | 
			
		||||
 *
 | 
			
		||||
 * (c) Fabien Potencier <fabien@symfony.com>
 | 
			
		||||
 *
 | 
			
		||||
 * For the full copyright and license information, please view the LICENSE
 | 
			
		||||
 * file that was distributed with this source code.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
namespace Symfony\Component\Serializer\Mapping\Factory;
 | 
			
		||||
 | 
			
		||||
use Psr\Cache\CacheItemPoolInterface;
 | 
			
		||||
use Symfony\Component\Serializer\Mapping\ClassMetadataInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Caches metadata using a PSR-6 implementation.
 | 
			
		||||
 *
 | 
			
		||||
 * @author Kévin Dunglas <dunglas@gmail.com>
 | 
			
		||||
 */
 | 
			
		||||
class CacheClassMetadataFactory implements ClassMetadataFactoryInterface
 | 
			
		||||
{
 | 
			
		||||
    use ClassResolverTrait;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @var array<string, ClassMetadataInterface>
 | 
			
		||||
     */
 | 
			
		||||
    private array $loadedClasses = [];
 | 
			
		||||
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        private readonly ClassMetadataFactoryInterface $decorated,
 | 
			
		||||
        private readonly CacheItemPoolInterface $cacheItemPool,
 | 
			
		||||
    ) {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getMetadataFor(string|object $value): ClassMetadataInterface
 | 
			
		||||
    {
 | 
			
		||||
        $class = $this->getClass($value);
 | 
			
		||||
 | 
			
		||||
        if (isset($this->loadedClasses[$class])) {
 | 
			
		||||
            return $this->loadedClasses[$class];
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $key = rawurlencode(strtr($class, '\\', '_'));
 | 
			
		||||
 | 
			
		||||
        $item = $this->cacheItemPool->getItem($key);
 | 
			
		||||
        if ($item->isHit()) {
 | 
			
		||||
            return $this->loadedClasses[$class] = $item->get();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $metadata = $this->decorated->getMetadataFor($value);
 | 
			
		||||
        $this->cacheItemPool->save($item->set($metadata));
 | 
			
		||||
 | 
			
		||||
        return $this->loadedClasses[$class] = $metadata;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function hasMetadataFor(mixed $value): bool
 | 
			
		||||
    {
 | 
			
		||||
        return $this->decorated->hasMetadataFor($value);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										67
									
								
								vendor/symfony/serializer/Mapping/Factory/ClassMetadataFactory.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										67
									
								
								vendor/symfony/serializer/Mapping/Factory/ClassMetadataFactory.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,67 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the Symfony package.
 | 
			
		||||
 *
 | 
			
		||||
 * (c) Fabien Potencier <fabien@symfony.com>
 | 
			
		||||
 *
 | 
			
		||||
 * For the full copyright and license information, please view the LICENSE
 | 
			
		||||
 * file that was distributed with this source code.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
namespace Symfony\Component\Serializer\Mapping\Factory;
 | 
			
		||||
 | 
			
		||||
use Symfony\Component\Serializer\Mapping\ClassMetadata;
 | 
			
		||||
use Symfony\Component\Serializer\Mapping\ClassMetadataInterface;
 | 
			
		||||
use Symfony\Component\Serializer\Mapping\Loader\LoaderInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Returns a {@link ClassMetadata}.
 | 
			
		||||
 *
 | 
			
		||||
 * @author Kévin Dunglas <dunglas@gmail.com>
 | 
			
		||||
 */
 | 
			
		||||
class ClassMetadataFactory implements ClassMetadataFactoryInterface
 | 
			
		||||
{
 | 
			
		||||
    use ClassResolverTrait;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @var array<string, ClassMetadataInterface>
 | 
			
		||||
     */
 | 
			
		||||
    private array $loadedClasses;
 | 
			
		||||
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        private readonly LoaderInterface $loader,
 | 
			
		||||
    ) {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getMetadataFor(string|object $value): ClassMetadataInterface
 | 
			
		||||
    {
 | 
			
		||||
        $class = $this->getClass($value);
 | 
			
		||||
 | 
			
		||||
        if (isset($this->loadedClasses[$class])) {
 | 
			
		||||
            return $this->loadedClasses[$class];
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $classMetadata = new ClassMetadata($class);
 | 
			
		||||
        $this->loader->loadClassMetadata($classMetadata);
 | 
			
		||||
 | 
			
		||||
        $reflectionClass = $classMetadata->getReflectionClass();
 | 
			
		||||
 | 
			
		||||
        // Include metadata from the parent class
 | 
			
		||||
        if ($parent = $reflectionClass->getParentClass()) {
 | 
			
		||||
            $classMetadata->merge($this->getMetadataFor($parent->name));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Include metadata from all implemented interfaces
 | 
			
		||||
        foreach ($reflectionClass->getInterfaces() as $interface) {
 | 
			
		||||
            $classMetadata->merge($this->getMetadataFor($interface->name));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $this->loadedClasses[$class] = $classMetadata;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function hasMetadataFor(mixed $value): bool
 | 
			
		||||
    {
 | 
			
		||||
        return \is_object($value) || (\is_string($value) && (class_exists($value) || interface_exists($value, false)));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										69
									
								
								vendor/symfony/serializer/Mapping/Factory/ClassMetadataFactoryCompiler.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										69
									
								
								vendor/symfony/serializer/Mapping/Factory/ClassMetadataFactoryCompiler.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,69 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the Symfony package.
 | 
			
		||||
 *
 | 
			
		||||
 * (c) Fabien Potencier <fabien@symfony.com>
 | 
			
		||||
 *
 | 
			
		||||
 * For the full copyright and license information, please view the LICENSE
 | 
			
		||||
 * file that was distributed with this source code.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
namespace Symfony\Component\Serializer\Mapping\Factory;
 | 
			
		||||
 | 
			
		||||
use Symfony\Component\Serializer\Mapping\ClassMetadataInterface;
 | 
			
		||||
use Symfony\Component\VarExporter\VarExporter;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Fabien Bourigault <bourigaultfabien@gmail.com>
 | 
			
		||||
 */
 | 
			
		||||
final class ClassMetadataFactoryCompiler
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @param ClassMetadataInterface[] $classMetadatas
 | 
			
		||||
     */
 | 
			
		||||
    public function compile(array $classMetadatas): string
 | 
			
		||||
    {
 | 
			
		||||
        return <<<EOF
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
// This file has been auto-generated by the Symfony Serializer Component.
 | 
			
		||||
 | 
			
		||||
return [{$this->generateDeclaredClassMetadata($classMetadatas)}
 | 
			
		||||
];
 | 
			
		||||
EOF;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param ClassMetadataInterface[] $classMetadatas
 | 
			
		||||
     */
 | 
			
		||||
    private function generateDeclaredClassMetadata(array $classMetadatas): string
 | 
			
		||||
    {
 | 
			
		||||
        $compiled = '';
 | 
			
		||||
 | 
			
		||||
        foreach ($classMetadatas as $classMetadata) {
 | 
			
		||||
            $attributesMetadata = [];
 | 
			
		||||
            foreach ($classMetadata->getAttributesMetadata() as $attributeMetadata) {
 | 
			
		||||
                $attributesMetadata[$attributeMetadata->getName()] = [
 | 
			
		||||
                    $attributeMetadata->getGroups(),
 | 
			
		||||
                    $attributeMetadata->getMaxDepth(),
 | 
			
		||||
                    $attributeMetadata->getSerializedName(),
 | 
			
		||||
                    $attributeMetadata->getSerializedPath(),
 | 
			
		||||
                ];
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            $classDiscriminatorMapping = $classMetadata->getClassDiscriminatorMapping() ? [
 | 
			
		||||
                $classMetadata->getClassDiscriminatorMapping()->getTypeProperty(),
 | 
			
		||||
                $classMetadata->getClassDiscriminatorMapping()->getTypesMapping(),
 | 
			
		||||
                $classMetadata->getClassDiscriminatorMapping()->getDefaultType(),
 | 
			
		||||
            ] : null;
 | 
			
		||||
 | 
			
		||||
            $compiled .= \sprintf("\n'%s' => %s,", $classMetadata->getName(), VarExporter::export([
 | 
			
		||||
                $attributesMetadata,
 | 
			
		||||
                $classDiscriminatorMapping,
 | 
			
		||||
            ]));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $compiled;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										45
									
								
								vendor/symfony/serializer/Mapping/Factory/ClassMetadataFactoryInterface.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								vendor/symfony/serializer/Mapping/Factory/ClassMetadataFactoryInterface.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,45 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the Symfony package.
 | 
			
		||||
 *
 | 
			
		||||
 * (c) Fabien Potencier <fabien@symfony.com>
 | 
			
		||||
 *
 | 
			
		||||
 * For the full copyright and license information, please view the LICENSE
 | 
			
		||||
 * file that was distributed with this source code.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
namespace Symfony\Component\Serializer\Mapping\Factory;
 | 
			
		||||
 | 
			
		||||
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
 | 
			
		||||
use Symfony\Component\Serializer\Mapping\ClassMetadataInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Returns a {@see ClassMetadataInterface}.
 | 
			
		||||
 *
 | 
			
		||||
 * @author Kévin Dunglas <dunglas@gmail.com>
 | 
			
		||||
 */
 | 
			
		||||
interface ClassMetadataFactoryInterface
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * If the method was called with the same class name (or an object of that
 | 
			
		||||
     * class) before, the same metadata instance is returned.
 | 
			
		||||
     *
 | 
			
		||||
     * If the factory was configured with a cache, this method will first look
 | 
			
		||||
     * for an existing metadata instance in the cache. If an existing instance
 | 
			
		||||
     * is found, it will be returned without further ado.
 | 
			
		||||
     *
 | 
			
		||||
     * Otherwise, a new metadata instance is created. If the factory was
 | 
			
		||||
     * configured with a loader, the metadata is passed to the
 | 
			
		||||
     * {@link \Symfony\Component\Serializer\Mapping\Loader\LoaderInterface::loadClassMetadata()} method for further
 | 
			
		||||
     * configuration. At last, the new object is returned.
 | 
			
		||||
     *
 | 
			
		||||
     * @throws InvalidArgumentException
 | 
			
		||||
     */
 | 
			
		||||
    public function getMetadataFor(string|object $value): ClassMetadataInterface;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Checks if class has metadata.
 | 
			
		||||
     */
 | 
			
		||||
    public function hasMetadataFor(mixed $value): bool;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										42
									
								
								vendor/symfony/serializer/Mapping/Factory/ClassResolverTrait.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								vendor/symfony/serializer/Mapping/Factory/ClassResolverTrait.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,42 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the Symfony package.
 | 
			
		||||
 *
 | 
			
		||||
 * (c) Fabien Potencier <fabien@symfony.com>
 | 
			
		||||
 *
 | 
			
		||||
 * For the full copyright and license information, please view the LICENSE
 | 
			
		||||
 * file that was distributed with this source code.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
namespace Symfony\Component\Serializer\Mapping\Factory;
 | 
			
		||||
 | 
			
		||||
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Resolves a class name.
 | 
			
		||||
 *
 | 
			
		||||
 * @internal
 | 
			
		||||
 *
 | 
			
		||||
 * @author Kévin Dunglas <dunglas@gmail.com>
 | 
			
		||||
 */
 | 
			
		||||
trait ClassResolverTrait
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * Gets a class name for a given class or instance.
 | 
			
		||||
     *
 | 
			
		||||
     * @throws InvalidArgumentException If the class does not exist
 | 
			
		||||
     */
 | 
			
		||||
    private function getClass(object|string $value): string
 | 
			
		||||
    {
 | 
			
		||||
        if (\is_string($value)) {
 | 
			
		||||
            if (!class_exists($value) && !interface_exists($value, false)) {
 | 
			
		||||
                throw new InvalidArgumentException(\sprintf('The class or interface "%s" does not exist.', $value));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return ltrim($value, '\\');
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $value::class;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										79
									
								
								vendor/symfony/serializer/Mapping/Factory/CompiledClassMetadataFactory.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										79
									
								
								vendor/symfony/serializer/Mapping/Factory/CompiledClassMetadataFactory.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,79 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the Symfony package.
 | 
			
		||||
 *
 | 
			
		||||
 * (c) Fabien Potencier <fabien@symfony.com>
 | 
			
		||||
 *
 | 
			
		||||
 * For the full copyright and license information, please view the LICENSE
 | 
			
		||||
 * file that was distributed with this source code.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
namespace Symfony\Component\Serializer\Mapping\Factory;
 | 
			
		||||
 | 
			
		||||
use Symfony\Component\Serializer\Mapping\AttributeMetadata;
 | 
			
		||||
use Symfony\Component\Serializer\Mapping\ClassDiscriminatorMapping;
 | 
			
		||||
use Symfony\Component\Serializer\Mapping\ClassMetadata;
 | 
			
		||||
use Symfony\Component\Serializer\Mapping\ClassMetadataInterface;
 | 
			
		||||
 | 
			
		||||
trigger_deprecation('symfony/serializer', '7.3', 'The "%s" class is deprecated.', CompiledClassMetadataFactory::class);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Fabien Bourigault <bourigaultfabien@gmail.com>
 | 
			
		||||
 *
 | 
			
		||||
 * @deprecated since Symfony 7.3
 | 
			
		||||
 */
 | 
			
		||||
final class CompiledClassMetadataFactory implements ClassMetadataFactoryInterface
 | 
			
		||||
{
 | 
			
		||||
    private array $compiledClassMetadata = [];
 | 
			
		||||
 | 
			
		||||
    private array $loadedClasses = [];
 | 
			
		||||
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        string $compiledClassMetadataFile,
 | 
			
		||||
        private readonly ClassMetadataFactoryInterface $classMetadataFactory,
 | 
			
		||||
    ) {
 | 
			
		||||
        if (!file_exists($compiledClassMetadataFile)) {
 | 
			
		||||
            throw new \RuntimeException("File \"{$compiledClassMetadataFile}\" could not be found.");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $compiledClassMetadata = require $compiledClassMetadataFile;
 | 
			
		||||
        if (!\is_array($compiledClassMetadata)) {
 | 
			
		||||
            throw new \RuntimeException(\sprintf('Compiled metadata must be of the type array, %s given.', \gettype($compiledClassMetadata)));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $this->compiledClassMetadata = $compiledClassMetadata;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getMetadataFor(string|object $value): ClassMetadataInterface
 | 
			
		||||
    {
 | 
			
		||||
        $className = \is_object($value) ? $value::class : $value;
 | 
			
		||||
 | 
			
		||||
        if (!isset($this->compiledClassMetadata[$className])) {
 | 
			
		||||
            return $this->classMetadataFactory->getMetadataFor($value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (!isset($this->loadedClasses[$className])) {
 | 
			
		||||
            $classMetadata = new ClassMetadata($className);
 | 
			
		||||
            foreach ($this->compiledClassMetadata[$className][0] as $name => $compiledAttributesMetadata) {
 | 
			
		||||
                $classMetadata->attributesMetadata[$name] = $attributeMetadata = new AttributeMetadata($name);
 | 
			
		||||
                [$attributeMetadata->groups, $attributeMetadata->maxDepth, $attributeMetadata->serializedName] = $compiledAttributesMetadata;
 | 
			
		||||
            }
 | 
			
		||||
            $classMetadata->classDiscriminatorMapping = $this->compiledClassMetadata[$className][1]
 | 
			
		||||
                ? new ClassDiscriminatorMapping(...$this->compiledClassMetadata[$className][1])
 | 
			
		||||
                : null
 | 
			
		||||
            ;
 | 
			
		||||
 | 
			
		||||
            $this->loadedClasses[$className] = $classMetadata;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $this->loadedClasses[$className];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function hasMetadataFor(mixed $value): bool
 | 
			
		||||
    {
 | 
			
		||||
        $className = \is_object($value) ? $value::class : $value;
 | 
			
		||||
 | 
			
		||||
        return isset($this->compiledClassMetadata[$className]) || $this->classMetadataFactory->hasMetadataFor($value);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user