Skip to content

Commit

Permalink
Merge pull request #1 from mybuilder/php-8
Browse files Browse the repository at this point in the history
Add support for PHP8
  • Loading branch information
maxbaldanza authored Sep 16, 2022
2 parents ff45b9a + af13c0d commit a477c03
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 33 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ composer.phar
composer.lock
phpunit.xml
/.idea
.phpunit.result.cache
4 changes: 2 additions & 2 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class Configuration implements ConfigurationInterface
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('liip_theme', 'array');
$treeBuilder = new TreeBuilder('liip_theme');
$rootNode = $treeBuilder->getRootNode();
$rootNode
->children()
->arrayNode('themes')
Expand Down
2 changes: 1 addition & 1 deletion Tests/Assetic/TwigFormulaLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class TwigFormulaLoaderTest extends \PHPUnit\Framework\TestCase
*/
private $loader;

public function setUp()
public function setUp(): void
{
if (!class_exists(\Assetic\AssetManager::class)) {
$this->markTestSkipped('Assetic not supported');
Expand Down
2 changes: 1 addition & 1 deletion Tests/CacheWarmer/TemplateFinderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class TemplateFinderTest extends \PHPUnit\Framework\TestCase
*/
private $templateReference;

public function setUp()
public function setUp(): void
{
parent::setUp();
$this->kernel = $this->getMockForAbstractClass('\Symfony\Component\HttpKernel\KernelInterface');
Expand Down
4 changes: 2 additions & 2 deletions Tests/CacheWarmer/TemplatePathsCacheWarmerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class TemplatePathsCacheWarmerTest extends \PHPUnit\Framework\TestCase
private $cacheDir;
private $templateCacheFile;

public function setUp()
public function setUp(): void
{
parent::setUp();
$this->cacheDir = __DIR__.'/../Fixtures/cachedir';
Expand All @@ -64,7 +64,7 @@ public function setUp()
->getMock();
}

protected function tearDown()
protected function tearDown(): void
{
parent::tearDown();
@unlink($this->templateCacheFile);
Expand Down
24 changes: 7 additions & 17 deletions Tests/Controller/ThemeControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Liip\ThemeBundle\ActiveTheme;
use Liip\ThemeBundle\Controller\ThemeController;
use Liip\ThemeBundle\Tests\Common\Comparator\SymfonyResponse as SymfonyResponseComparator;
use PHPUnit\Framework\MockObject\Matcher\Invocation;
use PHPUnit\Framework\MockObject\Rule\InvokedCount;
use SebastianBergmann\Comparator\Factory as ComparatorFactory;
use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\HttpFoundation\RedirectResponse;
Expand Down Expand Up @@ -112,15 +112,15 @@ public function testSwitchActionWithNotFoundTheme()
$controller->switchAction($this->createRequestWithWrongTheme());
}

protected function setUp()
protected function setUp(): void
{
parent::setUp();

$this->symfonyResponseComparator = new SymfonyResponseComparator();
ComparatorFactory::getInstance()->register($this->symfonyResponseComparator);
}

protected function tearDown()
protected function tearDown(): void
{
ComparatorFactory::getInstance()->unregister($this->symfonyResponseComparator);
$this->symfonyResponseComparator = null;
Expand All @@ -129,11 +129,9 @@ protected function tearDown()
}

/**
* @param Invocation $activeThemeInvocation
* @param mixed[]|null $cookieOptions
* @return ThemeController
*/
private function createThemeController(Invocation $activeThemeInvocation, array $cookieOptions = null)
private function createThemeController(InvokedCount $activeThemeInvocation, array $cookieOptions = null): ThemeController
{
return new ThemeController(
$this->createActiveThemeMock($activeThemeInvocation),
Expand All @@ -142,11 +140,7 @@ private function createThemeController(Invocation $activeThemeInvocation, array
);
}

/**
* @param Invocation $invocation
* @return ActiveTheme
*/
private function createActiveThemeMock(Invocation $invocation)
private function createActiveThemeMock(InvokedCount $invocation): ActiveTheme
{
$mock = $this->createMock('\Liip\ThemeBundle\ActiveTheme');

Expand All @@ -167,13 +161,9 @@ private function createRequest($referer)
{
$request = new Request(array('theme' => self::RIGHT_THEME));

$request->headers->add(
array('Referer' => array($referer))
);
$request->headers->add(['Referer' => ($referer)]);

$request->server->add(
array('REQUEST_TIME' => self::REQUEST_TIME)
);
$request->server->add(['REQUEST_TIME' => self::REQUEST_TIME]);

return $request;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class AsseticTwigFormulaPassTest extends \PHPUnit\Framework\TestCase
private $definition;
private $pass;

public function setUp()
public function setUp(): void
{
$this->container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')
->disableOriginalConstructor()
Expand Down
2 changes: 1 addition & 1 deletion Tests/EventListener/ThemeControllerListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ThemeControllerListenerTest extends \PHPUnit\Framework\TestCase
*/
private $request;

protected function setUp()
protected function setUp(): void
{
$this->request = Request::create('/foo');
}
Expand Down
7 changes: 7 additions & 0 deletions Tests/Twig/Loader/FilesystemLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public function testGetSourceContextWithLocator()
->method('locate')
->will($this->returnValue(__DIR__.'/Fixtures/Resources/views/layout.html.twig'));

$parser
->method('parse')
->willReturn('');

$loader = new FilesystemLoader($locator, $parser);
$loader->setActiveTheme($activeTheme);
Expand All @@ -38,6 +41,10 @@ public function testGetSourceContextWithFallback()
->method('locate')
->willThrowException(new \RuntimeException());

$parser
->method('parse')
->willReturn('');

$loader = new FilesystemLoader($locator, $parser);
$loader->addPath(__DIR__.'/Fixtures/Resources/views', 'namespace');
$loader->setActiveTheme($activeTheme);
Expand Down
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
}
],
"require": {
"php": "^7.0",
"symfony/framework-bundle": "^3.0|^4.0",
"symfony/finder": "^3.0|^4.0",
"symfony/twig-bundle": "^3.0|^4.0",
"symfony/templating": "^3.0|^4.0",
"php": ">=7.4",
"symfony/framework-bundle": "^4.0",
"symfony/finder": "^4.0",
"symfony/twig-bundle": "^4.0",
"symfony/templating": "^4.0",
"twig/twig": "^1.34|^2.4",
"psr/log": "~1.0"
},
"require-dev": {
"phpunit/phpunit": "^6.0",
"symfony/console": "^3.0|^4.0",
"symfony/expression-language": "^3.0|^4.0"
"phpunit/phpunit": "^8.0",
"symfony/console": "^4.0",
"symfony/expression-language": "^4.0"
},
"autoload": {
"psr-4": { "Liip\\ThemeBundle\\": "" }
Expand Down

0 comments on commit a477c03

Please sign in to comment.