From 76949b068d1b3756ffac8abb1ba758fcb979a6a3 Mon Sep 17 00:00:00 2001 From: chris Date: Thu, 14 Mar 2024 10:30:06 +0100 Subject: [PATCH] Drop support fot PHP < 8.1 (#297) Co-authored-by: Christopher Georg --- .github/workflows/ci.yml | 8 ++-- composer.json | 30 ++++++------- src/DependencyInjection/Configuration.php | 5 +-- tests/App/Kernel.php | 4 +- .../Compiler/FilesystemPassTest.php | 10 ++--- .../OneupFlysystemExtensionTest.php | 18 ++++---- tests/Model/ContainerAwareTestCase.php | 44 ------------------- 7 files changed, 36 insertions(+), 83 deletions(-) delete mode 100644 tests/Model/ContainerAwareTestCase.php diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 098044d..fec719a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@2.30.0 with: - php-version: 8.0 + php-version: 8.1 extensions: dom, fileinfo, filter, gd, hash, intl, json, mbstring, pcre, pdo, zlib coverage: none @@ -36,8 +36,8 @@ jobs: strategy: fail-fast: false matrix: - php: [8.0, 8.1, 8.2, 8.3] - symfony: [4.4, 5.4, 6.0, 7.0] + php: [8.1, 8.2, 8.3] + symfony: [5.4, 6.0, 7.0] exclude: - symfony: 7.0 php: 8.0 @@ -68,7 +68,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@2.30.0 with: - php-version: 8.0 + php-version: 8.1 extensions: dom, fileinfo, filter, gd, hash, intl, json, mbstring, pcre, pdo_mysql, zlib coverage: none diff --git a/composer.json b/composer.json index 2eca759..a1c9261 100644 --- a/composer.json +++ b/composer.json @@ -25,15 +25,15 @@ } ], "require": { - "php": "^8.0", + "php": "^8.1", "league/flysystem": "^2.0 || ^3.0", - "symfony/config": "^4.4 || ^5.3 || ^6.0 || ^7.0", - "symfony/dependency-injection": "^4.4 || ^5.3 || ^6.0 || ^7.0", - "symfony/http-kernel": "^4.4 || ^5.3 || ^6.0 || ^7.0" + "symfony/config": "^5.4 || ^6.0 || ^7.0", + "symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0", + "symfony/http-kernel": "^5.4 || ^6.0 || ^7.0" }, "require-dev": { "ext-simplexml": "*", - "friendsofphp/php-cs-fixer": "^2.16 || ^3.5", + "friendsofphp/php-cs-fixer": "^3.51", "league/flysystem-async-aws-s3": "^2.0 || ^3.0", "league/flysystem-aws-s3-v3": "^2.0 || ^3.0", "league/flysystem-ftp": "^2.0 || ^3.0", @@ -41,17 +41,17 @@ "league/flysystem-memory": "^2.0 || ^3.0", "league/flysystem-sftp-v3": "^2.0 || ^3.0", "league/flysystem-azure-blob-storage": "^3.0", - "phpstan/phpstan": "^1.4", - "phpunit/phpunit": "^9.5", + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^9.6.17", "royvoetman/flysystem-gitlab-storage": "^2.0 || ^3.0", - "symfony/asset": "^4.4 || ^5.3 || ^6.0 || ^7.0", - "symfony/browser-kit": "^4.4 || ^5.3 || ^6.0 || ^7.0", - "symfony/finder": "^4.4 || ^5.3 || ^6.0 || ^7.0", - "symfony/framework-bundle": "^4.4 || ^5.3 || ^6.0 || ^7.0", - "symfony/phpunit-bridge": "^6.0 || ^7.0", - "symfony/templating": "^4.4 || ^5.3 || ^6.0 || ^7.0", - "symfony/translation": "^4.4 || ^5.3 || ^6.0 || ^7.0", - "symfony/yaml": "^4.4 || ^5.3 || ^6.0 || ^7.0" + "symfony/asset": "^5.4 || ^6.0 || ^7.0", + "symfony/browser-kit": "^5.4 || ^6.0 || ^7.0", + "symfony/finder": "^5.4 || ^6.0 || ^7.0", + "symfony/framework-bundle": "^5.4 || ^6.0 || ^7.0", + "symfony/phpunit-bridge": "^7.0", + "symfony/templating": "^5.4 || ^6.0 || ^7.0", + "symfony/translation": "^5.4 || ^6.0 || ^7.0", + "symfony/yaml": "^5.4 || ^6.0 || ^7.0" }, "suggest": { "ext-fileinfo": "Required for MimeType", diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index b0d1eb3..7c3e077 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -11,11 +11,8 @@ class Configuration implements ConfigurationInterface { - protected array $adapterFactories; - - public function __construct(array $adapterFactories) + public function __construct(protected array $adapterFactories) { - $this->adapterFactories = $adapterFactories; } public function getConfigTreeBuilder(): TreeBuilder diff --git a/tests/App/Kernel.php b/tests/App/Kernel.php index 9ea6ad6..c7831f6 100644 --- a/tests/App/Kernel.php +++ b/tests/App/Kernel.php @@ -12,10 +12,10 @@ class Kernel extends BaseKernel public function registerBundles(): iterable { return [ - new FrameworkBundle(), + yield new FrameworkBundle(), // Test this Bundle - new OneupFlysystemBundle(), + yield new OneupFlysystemBundle(), ]; } diff --git a/tests/DependencyInjection/Compiler/FilesystemPassTest.php b/tests/DependencyInjection/Compiler/FilesystemPassTest.php index ced9938..f7d1325 100644 --- a/tests/DependencyInjection/Compiler/FilesystemPassTest.php +++ b/tests/DependencyInjection/Compiler/FilesystemPassTest.php @@ -6,18 +6,18 @@ use League\Flysystem\Filesystem; use League\Flysystem\MountManager; -use Oneup\FlysystemBundle\Tests\Model\ContainerAwareTestCase; +use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -final class FilesystemPassTest extends ContainerAwareTestCase +final class FilesystemPassTest extends WebTestCase { public function testMountIdentifiers(): void { /** @var MountManager $mountManager */ - $mountManager = $this->getContainer()->get('oneup_flysystem.mount_manager'); + $mountManager = self::getContainer()->get('oneup_flysystem.mount_manager'); /** @var Filesystem $filesystem1 */ - $filesystem1 = $this->getContainer()->get('oneup_flysystem.myfilesystem_filesystem'); + $filesystem1 = self::getContainer()->get('oneup_flysystem.myfilesystem_filesystem'); /** @var Filesystem $filesystem2 */ - $filesystem2 = $this->getContainer()->get('oneup_flysystem.myfilesystem2_filesystem'); + $filesystem2 = self::getContainer()->get('oneup_flysystem.myfilesystem2_filesystem'); self::assertFalse($filesystem1->fileExists('foo')); self::assertFalse($filesystem2->fileExists('bar')); diff --git a/tests/DependencyInjection/OneupFlysystemExtensionTest.php b/tests/DependencyInjection/OneupFlysystemExtensionTest.php index 7dc2677..259b451 100644 --- a/tests/DependencyInjection/OneupFlysystemExtensionTest.php +++ b/tests/DependencyInjection/OneupFlysystemExtensionTest.php @@ -11,10 +11,10 @@ use League\Flysystem\StorageAttributes; use League\Flysystem\Visibility; use Oneup\FlysystemBundle\DependencyInjection\OneupFlysystemExtension; -use Oneup\FlysystemBundle\Tests\Model\ContainerAwareTestCase; +use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Component\DependencyInjection\ContainerBuilder; -class OneupFlysystemExtensionTest extends ContainerAwareTestCase +class OneupFlysystemExtensionTest extends WebTestCase { public function testIfTestSuiteLoads(): void { @@ -28,21 +28,21 @@ public function testVisibilitySettings(): void * * @var Filesystem $filesystem1 */ - $filesystem1 = $this->getContainer()->get('oneup_flysystem.myfilesystem_filesystem'); + $filesystem1 = self::getContainer()->get('oneup_flysystem.myfilesystem_filesystem'); /** * Visibility flag is set to "public". * * @var Filesystem $filesystem2 */ - $filesystem2 = $this->getContainer()->get('oneup_flysystem.myfilesystem2_filesystem'); + $filesystem2 = self::getContainer()->get('oneup_flysystem.myfilesystem2_filesystem'); /** * Visibility flag is set to "private". * * @var Filesystem $filesystem3 */ - $filesystem3 = $this->getContainer()->get('oneup_flysystem.myfilesystem3_filesystem'); + $filesystem3 = self::getContainer()->get('oneup_flysystem.myfilesystem3_filesystem'); $filesystem1->write('1/meep', 'meep\'s content'); $filesystem2->write('2/meep', 'meep\'s content'); @@ -68,14 +68,14 @@ public function testDirectoryVisibilitySettings(): void * * @var Filesystem $filesystem5 */ - $filesystem5 = $this->getContainer()->get('oneup_flysystem.myfilesystem5_filesystem'); + $filesystem5 = self::getContainer()->get('oneup_flysystem.myfilesystem5_filesystem'); /** * Visibility flag is set to "public". * * @var Filesystem $filesystem6 */ - $filesystem6 = $this->getContainer()->get('oneup_flysystem.myfilesystem6_filesystem'); + $filesystem6 = self::getContainer()->get('oneup_flysystem.myfilesystem6_filesystem'); $filesystem5->createDirectory('5'); $filesystem6->createDirectory('6'); @@ -186,7 +186,7 @@ public function testServiceAliasWithoutFilesystemSuffix(): void public function testServiceAliasInjection(): void { /** @var TestService $testService */ - $testService = $this->getContainer()->get(TestService::class); + $testService = self::getContainer()->get(TestService::class); self::assertInstanceOf(TestService::class, $testService); self::assertInstanceOf(Filesystem::class, $testService->filesystem); @@ -194,7 +194,7 @@ public function testServiceAliasInjection(): void public function testGoogleCloudAdapter(): void { - $this->assertInstanceOf(Filesystem::class, $this->getContainer()->get('oneup_flysystem.myfilesystem4_filesystem')); + $this->assertInstanceOf(Filesystem::class, self::getContainer()->get('oneup_flysystem.myfilesystem4_filesystem')); } private function loadExtension(array $config): ContainerBuilder diff --git a/tests/Model/ContainerAwareTestCase.php b/tests/Model/ContainerAwareTestCase.php deleted file mode 100644 index 25c87c9..0000000 --- a/tests/Model/ContainerAwareTestCase.php +++ /dev/null @@ -1,44 +0,0 @@ -client = static::createClient(); - if (property_exists($this, 'container')) { - /* @phpstan-ignore-next-line */ - self::$container = $this->client->getContainer(); - } - } - - protected function tearDown(): void - { - parent::tearDown(); - - unset($this->client); - } - - /** - * BC layer: to be removed once sf <5.3 will not be supported anymore. - */ - protected static function getContainer(): Container - { - if (\is_callable('parent::getContainer')) { - /* @phpstan-ignore-next-line */ - return parent::getContainer(); - } - - /* @phpstan-ignore-next-line */ - return self::$container; - } -}