Skip to content

Commit

Permalink
Symfony 6 support, #3 (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
tacman authored Jan 1, 2022
1 parent ada5be3 commit 265feb3
Show file tree
Hide file tree
Showing 16 changed files with 49 additions and 33 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -42,6 +42,7 @@ jobs:
php:
- '7.4'
- '8.0'
- '8.1'
include:
- php: '7.4'
coverage: true
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand All @@ -85,14 +85,14 @@ wherever your Kernel class is located:
<?php
// app/AppKernel.php

public function registerBundles()
public function registerBundles(): iterable
{
$bundles = [
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
// ...
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
];

if (in_array($this->getEnvironment(), ['dev', 'test'])) {
//...
$bundles[] = new Nelmio\Alice\Bridge\Symfony\NelmioAliceBundle();
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion fixtures/Functional/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class AppKernel extends Kernel
/**
* {@inheritdoc}
*/
public function registerBundles()
public function registerBundles(): iterable
{
return [
new FrameworkBundle(),
Expand Down
2 changes: 1 addition & 1 deletion fixtures/Functional/ConfigurableKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ConfigurableKernel extends Kernel
/**
* {@inheritdoc}
*/
public function registerBundles()
public function registerBundles(): iterable
{
return array_merge(
[
Expand Down
4 changes: 2 additions & 2 deletions fixtures/Functional/SimpleKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SimpleKernel extends Kernel
/**
* {@inheritdoc}
*/
public function registerBundles()
public function registerBundles(): iterable
{
return [
new SimpleBundle(),
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion fixtures/Functional/TestKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*/
class TestKernel extends Kernel
{
public function registerBundles()
public function registerBundles(): iterable
{
return [
new FrameworkBundle(),
Expand Down
2 changes: 1 addition & 1 deletion fixtures/Functional/WithoutDoctrineKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class WithoutDoctrineKernel extends Kernel
/**
* {@inheritdoc}
*/
public function registerBundles()
public function registerBundles(): iterable
{
return array_merge(
[
Expand Down
36 changes: 23 additions & 13 deletions fixtures/HttpKernel/DummyKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -42,15 +45,15 @@ 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());
}

/**
* {@inheritdoc}
*/
public function registerBundles()
public function registerBundles(): iterable
{
$this->__call(__METHOD__, \func_get_args());
}
Expand Down Expand Up @@ -82,23 +85,23 @@ public function shutdown()
/**
* {@inheritdoc}
*/
public function getBundles()
public function getBundles(): array
{
return [];
}

/**
* {@inheritdoc}
*/
public function getBundle($name, $first = true)
public function getBundle($name, $first = true): BundleInterface
{
$this->__call(__METHOD__, \func_get_args());
}

/**
* {@inheritdoc}
*/
public function locateResource($name, $dir = null, $first = true)
public function locateResource($name, $dir = null, $first = true): string
{
$this->__call(__METHOD__, \func_get_args());
}
Expand All @@ -114,15 +117,15 @@ public function getName()
/**
* {@inheritdoc}
*/
public function getEnvironment()
public function getEnvironment(): string
{
return 'fake_env';
}

/**
* {@inheritdoc}
*/
public function isDebug()
public function isDebug(): bool
{
return true;
}
Expand All @@ -138,39 +141,39 @@ public function getRootDir()
/**
* {@inheritdoc}
*/
public function getContainer()
public function getContainer(): ContainerInterface
{
return new Container();
}

/**
* {@inheritdoc}
*/
public function getStartTime()
public function getStartTime(): float
{
$this->__call(__METHOD__, \func_get_args());
}

/**
* {@inheritdoc}
*/
public function getCacheDir()
public function getCacheDir(): string
{
$this->__call(__METHOD__, \func_get_args());
}

/**
* {@inheritdoc}
*/
public function getLogDir()
public function getLogDir(): string
{
$this->__call(__METHOD__, \func_get_args());
}

/**
* {@inheritdoc}
*/
public function getCharset()
public function getCharset(): string
{
$this->__call(__METHOD__, \func_get_args());
}
Expand All @@ -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.
}


}
2 changes: 1 addition & 1 deletion fixtures/Resolver/ResolverKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ResolverKernel extends Kernel
/**
* {@inheritdoc}
*/
public function registerBundles()
public function registerBundles(): iterable
{
return [
new ABundle(),
Expand Down
3 changes: 2 additions & 1 deletion src/PhpUnit/RecreateDatabaseTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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!).
Expand All @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion src/PhpUnit/RefreshDatabaseTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion src/PhpUnit/ReloadDatabaseTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

namespace Hautelook\AliceBundle\PhpUnit;

use Symfony\Component\HttpKernel\KernelInterface;

/**
* Purges and loads the fixtures before every tests.
*
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tests/DependencyInjection/HautelookAliceBundleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public function testServiceRegistration()
/**
* {@inheritdoc}
*/
protected static function getKernelClass()
protected static function getKernelClass(): string
{
return AppKernel::class;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/PhpUnit/RefreshTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function testShouldBeRefreshed()
$this->assertInitialState($this->getManager());
}

protected static function getKernelClass()
protected static function getKernelClass(): string
{
return TestKernel::class;
}
Expand Down

0 comments on commit 265feb3

Please sign in to comment.