diff --git a/lib/symfony/form/Test/FormBuilderInterface.php b/lib/symfony/form/Test/FormBuilderInterface.php deleted file mode 100644 index 185a8a12d..000000000 --- a/lib/symfony/form/Test/FormBuilderInterface.php +++ /dev/null @@ -1,18 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Test; - -use Symfony\Component\Form\FormBuilderInterface as BaseFormBuilderInterface; - -interface FormBuilderInterface extends \Iterator, BaseFormBuilderInterface -{ -} diff --git a/lib/symfony/form/Test/FormIntegrationTestCase.php b/lib/symfony/form/Test/FormIntegrationTestCase.php deleted file mode 100644 index 5bf37fd48..000000000 --- a/lib/symfony/form/Test/FormIntegrationTestCase.php +++ /dev/null @@ -1,54 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Test; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Form\FormFactoryInterface; -use Symfony\Component\Form\Forms; - -/** - * @author Bernhard Schussek - */ -abstract class FormIntegrationTestCase extends TestCase -{ - protected FormFactoryInterface $factory; - - protected function setUp(): void - { - $this->factory = Forms::createFormFactoryBuilder() - ->addExtensions($this->getExtensions()) - ->addTypeExtensions($this->getTypeExtensions()) - ->addTypes($this->getTypes()) - ->addTypeGuessers($this->getTypeGuessers()) - ->getFormFactory(); - } - - protected function getExtensions() - { - return []; - } - - protected function getTypeExtensions() - { - return []; - } - - protected function getTypes() - { - return []; - } - - protected function getTypeGuessers() - { - return []; - } -} diff --git a/lib/symfony/form/Test/FormInterface.php b/lib/symfony/form/Test/FormInterface.php deleted file mode 100644 index 4af460308..000000000 --- a/lib/symfony/form/Test/FormInterface.php +++ /dev/null @@ -1,18 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Test; - -use Symfony\Component\Form\FormInterface as BaseFormInterface; - -interface FormInterface extends \Iterator, BaseFormInterface -{ -} diff --git a/lib/symfony/form/Test/FormPerformanceTestCase.php b/lib/symfony/form/Test/FormPerformanceTestCase.php deleted file mode 100644 index 7774d9b9b..000000000 --- a/lib/symfony/form/Test/FormPerformanceTestCase.php +++ /dev/null @@ -1,64 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Test; - -use Symfony\Component\Form\Test\Traits\RunTestTrait; - -/** - * Base class for performance tests. - * - * Copied from Doctrine 2's OrmPerformanceTestCase. - * - * @author robo - * @author Bernhard Schussek - */ -abstract class FormPerformanceTestCase extends FormIntegrationTestCase -{ - use RunTestTrait; - - /** - * @var int - */ - protected $maxRunningTime = 0; - - private function doRunTest(): mixed - { - $s = microtime(true); - $result = parent::runTest(); - $time = microtime(true) - $s; - - if (0 != $this->maxRunningTime && $time > $this->maxRunningTime) { - $this->fail(sprintf('expected running time: <= %s but was: %s', $this->maxRunningTime, $time)); - } - - $this->expectNotToPerformAssertions(); - - return $result; - } - - /** - * @throws \InvalidArgumentException - */ - public function setMaxRunningTime(int $maxRunningTime) - { - if ($maxRunningTime < 0) { - throw new \InvalidArgumentException(); - } - - $this->maxRunningTime = $maxRunningTime; - } - - public function getMaxRunningTime(): int - { - return $this->maxRunningTime; - } -} diff --git a/lib/symfony/form/Test/Traits/RunTestTrait.php b/lib/symfony/form/Test/Traits/RunTestTrait.php deleted file mode 100644 index 17204b967..000000000 --- a/lib/symfony/form/Test/Traits/RunTestTrait.php +++ /dev/null @@ -1,36 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Test\Traits; - -use PHPUnit\Framework\TestCase; - -if ((new \ReflectionMethod(TestCase::class, 'runTest'))->hasReturnType()) { - // PHPUnit 10 - /** @internal */ - trait RunTestTrait - { - protected function runTest(): mixed - { - return $this->doRunTest(); - } - } -} else { - // PHPUnit 9 - /** @internal */ - trait RunTestTrait - { - protected function runTest() - { - return $this->doRunTest(); - } - } -} diff --git a/lib/symfony/form/Test/Traits/ValidatorExtensionTrait.php b/lib/symfony/form/Test/Traits/ValidatorExtensionTrait.php deleted file mode 100644 index 70240fc3e..000000000 --- a/lib/symfony/form/Test/Traits/ValidatorExtensionTrait.php +++ /dev/null @@ -1,44 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Test\Traits; - -use Symfony\Component\Form\Extension\Validator\ValidatorExtension; -use Symfony\Component\Form\Test\TypeTestCase; -use Symfony\Component\Validator\ConstraintViolationList; -use Symfony\Component\Validator\Mapping\ClassMetadata; -use Symfony\Component\Validator\Validator\ValidatorInterface; - -trait ValidatorExtensionTrait -{ - /** - * @var ValidatorInterface|null - */ - protected $validator; - - protected function getValidatorExtension(): ValidatorExtension - { - if (!interface_exists(ValidatorInterface::class)) { - throw new \Exception('In order to use the "ValidatorExtensionTrait", the symfony/validator component must be installed.'); - } - - if (!$this instanceof TypeTestCase) { - throw new \Exception(sprintf('The trait "ValidatorExtensionTrait" can only be added to a class that extends "%s".', TypeTestCase::class)); - } - - $this->validator = $this->createMock(ValidatorInterface::class); - $metadata = $this->getMockBuilder(ClassMetadata::class)->setConstructorArgs([''])->onlyMethods(['addPropertyConstraint'])->getMock(); - $this->validator->expects($this->any())->method('getMetadataFor')->willReturn($metadata); - $this->validator->expects($this->any())->method('validate')->willReturn(new ConstraintViolationList()); - - return new ValidatorExtension($this->validator, false); - } -} diff --git a/lib/symfony/form/Test/TypeTestCase.php b/lib/symfony/form/Test/TypeTestCase.php deleted file mode 100644 index ac8eb9baa..000000000 --- a/lib/symfony/form/Test/TypeTestCase.php +++ /dev/null @@ -1,58 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Test; - -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\Form\FormBuilder; -use Symfony\Component\Form\Test\Traits\ValidatorExtensionTrait; - -abstract class TypeTestCase extends FormIntegrationTestCase -{ - /** - * @var FormBuilder - */ - protected $builder; - - /** - * @var EventDispatcherInterface - */ - protected $dispatcher; - - protected function setUp(): void - { - parent::setUp(); - - $this->dispatcher = $this->createMock(EventDispatcherInterface::class); - $this->builder = new FormBuilder('', null, $this->dispatcher, $this->factory); - } - - protected function getExtensions() - { - $extensions = []; - - if (\in_array(ValidatorExtensionTrait::class, class_uses($this))) { - $extensions[] = $this->getValidatorExtension(); - } - - return $extensions; - } - - public static function assertDateTimeEquals(\DateTime $expected, \DateTime $actual) - { - self::assertEquals($expected->format('c'), $actual->format('c')); - } - - public static function assertDateIntervalEquals(\DateInterval $expected, \DateInterval $actual) - { - self::assertEquals($expected->format('%RP%yY%mM%dDT%hH%iM%sS'), $actual->format('%RP%yY%mM%dDT%hH%iM%sS')); - } -} diff --git a/lib/symfony/property-info/PhpStan/NameScope.php b/lib/symfony/property-info/PhpStan/NameScope.php deleted file mode 100644 index 91d91fa8e..000000000 --- a/lib/symfony/property-info/PhpStan/NameScope.php +++ /dev/null @@ -1,65 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\PropertyInfo\PhpStan; - -/** - * NameScope class adapted from PHPStan code. - * - * @copyright Copyright (c) 2016, PHPStan https://github.com/phpstan/phpstan-src - * @copyright Copyright (c) 2016, Ondřej Mirtes - * @author Baptiste Leduc - * - * @internal - */ -final class NameScope -{ - private string $calledClassName; - private string $namespace; - /** @var array alias(string) => fullName(string) */ - private array $uses; - - public function __construct(string $calledClassName, string $namespace, array $uses = []) - { - $this->calledClassName = $calledClassName; - $this->namespace = $namespace; - $this->uses = $uses; - } - - public function resolveStringName(string $name): string - { - if (str_starts_with($name, '\\')) { - return ltrim($name, '\\'); - } - - $nameParts = explode('\\', $name); - $firstNamePart = $nameParts[0]; - if (isset($this->uses[$firstNamePart])) { - if (1 === \count($nameParts)) { - return $this->uses[$firstNamePart]; - } - array_shift($nameParts); - - return sprintf('%s\\%s', $this->uses[$firstNamePart], implode('\\', $nameParts)); - } - - if (null !== $this->namespace) { - return sprintf('%s\\%s', $this->namespace, $name); - } - - return $name; - } - - public function resolveRootClass(): string - { - return $this->resolveStringName($this->calledClassName); - } -} diff --git a/lib/symfony/property-info/PhpStan/NameScopeFactory.php b/lib/symfony/property-info/PhpStan/NameScopeFactory.php deleted file mode 100644 index 162a72a9e..000000000 --- a/lib/symfony/property-info/PhpStan/NameScopeFactory.php +++ /dev/null @@ -1,70 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\PropertyInfo\PhpStan; - -use phpDocumentor\Reflection\Types\ContextFactory; - -/** - * @author Baptiste Leduc - * - * @internal - */ -final class NameScopeFactory -{ - public function create(string $calledClassName, ?string $declaringClassName = null): NameScope - { - $declaringClassName ??= $calledClassName; - - $path = explode('\\', $calledClassName); - $calledClassName = array_pop($path); - - $declaringReflection = new \ReflectionClass($declaringClassName); - [$declaringNamespace, $declaringUses] = $this->extractFromFullClassName($declaringReflection); - $declaringUses = array_merge($declaringUses, $this->collectUses($declaringReflection)); - - return new NameScope($calledClassName, $declaringNamespace, $declaringUses); - } - - private function collectUses(\ReflectionClass $reflection): array - { - $uses = [$this->extractFromFullClassName($reflection)[1]]; - - foreach ($reflection->getTraits() as $traitReflection) { - $uses[] = $this->extractFromFullClassName($traitReflection)[1]; - } - - if (false !== $parentClass = $reflection->getParentClass()) { - $uses[] = $this->collectUses($parentClass); - } - - return $uses ? array_merge(...$uses) : []; - } - - private function extractFromFullClassName(\ReflectionClass $reflection): array - { - $namespace = trim($reflection->getNamespaceName(), '\\'); - $fileName = $reflection->getFileName(); - - if (\is_string($fileName) && is_file($fileName)) { - if (false === $contents = file_get_contents($fileName)) { - throw new \RuntimeException(sprintf('Unable to read file "%s".', $fileName)); - } - - $factory = new ContextFactory(); - $context = $factory->createForNamespace($namespace, $contents); - - return [$namespace, $context->getNamespaceAliases()]; - } - - return [$namespace, []]; - } -}