From 265feb3c23f32fff73613102f92c98fd4d7bb826 Mon Sep 17 00:00:00 2001 From: Tac Tacelosky Date: Sat, 1 Jan 2022 10:27:21 -0500 Subject: [PATCH] Symfony 6 support, #3 (#4) --- .github/workflows/ci.yml | 7 ++-- .php_cs.dist => .php-cs-fixer.dist.php | 0 README.md | 6 ++-- composer.json | 4 +-- fixtures/Functional/AppKernel.php | 2 +- fixtures/Functional/ConfigurableKernel.php | 2 +- fixtures/Functional/SimpleKernel.php | 4 +-- fixtures/Functional/TestKernel.php | 2 +- fixtures/Functional/WithoutDoctrineKernel.php | 2 +- fixtures/HttpKernel/DummyKernel.php | 36 ++++++++++++------- fixtures/Resolver/ResolverKernel.php | 2 +- src/PhpUnit/RecreateDatabaseTrait.php | 3 +- src/PhpUnit/RefreshDatabaseTrait.php | 4 ++- src/PhpUnit/ReloadDatabaseTrait.php | 4 ++- .../HautelookAliceBundleTest.php | 2 +- tests/PhpUnit/RefreshTestTrait.php | 2 +- 16 files changed, 49 insertions(+), 33 deletions(-) rename .php_cs.dist => .php-cs-fixer.dist.php (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4d19e31a..c937db26 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - extensions: intl, bcmath, curl, openssl, mbstring + extensions: intl, bcmath, curl, openssl, mbstring ini-values: memory_limit=-1 tools: composer, php-cs-fixer coverage: none @@ -42,6 +42,7 @@ jobs: php: - '7.4' - '8.0' + - '8.1' include: - php: '7.4' coverage: true @@ -65,7 +66,7 @@ jobs: with: php-version: ${{ matrix.php }} tools: pecl, composer - extensions: intl, bcmath, curl, openssl, mbstring + extensions: intl, bcmath, curl, openssl, mbstring coverage: pcov ini-values: memory_limit=-1 - name: Get composer cache directory @@ -114,7 +115,7 @@ jobs: with: php-version: ${{ matrix.php }} tools: pecl, composer - extensions: intl, bcmath, curl, openssl, mbstring + extensions: intl, bcmath, curl, openssl, mbstring coverage: pcov ini-values: memory_limit=-1 - name: Get composer cache directory diff --git a/.php_cs.dist b/.php-cs-fixer.dist.php similarity index 100% rename from .php_cs.dist rename to .php-cs-fixer.dist.php diff --git a/README.md b/README.md index 23d55ae7..cb7c5e45 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ With [Symfony Flex](https://symfony.com/doc/current/setup/flex.html) (recommende # If you do not have Doctrine installed yet: composer require doctrine-orm -composer require --dev hautelook/alice-bundle +composer require --dev hautelook/alice-bundle ``` You're ready to use AliceBundle, and can jump to the next section! @@ -85,14 +85,14 @@ wherever your Kernel class is located: getEnvironment(), ['dev', 'test'])) { //... $bundles[] = new Nelmio\Alice\Bridge\Symfony\NelmioAliceBundle(); diff --git a/composer.json b/composer.json index 290969f2..3d3964fe 100644 --- a/composer.json +++ b/composer.json @@ -37,8 +37,8 @@ "doctrine/orm": "^2.5.11", "doctrine/persistence": "^1.3.4 || ^2.0", "psr/log": "^1.0 || ^2.0 || ^3.0", - "symfony/finder": "^3.4 || ^4.0 || ^5.0", - "symfony/framework-bundle": "^3.4.24 || ^4.0 || ^5.0", + "symfony/finder": "^3.4 || ^4.0 || ^5.0 || ^6.0", + "symfony/framework-bundle": "^3.4.24 || ^4.0 || ^5.0 || ^6.0", "theofidry/alice-data-fixtures": "^1.4" }, "require-dev": { diff --git a/fixtures/Functional/AppKernel.php b/fixtures/Functional/AppKernel.php index 4738f29a..803abfbe 100644 --- a/fixtures/Functional/AppKernel.php +++ b/fixtures/Functional/AppKernel.php @@ -27,7 +27,7 @@ class AppKernel extends Kernel /** * {@inheritdoc} */ - public function registerBundles() + public function registerBundles(): iterable { return [ new FrameworkBundle(), diff --git a/fixtures/Functional/ConfigurableKernel.php b/fixtures/Functional/ConfigurableKernel.php index 0d7dd9ea..756ed803 100644 --- a/fixtures/Functional/ConfigurableKernel.php +++ b/fixtures/Functional/ConfigurableKernel.php @@ -27,7 +27,7 @@ class ConfigurableKernel extends Kernel /** * {@inheritdoc} */ - public function registerBundles() + public function registerBundles(): iterable { return array_merge( [ diff --git a/fixtures/Functional/SimpleKernel.php b/fixtures/Functional/SimpleKernel.php index ddd20355..9dbde72d 100644 --- a/fixtures/Functional/SimpleKernel.php +++ b/fixtures/Functional/SimpleKernel.php @@ -28,7 +28,7 @@ class SimpleKernel extends Kernel /** * {@inheritdoc} */ - public function registerBundles() + public function registerBundles(): iterable { return [ new SimpleBundle(), @@ -50,7 +50,7 @@ public function setLocateResourceFirst(bool $overrideFirst = null) /** * {@inheritdoc} */ - public function locateResource($name, $dir = null, $first = true) + public function locateResource($name, $dir = null, $first = true): string { if (null !== $this->overrideFirst) { $first = $this->overrideFirst; diff --git a/fixtures/Functional/TestKernel.php b/fixtures/Functional/TestKernel.php index 5849b2aa..5caf29fe 100644 --- a/fixtures/Functional/TestKernel.php +++ b/fixtures/Functional/TestKernel.php @@ -28,7 +28,7 @@ */ class TestKernel extends Kernel { - public function registerBundles() + public function registerBundles(): iterable { return [ new FrameworkBundle(), diff --git a/fixtures/Functional/WithoutDoctrineKernel.php b/fixtures/Functional/WithoutDoctrineKernel.php index 30e79443..fb5044fb 100644 --- a/fixtures/Functional/WithoutDoctrineKernel.php +++ b/fixtures/Functional/WithoutDoctrineKernel.php @@ -27,7 +27,7 @@ class WithoutDoctrineKernel extends Kernel /** * {@inheritdoc} */ - public function registerBundles() + public function registerBundles(): iterable { return array_merge( [ diff --git a/fixtures/HttpKernel/DummyKernel.php b/fixtures/HttpKernel/DummyKernel.php index 36fd865c..535f1628 100644 --- a/fixtures/HttpKernel/DummyKernel.php +++ b/fixtures/HttpKernel/DummyKernel.php @@ -13,7 +13,10 @@ use Hautelook\AliceBundle\NotCallableTrait; use Symfony\Component\DependencyInjection\Container; +use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\Bundle\BundleInterface; use Symfony\Component\HttpKernel\KernelInterface; /** @@ -42,7 +45,7 @@ public function unserialize($serialized) /** * {@inheritdoc} */ - public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true) + public function handle(Request $request, $type = self::MAIN_REQUEST, $catch = true): Response { $this->__call(__METHOD__, \func_get_args()); } @@ -50,7 +53,7 @@ public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = /** * {@inheritdoc} */ - public function registerBundles() + public function registerBundles(): iterable { $this->__call(__METHOD__, \func_get_args()); } @@ -82,7 +85,7 @@ public function shutdown() /** * {@inheritdoc} */ - public function getBundles() + public function getBundles(): array { return []; } @@ -90,7 +93,7 @@ public function getBundles() /** * {@inheritdoc} */ - public function getBundle($name, $first = true) + public function getBundle($name, $first = true): BundleInterface { $this->__call(__METHOD__, \func_get_args()); } @@ -98,7 +101,7 @@ public function getBundle($name, $first = true) /** * {@inheritdoc} */ - public function locateResource($name, $dir = null, $first = true) + public function locateResource($name, $dir = null, $first = true): string { $this->__call(__METHOD__, \func_get_args()); } @@ -114,7 +117,7 @@ public function getName() /** * {@inheritdoc} */ - public function getEnvironment() + public function getEnvironment(): string { return 'fake_env'; } @@ -122,7 +125,7 @@ public function getEnvironment() /** * {@inheritdoc} */ - public function isDebug() + public function isDebug(): bool { return true; } @@ -138,7 +141,7 @@ public function getRootDir() /** * {@inheritdoc} */ - public function getContainer() + public function getContainer(): ContainerInterface { return new Container(); } @@ -146,7 +149,7 @@ public function getContainer() /** * {@inheritdoc} */ - public function getStartTime() + public function getStartTime(): float { $this->__call(__METHOD__, \func_get_args()); } @@ -154,7 +157,7 @@ public function getStartTime() /** * {@inheritdoc} */ - public function getCacheDir() + public function getCacheDir(): string { $this->__call(__METHOD__, \func_get_args()); } @@ -162,7 +165,7 @@ public function getCacheDir() /** * {@inheritdoc} */ - public function getLogDir() + public function getLogDir(): string { $this->__call(__METHOD__, \func_get_args()); } @@ -170,7 +173,7 @@ public function getLogDir() /** * {@inheritdoc} */ - public function getCharset() + public function getCharset(): string { $this->__call(__METHOD__, \func_get_args()); } @@ -186,8 +189,15 @@ public function isClassInActiveBundle($class) /** * {@inheritdoc} */ - public function getProjectDir() + public function getProjectDir(): string { $this->__call(__METHOD__, \func_get_args()); } + + public function getBuildDir(): string + { + // TODO: Implement getBuildDir() method. + } + + } diff --git a/fixtures/Resolver/ResolverKernel.php b/fixtures/Resolver/ResolverKernel.php index 5bcb0e19..abaeaa41 100644 --- a/fixtures/Resolver/ResolverKernel.php +++ b/fixtures/Resolver/ResolverKernel.php @@ -22,7 +22,7 @@ class ResolverKernel extends Kernel /** * {@inheritdoc} */ - public function registerBundles() + public function registerBundles(): iterable { return [ new ABundle(), diff --git a/src/PhpUnit/RecreateDatabaseTrait.php b/src/PhpUnit/RecreateDatabaseTrait.php index 30620c64..10d35b5d 100644 --- a/src/PhpUnit/RecreateDatabaseTrait.php +++ b/src/PhpUnit/RecreateDatabaseTrait.php @@ -15,6 +15,7 @@ use Doctrine\ORM\Tools\SchemaTool; use Doctrine\ORM\Tools\ToolsException; +use Symfony\Component\HttpKernel\KernelInterface; /** * Erase and recreate database schema before each tests. (All existing data will be lost!). @@ -25,7 +26,7 @@ trait RecreateDatabaseTrait { use BaseDatabaseTrait; - protected static function bootKernel(array $options = []) + protected static function bootKernel(array $options = []): KernelInterface { static::ensureKernelTestCase(); $kernel = parent::bootKernel($options); diff --git a/src/PhpUnit/RefreshDatabaseTrait.php b/src/PhpUnit/RefreshDatabaseTrait.php index e796ffcd..60102f3f 100644 --- a/src/PhpUnit/RefreshDatabaseTrait.php +++ b/src/PhpUnit/RefreshDatabaseTrait.php @@ -13,6 +13,8 @@ namespace Hautelook\AliceBundle\PhpUnit; +use Symfony\Component\HttpKernel\KernelInterface; + /** * Purges and loads the fixtures before the first test and wraps all test in a transaction that will be roll backed when * it has finished. @@ -25,7 +27,7 @@ trait RefreshDatabaseTrait protected static $dbPopulated = false; - protected static function bootKernel(array $options = []) + protected static function bootKernel(array $options = []): KernelInterface { static::ensureKernelTestCase(); $kernel = parent::bootKernel($options); diff --git a/src/PhpUnit/ReloadDatabaseTrait.php b/src/PhpUnit/ReloadDatabaseTrait.php index bcb33ab2..b70d6a32 100644 --- a/src/PhpUnit/ReloadDatabaseTrait.php +++ b/src/PhpUnit/ReloadDatabaseTrait.php @@ -13,6 +13,8 @@ namespace Hautelook\AliceBundle\PhpUnit; +use Symfony\Component\HttpKernel\KernelInterface; + /** * Purges and loads the fixtures before every tests. * @@ -22,7 +24,7 @@ trait ReloadDatabaseTrait { use BaseDatabaseTrait; - protected static function bootKernel(array $options = []) + protected static function bootKernel(array $options = []): KernelInterface { static::ensureKernelTestCase(); $kernel = parent::bootKernel($options); diff --git a/tests/DependencyInjection/HautelookAliceBundleTest.php b/tests/DependencyInjection/HautelookAliceBundleTest.php index 5a0715a3..62ab9256 100644 --- a/tests/DependencyInjection/HautelookAliceBundleTest.php +++ b/tests/DependencyInjection/HautelookAliceBundleTest.php @@ -140,7 +140,7 @@ public function testServiceRegistration() /** * {@inheritdoc} */ - protected static function getKernelClass() + protected static function getKernelClass(): string { return AppKernel::class; } diff --git a/tests/PhpUnit/RefreshTestTrait.php b/tests/PhpUnit/RefreshTestTrait.php index 9565671b..39173d24 100644 --- a/tests/PhpUnit/RefreshTestTrait.php +++ b/tests/PhpUnit/RefreshTestTrait.php @@ -41,7 +41,7 @@ public function testShouldBeRefreshed() $this->assertInitialState($this->getManager()); } - protected static function getKernelClass() + protected static function getKernelClass(): string { return TestKernel::class; }