ge.
 *
 * (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\Config;

use Symfony\Component\Config\Exception\FileLocatorFileNotFoundException;

/**
 * FileLocator uses an array of pre-defined paths to find files.
 *
 * @author Fabien Potencier <fabien@symfony.com>
 */
class FileLocator implements FileLocatorInterface
{
    protected array $paths;

    /**

turn string|string[]
     *
     * @psalm-return ($first is true ? string : string[])
     */
    public function locate(string $name, ?string $currentPath = null, bool $first = true): string|array
    {
        if ('' === $name) {
            throw new \I

     * @param string|string[] $paths A path or an array of paths where to look for resources
     */
    public function __construct(string|array $paths = [])
    {
        $this->paths = (array) $paths;
    }

    /**
     * @re


buted with this source code.
 */

namespace Symfony\Component\DomCrawler\Tests;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DomCrawler\Link;

class LinkTest extends TestCase
{
    public function testConstructorWithANonATag()
    {
        $this->expectException(\LogicException::class);
        $dom = new \DOMDocument();
        $dom->loadHTML('

');

        new Link($dom->getElementsByTagName('div')->item(0), 'http://www.exampl

k($dom->getElementsByTagName('a')->item(0));
        $this->assertSame('https://example.com/foo', $link->getUri());
    }

    public function testAbsoluteBaseUriIsMandatoryWhenLinkUrlIsRelative()
    {
        $this->expectException(\InvalidArgumentExcept

e.com/');
    }

    public function testBaseUriIsOptionalWhenLinkUrlIsAbsolute()
    {
        $dom = new \DOMDocument();
        $dom->loadHTML('foo');

        $link = new Lin


/*
 * 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\DomCrawler\Test\Constraint;

use PHPUnit\Framework\Constraint\Constraint;
use Symfony\Component\DomCrawler\Crawler;

final class CrawlerSelectorCount extends Constraint
{
    public function __construct(
        private readonly int $count,
        pri

 */
    protected function matches($crawler): bool
    {
        return $this->count === \count($crawler->filter($this->selector));
    }

    /**
     * @param Crawler $crawler
     */
    protected function failureDescription($crawler): string
    {

vate readonly string $selector,
    ) {
    }

    public function toString(): string
    {
        return \sprintf('selector "%s" count is "%d"', $this->selector, $this->count);
    }

    /**
     * @param Crawler $crawler


 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\DomCrawler\Test\Constraint;

use PHPUnit\Framework\Constraint\Constraint;
use Symfony\Component\DomCrawler\Crawler;

final class CrawlerAnySelectorTextContains extends Constraint
{
    private bool $hasNode = false;

    public function __construct(
        private strin

 $this->selector, $this->expectedText);
        }

        return \sprintf('the Crawler has a node matching selector "%s"', $this->selector);
    }

    protected function matches($other): bool
    {
        if (!$other instanceof Crawler) {
            th

g $selector,
        private string $expectedText,
    ) {
    }

    public function toString(): string
    {
        if ($this->hasNode) {
            return \sprintf('the text of any node matching selector "%s" contains "%s"',


<?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\Config\Definition\Builder;

use Symfony\Component\Config\Definition\StringNode;

/**
 * This class provides a fluent interface for defining a node.
 *
 * @template TParent of NodeParentInterface|null = null
 *
 * @extends ScalarNodeDefinition<TPa

entInterface $parent = null)
    {
        parent::__construct($name, $parent);

        $this->nullEquivalent = '';
    }

    protected function instantiateNode(): StringNode
    {
        return new StringNode($this->name, $this->parent, $this->pathSepa

rent>
 *
 * @author Raffaele Carelle <raffaele.carelle@gmail.com>
 */
class StringNodeDefinition extends ScalarNodeDefinition
{
    /**
     * @param TParent $parent
     */
    public function __construct(?string $name, ?NodePar


buted with this source code.
 */

namespace Symfony\Component\Config\Tests\Resource;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Resource\DirectoryResource;

class DirectoryResourceTest extends TestCase
{
    protected string $directory;

    protected function setUp(): void
    {
        $this->directory = sys_get_temp_dir().\DIRECTORY_SEPARATOR.'symfonyDirectoryIterator';
        if (!file_exists($this->directory)) {
            mkdir($this->directory);
        }
        touch($this->dir

eDirectory(string $directory): void
    {
        $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($directory), \RecursiveIteratorIterator::CHILD_FIRST);
        foreach ($iterator as $path) {
            if (preg_match('#[/\\\\]\

ectory.'/tmp.xml');
    }

    protected function tearDown(): void
    {
        if (!is_dir($this->directory)) {
            return;
        }
        $this->removeDirectory($this->directory);
    }

    protected function remov


ge.
 *
 * (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\Config\Tests\Resource;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Resource\FileExistenceResource;

class FileExistenceResourceTest extends TestCase
{
    protected FileExistenceResource $resource;
    protected string $file;
    protected int $time;

    protected function setU

       if (file_exists($this->file)) {
            @unlink($this->file);
        }
    }

    public function testToString()
    {
        $this->assertSame('existence.'.$this->file, (string) $this->resource);
    }

    public function testGetResource()

p(): void
    {
        $this->file = realpath(sys_get_temp_dir()).'/tmp.xml';
        $this->time = time();
        $this->resource = new FileExistenceResource($this->file);
    }

    protected function tearDown(): void
    {


ge.
 *
 * (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\Config\Tests\Resource;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Resource\FileResource;

class FileResourceTest extends TestCase
{
    protected FileResource $resource;
    protected string $file;
    protected int $time;

    protected function setUp(): void
    {
        $th

  if (file_exists($this->file)) {
            @unlink($this->file);
        }
    }

    public function testGetResource()
    {
        $this->assertSame(realpath($this->file), $this->resource->getResource(), '->getResource() returns the path to the resou

is->file = sys_get_temp_dir().'/tmp.xml';
        $this->time = time();
        touch($this->file, $this->time);
        $this->resource = new FileResource($this->file);
    }

    protected function tearDown(): void
    {


buted with this source code.
 */

namespace Symfony\Component\Config\Tests\Resource;

use PHPUnit\Framework\Attributes\TestWith;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Resource\GlobResource;

class GlobResourceTest extends TestCase
{
    protected function tearDown(): void
    {
        $dir = \dirname(__DIR__).'/Fixtures';
        @rmdir($dir.'/TmpGlob');
        @unlink($dir.'/TmpGlob');
        @unlink($dir.'/Resource/TmpGlob');
        touch($dir.'/Resource/.hiddenFile');
    }

resource = new GlobResource($dir, $pattern, true);

        $paths = iterator_to_array($resource);

        $file = $dir.'/Resource'.\DIRECTORY_SEPARATOR.'ConditionalClass.php';
        $this->assertEquals([$file => new \SplFileInfo($file)], $paths);

  #[TestWith(['/Resource'])]
    #[TestWith(['/**/Resource'])]
    #[TestWith(['/**/Resource/'])]
    public function testIterator(string $pattern)
    {
        $dir = \dirname(__DIR__).\DIRECTORY_SEPARATOR.'Fixtures';
        $


flectionClassResource;
use Symfony\Component\Config\Tests\Fixtures\FakeVendor\Base;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Contracts\Service\ServiceSubscriberInterface;

class ReflectionClassResourceTest extends TestCase
{
    public function testToString()
    {
        $res = new ReflectionClassResource(new \ReflectionClass(\ErrorException::class));

        $this->assertSame('reflection.ErrorException', (string) $res);
    }

    public function testSerializeUnseriali

h(0));

        $this->assertSame((string) $res, (string) $ser);
    }

    public function testIsFresh()
    {
        $res = new ReflectionClassResource(new \ReflectionClass(__CLASS__));
        $mtime = filemtime(__FILE__);

        $this->assertTrue($r

ze()
    {
        $res = new ReflectionClassResource(new \ReflectionClass(DummyInterface::class));
        $ser = unserialize(serialize($res));

        $this->assertTrue($res->isFresh(0));
        $this->assertTrue($ser->isFres


ge.
 *
 * (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\Config\Tests\Loader;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Exception\LoaderLoadException;
use Symfony\Component\Config\Loader\DelegatingLoader;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\Config\Loader\LoaderResolver;

class DelegatingLoaderT

  }

    public function testGetSetResolver()
    {
        $resolver = new LoaderResolver();
        $loader = new DelegatingLoader($resolver);
        $this->assertSame($resolver, $loader->getResolver(), '->getResolver() gets the resolver loader');

est extends TestCase
{
    public function testConstructor()
    {
        new DelegatingLoader($resolver = new LoaderResolver());
        $this->assertTrue(true, '__construct() takes a loader resolver as its first argument');


buted with this source code.
 */

namespace Symfony\Component\Config\Tests\Loader;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Exception\FileLoaderImportCircularReferenceException;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Config\FileLocatorInterface;
use Symfony\Component\Config\Loader\FileLoader;
use Symfony\Component\Config\Loader\LoaderResolver;

class FileLoaderTest extends TestCase
{
    public function testImportWi

      ['path/to/file1'],
                ['path/to/file1', 'path/to/file2'],
                ['path/to/file1', 'path/to/file2'],
                ['path/to/file1'],
                ['path/to/file1', 'path/to/file2']
            );

        $fileLoader = new

thFileLocatorDelegation()
    {
        $locatorMockForAdditionalLoader = $this->createStub(FileLocatorInterface::class);
        $locatorMockForAdditionalLoader
            ->method('locate')
            ->willReturn(


 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\Config\Tests\Loader;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\Config\Loader\LoaderResolver;

class LoaderResolverTest extends TestCase
{
    public function testConstructor()
    {
        $resolver = new

 }

    public function testResolve()
    {
        $loader = $this->createStub(LoaderInterface::class);
        $resolver = new LoaderResolver([$loader]);
        $this->assertFalse($resolver->resolve('foo.foo'), '->resolve() returns false if no loader is

 LoaderResolver([
            $loader = $this->createStub(LoaderInterface::class),
        ]);

        $this->assertEquals([$loader], $resolver->getLoaders(), '__construct() takes an array of loaders as its first argument');


 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Config\Tests\Loader;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Exception\LoaderLoadException;
use Symfony\Component\Config\Exception\LogicException;
use Symfony\Component\Config\Loader\Loader;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\Config\Loader\LoaderResolver;
use Symfony\Component\Config\L

$resolver);

        $this->assertSame($resolver, $loader->getResolver(), '->setResolver() sets the resolver loader');
    }

    public function testGetResolverWithoutSetResolver()
    {
        $this->expectException(LogicException::class);

        $loa

oader\LoaderResolverInterface;

class LoaderTest extends TestCase
{
    public function testGetSetResolver()
    {
        $resolver = new LoaderResolver([]);

        $loader = new ProjectLoader1();
        $loader->setResolver(


n\ArrayNode;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
use Symfony\Component\Config\Definition\ScalarNode;

class ArrayNodeTest extends TestCase
{
    public function testNormalizeThrowsExceptionWhenFalseIsNotAllowed()
    {
        $node = new ArrayNode('root');

        $this->expectException(InvalidTypeException::class);

        $node->normalize(false);
    }

    public function testExceptionT

    $node->normalize(['foo' => 'bar']);
    }

    public function testNormalizeWithProposals()
    {
        $node = new ArrayNode('root');
        $node->addChild(new ArrayNode('alpha1'));
        $node->addChild(new ArrayNode('alpha2'));
        $node->

hrownOnUnrecognizedChild()
    {
        $node = new ArrayNode('root');

        $this->expectException(InvalidConfigurationException::class);
        $this->expectExceptionMessage('Unrecognized option "foo" under "root"');


n\ArrayNode;
use Symfony\Component\Config\Definition\ArrayShapeGenerator;
use Symfony\Component\Config\Definition\BooleanNode;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\EnumNode;
use Symfony\Component\Config\Definition\FloatNode;
use Symfony\Component\Config\Definition\IntegerNode;
use Symfony\Component\Config\Definition\NodeInterface;
use Symfony\Component\Config\Definition\PrototypedArrayNode;
use Symfony\Component\Config\Definition\Scalar

BackedTestEnum;

class ArrayShapeGeneratorTest extends TestCase
{
    #[DataProvider('provideNodes')]
    public function testPhpDocHandlesNodeTypes(NodeInterface $node, string $expected)
    {
        $arrayNode = new ArrayNode('root');
        $arrayNode

Node;
use Symfony\Component\Config\Definition\StringNode;
use Symfony\Component\Config\Definition\VariableNode;
use Symfony\Component\Config\Tests\Fixtures\IntegerBackedTestEnum;
use Symfony\Component\Config\Tests\Fixtures\String


ge.
 *
 * (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\Config\Tests\Definition;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Definition\BaseNode;
use Symfony\Component\Config\Definition\NodeInterface;

class BaseNodeTest extends TestCase
{
    #[DataProvider('providePath')]
    public fu

::class);
            $parent->method('getPath')->willReturn($params[1]);

            $constructorArgs[] = $parent;

            if (isset($params[2])) {
                $constructorArgs[] = $params[2];
            }
        }

        $node = new class(.

nction testGetPathForChildNode(string $expected, array $params)
    {
        $constructorArgs = [];
        $constructorArgs[] = $params[0];

        if (isset($params[1])) {
            $parent = $this->createStub(NodeInterface


ge.
 *
 * (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\Config\Tests\Definition;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Definition\BooleanNode;
use Symfony\Component\Config\Definition\Exception\InvalidTypeException;

class BooleanNodeTest extends TestCase
{
    #[DataProvider('getVa

      $node = new BooleanNode('test', null, '.', true);

        $this->assertNull($node->normalize(null));
    }

    public function testNullValueOnNotNullable()
    {
        $node = new BooleanNode('test', null, '.', false);

        $this->expectExcep

lidValues')]
    public function testNormalize(bool $value)
    {
        $node = new BooleanNode('test');
        $this->assertSame($value, $node->normalize($value));
    }

    public function testNullValueOnNullable()
    {


tion\Exception\InvalidConfigurationException;
use Symfony\Component\Config\Tests\Fixtures\IntegerBackedTestEnum;
use Symfony\Component\Config\Tests\Fixtures\StringBackedTestEnum;
use Symfony\Component\Config\Tests\Fixtures\StringBackedTestEnum2;
use Symfony\Component\Config\Tests\Fixtures\TestEnum;
use Symfony\Component\Config\Tests\Fixtures\TestEnum2;

class EnumNodeTest extends TestCase
{
    public function testFinalizeValue()
    {
        $node = new EnumNode('foo', null, ['foo', 'bar', TestEnum::Bar])

\InvalidArgumentException::class);
        $this->expectExceptionMessage('$values must contain at least one element.');
        new EnumNode('foo', null, []);
    }

    public function testConstructionWithBothValuesAndEnumFqcn()
    {
        $this->expec

;
        $this->assertSame('foo', $node->finalize('foo'));
        $this->assertSame(TestEnum::Bar, $node->finalize(TestEnum::Bar));
    }

    public function testConstructionWithNoValues()
    {
        $this->expectException(


ge.
 *
 * (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\Config\Tests\Definition;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\NodeInterface;
use Symfony\Component\Config\Definition\Processor;

class FinalizationTest extends TestCase
{
    public function testUnset

anBeUnset()
                        ->children()
                            ->node('level2', 'array')
                                ->canBeUnset()
                                ->children()
                                    ->node('somevalue', 'scal

KeyWithDeepHierarchy()
    {
        $tb = new TreeBuilder('config', 'array');
        $tree = $tb
            ->getRootNode()
                ->children()
                    ->node('level1', 'array')
                        ->c


ge.
 *
 * (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\Config\Tests\Definition;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
use Symfony\Component\Config\Definition\FloatNode;
use Symfony\Component\Config\Definition\NumericNode;

class FloatNode

  #[DataProvider('getValidValues')]
    public function testValidNonEmptyValues(int|float $value)
    {
        $node = new FloatNode('test');
        $node->setAllowEmptyValue(false);

        $this->assertSame($value, $node->finalize($value));
    }

Test extends TestCase
{
    #[DataProvider('getValidValues')]
    public function testNormalize(int|float $value)
    {
        $node = new FloatNode('test');
        $this->assertSame($value, $node->normalize($value));
    }


/*
 * 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\Config\Tests\Resource;

use Composer\Autoload\ClassLoader;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Resource\ComposerResource;

class ComposerResourceTest extends TestCase
{
    public function testGetVendor()
    {
        $res = n

               $found = true;
                break;
            }
        }

        $this->assertTrue($found);
    }

    public function testSerializeUnserialize()
    {
        $res = new ComposerResource();
        $ser = unserialize(serialize($res));

ew ComposerResource();

        $r = new \ReflectionClass(ClassLoader::class);
        $found = false;

        foreach ($res->getVendors() as $vendor) {
            if ($vendor && str_starts_with($r->getFileName(), $vendor)) {


 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\Config\Definition\Builder;

use Symfony\Component\Config\Definition\BooleanNode;
use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException;

/**
 * This class provides a fluent interface for defining a node.
 *
 * @template TParent of NodeParentInterfa

 function __construct(?string $name, ?NodeParentInterface $parent = null)
    {
        parent::__construct($name, $parent);

        $this->nullEquivalent = true;
    }

    protected function instantiateNode(): BooleanNode
    {
        return new Boolea

ce|null
 *
 * @extends ScalarNodeDefinition<TParent>
 *
 * @author Johannes M. Schmitt <schmittjoh@gmail.com>
 */
class BooleanNodeDefinition extends ScalarNodeDefinition
{
    /**
     * @param TParent $parent
     */
    public


buted with this source code.
 */

namespace Symfony\Component\Config\Definition\Builder;

use Symfony\Component\Config\Definition\Exception\UnsetKeyException;

/**
 * This class builds an if expression.
 *
 * @template T of NodeDefinition
 *
 * @author Johannes M. Schmitt <schmittjoh@gmail.com>
 * @author Christophe Coevoet <stof@notk.org>
 */
class ExprBuilder
{
    public const TYPE_ANY = 'any';
    public const TYPE_STRING = 'string';
    public const TYPE_NULL = 'null';
    public const TYPE_ARRAY = 'ar

t = null;

    /**
     * @param T $node
     */
    public function __construct(
        protected NodeDefinition $node,
    ) {
    }

    /**
     * Marks the expression as being always used.
     *
     * @return $this
     */
    public function alway

ray';
    public const TYPE_BOOL = 'bool';
    public const TYPE_INT = 'int';
    public const TYPE_BACKED_ENUM = 'backed-enum';

    public string $allowedTypes;
    public ?\Closure $ifPart = null;
    public ?\Closure $thenPar


 * 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\Config\Definition\Builder;

use Symfony\Component\Config\Definition\FloatNode;

/**
 * This class provides a fluent interface for defining a float node.
 *
 * @template TParent of NodeParentInterface|null = null
 *
 * @extends NumericNodeDefinition<TParent

r Jeanmonod David <david.jeanmonod@gmail.com>
 */
class FloatNodeDefinition extends NumericNodeDefinition
{
    protected function instantiateNode(): FloatNode
    {
        return new FloatNode($this->name, $this->parent, $this->min, $this->max, $this->pa


buted with this source code.
 */

namespace Symfony\Component\Config\Definition\Builder;

/**
 * This class provides a fluent interface for building a node.
 *
 * @template TParent of (NodeDefinition&ParentNodeDefinitionInterface)|null = null
 *
 * @author Johannes M. Schmitt <schmittjoh@gmail.com>
 */
class NodeBuilder implements NodeParentInterface
{
    /**
     * @var TParent
     */
    protected (NodeDefinition&ParentNodeDefinitionInterface)|null $parent = null;
    /**
     * @var array<string, class

efinitionConfigurator
        $this->nodeMapping = [
            'array' => ArrayNodeDefinition::class,
            'variable' => VariableNodeDefinition::class,
            'scalar' => ScalarNodeDefinition::class,
            'string' => StringNodeDefiniti

-string<NodeDefinition>>
     */
    protected array $nodeMapping;

    public function __construct()
    {
        // This list should be in sync with generics on method node() below and on TreeBuilder, ArrayNodeDefinition and D


nition\Exception\InvalidDefinitionException;
use Symfony\Component\Config\Definition\NodeInterface;

/**
 * This class provides a fluent interface for defining a node.
 *
 * @template-covariant TParent of NodeParentInterface|null = null
 *
 * @author Johannes M. Schmitt <schmittjoh@gmail.com>
 */
abstract class NodeDefinition implements NodeParentInterface
{
    protected ?string $name = null;
    /**
     * @var NormalizationBuilder<$this>
     */
    protected NormalizationBuilder $normalization;
    /**

ion = [];
    /**
     * @var MergeBuilder<$this>
     */
    protected MergeBuilder $merge;
    protected bool $allowEmptyValue = true;
    protected mixed $nullEquivalent = null;
    protected mixed $trueEquivalent = true;
    protected mixed $falseEquiv

     * @var ValidationBuilder<$this>
     */
    protected ValidationBuilder $validation;
    protected mixed $defaultValue;
    protected bool $default = false;
    protected bool $required = false;
    protected array $deprecat


/*
 * 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\Config\Definition\Builder;

/**
 * An interface that must be implemented by nodes which can have children.
 *
 * @author Victor Berchet <victor@suumit.com>
 */
interface ParentNodeDefinitionInterface extends BuilderAwareInterface
{
    /**
     * Retur

ode
     *         ->children()
     *             ->scalarNode('foo')->end()
     *             ->scalarNode('baz')->end()
     *             ->append($this->getBarNodeDefinition())
     *         ->end()
     *     ;
     *
     * @return $this
     */

ns a builder to add children nodes.
     *
     * @return NodeBuilder<static>
     */
    public function children(): NodeBuilder;

    /**
     * Appends a node definition.
     *
     * Usage:
     *
     *     $node = $parentN


 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\Config\Definition\Builder;

use Symfony\Component\Config\Definition\NodeInterface;

/**
 * This is the entry class for building a config tree.
 *
 * @template T of 'array'|'variable'|'scalar'|'string'|'boolean'|'integer'|'float'|'enum' = 'array'
 *
 * @author Johannes M.

    /**
     * @param T $type
     */
    public function __construct(string $name, string $type = 'array', ?NodeBuilder $builder = null)
    {
        $builder ??= new NodeBuilder();
        $this->root = $builder->node($name, $type)->setParent($this);

 Schmitt <schmittjoh@gmail.com>
 */
class TreeBuilder implements NodeParentInterface
{
    protected ?NodeInterface $tree = null;
    /**
     * @var NodeDefinition<$this>|null
     */
    protected ?NodeDefinition $root = null;


 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\Config\Definition\Builder;

use Symfony\Component\Config\Definition\NodeInterface;
use Symfony\Component\Config\Definition\VariableNode;

/**
 * This class provides a fluent interface for defining a node.
 *
 * @template TParent of NodeParentInterface|null = null
 *
 * @

riableNode($this->name, $this->parent, $this->pathSeparator);
    }

    protected function createNode(): NodeInterface
    {
        $node = $this->instantiateNode();

        if (isset($this->normalization)) {
            $node->setNormalizationClosures(

extends NodeDefinition<TParent>
 *
 * @author Johannes M. Schmitt <schmittjoh@gmail.com>
 */
class VariableNodeDefinition extends NodeDefinition
{
    protected function instantiateNode(): VariableNode
    {
        return new Va


/*
 * 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\Config\Definition\Exception;

/**
 * A very general exception which can be thrown whenever non of the more specific
 * exceptions is suitable.
 *
 * @author Johannes M. Schmitt <schmittjoh@gmail.com>
 */
class InvalidConfigurationException extends Exce

turn $this->path;
    }

    /**
     * Adds extra information that is suffixed to the original exception message.
     */
    public function addHint(string $hint): void
    {
        if (!$this->containsHints) {
            $this->message .= "\nHint: ".$

ption
{
    private ?string $path = null;
    private bool $containsHints = false;

    public function setPath(string $path): void
    {
        $this->path = $path;
    }

    public function getPath(): ?string
    {
        re


ponent\Config\Definition\BooleanNode;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\Config\Definition\EnumNode;
use Symfony\Component\Config\Definition\FloatNode;
use Symfony\Component\Config\Definition\IntegerNode;
use Symfony\Component\Config\Definition\NodeInterface;
use Symfony\Component\Config\Definition\PrototypedArrayNode;
use Symfony\Component\Config\Definition\ScalarNode;

/**
 * Dumps an XML reference configuration for the given configuration/node instance.

       return $this->dumpNode($configuration->getConfigTreeBuilder()->buildTree(), $namespace);
    }

    public function dumpNode(NodeInterface $node, ?string $namespace = null): string
    {
        $this->reference = '';
        $this->writeNode($node,

 *
 * @author Wouter J <waldio.webdesign@gmail.com>
 */
class XmlReferenceDumper
{
    private ?string $reference = null;

    public function dump(ConfigurationInterface $configuration, ?string $namespace = null): string
    {


 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Config\Tests;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\ConfigCache;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\Config\Resource\SelfCheckingResourceChecker;
use Symfony\Component\Config\Tests\Resource\ResourceStub;

class ConfigCacheTest extends Test

(), 'config_');
    }

    protected function tearDown(): void
    {
        $files = [$this->cacheFile, $this->cacheFile.'.meta', $this->metaFile];

        foreach ($files as $file) {
            if (file_exists($file)) {
                @unlink($file);

Case
{
    private string $cacheFile;
    private string $metaFile;

    protected function setUp(): void
    {
        $this->cacheFile = tempnam(sys_get_temp_dir(), 'config_');
        $this->metaFile = tempnam(sys_get_temp_dir


buted with this source code.
 */

namespace Symfony\Component\Config\Tests;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\Config\ResourceCheckerConfigCache;
use Symfony\Component\Config\ResourceCheckerInterface;
use Symfony\Component\Config\Tests\Fixtures\ResourceWithVeryVeryVeryVeryVeryVeryVeryVeryLongName;
use Symfony\Component\Config\Tests\Resource\ResourceStub;

class ResourceCheckerConfigCacheTest extends TestCase
{
    private string $cacheF

ted function tearDown(): void
    {
        $files = [$this->cacheFile, $this->cacheFile.'.meta', $this->cacheFile.'.meta.json', $this->metaFile, $this->metaFile.'.json'];

        foreach ($files as $file) {
            if (file_exists($file)) {

ile;
    private string $metaFile;

    protected function setUp(): void
    {
        $this->cacheFile = tempnam(sys_get_temp_dir(), 'config_');
        $this->metaFile = tempnam(sys_get_temp_dir(), 'config_');
    }

    protec


buted with this source code.
 */

namespace Symfony\Component\Config\Tests\Util;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Util\Exception\InvalidXmlException;
use Symfony\Component\Config\Util\XmlUtils;

class XmlUtilsTest extends TestCase
{
    public function testLoadFile()
    {
        $fixtures = __DIR__.'/../Fixtures/Util/';

        try {
            XmlUtils::loadFile($fixtures);
            $this->fail();
        } catch (\InvalidAr

atch (\InvalidArgumentException $e) {
            $this->assertStringContainsString('is not a file', $e->getMessage());
        }

        try {
            if ('\\' === \DIRECTORY_SEPARATOR) {
                $this->markTestSkipped('chmod is not supported

gumentException $e) {
            $this->assertStringContainsString('is not a file', $e->getMessage());
        }

        try {
            XmlUtils::loadFile($fixtures.'non_existing.xml');
            $this->fail();
        } c


s\Fixtures\Configuration;

use Symfony\Component\Config\Definition\NodeInterface;

class CustomNode implements NodeInterface
{
    public function getName(): string
    {
        return 'custom_node';
    }

    public function getPath(): string
    {
        return 'custom';
    }

    public function isRequired(): bool
    {
        return false;
    }

    public function hasDefaultValue(): bool
    {
        return true;
    }

    public function getDefaultValue(): mixed
    {
        return true;

d
    {
        return $value;
    }

    public function merge(mixed $leftSide, mixed $rightSide): mixed
    {
        return array_merge($leftSide, $rightSide);
    }

    public function finalize(mixed $value): mixed
    {
        return $value;
    }
}

}

    public function normalize(mixed $value): mixe


 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Config\Tests\Resource;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Resource\ClassExistenceResource;
use Symfony\Component\Config\Tests\Fixtures\BadFileName;
use Symfony\Component\Config\Tests\Fixtures\BadParent;
use Symfony\Component\Config\Tests\Fixtures\ParseError;
use Symfony\Component\Config\Tests\Fixtures\Resource\Condition

 function testGetResource()
    {
        $res = new ClassExistenceResource('BarClass');
        $this->assertSame('BarClass', $res->getResource());
    }

    public function testIsFreshWhenClassDoesNotExist()
    {
        $res = new ClassExistenceResour

alClass;

class ClassExistenceResourceTest extends TestCase
{
    public function testToString()
    {
        $res = new ClassExistenceResource('BarClass');
        $this->assertSame('BarClass', (string) $res);
    }

    public


on implements ParentNodeDefinitionInterface
{
    protected bool $performDeepMerging = true;
    protected bool $ignoreExtraKeys = false;
    protected bool $removeExtraKeys = true;
    /**
     * @var NodeDefinition<$this>[]
     */
    protected array $children = [];
    /**
     * @var NodeDefinition<$this>
     */
    protected NodeDefinition $prototype;
    protected bool $atLeastOne = false;
    protected bool $allowNewKeys = true;
    protected ?string $key = null;
    protected bool $removeKeyItem =

ormalizeKeys = true;

    /**
     * @var list<ExprBuilder::TYPE_*>|null
     */
    protected ?array $allowedTypes = null;

    /**
     * @param TParent $parent
     */
    public function __construct(?string $name, ?NodeParentInterface $parent = null)

 false;
    protected bool $addDefaults = false;
    protected int|string|array|false|null $addDefaultChildren = false;
    /**
     * @var NodeBuilder<static>
     */
    protected NodeBuilder $nodeBuilder;
    protected bool $n


 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\Config\Definition\Builder;

/**
 * This class builds merge conditions.
 *
 * @template T of NodeDefinition
 *
 * @author Johannes M. Schmitt <schmittjoh@gmail.com>
 */
class MergeBuilder
{
    public bool $allowFalse = false;
    public bool $allowOverwrite

lic function allowUnset(bool $allow = true): static
    {
        $this->allowFalse = $allow;

        return $this;
    }

    /**
     * Sets whether the node can be overwritten.
     *
     * @return $this
     */
    public function denyOverwrite(bool

= true;

    /**
     * @param T $node
     */
    public function __construct(
        protected NodeDefinition $node,
    ) {
    }

    /**
     * Sets whether the node can be unset.
     *
     * @return $this
     */
    pub


ge.
 *
 * (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\Config\Definition\Builder;

use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException;

/**
 * Abstract class that contains common code of integer and float node definitions.
 *
 * @template TParent of NodeParentInterface|null = null
 *
 * @extends ScalarNodeDefinition<TParent>

* Ensures that the value is smaller than the given reference.
     *
     * @return $this
     *
     * @throws \InvalidArgumentException when the constraint is inconsistent
     */
    public function max(int|float $max): static
    {
        if (isset($t

 *
 * @author David Jeanmonod <david.jeanmonod@gmail.com>
 */
abstract class NumericNodeDefinition extends ScalarNodeDefinition
{
    protected int|float|null $min = null;
    protected int|float|null $max = null;

    /**


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\Config\Definition\Builder;

use Symfony\Component\Config\Definition\ScalarNode;

/**
 * This class provides a fluent interface for defining a node.
 *
 * @template TParent of NodeParentInterface|null = null
 *
 * @extends VariableNodeDefinition<TPa

uthor Johannes M. Schmitt <schmittjoh@gmail.com>
 */
class ScalarNodeDefinition extends VariableNodeDefinition
{
    protected function instantiateNode(): ScalarNode
    {
        return new ScalarNode($this->name, $this->parent, $this->pathSeparator);


ge.
 *
 * (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\Config\Definition\Configurator;

use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\BooleanNodeDefinition;
use Symfony\Component\Config\Definition\Builder\EnumNodeDefinition;
use Symfony\Component\Config\Definition\Builder\FloatNod

eDefinition;
use Symfony\Component\Config\Definition\Builder\IntegerNodeDefinition;
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
use Symfony\Component\Config\Definition\Builder\ScalarNodeDefinition;
use Symfony


 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Config\Definition\Loader;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\Configurator\DefinitionConfigurator;
use Symfony\Component\Config\FileLocatorInterface;
use Symfony\Component\Config\Loader\FileLoader;
use Symfony\Component\DependencyInjection\ContainerBuilder;

/**
 * DefinitionFileLo

e TreeBuilder $treeBuilder,
        FileLocatorInterface $locator,
        private ?ContainerBuilder $container = null,
    ) {
        parent::__construct($locator);
    }

    public function load(mixed $resource, ?string $type = null): mixed
    {

ader loads config definitions from a PHP file.
 *
 * The PHP file is required.
 *
 * @author Yonel Ceruto <yonelceruto@gmail.com>
 */
class DefinitionFileLoader extends FileLoader
{
    public function __construct(
        privat


 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Config\Tests\Exception;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Exception\LoaderLoadException;

class LoaderLoadExceptionTest extends TestCase
{
    public function testMessageCannotLoadResource()
    {
        $exception = new LoaderLoadException('resource', null);
        $this->assertEquals('Cannot load resource "resource

resource "resource". Make sure there is a loader supporting the "foobar" type.', $exception->getMessage());
    }

    public function testMessageCannotLoadResourceWithAnnotationType()
    {
        $exception = new LoaderLoadException('resource', null, 0,

".', $exception->getMessage());
    }

    public function testMessageCannotLoadResourceWithType()
    {
        $exception = new LoaderLoadException('resource', null, 0, null, 'foobar');
        $this->assertEquals('Cannot load


 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Config\Tests\Fixtures\Configuration;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\Config\Tests\Fixtures\StringBackedTestEnum;
use Symfony\Component\Config\Tests\Fixtures\TestEnum;

class ExampleConfiguration implements ConfigurationInterface
{

')
            ->fixXmlConfig('cms_page')
            ->children()
                ->booleanNode('boolean')->defaultTrue()->end()
                ->scalarNode('scalar_empty')->end()
                ->scalarNode('scalar_null')->defaultNull()->end()

   public function getConfigTreeBuilder(): TreeBuilder
    {
        $treeBuilder = new TreeBuilder('acme_root');

        $treeBuilder->getRootNode()
            ->fixXmlConfig('parameter')
            ->fixXmlConfig('connection


 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\Config\Definition\Builder;

use Symfony\Component\Config\Definition\EnumNode;

/**
 * Enum Node Definition.
 *
 * @template TParent of NodeParentInterface|null
 *
 * @extends ScalarNodeDefinition<TParent>
 *
 * @author Johannes M. Schmitt <schmittjoh@gmail.com>
 */
class

         throw new \InvalidArgumentException('->values() must be called with at least one value.');
        }

        $this->values = $values;

        return $this;
    }

    /**
     * @param class-string<\UnitEnum> $enumFqcn
     *
     * @return $thi

 EnumNodeDefinition extends ScalarNodeDefinition
{
    private array $values;
    private string $enumFqcn;

    /**
     * @return $this
     */
    public function values(array $values): static
    {
        if (!$values) {


hp

/*
 * 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\Config\Definition\Builder;

/**
 * This class builds validation conditions.
 *
 * @template T of NodeDefinition
 *
 * @author Christophe Coevoet <stof@notk.org>
 */
class ValidationBuilder
{
    /**
     * @var (ExprBuilder<T>|\Closure)[]
     */

n builder to build it if null is provided.
     *
     * @return ($closure is \Closure ? $this : ExprBuilder<T>)
     */
    public function rule(?\Closure $closure = null): ExprBuilder|static
    {
        if ($closure) {
            $this->rules[] = $clo

  public array $rules = [];

    /**
     * @param T $node
     */
    public function __construct(
        protected NodeDefinition $node,
    ) {
    }

    /**
     * Registers a closure to run as normalization or an expressio


 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Config\Tests;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Exception\FileLocatorFileNotFoundException;
use Symfony\Component\Config\FileLocator;

class FileLocatorTest extends TestCase
{
    #[DataProvider('getIsAbsolutePathTests')]
    public function testIsAbsolutePath(string $path

 an absolute path');
    }

    public static function getIsAbsolutePathTests(): array
    {
        return [
            ['/foo.xml'],
            ['c:\\\\foo.xml'],
            ['c:/foo.xml'],
            ['\\server\\foo.xml'],
            ['https://serv

)
    {
        $loader = new FileLocator([]);
        $r = new \ReflectionObject($loader);
        $m = $r->getMethod('isAbsolutePath');

        $this->assertTrue($m->invoke($loader, $path), '->isAbsolutePath() returns true for


/*
 * 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\Config\Definition\Builder;

use Symfony\Component\Config\Definition\IntegerNode;

/**
 * This class provides a fluent interface for defining an integer node.
 *
 * @template TParent of NodeParentInterface|null = null
 *
 * @extends NumericNodeDefiniti

nmonod@gmail.com>
 */
class IntegerNodeDefinition extends NumericNodeDefinition
{
    protected function instantiateNode(): IntegerNode
    {
        return new IntegerNode($this->name, $this->parent, $this->min, $this->max, $this->pathSeparator);
    }
}

on<TParent>
 *
 * @author Jeanmonod David <david.jea


 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\Config\Definition\Builder;

/**
 * This class builds normalization conditions.
 *
 * @template T of NodeDefinition
 *
 * @author Johannes M. Schmitt <schmittjoh@gmail.com>
 */
class NormalizationBuilder
{
    /**
     * @var (ExprBuilder<T>|\Closure)[]
     */
    public

     * Registers a key to remap to its plural form.
     *
     * @param string      $key    The key to remap
     * @param string|null $plural The plural of the key in case of irregular plural
     *
     * @return $this
     */
    public function remap(

 array $before = [];
    public array $declaredTypes = [];
    public array $remappings = [];

    /**
     * @param T $node
     */
    public function __construct(
        protected NodeDefinition $node,
    ) {
    }

    /**


ackage.
 *
 * (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\Config\Tests\Fixtures\Builder;

use Symfony\Component\Config\Definition\Builder\NodeBuilder as BaseNodeBuilder;
use Symfony\Component\Config\Definition\Builder\NodeDefinition;

class NodeBuilder extends BaseNodeBuilder
{
    public function barNode(?string $name): NodeDefinition
    {

ted function getNodeClass(string $type): string
    {
        return match ($type) {
            'bar',
            'variable' => __NAMESPACE__ . '\\' . ucfirst($type) . 'NodeDefinition',
            default => parent::getNodeClass($type),
        };
    }

 return $this->node($name, 'bar');
    }

    protec


buted with this source code.
 */

namespace Symfony\Component\Config\Definition\Dumper;

use Symfony\Component\Config\Definition\ArrayNode;
use Symfony\Component\Config\Definition\BaseNode;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\Config\Definition\EnumNode;
use Symfony\Component\Config\Definition\NodeInterface;
use Symfony\Component\Config\Definition\PrototypedArrayNode;
use Symfony\Component\Config\Definition\ScalarNode;
use Symfony\Component\Yaml\Inline;

/**

nfigurationInterface $configuration): string
    {
        return $this->dumpNode($configuration->getConfigTreeBuilder()->buildTree());
    }

    public function dumpAtPath(ConfigurationInterface $configuration, string $path): string
    {
        $rootNo

 * Dumps a Yaml reference configuration for the given configuration/node instance.
 *
 * @author Kevin Bond <kevinbond@gmail.com>
 */
class YamlReferenceDumper
{
    private ?string $reference = null;

    public function dump(Co


buted with this source code.
 */

namespace Symfony\Component\Config\Tests\Definition;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
use Symfony\Component\Config\Definition\NodeInterface;

class NormalizationTest extends TestCase
{
    #[DataProvider('getEncoderTests')]
    public function testNormalizeEncoders($denormalized)
    {

             ->useAttributeAsKey('class')
                        ->prototype('array')
                            ->beforeNormalization()->ifString()->then(static fn ($v) => ['algorithm' => $v])->end()
                            ->children()

      $tb = new TreeBuilder('root_name', 'array');
        $tree = $tb
            ->getRootNode()
                ->fixXmlConfig('encoder')
                ->children()
                    ->node('encoders', 'array')


n\ArrayNode;
use Symfony\Component\Config\Definition\PrototypedArrayNode;
use Symfony\Component\Config\Definition\ScalarNode;
use Symfony\Component\Config\Definition\VariableNode;

class PrototypedArrayNodeTest extends TestCase
{
    public function testGetDefaultValueReturnsAnEmptyArrayForPrototypes()
    {
        $node = new PrototypedArrayNode('root');
        $prototype = new ArrayNode(null, $node);
        $node->setPrototype($prototype);
        $this->assertSame([], $node->getDefaultValue());
    }

node->setDefaultValue(['test']);
        $this->assertEquals(['test'], $node->getDefaultValue());
    }

    // a remapped key (e.g. "mapping" -> "mappings") should be unset after being used
    public function testRemappedKeysAreUnset()
    {
        $nod

    public function testGetDefaultValueReturnsDefaultValueForPrototypes()
    {
        $node = new PrototypedArrayNode('root');
        $prototype = new ArrayNode(null, $node);
        $node->setPrototype($prototype);
        $


ge.
 *
 * (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\BrowserKit\Tests;

use Symfony\Component\BrowserKit\CookieJar;
use Symfony\Component\BrowserKit\History;
use Symfony\Component\BrowserKit\HttpBrowser;
use Symfony\Component\BrowserKit\Response;
use Symfony\Component\HttpClient\MockHttpClient;
use Symfony\Component\HttpClient\Response\MockResponse

null)
    {
        $client = new MockHttpClient(function (string $method, string $url, array $options) {
            if (null === $this->nextResponse) {
                return new MockResponse();
            }

            return new MockResponse($this->n

;

class TestHttpClient extends HttpBrowser
{
    protected ?Response $nextResponse = null;
    protected string $nextScript;

    public function __construct(array $server = [], ?History $history = null, ?CookieJar $cookieJar =


 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\BrowserKit\Tests\Test\Constraint;

use PHPUnit\Framework\ExpectationFailedException;
use PHPUnit\Framework\TestCase;
use Symfony\Component\BrowserKit\AbstractBrowser;
use Symfony\Component\BrowserKit\Cookie;
use Symfony\Component\BrowserKit\CookieJar;
use Symfony\Compone

ValueSame('foo', 'bar', false, '/path');
        $this->assertTrue($constraint->evaluate($browser, '', true));
        $constraint = new BrowserCookieValueSame('foo', 'bar', true, '/path');
        $this->assertTrue($constraint->evaluate($browser, '', true

nt\BrowserKit\Test\Constraint\BrowserCookieValueSame;

class BrowserCookieValueSameTest extends TestCase
{
    public function testConstraint()
    {
        $browser = $this->getBrowser();
        $constraint = new BrowserCookie


ge.
 *
 * (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\BrowserKit\Tests\Test\Constraint;

use PHPUnit\Framework\ExpectationFailedException;
use PHPUnit\Framework\TestCase;
use Symfony\Component\BrowserKit\AbstractBrowser;
use Symfony\Component\BrowserKit\Cookie;
use Symfony\Component\BrowserKit\CookieJar;
use Symfony\Component\BrowserKit\Test\Constra

sertTrue($constraint->evaluate($browser, '', true));
        $constraint = new BrowserHasCookie('foo', '/path', 'example.com');
        $this->assertTrue($constraint->evaluate($browser, '', true));
        $constraint = new BrowserHasCookie('bar');

int\BrowserHasCookie;

class BrowserHasCookieTest extends TestCase
{
    public function testConstraint()
    {
        $browser = $this->getBrowser();
        $constraint = new BrowserHasCookie('foo', '/path');
        $this->as


 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\BrowserKit\Test\Constraint;

use PHPUnit\Framework\Constraint\Constraint;
use Symfony\Component\BrowserKit\AbstractBrowser;

final class BrowserCookieValueSame extends Constraint
{
    public function __construct(
        private string $name,
        private string $val

);
        if ('/' !== $this->path) {
            $str .= \sprintf(' with path "%s"', $this->path);
        }
        if ($this->domain) {
            $str .= \sprintf(' for domain "%s"', $this->domain);
        }
        $str .= \sprintf(' with %svalue "%

ue,
        private bool $raw = false,
        private string $path = '/',
        private ?string $domain = null,
    ) {
    }

    public function toString(): string
    {
        $str = \sprintf('has cookie "%s"', $this->name


 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\BrowserKit\Test\Constraint;

use PHPUnit\Framework\Constraint\Constraint;
use Symfony\Component\BrowserKit\AbstractBrowser;

final class BrowserHasCookie extends Constraint
{
    public function __construct(
        private string $name,
        private stri

sprintf(' with path "%s"', $this->path);
        }
        if ($this->domain) {
            $str .= \sprintf(' for domain "%s"', $this->domain);
        }

        return $str;
    }

    /**
     * @param AbstractBrowser $browser
     */
    protected fun

ng $path = '/',
        private ?string $domain = null,
    ) {
    }

    public function toString(): string
    {
        $str = \sprintf('has cookie "%s"', $this->name);
        if ('/' !== $this->path) {
            $str .= \


ony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\BrowserKit\Test\Constraint;

use PHPUnit\Framework\Constraint\Constraint;
use Symfony\Component\BrowserKit\AbstractBrowser;

final class BrowserHistoryIsOnFirstPage extends Constraint
{
    public function toString(): string
    {
        return 'is on the first page';
    }

    protected function matches($other): bool
    {
        if (

row new \LogicException('Can only test on an AbstractBrowser instance.');
        }

        return $other->getHistory()->isFirstPage();
    }

    protected function failureDescription($other): string
    {
        return 'the Browser history '.$this->toS

!$other instanceof AbstractBrowser) {
            th


ony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\BrowserKit\Test\Constraint;

use PHPUnit\Framework\Constraint\Constraint;
use Symfony\Component\BrowserKit\AbstractBrowser;

final class BrowserHistoryIsOnLastPage extends Constraint
{
    public function toString(): string
    {
        return 'is on the last page';
    }

    protected function matches($other): bool
    {
        if (!$

w new \LogicException('Can only test on an AbstractBrowser instance.');
        }

        return $other->getHistory()->isLastPage();
    }

    protected function failureDescription($other): string
    {
        return 'the Browser history '.$this->toStri

other instanceof AbstractBrowser) {
            thro


/*
 * 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\JsonPath;

/**
 * Declares the return type of a custom JsonPath function as defined in RFC 9535.
 *
 * @see https://datatracker.ietf.org/doc/html/rfc9535#name-type-system-for-function-ex
 */
enum FunctionReturnType: string
{
    /**
     * A JSON valu

Value = 'value';

    /**
     * A boolean result usable as a filter expression (e.g. existence tests).
     */
    case Logical = 'logical';

    /**
     * A nodelist (array of matched nodes), not directly comparable.
     */
    case Nodes = 'nodes';
}

e that can be used in comparisons.
     */
    case


nterface<callable(mixed ...$arguments): mixed>|null $functionsProvider
     * @param array<string, array{arity?: int|null, return_type?: FunctionReturnType|null}>          $functionsMetadata
     */
    public function __construct(
        private readonly mixed $raw,
        private readonly ?ContainerInterface $functionsProvider = null,
        private readonly array $functionsMetadata = [],
    ) {
        if (!\is_string($raw) && !\is_resource($raw)) {
            throw new InvalidArgumentException(\spr

ry);
    }

    private function evaluate(JsonPath $query): array
    {
        try {
            if ($this->isComplexBracketExpression($query)) {
                preg_match('/^\$\[([^\[\]]+)]$/', $query, $matches);

                if (\is_resource($json

intf('Expected string or resource, got "%s".', get_debug_type($raw)));
        }
    }

    public function find(string|JsonPath $query): array
    {
        return $this->evaluate(\is_string($query) ? new JsonPath($query) : $que


*
 * 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\JsonPath;

use Symfony\Component\JsonPath\Exception\InvalidArgumentException;
use Symfony\Component\JsonPath\Exception\JsonCrawlerException;

/**
 * @author Alexandre Daubois <alex.daubois@gmail.com>
 */
interface JsonCrawlerInterface
{
    /**
     * @r

     * @throws InvalidArgumentException When the JSON string provided to the crawler cannot be decoded
     * @throws JsonCrawlerException     When a syntax error occurs in the provided JSON path
     */
    public function find(string|JsonPath $query): ar

eturn list<array|string|float|int|bool|null>
     *


ge.
 *
 * (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\JsonPath;

/**
 * @author Alexandre Daubois <alex.daubois@gmail.com>
 *
 * @immutable
 */
final class JsonPath
{
    /**
     * @param non-empty-string $path
     */
    public function __construct(
        private readonly string $path = '$',
    ) {
    }

    public function key(string $key):

 }

    public function deepScan(): static
    {
        return new self($this->path.'..');
    }

    public function all(): static
    {
        return new self($this->path.'[*]');
    }

    public function first(): static
    {
        return new self(

static
    {
        $escaped = $this->escapeKey($key);

        return new self($this->path.'["'.$escaped.'"]');
    }

    public function index(int $index): static
    {
        return new self($this->path.'['.$index.']');


hp

/*
 * 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\JsonPath;

use Psr\Container\ContainerInterface;
use Symfony\Contracts\Service\ServiceProviderInterface;

final class JsonPathCrawler implements JsonPathCrawlerInterface
{
    /**
     * @param ContainerInterface|ServiceProviderInterface<callable(mi

eadonly ?ContainerInterface $functionsProvider = null,
        private readonly array $functionsMetadata = [],
    ) {
    }

    /**
     * @param resource|string $raw
     */
    public function crawl(mixed $raw): JsonCrawlerInterface
    {
        retur

xed ...$arguments): mixed>|null $functionsProvider
     * @param array<string, array{arity?: int|null, return_type?: FunctionReturnType|null}>          $functionsMetadata
     */
    public function __construct(
        private r


buted with this source code.
 */

namespace Symfony\Component\JsonPath;

use Symfony\Component\JsonPath\Exception\InvalidArgumentException;
use Symfony\Component\JsonPath\Exception\JsonCrawlerException;
use Symfony\Component\JsonPath\Tokenizer\JsonPathToken;
use Symfony\Component\JsonPath\Tokenizer\TokenType;
use Symfony\Component\JsonStreamer\Read\Splitter;

/**
 * Get the smallest deserializable JSON string from a list of tokens that doesn't need any processing.
 *
 * @author Alexandre Daubois <alex.daubo

blic static function findSmallestDeserializableStringAndPath(array $tokens, mixed $json): array
    {
        if (!\is_resource($json)) {
            throw new InvalidArgumentException('The JSON parameter must be a resource.');
        }

        $currentO

is@gmail.com>
 *
 * @internal
 */
final class JsonPathUtils
{
    /**
     * @param JsonPathToken[] $tokens
     * @param resource        $json
     *
     * @return array{json: string, tokens: list<JsonPathToken>}
     */
    pu


TERAL_REGEX = '(true|false|null|\d+(\.\d+)?([eE][+-]?\d+)?|\'[^\']*\'|"[^"]*")';

    /**
     * @return JsonPathToken[]
     */
    public static function tokenize(JsonPath $query): array
    {
        $tokens = [];
        $current = '';
        $inBracket = false;
        $bracketDepth = 0;
        $inFilter = false;
        $inQuote = false;
        $quoteChar = '';
        $filterParenthesisDepth = 0;
        $filterBracketDepth = 0;
        $hasContentAfterRoot = false;

        $chars = mb_str_split(

     if ($i >= $length || '$' !== $chars[$i]) {
            throw new InvalidJsonPathException('expression must start with $.');
        }

        $rootIndex = $i;
        if ($rootIndex + 1 < $length) {
            $hasContentAfterRoot = true;
        }

(string) $query);
        $length = \count($chars);

        if (0 === $length) {
            throw new InvalidJsonPathException('empty JSONPath expression.');
        }

        $i = self::skipWhitespace($chars, 0, $length);


?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\JsonPath\Tests;

use Psr\Container\ContainerInterface;

trait FunctionsLocatorTrait
{
    private function createFunctionsLocator(array $functions): ContainerInterface
    {
        return new class($functions) implements ContainerInterface {

throw new \RuntimeException(\sprintf('Unknown custom JSONPath function "%s".', $id));
                }

                return $this->functions[$id];
            }

            public function has(string $id): bool
            {
                return iss

        public function __construct(private array $functions)
            {
            }

            public function get(string $id): mixed
            {
                if (!isset($this->functions[$id])) {


nCrawlerTest extends TestCase
{
    use FunctionsLocatorTrait;

    public function testNotStringOrResourceThrows()
    {
        $this->expectException(InvalidArgumentException::class);
        $this->expectExceptionMessage('Expected string or resource, got "int".');

        new JsonCrawler(42);
    }

    public function testInvalidInputJson()
    {
        $this->expectException(InvalidJsonStringInputException::class);
        $this->expectExceptionMessage('Invalid JSON input: Syntax error');

        (

mixed $value): ?string => \is_string($value) ? strtoupper($value) : null,
        ]));

        $this->assertInstanceOf(JsonPathCrawlerInterface::class, $jsonPathCrawler);

        $crawler = $jsonPathCrawler->crawl('{"items": [{"title": "hello"}, {"title"

new JsonCrawler('invalid'))->find('$..*');
    }

    public function testJsonPathCrawlerCreatesJsonCrawler()
    {
        $jsonPathCrawler = new JsonPathCrawler($this->createFunctionsLocator([
            'upper' => static fn (


 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\JsonPath\Tests;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\JsonPath\Exception\JsonCrawlerException;
use Symfony\Component\JsonPath\JsonCrawler;

final class JsonPathComplianceTestSuiteTest extends TestCase
{
    private const COMPLIANCE_TEST_SUITE_FILE = 'vendor/jsonpath-standard/jsonpath

 === $selector) {
            $this->markTestSkipped('The JsonPath compliance test suite is not available. Did you run "composer update"?');
        }

        $jsonCrawler = new JsonCrawler(json_encode($document));

        if ($invalidSelector) {

-compliance-test-suite/cts.json';

    #[DataProvider('complianceCaseProvider')]
    public function testComplianceTestCase(?string $selector, mixed $document, array $expectedResults, bool $invalidSelector)
    {
        if (null


 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\JsonPath\Tests;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\JsonPath\JsonPath;

class JsonPathTest extends TestCase
{
    public function testBuildPath()
    {
        $path = new JsonPath();
        $path = $path->key('users')
            ->index(0)
            ->key('address');

   $path = new JsonPath();
        $path = $path->key('users')
            ->filter('@.age > 18');

        $this->assertSame('$["users"][?(@.age > 18)]', (string) $path);
    }

    public function testAll()
    {
        $path = new JsonPath();
        $

$this->assertSame('$["users"][0]["address"]', (string) $path);
        $this->assertSame('$["users"][0]["address"]..["city"]', (string) $path->deepScan()->key('city'));
    }

    public function testBuildWithFilter()
    {


buted with this source code.
 */

namespace Symfony\Component\JsonPath\Tests;

use PHPUnit\Framework\TestCase;
use Symfony\Component\JsonPath\JsonPath;
use Symfony\Component\JsonPath\JsonPathUtils;
use Symfony\Component\JsonPath\Tokenizer\JsonPathToken;
use Symfony\Component\JsonPath\Tokenizer\JsonPathTokenizer;
use Symfony\Component\JsonPath\Tokenizer\TokenType;

class JsonPathUtilsTest extends TestCase
{
    public function testReduceWithArrayAccess()
    {
        $path = new JsonPath('$.store.book[0].ti

$resource);

        $this->assertSame('{"category": "reference", "author": "Nigel Rees", "title": "Sayings", "price": 8.95}', $reduced['json']);
        $this->assertEquals([new JsonPathToken(TokenType::Name, 'title')], $reduced['tokens']);
    }

    pub

tle');
        $resource = self::provideJsonResource();

        $reduced = JsonPathUtils::findSmallestDeserializableStringAndPath(
            JsonPathTokenizer::tokenize($path),
            $resource
        );

        fclose(


he 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\JsonPath\Tests\Attribute;

use PHPUnit\Framework\TestCase;
use Symfony\Component\JsonPath\Attribute\AsJsonPathFunction;

class AsJsonPathFunctionTest extends TestCase
{
    public function testAttributeStoresFunctionName()
    {
        $attribute = new AsJsonPathFunction('upper')

me);
    }

    public function testAttributeTargetsClassesOnly()
    {
        $reflection = new \ReflectionClass(AsJsonPathFunction::class);
        $attribute = $reflection->getAttributes(\Attribute::class)[0]->newInstance();

        $this->assertSame(

;

        $this->assertSame('upper', $attribute->na


ion\InvalidJsonPathException;
use Symfony\Component\JsonPath\JsonPath;
use Symfony\Component\JsonPath\Tokenizer\JsonPathTokenizer;
use Symfony\Component\JsonPath\Tokenizer\TokenType;

class JsonPathTokenizerTest extends TestCase
{
    #[DataProvider('simplePathProvider')]
    public function testSimplePath(string $path, array $expectedTokens)
    {
        $jsonPath = new JsonPath($path);
        $tokens = JsonPathTokenizer::tokenize($jsonPath);

        $this->assertCount(\count($expectedTokens), $tokens);

implePathProvider(): array
    {
        return [
            'root only' => [
                '$',
                [],
            ],
            'simple property' => [
                '$.store',
                [[TokenType::Name, 'store']],
            ]

        foreach ($tokens as $i => $token) {
            $this->assertSame($expectedTokens[$i][0], $token->type);
            $this->assertSame($expectedTokens[$i][1], $token->value);
        }
    }

    public static function s


buted with this source code.
 */

namespace Symfony\Component\JsonPath\Tests\Functions;

use PHPUnit\Framework\TestCase;
use Symfony\Component\JsonPath\Exception\JsonCrawlerException;
use Symfony\Component\JsonPath\FunctionReturnType;
use Symfony\Component\JsonPath\JsonCrawler;
use Symfony\Component\JsonPath\Tests\FunctionsLocatorTrait;

class CustomFunctionTest extends TestCase
{
    use FunctionsLocatorTrait;

    public function testCustomFunctionWithSingleArgument()
    {
        $upperFunction = static

s->createFunctionsLocator(['upper' => $upperFunction]));

        $result = $crawler->find('$.items[?upper(@.title) == "HELLO"]');
        $this->assertCount(1, $result);
        $this->assertEquals('hello', $result[0]['title']);
    }

    public function

 fn (mixed $value): ?string => \is_string($value) ? strtoupper($value) : null;

        $crawler = new JsonCrawler(<<<JSON
                {"name": "test", "items": [{"title": "hello"}, {"title": "world"}]}
            JSON, $thi


buted with this source code.
 */

namespace Symfony\Component\JsonPath\Tests\Test;

use PHPUnit\Framework\AssertionFailedError;
use PHPUnit\Framework\TestCase;
use Symfony\Component\JsonPath\Test\JsonPathAssertionsTrait;

class JsonPathAssertionsTraitTest extends TestCase
{
    use JsonPathAssertionsTrait;

    public function testAssertJsonPathEqualsOk()
    {
        self::assertJsonPathEquals([1], '$.a[2]', self::getSimpleCollectionCrawlerData());
    }

    public function testAssertJsonPathEqualsOkWith

lf::assertJsonPathEquals([2], '$.a[2]', self::getSimpleCollectionCrawlerData());
        } catch (AssertionFailedError $exception) {
            self::assertMatchesRegularExpression('/Failed asserting that .+ equals JSON path "\$\.a\[2]" result./s', $excep

TypeCoercion()
    {
        self::assertJsonPathEquals(['1'], '$.a[2]', self::getSimpleCollectionCrawlerData());
    }

    public function testAssertJsonPathEqualsKo()
    {
        $thrown = false;
        try {
            se


ge.
 *
 * (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\JsonPath\Test;

use PHPUnit\Framework\Assert;
use PHPUnit\Framework\ExpectationFailedException;
use Symfony\Component\JsonPath\JsonPath;

/**
 * @author Alexandre Daubois <alex.daubois@gmail.com>
 */
trait JsonPathAssertionsTrait
{
    /**
     * @throws ExpectationFailedException
     */
    fin

sage);
    }

    /**
     * @throws ExpectationFailedException
     */
    final public static function assertJsonPathNotEquals(mixed $expectedValue, JsonPath|string $jsonPath, string $json, string $message = ''): void
    {
        Assert::assertThat($ex

al public static function assertJsonPathEquals(mixed $expectedValue, JsonPath|string $jsonPath, string $json, string $message = ''): void
    {
        Assert::assertThat($expectedValue, new JsonPathEquals($jsonPath, $json), $mes


<?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\JsonPath\Test;

use PHPUnit\Framework\Constraint\Constraint;
use Symfony\Component\JsonPath\JsonCrawler;
use Symfony\Component\JsonPath\JsonPath;

/**
 * @author Alexandre Daubois <alex.daubois@gmail.com>
 */
class JsonPathContains extends Constr

intf('is found in elements at JSON path "%s"', $this->jsonPath);
    }

    protected function matches(mixed $other): bool
    {
        $result = (new JsonCrawler($this->json))->find($this->jsonPath);

        return \in_array($other, $result, $this->stri

aint
{
    public function __construct(
        private JsonPath|string $jsonPath,
        private string $json,
        private bool $strict = true,
    ) {
    }

    public function toString(): string
    {
        return \spr


ony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\JsonPath\Test;

use PHPUnit\Framework\Constraint\Constraint;
use Symfony\Component\JsonPath\JsonCrawler;
use Symfony\Component\JsonPath\JsonPath;

/**
 * @author Alexandre Daubois <alex.daubois@gmail.com>
 */
class JsonPathCount extends Constraint
{
    public function __construct(
        private JsonPath|string $jsonPath,
        privat

oString(): string
    {
        return \sprintf('matches expected count of JSON path "%s"', $this->jsonPath);
    }

    protected function matches(mixed $other): bool
    {
        return $other === \count((new JsonCrawler($this->json))->find($this->jsonP

e string $json,
    ) {
    }

    public function t


he 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\JsonPath\Test;

use PHPUnit\Framework\Constraint\Constraint;
use Symfony\Component\JsonPath\JsonCrawler;
use Symfony\Component\JsonPath\JsonPath;

/**
 * @author Alexandre Daubois <alex.daubois@gmail.com>
 */
class JsonPathEquals extends Constraint
{
    public function __construc

  private string $json,
    ) {
    }

    public function toString(): string
    {
        return \sprintf('equals JSON path "%s" result', $this->jsonPath);
    }

    protected function matches(mixed $other): bool
    {
        return (new JsonCrawler($t

t(
        private JsonPath|string $jsonPath,


<?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\JsonPath\Test;

use PHPUnit\Framework\Constraint\Constraint;
use Symfony\Component\JsonPath\JsonCrawler;
use Symfony\Component\JsonPath\JsonPath;

/**
 * @author Alexandre Daubois <alex.daubois@gmail.com>
 */
class JsonPathNotContains extends Con

sprintf('is not found in elements at JSON path "%s"', $this->jsonPath);
    }

    protected function matches(mixed $other): bool
    {
        $result = (new JsonCrawler($this->json))->find($this->jsonPath);

        return !\in_array($other, $result, $th

straint
{
    public function __construct(
        private JsonPath|string $jsonPath,
        private string $json,
        private bool $strict = true,
    ) {
    }

    public function toString(): string
    {
        return \


ony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\JsonPath\Test;

use PHPUnit\Framework\Constraint\Constraint;
use Symfony\Component\JsonPath\JsonCrawler;
use Symfony\Component\JsonPath\JsonPath;

/**
 * @author Alexandre Daubois <alex.daubois@gmail.com>
 */
class JsonPathNotEquals extends Constraint
{
    public function __construct(
        private JsonPath|string $jsonPath,
        pr

on toString(): string
    {
        return \sprintf('does not equal JSON path "%s" result', $this->jsonPath);
    }

    protected function matches(mixed $other): bool
    {
        return (new JsonCrawler($this->json))->find($this->jsonPath) != $other;

ivate string $json,
    ) {
    }

    public functi


ony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\JsonPath\Test;

use PHPUnit\Framework\Constraint\Constraint;
use Symfony\Component\JsonPath\JsonCrawler;
use Symfony\Component\JsonPath\JsonPath;

/**
 * @author Alexandre Daubois <alex.daubois@gmail.com>
 */
class JsonPathNotSame extends Constraint
{
    public function __construct(
        private JsonPath|string $jsonPath,
        priv

 toString(): string
    {
        return \sprintf('is not identical to JSON path "%s" result', $this->jsonPath);
    }

    protected function matches(mixed $other): bool
    {
        return (new JsonCrawler($this->json))->find($this->jsonPath) !== $other

ate string $json,
    ) {
    }

    public function


ony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\JsonPath\Test;

use PHPUnit\Framework\Constraint\Constraint;
use Symfony\Component\JsonPath\JsonCrawler;
use Symfony\Component\JsonPath\JsonPath;

/**
 * @author Alexandre Daubois <alex.daubois@gmail.com>
 */
class JsonPathSame extends Constraint
{
    public function __construct(
        private JsonPath|string $jsonPath,
        private

String(): string
    {
        return \sprintf('is identical to JSON path "%s" result', $this->jsonPath);
    }

    protected function matches(mixed $other): bool
    {
        return (new JsonCrawler($this->json))->find($this->jsonPath) === $other;
    }

 string $json,
    ) {
    }

    public function to


ge.
 *
 * (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\Messenger;

use Symfony\Component\Messenger\Stamp\StampInterface;

/**
 * A message wrapped in an envelope with stamps (configurations, markers, ...).
 *
 * @author Maxime Steinhausser <maxime.steinhausser@gmail.com>
 */
final class Envelope
{
    /**
     * @var array<class-string<StampInterface

      array $stamps = [],
    ) {
        foreach ($stamps as $stamp) {
            $this->stamps[$stamp::class][] = $stamp;
        }
    }

    /**
     * Makes sure the message is in an Envelope and adds the given stamps.
     *
     * @param StampInter

>, list<StampInterface>>
     */
    private array $stamps = [];

    /**
     * @param object|Envelope  $message
     * @param StampInterface[] $stamps
     */
    public function __construct(
        private object $message,


/*
 * 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\Config\Tests\Definition;

use PHPUnit\Framework\Attributes\TestWith;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
use Symfony\Component\Config\Definition\StringNode;

class StringNodeTest exten

 }

    #[TestWith([null])]
    #[TestWith([false])]
    #[TestWith([true])]
    #[TestWith([0])]
    #[TestWith([1])]
    #[TestWith([0.0])]
    #[TestWith([0.1])]
    #[TestWith([[]])]
    #[TestWith([['foo' => 'bar']])]
    public function testNormalize

ds TestCase
{
    #[TestWith([''])]
    #[TestWith(['valid string'])]
    public function testNormalize(string $value)
    {
        $node = new StringNode('test');
        $this->assertSame($value, $node->normalize($value));


ge.
 *
 * (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\Config\Tests\Definition\Builder;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Definition\Builder\BooleanNodeDefinition;
use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException;

class BooleanNodeDefinitionTest extends TestCase
{
    public function testCannot

nNodeDefinition('foo');
        $def->cannotBeEmpty();
    }

    public function testBooleanNodeWithDefaultNull()
    {
        $def = new BooleanNodeDefinition('foo');
        $def->defaultNull();

        $node = $def->getNode();
        $this->assertTr

BeEmptyThrowsAnException()
    {
        $this->expectException(InvalidDefinitionException::class);
        $this->expectExceptionMessage('->cannotBeEmpty() is not applicable to BooleanNodeDefinition.');
        $def = new Boolea


efinition\Builder\ExprBuilder;
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;

class ExprBuilderTest extends TestCase
{
    public function testAlwaysExpression()
    {
        $test = $this->getTestBuilder()
            ->always($this->returnClosure('new_value'))
        ->end();

        $this->assertFinalizedValueIs('new_value', $test);
    }

 $test, ['key' => true]);

        $test = $this->getTestBuilder()
            ->ifTrue(static fn () => true)
            ->then($this->returnClosure('new_value'))
        ->end();
        $this->assertFinalizedValueIs('new_value', $test);

        $test =

public function testIfTrueExpression()
    {
        $test = $this->getTestBuilder()
            ->ifTrue()
            ->then($this->returnClosure('new_value'))
        ->end();
        $this->assertFinalizedValueIs('new_value',


 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Config\Tests\Definition\Builder;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Definition\Builder\FloatNodeDefinition;
use Symfony\Component\Config\Definition\Builder\IntegerNodeDefinition;
use Symfony\Component\Config\Definition\Builder\NodeBuilder as BaseNodeBuilder;
use Symfony\Component\Config\Definition\Builder\StringNodeDefi

Type()
    {
        $this->expectException(\RuntimeException::class);
        $builder = new BaseNodeBuilder();
        $builder->node('', 'foobar');
    }

    public function testThrowsAnExceptionWhenTheNodeClassIsNotFound()
    {
        $this->expectE

nition;
use Symfony\Component\Config\Definition\Builder\VariableNodeDefinition as BaseVariableNodeDefinition;

class NodeBuilderTest extends TestCase
{
    public function testThrowsAnExceptionWhenTryingToCreateANonRegisteredNode


ge.
 *
 * (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\Config\Tests\Definition;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
use Symfony\Component\Config\Definition\IntegerNode;
use Symfony\Component\Config\Definition\NumericNode;

class Integer

  #[DataProvider('getValidValues')]
    public function testValidNonEmptyValues(int $value)
    {
        $node = new IntegerNode('test');
        $node->setAllowEmptyValue(false);

        $this->assertSame($value, $node->finalize($value));
    }

    pub

NodeTest extends TestCase
{
    #[DataProvider('getValidValues')]
    public function testNormalize(int $value)
    {
        $node = new IntegerNode('test');
        $this->assertSame($value, $node->normalize($value));
    }


buted with this source code.
 */

namespace Symfony\Component\Config\Tests\Definition\Builder;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Definition\BaseNode;
use Symfony\Component\Config\Definition\BooleanNode;
use Symfony\Component\Config\Definition\Builder\BooleanNodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Tests\Fixtures\BarNode;
use Symfony\Component\Config\Tests\Fixtures\Builder\BarNodeDefinition;
use Symfony\Component\Con

    {
        $builder = new TreeBuilder('custom', 'array', new CustomNodeBuilder());

        $nodeBuilder = $builder->getRootNode()->children();

        $this->assertInstanceOf(CustomNodeBuilder::class, $nodeBuilder);

        $nodeBuilder = $nodeBuilde

fig\Tests\Fixtures\Builder\NodeBuilder as CustomNodeBuilder;
use Symfony\Component\Config\Tests\Fixtures\Builder\VariableNodeDefinition;

class TreeBuilderTest extends TestCase
{
    public function testUsingACustomNodeBuilder()


buted with this source code.
 */

namespace Symfony\Component\Config\Tests\Definition;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\Exception\ForbiddenOverwriteException;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;

class MergeTest extends TestCase
{
    public function testForbiddenOverwrite()
    {
        $tb = new TreeBuilder('root', 'array');
        $tree = $tb
            ->ge

)
        ;

        $a = [
            'foo' => 'bar',
        ];

        $b = [
            'foo' => 'moo',
        ];

        $this->expectException(ForbiddenOverwriteException::class);

        $tree->merge($a, $b);
    }

    public function testUns

tRootNode()
                ->children()
                    ->node('foo', 'scalar')
                        ->cannotBeOverwritten()
                    ->end()
                ->end()
            ->end()
            ->buildTree(


t the doRequest() method.
 *
 * If you want to be able to run requests in their own process (insulated flag),
 * you need to also implement the getScript() method.
 *
 * @author Fabien Potencier <fabien@symfony.com>
 *
 * @template TRequest of object
 * @template TResponse of object
 */
abstract class AbstractBrowser
{
    protected History $history;
    protected CookieJar $cookieJar;
    protected array $server = [];
    protected Request $internalRequest;
    /** @psalm-var TRequest */
    protected obje

sulated = false;
    protected ?string $redirect;
    protected bool $followRedirects = true;
    protected bool $followMetaRefresh = false;

    private int $maxRedirects = -1;
    private int $redirectCount = 0;
    private array $redirects = [];
    pri

ct $request;
    protected Response $internalResponse;
    /** @psalm-var TResponse */
    protected object $response;
    protected Crawler $crawler;
    protected string|false $wrapContentPattern = false;
    protected bool $in


buted with this source code.
 */

namespace Symfony\Component\BrowserKit;

use Symfony\Component\BrowserKit\Exception\InvalidArgumentException;
use Symfony\Component\BrowserKit\Exception\UnexpectedValueException;

/**
 * Cookie represents an HTTP cookie.
 *
 * @author Fabien Potencier <fabien@symfony.com>
 */
class Cookie
{
    /**
     * Handles dates as defined by RFC 2616 section 3.3.1, and also some other
     * non-standard, but common formats.
     */
    private const DATE_FORMATS = [
        'D, d M

string $expires = null;
    protected string $path;
    protected string $rawValue;

    /**
     * Sets a cookie.
     *
     * @param string          $name         The cookie name
     * @param string|null     $value        The value of the cookie
     *

 Y H:i:s T',
        'D, d-M-y H:i:s T',
        'D, d-M-Y H:i:s T',
        'D, d-m-y H:i:s T',
        'D, d-m-Y H:i:s T',
        'D M j G:i:s Y',
        'D M d H:i:s Y T',
    ];

    protected string $value;
    protected ?


buted with this source code.
 */

namespace Symfony\Component\BrowserKit;

use Symfony\Component\BrowserKit\Exception\LogicException;
use Symfony\Component\HttpClient\HttpClient;
use Symfony\Component\Mime\Part\AbstractPart;
use Symfony\Component\Mime\Part\DataPart;
use Symfony\Component\Mime\Part\Multipart\FormDataPart;
use Symfony\Component\Mime\Part\TextPart;
use Symfony\Contracts\HttpClient\HttpClientInterface;

/**
 * An implementation of a browser using the HttpClient component
 * to make real HTTP re

__construct(?HttpClientInterface $client = null, ?History $history = null, ?CookieJar $cookieJar = null)
    {
        if (!$client && !class_exists(HttpClient::class)) {
            throw new LogicException(\sprintf('You cannot use "%s" as the HttpClient

quests.
 *
 * @author Fabien Potencier <fabien@symfony.com>
 *
 * @template-extends AbstractBrowser<Request, Response>
 */
class HttpBrowser extends AbstractBrowser
{
    private HttpClientInterface $client;

    public function


ge.
 *
 * (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\BrowserKit;

/**
 * @author Fabien Potencier <fabien@symfony.com>
 */
class Request
{
    /**
     * @param string      $uri        The request URI
     * @param string      $method     The HTTP method request
     * @param array       $parameters The request parameters
     * @param array

    public function __construct(
        protected string $uri,
        protected string $method,
        protected array $parameters = [],
        protected array $files = [],
        protected array $cookies = [],
        protected array $server = [],

$files      An array of uploaded files
     * @param array       $cookies    An array of cookies
     * @param array       $server     An array of server parameters
     * @param string|null $content    The raw body data
     */


Symfony\Component\BrowserKit\CookieJar;
use Symfony\Component\BrowserKit\Response;

class CookieJarTest extends TestCase
{
    public function testSetGet()
    {
        $cookieJar = new CookieJar();
        $cookieJar->set($cookie = new Cookie('foo', 'bar'));

        $this->assertEquals($cookie, $cookieJar->get('foo'), '->set() sets a cookie');

        $this->assertNull($cookieJar->get('foobar'), '->get() returns null if the cookie does not exist');

        $cookieJar->set($cookie = new Cookie('foo', 'b

t($cookie = new Cookie('foo', 'bar'));
        $cookieJar->expire('foo');
        $this->assertNull($cookieJar->get('foo'), '->get() returns null if the cookie is expired');
    }

    public function testAll()
    {
        $cookieJar = new CookieJar();

ar', time() - 86400));
        $this->assertNull($cookieJar->get('foo'), '->get() returns null if the cookie is expired');
    }

    public function testExpire()
    {
        $cookieJar = new CookieJar();
        $cookieJar->se


 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\BrowserKit\Tests;

use PHPUnit\Framework\TestCase;
use Symfony\Component\BrowserKit\History;
use Symfony\Component\BrowserKit\Request;

class HistoryTest extends TestCase
{
    public function testAdd()
    {
        $history = new History();
        $history->add(new Request('http://www.example1.com/', 'get'));
        $this->assertSame('http://

current()->getUri(), '->add() adds a request to the history');

        $history->add(new Request('http://www.example3.com/', 'get'));
        $history->back();
        $history->add(new Request('http://www.example4.com/', 'get'));
        $this->assertSam

www.example1.com/', $history->current()->getUri(), '->add() adds a request to the history');

        $history->add(new Request('http://www.example2.com/', 'get'));
        $this->assertSame('http://www.example2.com/', $history->


ge.
 *
 * (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\BrowserKit\Tests;

use PHPUnit\Framework\TestCase;
use Symfony\Component\BrowserKit\Request;

class RequestTest extends TestCase
{
    public function testGetUri()
    {
        $request = new Request('http://www.example.com/', 'get');
        $this->assertEquals('http://www.example.com/', $reque

(), '->getMethod() returns the method of the request');
    }

    public function testGetParameters()
    {
        $request = new Request('http://www.example.com/', 'get', ['foo' => 'bar']);
        $this->assertEquals(['foo' => 'bar'], $request->getPara

st->getUri(), '->getUri() returns the URI of the request');
    }

    public function testGetMethod()
    {
        $request = new Request('http://www.example.com/', 'get');
        $this->assertEquals('get', $request->getMethod


 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\BrowserKit\Tests;

use Symfony\Component\BrowserKit\AbstractBrowser;
use Symfony\Component\BrowserKit\Response;

class TestClient extends AbstractBrowser
{
    protected ?Response $nextResponse = null;
    protected string $nextScript;

    public function s

$request): Response
    {
        if (null === $this->nextResponse) {
            return new Response();
        }

        $response = $this->nextResponse;
        $this->nextResponse = null;

        return $response;
    }

    protected function getScr

etNextResponse(Response $response)
    {
        $this->nextResponse = $response;
    }

    public function setNextScript(string $script)
    {
        $this->nextScript = $script;
    }

    protected function doRequest(object


buted with this source code.
 */

namespace Symfony\Component\Config\Tests\Definition;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Definition\ArrayNode;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
use Symfony\Component\Config\Definition\ScalarNode;
use Symfony\Component\Config\Exception\LogicException;

class ScalarNodeTest extends Test

etValidValues(): array
    {
        return [
            [false],
            [true],
            [null],
            [''],
            ['foo'],
            [0],
            [1],
            [0.0],
            [0.1],
        ];
    }

    public function

Case
{
    #[DataProvider('getValidValues')]
    public function testNormalize($value)
    {
        $node = new ScalarNode('test');
        $this->assertSame($value, $node->normalize($value));
    }

    public static function g


fony\Component\Config\Definition\Processor;
use Symfony\Component\Config\Definition\PrototypedArrayNode;

class ArrayNodeDefinitionTest extends TestCase
{
    public function testAppendingSomeNode()
    {
        $parent = new ArrayNodeDefinition('root');
        $child = new ScalarNodeDefinition('child');

        $parent
            ->children()
                ->scalarNode('foo')->end()
                ->scalarNode('bar')->end()
            ->end()
            ->append($child);

        $this->assertCoun

cOption(string $method, array $args)
    {
        $this->expectException(InvalidDefinitionException::class);
        $node = new ArrayNodeDefinition('root');

        $node->{$method}(...$args);

        $node->getNode();
    }

    public static function

t(3, $this->getField($parent, 'children'));
        $this->assertContains($child, $this->getField($parent, 'children'));
    }

    #[DataProvider('providePrototypeNodeSpecificCalls')]
    public function testPrototypeNodeSpecifi