From eb8d626c27b2b30e2c9cf661b2793b0dcd5a9c74 Mon Sep 17 00:00:00 2001 From: vudaltsov Date: Sat, 16 May 2020 16:15:54 +0300 Subject: [PATCH 01/13] Properties $originalName and $mimeType are never null in UploadedFile --- src/Symfony/Component/HttpFoundation/File/UploadedFile.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/File/UploadedFile.php b/src/Symfony/Component/HttpFoundation/File/UploadedFile.php index 5b75dd84fc..5206156032 100644 --- a/src/Symfony/Component/HttpFoundation/File/UploadedFile.php +++ b/src/Symfony/Component/HttpFoundation/File/UploadedFile.php @@ -24,7 +24,7 @@ use Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser; */ class UploadedFile extends File { - private $test = false; + private $test; private $originalName; private $mimeType; private $size; @@ -72,7 +72,7 @@ class UploadedFile extends File * It is extracted from the request from which the file has been uploaded. * Then it should not be considered as a safe value. * - * @return string|null The original name + * @return string The original name */ public function getClientOriginalName() { @@ -101,7 +101,7 @@ class UploadedFile extends File * For a trusted mime type, use getMimeType() instead (which guesses the mime * type based on the file content). * - * @return string|null The mime type + * @return string The mime type * * @see getMimeType() */ From 53b1677a4e82d7c11b3dc99eeb4c1c2264947ef5 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Thu, 21 May 2020 13:30:55 +0200 Subject: [PATCH 02/13] Address deprecation of ReflectionType::getClass(). --- .../Compiler/AutowirePass.php | 11 +++++++++- .../Controller/ControllerResolver.php | 20 ++++++++++++++++++- .../OptionsResolver/OptionsResolver.php | 18 ++++++++++++++++- 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php index 91b279c77a..d97f121ab9 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php @@ -525,7 +525,16 @@ class AutowirePass extends AbstractRecursivePass $methodArgumentsMetadata = []; foreach ($method->getParameters() as $parameter) { try { - $class = $parameter->getClass(); + if (method_exists($parameter, 'getType')) { + $type = $parameter->getType(); + if ($type && !$type->isBuiltin()) { + $class = new \ReflectionClass(method_exists($type, 'getName') ? $type->getName() : (string) $type); + } else { + $class = null; + } + } else { + $class = $parameter->getClass(); + } } catch (\ReflectionException $e) { // type-hint is against a non-existent class $class = false; diff --git a/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php b/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php index e3a7211c1b..688d574ceb 100644 --- a/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php +++ b/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php @@ -136,7 +136,7 @@ class ControllerResolver implements ArgumentResolverInterface, ControllerResolve } else { $arguments[] = $attributes[$param->name]; } - } elseif ($param->getClass() && $param->getClass()->isInstance($request)) { + } elseif ($this->typeMatchesRequestClass($param, $request)) { $arguments[] = $request; } elseif ($param->isDefaultValueAvailable()) { $arguments[] = $param->getDefaultValue(); @@ -260,4 +260,22 @@ class ControllerResolver implements ArgumentResolverInterface, ControllerResolve return $message; } + + /** + * @return bool + */ + private function typeMatchesRequestClass(\ReflectionParameter $param, Request $request) + { + if (!method_exists($param, 'getType')) { + return $param->getClass() && $param->getClass()->isInstance($request); + } + + if (!($type = $param->getType()) || $type->isBuiltin()) { + return false; + } + + $class = new \ReflectionClass(method_exists($type, 'getName') ? $type->getName() : (string) $type); + + return $class && $class->isInstance($request); + } } diff --git a/src/Symfony/Component/OptionsResolver/OptionsResolver.php b/src/Symfony/Component/OptionsResolver/OptionsResolver.php index fd8a603fe2..7354caf8a6 100644 --- a/src/Symfony/Component/OptionsResolver/OptionsResolver.php +++ b/src/Symfony/Component/OptionsResolver/OptionsResolver.php @@ -146,7 +146,7 @@ class OptionsResolver implements Options $reflClosure = new \ReflectionFunction($value); $params = $reflClosure->getParameters(); - if (isset($params[0]) && null !== ($class = $params[0]->getClass()) && Options::class === $class->name) { + if (isset($params[0]) && Options::class === $this->getParameterClassName($params[0])) { // Initialize the option if no previous value exists if (!isset($this->defaults[$option])) { $this->defaults[$option] = null; @@ -1066,4 +1066,20 @@ class OptionsResolver implements Options { return (\function_exists($isFunction = 'is_'.$type) && $isFunction($value)) || $value instanceof $type; } + + /** + * @return string|null + */ + private function getParameterClassName(\ReflectionParameter $parameter) + { + if (!method_exists($parameter, 'getType')) { + return ($class = $parameter->getClass()) ? $class->name : null; + } + + if (!($type = $parameter->getType()) || $type->isBuiltin()) { + return null; + } + + return method_exists($type, 'getName') ? $type->getName() : (string) $type; + } } From 573d0dd493d494093fd78c20caa252c7da0b2a21 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Thu, 21 May 2020 16:02:48 +0200 Subject: [PATCH 03/13] [Debug] Skip test that would trigger a fatal error on php 8. --- src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php b/src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php index 86ecf16df0..3cde54b3cd 100644 --- a/src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php +++ b/src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php @@ -97,6 +97,9 @@ class DebugClassLoaderTest extends TestCase $this->assertStringMatchesFormat('%aParse error%a', $output); } + /** + * @requires PHP < 8.0 + */ public function testStacking() { // the ContextErrorException must not be loaded to test the workaround From 1d20b514f2b3876b7d1b54c75316bf3a77bfff3c Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Fri, 22 May 2020 12:18:15 +0200 Subject: [PATCH 04/13] [Debug] Undefined variables raise a warning in php 8. --- .../Debug/Tests/ErrorHandlerTest.php | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php index 01c63aea88..118935e769 100644 --- a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php +++ b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php @@ -101,9 +101,14 @@ class ErrorHandlerTest extends TestCase $this->fail('ErrorException expected'); } catch (\ErrorException $exception) { // if an exception is thrown, the test passed - $this->assertEquals(E_NOTICE, $exception->getSeverity()); + if (\PHP_VERSION_ID < 80000) { + $this->assertEquals(E_NOTICE, $exception->getSeverity()); + $this->assertRegExp('/^Notice: Undefined variable: (foo|bar)/', $exception->getMessage()); + } else { + $this->assertEquals(E_WARNING, $exception->getSeverity()); + $this->assertRegExp('/^Warning: Undefined variable \$(foo|bar)/', $exception->getMessage()); + } $this->assertEquals(__FILE__, $exception->getFile()); - $this->assertRegExp('/^Notice: Undefined variable: (foo|bar)/', $exception->getMessage()); $trace = $exception->getTrace(); @@ -247,11 +252,17 @@ class ErrorHandlerTest extends TestCase $line = null; $logArgCheck = function ($level, $message, $context) use (&$line) { - $this->assertEquals('Notice: Undefined variable: undefVar', $message); $this->assertArrayHasKey('exception', $context); $exception = $context['exception']; + + if (\PHP_VERSION_ID < 80000) { + $this->assertEquals('Notice: Undefined variable: undefVar', $message); + $this->assertSame(E_NOTICE, $exception->getSeverity()); + } else { + $this->assertEquals('Warning: Undefined variable $undefVar', $message); + $this->assertSame(E_WARNING, $exception->getSeverity()); + } $this->assertInstanceOf(SilencedErrorContext::class, $exception); - $this->assertSame(E_NOTICE, $exception->getSeverity()); $this->assertSame(__FILE__, $exception->getFile()); $this->assertSame($line, $exception->getLine()); $this->assertNotEmpty($exception->getTrace()); @@ -265,8 +276,13 @@ class ErrorHandlerTest extends TestCase ; $handler = ErrorHandler::register(); - $handler->setDefaultLogger($logger, E_NOTICE); - $handler->screamAt(E_NOTICE); + if (\PHP_VERSION_ID < 80000) { + $handler->setDefaultLogger($logger, E_NOTICE); + $handler->screamAt(E_NOTICE); + } else { + $handler->setDefaultLogger($logger, E_WARNING); + $handler->screamAt(E_WARNING); + } unset($undefVar); $line = __LINE__ + 1; @$undefVar++; From 8adbadede7716ffbea90a5fdc4bcb3444258ab9c Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Fri, 22 May 2020 11:54:22 +0200 Subject: [PATCH 05/13] [Config] Removed implicit cast of ReflectionProperty to string. --- .../Component/Config/Resource/ReflectionClassResource.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Config/Resource/ReflectionClassResource.php b/src/Symfony/Component/Config/Resource/ReflectionClassResource.php index 4c8f89cd3f..cfab1f6c10 100644 --- a/src/Symfony/Component/Config/Resource/ReflectionClassResource.php +++ b/src/Symfony/Component/Config/Resource/ReflectionClassResource.php @@ -139,7 +139,11 @@ class ReflectionClassResource implements SelfCheckingResourceInterface, \Seriali $defaults = $class->getDefaultProperties(); foreach ($class->getProperties(\ReflectionProperty::IS_PUBLIC | \ReflectionProperty::IS_PROTECTED) as $p) { - yield $p->getDocComment().$p; + yield $p->getDocComment(); + yield $p->isDefault() ? '' : ''; + yield $p->isPublic() ? 'public' : 'protected'; + yield $p->isStatic() ? 'static' : ''; + yield '$'.$p->name; yield print_r(isset($defaults[$p->name]) && !\is_object($defaults[$p->name]) ? $defaults[$p->name] : null, true); } } From 593897c9e1fae362d4cea8e940e52d7ba034682b Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Fri, 22 May 2020 13:12:29 +0200 Subject: [PATCH 06/13] [Debug] php 8 does not pass $context to error handlers. --- .../Tests/Fixtures/ErrorHandlerThatUsesThePreviousOne.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Debug/Tests/Fixtures/ErrorHandlerThatUsesThePreviousOne.php b/src/Symfony/Component/Debug/Tests/Fixtures/ErrorHandlerThatUsesThePreviousOne.php index d449c40cc7..bb2fba51f0 100644 --- a/src/Symfony/Component/Debug/Tests/Fixtures/ErrorHandlerThatUsesThePreviousOne.php +++ b/src/Symfony/Component/Debug/Tests/Fixtures/ErrorHandlerThatUsesThePreviousOne.php @@ -15,8 +15,8 @@ class ErrorHandlerThatUsesThePreviousOne return $handler; } - public function handleError($type, $message, $file, $line, $context) + public function handleError() { - return \call_user_func(self::$previous, $type, $message, $file, $line, $context); + return \call_user_func_array(self::$previous, \func_get_args()); } } From 1bbfdcbb8dff99ad52cfa26300dca56d09d87a3c Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Fri, 22 May 2020 15:23:31 +0200 Subject: [PATCH 07/13] [HttpKernel] Prevent calling method_exists() with non-string values. --- .../Component/HttpKernel/Controller/ControllerResolver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php b/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php index e3a7211c1b..e01c725454 100644 --- a/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php +++ b/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php @@ -77,7 +77,7 @@ class ControllerResolver implements ArgumentResolverInterface, ControllerResolve throw new \InvalidArgumentException(sprintf('Controller "%s" for URI "%s" is not callable.', \get_class($controller), $request->getPathInfo())); } - if (false === strpos($controller, ':')) { + if (\is_string($controller) && false === strpos($controller, ':')) { if (method_exists($controller, '__invoke')) { return $this->instantiateController($controller); } elseif (\function_exists($controller)) { From d4045897d657afa39b8f57492ccac897786fb146 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Fri, 22 May 2020 15:42:59 +0200 Subject: [PATCH 08/13] [Intl] Fix call to ReflectionProperty::getValue() for static properties. --- .../Tests/NumberFormatter/AbstractNumberFormatterTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php index f64131a61b..ac317d21bf 100644 --- a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php @@ -602,7 +602,7 @@ abstract class AbstractNumberFormatterTest extends TestCase $r = new \ReflectionProperty('Symfony\Component\Intl\NumberFormatter\NumberFormatter', 'enSymbols'); $r->setAccessible(true); - $expected = $r->getValue('Symfony\Component\Intl\NumberFormatter\NumberFormatter'); + $expected = $r->getValue(); for ($i = 0; $i <= 17; ++$i) { $this->assertSame($expected[1][$i], $decimalFormatter->getSymbol($i)); @@ -619,7 +619,7 @@ abstract class AbstractNumberFormatterTest extends TestCase $r = new \ReflectionProperty('Symfony\Component\Intl\NumberFormatter\NumberFormatter', 'enTextAttributes'); $r->setAccessible(true); - $expected = $r->getValue('Symfony\Component\Intl\NumberFormatter\NumberFormatter'); + $expected = $r->getValue(); for ($i = 0; $i <= 5; ++$i) { $this->assertSame($expected[1][$i], $decimalFormatter->getTextAttribute($i)); From 7100c3ce1b8bfd2cffbbacfc376961da32c5a801 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Fri, 22 May 2020 16:26:18 +0200 Subject: [PATCH 09/13] [PropertyAccess] Parse php 8 TypeErrors correctly. --- .../PropertyAccess/PropertyAccessor.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php index 6f715d6204..3bb5d6dcf7 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php +++ b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php @@ -255,12 +255,15 @@ class PropertyAccessor implements PropertyAccessorInterface private static function throwInvalidArgumentException($message, $trace, $i, $previous = null) { - // the type mismatch is not caused by invalid arguments (but e.g. by an incompatible return type hint of the writer method) - if (0 !== strpos($message, 'Argument ')) { + if (!isset($trace[$i]['file']) || __FILE__ !== $trace[$i]['file']) { return; } - if (isset($trace[$i]['file']) && __FILE__ === $trace[$i]['file']) { + if (\PHP_VERSION_ID < 80000) { + if (0 !== strpos($message, 'Argument ')) { + return; + } + $pos = strpos($message, $delim = 'must be of the type ') ?: (strpos($message, $delim = 'must be an instance of ') ?: strpos($message, $delim = 'must implement interface ')); $pos += \strlen($delim); $j = strpos($message, ',', $pos); @@ -269,6 +272,12 @@ class PropertyAccessor implements PropertyAccessorInterface throw new InvalidArgumentException(sprintf('Expected argument of type "%s", "%s" given.', $message, 'NULL' === $type ? 'null' : $type), 0, $previous); } + + if (preg_match('/^\S+::\S+\(\): Argument #\d+ \(\$\S+\) must be of type (\S+), (\S+) given/', $message, $matches)) { + list(, $expectedType, $actualType) = $matches; + + throw new InvalidArgumentException(sprintf('Expected argument of type "%s", "%s" given.', $expectedType, 'NULL' === $actualType ? 'null' : $actualType), 0, $previous); + } } /** @@ -471,7 +480,7 @@ class PropertyAccessor implements PropertyAccessorInterface $result[self::VALUE] = $object->{$access[self::ACCESS_NAME]}(); } catch (\TypeError $e) { // handle uninitialized properties in PHP >= 7 - if (preg_match((sprintf('/^Return value of %s::%s\(\) must be of the type (\w+), null returned$/', preg_quote(\get_class($object)), $access[self::ACCESS_NAME])), $e->getMessage(), $matches)) { + if (preg_match((sprintf('/^Return value of %s::%s\(\) must be of (?:the )?type (\w+), null returned$/', preg_quote(\get_class($object)), $access[self::ACCESS_NAME])), $e->getMessage(), $matches)) { throw new AccessException(sprintf('The method "%s::%s()" returned "null", but expected type "%3$s". Did you forget to initialize a property or to make the return type nullable using "?%3$s"?', \get_class($object), $access[self::ACCESS_NAME], $matches[1]), 0, $e); } From 1da347e5ba96f3ebd5950aa0ac5540d51a1d5722 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Fri, 22 May 2020 14:25:04 +0200 Subject: [PATCH 10/13] [VarDumper] ReflectionFunction::isDisabled() is deprecated. --- src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php b/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php index 1543bbfdfa..067da6bbd3 100644 --- a/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php @@ -333,6 +333,10 @@ class ReflectionCaster private static function addMap(&$a, \Reflector $c, $map, $prefix = Caster::PREFIX_VIRTUAL) { foreach ($map as $k => $m) { + if (\PHP_VERSION_ID >= 80000 && 'isDisabled' === $k) { + continue; + } + if (method_exists($c, $m) && false !== ($m = $c->$m()) && null !== $m) { $a[$prefix.$k] = $m instanceof \Reflector ? $m->name : $m; } From 8f3f67f82aa0f23e8c0c709fa8f446b5dd75e9b4 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Fri, 22 May 2020 18:14:17 +0200 Subject: [PATCH 11/13] [Validator] Catch expected ValueError. --- .../Validator/Constraints/LengthValidator.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Validator/Constraints/LengthValidator.php b/src/Symfony/Component/Validator/Constraints/LengthValidator.php index 01955ed035..0c11dfca84 100644 --- a/src/Symfony/Component/Validator/Constraints/LengthValidator.php +++ b/src/Symfony/Component/Validator/Constraints/LengthValidator.php @@ -39,8 +39,14 @@ class LengthValidator extends ConstraintValidator $stringValue = (string) $value; - if (!$invalidCharset = !@mb_check_encoding($stringValue, $constraint->charset)) { - $length = mb_strlen($stringValue, $constraint->charset); + try { + $invalidCharset = !@mb_check_encoding($stringValue, $constraint->charset); + } catch (\ValueError $e) { + if (!str_starts_with($e->getMessage(), 'mb_check_encoding(): Argument #2 ($encoding) must be a valid encoding')) { + throw $e; + } + + $invalidCharset = true; } if ($invalidCharset) { @@ -54,6 +60,8 @@ class LengthValidator extends ConstraintValidator return; } + $length = mb_strlen($stringValue, $constraint->charset); + if (null !== $constraint->max && $length > $constraint->max) { $this->context->buildViolation($constraint->min == $constraint->max ? $constraint->exactMessage : $constraint->maxMessage) ->setParameter('{{ value }}', $this->formatValue($stringValue)) From b1db13728b6ef102d77c2355a5b0b7a0586340dd Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Fri, 22 May 2020 18:49:08 +0200 Subject: [PATCH 12/13] [DomCrawler] Catch expected ValueError. --- src/Symfony/Component/DomCrawler/Crawler.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index 1cc72cc132..1f8f993324 100644 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -193,10 +193,11 @@ class Crawler implements \Countable, \IteratorAggregate // Convert charset to HTML-entities to work around bugs in DOMDocument::loadHTML() $content = mb_convert_encoding($content, 'HTML-ENTITIES', $charset); } catch (\Exception $e) { + } catch (\ValueError $e) { + } finally { + restore_error_handler(); } - restore_error_handler(); - if ('' !== trim($content)) { @$dom->loadHTML($content); } From 1090738264e0ebc816ede60f42365c8694b8b165 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Fri, 22 May 2020 09:54:48 +0200 Subject: [PATCH 13/13] Skip Doctrine DBAL on php 8 until we have a compatible version. --- .../Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php | 7 +++++++ .../Tests/Security/User/EntityUserProviderTest.php | 7 +++++++ .../Validator/Constraints/UniqueEntityValidatorTest.php | 7 +++++++ .../SecurityBundle/Tests/Functional/SetAclCommandTest.php | 7 +++++++ .../Component/Cache/Tests/Adapter/PdoDbalAdapterTest.php | 5 +++++ .../Component/Cache/Tests/Simple/PdoDbalCacheTest.php | 5 +++++ src/Symfony/Component/Cache/composer.json | 2 +- 7 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php index 7bb57d707d..4d5691e223 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php @@ -61,6 +61,13 @@ class EntityTypeTest extends BaseTypeTest protected static $supportedFeatureSetVersion = 304; + public static function setUpBeforeClass() + { + if (\PHP_VERSION_ID >= 80000) { + self::markTestSkipped('Doctrine DBAL 2.x is incompatible with PHP 8.'); + } + } + protected function setUp() { $this->em = DoctrineTestHelper::createTestEntityManager(); diff --git a/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php index 8916f8fb92..e43940d85c 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php @@ -23,6 +23,13 @@ use Symfony\Bridge\Doctrine\Tests\Fixtures\User; class EntityUserProviderTest extends TestCase { + public static function setUpBeforeClass() + { + if (\PHP_VERSION_ID >= 80000) { + self::markTestSkipped('Doctrine DBAL 2.x is incompatible with PHP 8.'); + } + } + public function testRefreshUserGetsUserByPrimaryKey() { $em = DoctrineTestHelper::createTestEntityManager(); diff --git a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php index 77d1599990..ba772e58fd 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php @@ -63,6 +63,13 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase protected $repositoryFactory; + public static function setUpBeforeClass() + { + if (\PHP_VERSION_ID >= 80000) { + self::markTestSkipped('Doctrine DBAL 2.x is incompatible with PHP 8.'); + } + } + protected function setUp() { $this->repositoryFactory = new TestRepositoryFactory(); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SetAclCommandTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SetAclCommandTest.php index 8eb70c09c1..892a51f9bd 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SetAclCommandTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SetAclCommandTest.php @@ -40,6 +40,13 @@ class SetAclCommandTest extends AbstractWebTestCase const OBJECT_CLASS = 'Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\AclBundle\Entity\Car'; const SECURITY_CLASS = 'Symfony\Component\Security\Core\User\User'; + public static function setUpBeforeClass() + { + if (\PHP_VERSION_ID >= 80000) { + self::markTestSkipped('Doctrine DBAL 2.x is incompatible with PHP 8.'); + } + } + public function testSetAclUser() { $objectId = 1; diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PdoDbalAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PdoDbalAdapterTest.php index aa53958cfa..351972da48 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PdoDbalAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PdoDbalAdapterTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Cache\Tests\Adapter; use Doctrine\DBAL\DriverManager; +use Doctrine\DBAL\Version; use Symfony\Component\Cache\Adapter\PdoAdapter; use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait; @@ -30,6 +31,10 @@ class PdoDbalAdapterTest extends AdapterTestCase self::markTestSkipped('Extension pdo_sqlite required.'); } + if (\PHP_VERSION_ID >= 80000 && class_exists(Version::class)) { + self::markTestSkipped('Doctrine DBAL 2.x is incompatible with PHP 8.'); + } + self::$dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_cache'); $pool = new PdoAdapter(DriverManager::getConnection(['driver' => 'pdo_sqlite', 'path' => self::$dbFile])); diff --git a/src/Symfony/Component/Cache/Tests/Simple/PdoDbalCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/PdoDbalCacheTest.php index 4da2b603cf..79fd97a752 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/PdoDbalCacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/PdoDbalCacheTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Cache\Tests\Simple; use Doctrine\DBAL\DriverManager; +use Doctrine\DBAL\Version; use Symfony\Component\Cache\Simple\PdoCache; use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait; @@ -30,6 +31,10 @@ class PdoDbalCacheTest extends CacheTestCase self::markTestSkipped('Extension pdo_sqlite required.'); } + if (\PHP_VERSION_ID >= 80000 && class_exists(Version::class)) { + self::markTestSkipped('Doctrine DBAL 2.x is incompatible with PHP 8.'); + } + self::$dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_cache'); $pool = new PdoCache(DriverManager::getConnection(['driver' => 'pdo_sqlite', 'path' => self::$dbFile])); diff --git a/src/Symfony/Component/Cache/composer.json b/src/Symfony/Component/Cache/composer.json index e13cd96751..3d82799e00 100644 --- a/src/Symfony/Component/Cache/composer.json +++ b/src/Symfony/Component/Cache/composer.json @@ -29,7 +29,7 @@ "require-dev": { "cache/integration-tests": "dev-master", "doctrine/cache": "~1.6", - "doctrine/dbal": "~2.4", + "doctrine/dbal": "~2.4|~3.0", "predis/predis": "~1.0" }, "conflict": {