Skip to content

Commit

Permalink
feature #45377 Bump minimum version of PHP to 8.1 (nicolas-grekas)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the 6.1 branch.

Discussion
----------

Bump minimum version of PHP to 8.1

| Q             | A
| ------------- | ---
| Branch?       | 6.1
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #44364
| License       | MIT
| Doc PR        | -

While reviewing #44380, I wondered: why should we maintain such a complex piece of logic while only PHP 8.0 is affected?
So here we are: what about bumping Symfony 6.1 to PHP 8.1 minimum?
That would free ourselves from maintaining this workaround.

The good news is that Ubuntu 22.04LTS will ship PHP 8.1, so that it's going to be easy to have it widely installed.

Also, looking at https://packagist.org/packages/symfony/framework-bundle/php-stats#6.0, early adopters of Symfony 6 are already using PHP 8.1 en masse, and it's growing fast.

Let's do it?

Commits
-------

b0217c6 Bump minimum version of PHP to 8.1
  • Loading branch information
fabpot committed Feb 25, 2022
2 parents 8b23089 + b0217c6 commit 08fa74a
Show file tree
Hide file tree
Showing 418 changed files with 516 additions and 1,256 deletions.
12 changes: 6 additions & 6 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ init:

install:
- mkdir c:\php && cd c:\php
- appveyor DownloadFile https://github.com/symfony/binary-utils/releases/download/v0.1/php-8.0.2-Win32-vs16-x86.zip
- 7z x php-8.0.2-Win32-vs16-x86.zip -y >nul
- appveyor DownloadFile https://github.com/symfony/binary-utils/releases/download/v0.1/php-8.1.0-Win32-vs16-x86.zip
- 7z x php-8.1.0-Win32-vs16-x86.zip -y >nul
- cd ext
- appveyor DownloadFile https://github.com/symfony/binary-utils/releases/download/v0.1/php_apcu-5.1.21-8.0-ts-vs16-x86.zip
- 7z x php_apcu-5.1.21-8.0-ts-vs16-x86.zip -y >nul
- appveyor DownloadFile https://github.com/symfony/binary-utils/releases/download/v0.1/php_redis-5.3.5-8.0-ts-vs16-x86.zip
- 7z x php_redis-5.3.5-8.0-ts-vs16-x86.zip -y >nul
- appveyor DownloadFile https://github.com/symfony/binary-utils/releases/download/v0.1/php_apcu-5.1.21-8.1-ts-vs16-x86.zip
- 7z x php_apcu-5.1.21-8.1-ts-vs16-x86.zip -y >nul
- appveyor DownloadFile https://github.com/symfony/binary-utils/releases/download/v0.1/php_redis-5.3.7rc1-8.1-ts-vs16-x86.zip
- 7z x php_redis-5.3.7rc1-8.1-ts-vs16-x86.zip -y >nul
- cd ..
- copy /Y php.ini-development php.ini-min
- echo memory_limit=-1 >> php.ini-min
Expand Down
65 changes: 38 additions & 27 deletions .github/expected-missing-return-types.diff
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
# Run these steps to update this file:
sed -i 's/ *"\*\*\/Tests\/"//' composer.json
composer u -o
SYMFONY_PATCH_TYPE_DECLARATIONS='force=2&php=8.0' php .github/patch-types.php
SYMFONY_PATCH_TYPE_DECLARATIONS='force=2&php=8.1' php .github/patch-types.php
head=$(sed '/^diff /Q' .github/expected-missing-return-types.diff)
(echo "$head" && echo && git diff -U2 composer.json src/) > .github/expected-missing-return-types.diff
(echo "$head" && echo && git diff -U2 src/) > .github/expected-missing-return-types.diff
git checkout composer.json src/

diff --git a/composer.json b/composer.json
index c7b7eac4c7..2b60fb6a19 100644
--- a/composer.json
+++ b/composer.json
@@ -180,5 +180,5 @@
],
"exclude-from-classmap": [
- "**/Tests/"
+
]
},
diff --git a/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php b/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php
index d68ae4c8b3..8e980a9e70 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php
Expand Down Expand Up @@ -60,6 +49,17 @@ index 697e34cb77..9a1e4c5618 100644
+ protected function filterResponse(object $response): Response
{
return $response;
diff --git a/src/Symfony/Component/Config/Definition/Builder/NodeBuilder.php b/src/Symfony/Component/Config/Definition/Builder/NodeBuilder.php
index 89d6adb70e..c569992efc 100644
--- a/src/Symfony/Component/Config/Definition/Builder/NodeBuilder.php
+++ b/src/Symfony/Component/Config/Definition/Builder/NodeBuilder.php
@@ -108,5 +108,5 @@ class NodeBuilder implements NodeParentInterface
* @return NodeDefinition&ParentNodeDefinitionInterface
*/
- public function end()
+ public function end(): NodeDefinition&ParentNodeDefinitionInterface
{
return $this->parent;
diff --git a/src/Symfony/Component/Config/Definition/ConfigurationInterface.php b/src/Symfony/Component/Config/Definition/ConfigurationInterface.php
index 7b5d443fe6..d64ae0d024 100644
--- a/src/Symfony/Component/Config/Definition/ConfigurationInterface.php
Expand Down Expand Up @@ -156,7 +156,7 @@ index 6b1c6c5fbe..bb80ed461e 100644
+ public function isFresh(ResourceInterface $resource, int $timestamp): bool;
}
diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php
index 0ed5649b8a..6c814bf82c 100644
index c654b93790..ce744f5c6d 100644
--- a/src/Symfony/Component/Console/Application.php
+++ b/src/Symfony/Component/Console/Application.php
@@ -218,5 +218,5 @@ class Application implements ResetInterface
Expand Down Expand Up @@ -209,17 +209,17 @@ index 0ed5649b8a..6c814bf82c 100644
{
foreach ($command->getHelperSet() as $helper) {
diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php
index 0bd3426c07..b38caf989e 100644
index e84307207a..bc503462c1 100644
--- a/src/Symfony/Component/Console/Command/Command.php
+++ b/src/Symfony/Component/Console/Command/Command.php
@@ -171,5 +171,5 @@ class Command
@@ -187,5 +187,5 @@ class Command
* @return bool
*/
- public function isEnabled()
+ public function isEnabled(): bool
{
return true;
@@ -197,5 +197,5 @@ class Command
@@ -213,5 +213,5 @@ class Command
* @see setCode()
*/
- protected function execute(InputInterface $input, OutputInterface $output)
Expand Down Expand Up @@ -297,7 +297,7 @@ index c2824f4578..032f5c2318 100644
{
if (\is_array($value)) {
diff --git a/src/Symfony/Component/DependencyInjection/Container.php b/src/Symfony/Component/DependencyInjection/Container.php
index b9dd838898..3a8cb63eac 100644
index f9820f5ede..d28a418429 100644
--- a/src/Symfony/Component/DependencyInjection/Container.php
+++ b/src/Symfony/Component/DependencyInjection/Container.php
@@ -108,5 +108,5 @@ class Container implements ContainerInterface, ResetInterface
Expand All @@ -308,7 +308,7 @@ index b9dd838898..3a8cb63eac 100644
{
return $this->parameterBag->get($name);
diff --git a/src/Symfony/Component/DependencyInjection/ContainerInterface.php b/src/Symfony/Component/DependencyInjection/ContainerInterface.php
index aa5d6b317e..31ffbca4ef 100644
index cad44026c0..14cd192e07 100644
--- a/src/Symfony/Component/DependencyInjection/ContainerInterface.php
+++ b/src/Symfony/Component/DependencyInjection/ContainerInterface.php
@@ -53,5 +53,5 @@ interface ContainerInterface extends PsrContainerInterface
Expand Down Expand Up @@ -635,6 +635,17 @@ index 125b6eae50..ac327e8981 100644
+ public function createLockFromKey(Key $key, ?float $ttl = 300.0, bool $autoRelease = true): SharedLockInterface
{
$lock = new Lock($key, $this->store, $ttl, $autoRelease);
diff --git a/src/Symfony/Component/Messenger/Bridge/AmazonSqs/Transport/AmazonSqsTransport.php b/src/Symfony/Component/Messenger/Bridge/AmazonSqs/Transport/AmazonSqsTransport.php
index 297fccbd3f..4c47d95b38 100644
--- a/src/Symfony/Component/Messenger/Bridge/AmazonSqs/Transport/AmazonSqsTransport.php
+++ b/src/Symfony/Component/Messenger/Bridge/AmazonSqs/Transport/AmazonSqsTransport.php
@@ -109,5 +109,5 @@ class AmazonSqsTransport implements TransportInterface, SetupableTransportInterf
* @return MessageCountAwareInterface&ReceiverInterface
*/
- private function getReceiver(): ReceiverInterface
+ private function getReceiver(): MessageCountAwareInterface&ReceiverInterface
{
return $this->receiver ??= new AmazonSqsReceiver($this->connection, $this->serializer);
diff --git a/src/Symfony/Component/OptionsResolver/OptionsResolver.php b/src/Symfony/Component/OptionsResolver/OptionsResolver.php
index 205c15b4cd..e93e460ed1 100644
--- a/src/Symfony/Component/OptionsResolver/OptionsResolver.php
Expand Down Expand Up @@ -720,10 +731,10 @@ index fbb37d9f94..522e0487a9 100644
+ public function isIndex(int $index): bool;
}
diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php
index cfffdb2f71..3e2261898a 100644
index 972d169caa..0b6dae1abe 100644
--- a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php
+++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php
@@ -725,5 +725,5 @@ class PropertyAccessorTest extends TestCase
@@ -743,5 +743,5 @@ class PropertyAccessorTest extends TestCase
* @return mixed
*/
- public function getFoo()
Expand Down Expand Up @@ -923,7 +934,7 @@ index 7f86ed8d78..cf084423ec 100644
{
if (null !== $object = $this->extractObjectToPopulate($class, $context, self::OBJECT_TO_POPULATE)) {
diff --git a/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php
index a8943113c4..2983dabd0f 100644
index 1abdb634ce..d2e7f41562 100644
--- a/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php
+++ b/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php
@@ -138,5 +138,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
Expand All @@ -940,35 +951,35 @@ index a8943113c4..2983dabd0f 100644
+ public function normalize(mixed $object, string $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
{
if (!isset($context['cache_key'])) {
@@ -279,5 +279,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
@@ -280,5 +280,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
* {@inheritdoc}
*/
- protected function instantiateObject(array &$data, string $class, array &$context, \ReflectionClass $reflectionClass, array|bool $allowedAttributes, string $format = null)
+ protected function instantiateObject(array &$data, string $class, array &$context, \ReflectionClass $reflectionClass, array|bool $allowedAttributes, string $format = null): object
{
if ($this->classDiscriminatorResolver && $mapping = $this->classDiscriminatorResolver->getMappingForClass($class)) {
@@ -341,5 +341,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
@@ -342,5 +342,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
* @return string[]
*/
- abstract protected function extractAttributes(object $object, string $format = null, array $context = []);
+ abstract protected function extractAttributes(object $object, string $format = null, array $context = []): array;

/**
@@ -348,5 +348,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
@@ -349,5 +349,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
* @return mixed
*/
- abstract protected function getAttributeValue(object $object, string $attribute, string $format = null, array $context = []);
+ abstract protected function getAttributeValue(object $object, string $attribute, string $format = null, array $context = []): mixed;

/**
@@ -355,5 +355,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
@@ -356,5 +356,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
* @param array $context
*/
- public function supportsDenormalization(mixed $data, string $type, string $format = null /*, array $context = [] */)
+ public function supportsDenormalization(mixed $data, string $type, string $format = null /*, array $context = [] */): bool
{
return class_exists($type) || (interface_exists($type, false) && $this->classDiscriminatorResolver && null !== $this->classDiscriminatorResolver->getMappingForClass($type));
@@ -363,5 +363,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
@@ -364,5 +364,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
* {@inheritdoc}
*/
- public function denormalize(mixed $data, string $type, string $format = null, array $context = [])
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

strategy:
matrix:
php: ['8.0']
php: ['8.1']

services:
postgres:
Expand Down Expand Up @@ -129,7 +129,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
coverage: "none"
extensions: "json,couchbase,memcached,mongodb-1.10.0,redis-5.3.4,rdkafka,xsl,ldap"
extensions: "json,couchbase,memcached,mongodb-1.12.0,redis-5.3.4,rdkafka,xsl,ldap"
ini-values: date.timezone=Europe/Paris,memory_limit=-1,default_socket_timeout=10,session.gc_probability=0,apc.enable_cli=1,zend.assertions=1
php-version: "${{ matrix.php }}"
tools: pecl
Expand All @@ -153,7 +153,7 @@ jobs:
echo COMPOSER_ROOT_VERSION=$COMPOSER_ROOT_VERSION >> $GITHUB_ENV
echo "::group::composer update"
composer require --dev --no-update mongodb/mongodb:"1.9.1@dev|^1.9.1@stable"
composer require --dev --no-update mongodb/mongodb:"^1.11"
composer update --no-progress --ansi
echo "::endgroup::"
Expand All @@ -176,11 +176,11 @@ jobs:
POSTGRES_HOST: localhost

#- name: Run HTTP push tests
# if: matrix.php == '8.0'
# if: matrix.php == '8.1'
# run: |
# [ -d .phpunit ] && mv .phpunit .phpunit.bak
# wget -q https://github.com/symfony/binary-utils/releases/download/v0.1/vulcain_0.1.3_Linux_x86_64.tar.gz -O - | tar xz && mv vulcain /usr/local/bin
# docker run --rm -e COMPOSER_ROOT_VERSION -v $(pwd):/app -v $(which composer):/usr/local/bin/composer -v $(which vulcain):/usr/local/bin/vulcain -w /app php:8.0-alpine ./phpunit src/Symfony/Component/HttpClient/Tests/CurlHttpClientTest.php --filter testHttp2Push
# docker run --rm -e COMPOSER_ROOT_VERSION -v $(pwd):/app -v $(which composer):/usr/local/bin/composer -v $(which vulcain):/usr/local/bin/vulcain -w /app php:8.1-alpine ./phpunit src/Symfony/Component/HttpClient/Tests/CurlHttpClientTest.php --filter testHttp2Push
# sudo rm -rf .phpunit
# [ -d .phpunit.bak ] && mv .phpunit.bak .phpunit

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/intl-data-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
coverage: "none"
extensions: "zip,intl-${{env.SYMFONY_ICU_VERSION}}"
ini-values: "memory_limit=-1"
php-version: "8.0"
php-version: "8.1"

- name: Install dependencies
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/psalm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
php-version: '8.1'
extensions: "json,couchbase,memcached,mongodb,redis,xsl,ldap,dom"
ini-values: "memory_limit=-1"
coverage: none
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
matrix:
include:
- php: '8.1'
- php: '8.0'
- php: '8.1'
mode: high-deps
- php: '8.1'
mode: low-deps
Expand Down Expand Up @@ -144,8 +144,8 @@ jobs:
patch -sp1 < .github/expected-missing-return-types.diff
git add .
composer install -q --optimize-autoloader
SYMFONY_PATCH_TYPE_DECLARATIONS='force=2&php=8.0' php .github/patch-types.php
SYMFONY_PATCH_TYPE_DECLARATIONS='force=2&php=8.0' php .github/patch-types.php # ensure the script is idempotent
SYMFONY_PATCH_TYPE_DECLARATIONS='force=2&php=8.1' php .github/patch-types.php
SYMFONY_PATCH_TYPE_DECLARATIONS='force=2&php=8.1' php .github/patch-types.php # ensure the script is idempotent
git diff --exit-code
- name: Run tests
Expand Down Expand Up @@ -222,12 +222,12 @@ jobs:
script -e -c './phpunit --group tty' /dev/null
- name: Run tests with SIGCHLD enabled PHP
if: "matrix.php == '8.0' && ! matrix.mode"
if: "matrix.php == '8.1' && ! matrix.mode"
run: |
mkdir build
cd build
wget -q https://github.com/symfony/binary-utils/releases/download/v0.1/php-8.0.2-pcntl-sigchild.tar.bz2
tar -xjf php-8.0.2-pcntl-sigchild.tar.bz2
wget -q https://github.com/symfony/binary-utils/releases/download/v0.1/php-8.1.2-pcntl-sigchild.tar.bz2
tar -xjf php-8.1.2-pcntl-sigchild.tar.bz2
cd ..
./build/php/bin/php ./phpunit --colors=always src/Symfony/Component/Process
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"symfony/translation-implementation": "2.3|3.0"
},
"require": {
"php": ">=8.0.2",
"php": ">=8.1",
"composer-runtime-api": ">=2.1",
"ext-xml": "*",
"friendsofphp/proxy-manager-lts": "^1.0.2",
Expand All @@ -51,7 +51,6 @@
"symfony/polyfill-intl-idn": "^1.10",
"symfony/polyfill-intl-normalizer": "~1.0",
"symfony/polyfill-mbstring": "~1.0",
"symfony/polyfill-php81": "^1.23",
"symfony/polyfill-uuid": "^1.15"
},
"replace": {
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public function configureOptions(OptionsResolver $resolver)
$choiceValue = function (Options $options) {
// If the entity has a single-column ID, use that ID as value
if ($options['id_reader'] instanceof IdReader && $options['id_reader']->isSingleId()) {
return ChoiceList::value($this, [$options['id_reader'], 'getIdValue'], $options['id_reader']);
return ChoiceList::value($this, $options['id_reader']->getIdValue(...), $options['id_reader']);
}

// Otherwise, an incrementing integer is used as value automatically
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function getQueryBuilderPartsForCachingHash(object $queryBuilder): ?array

return [
$queryBuilder->getQuery()->getSQL(),
array_map([$this, 'parameterToArray'], $queryBuilder->getParameters()->toArray()),
array_map($this->parameterToArray(...), $queryBuilder->getParameters()->toArray()),
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ public function testFixManagersAutoMappingsWithTwoAutomappings()

$reflection = new \ReflectionClass(\get_class($this->extension));
$method = $reflection->getMethod('fixManagersAutoMappings');
$method->setAccessible(true);

$method->invoke($this->extension, $emConfigs, $bundles);
}
Expand Down Expand Up @@ -168,7 +167,6 @@ public function testFixManagersAutoMappings(array $originalEm1, array $originalE

$reflection = new \ReflectionClass(\get_class($this->extension));
$method = $reflection->getMethod('fixManagersAutoMappings');
$method->setAccessible(true);

$newEmConfigs = $method->invoke($this->extension, $emConfigs, $bundles);

Expand All @@ -186,7 +184,6 @@ public function testMappingTypeDetection()

$reflection = new \ReflectionClass(\get_class($this->extension));
$method = $reflection->getMethod('detectMappingType');
$method->setAccessible(true);

// The ordinary fixtures contain annotation
$mappingType = $method->invoke($this->extension, __DIR__.'/../Fixtures', $container);
Expand Down Expand Up @@ -329,7 +326,6 @@ public function testBundleAutoMapping(string $bundle, string $expectedType, stri

$reflection = new \ReflectionClass(\get_class($this->extension));
$method = $reflection->getMethod('getMappingDriverBundleConfigDefaults');
$method->setAccessible(true);

$this->assertSame(
[
Expand All @@ -347,8 +343,6 @@ protected function invokeLoadCacheDriver(array $objectManager, ContainerBuilder
{
$method = new \ReflectionMethod($this->extension, 'loadObjectManagerCacheDriver');

$method->setAccessible(true);

$method->invokeArgs($this->extension, [$objectManager, $container, $cacheName]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1310,10 +1310,7 @@ public function testLoaderCachingWithParameters()
$this->assertSame($choiceList1, $choiceList3);
}

/**
* @return MockObject&ManagerRegistry
*/
protected function createRegistryMock($name, $em): ManagerRegistry
protected function createRegistryMock($name, $em): MockObject&ManagerRegistry
{
$registry = $this->createMock(ManagerRegistry::class);
$registry->expects($this->any())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,6 @@ public function testExtractWithEmbedded()
$this->assertEquals($expectedTypes, $actualTypes);
}

/**
* @requires PHP 8.1
*/
public function testExtractEnum()
{
if (!property_exists(Column::class, 'enumType')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,6 @@ public function testLoadClassMetadata()
$this->assertSame(AutoMappingStrategy::DISABLED, $noAutoMappingMetadata[0]->getAutoMappingStrategy());
}

/**
* @requires PHP 8.1
*/
public function testExtractEnum()
{
if (!property_exists(Column::class, 'enumType')) {
Expand Down
Loading

0 comments on commit 08fa74a

Please sign in to comment.