From af13c0d441fa56bbb70dc512e27b728f8915a2f4 Mon Sep 17 00:00:00 2001 From: Max Baldanza Date: Fri, 16 Sep 2022 14:29:21 +0100 Subject: [PATCH] Add support for PHP8 --- .gitignore | 1 + DependencyInjection/Configuration.php | 4 ++-- Tests/Assetic/TwigFormulaLoaderTest.php | 2 +- Tests/CacheWarmer/TemplateFinderTest.php | 2 +- .../TemplatePathsCacheWarmerTest.php | 4 ++-- Tests/Controller/ThemeControllerTest.php | 24 ++++++------------- .../Compiler/AsseticTwigFormulaPassTest.php | 2 +- .../ThemeControllerListenerTest.php | 2 +- Tests/Twig/Loader/FilesystemLoaderTest.php | 7 ++++++ composer.json | 16 ++++++------- 10 files changed, 31 insertions(+), 33 deletions(-) diff --git a/.gitignore b/.gitignore index f2c9c5c..132f5f2 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ composer.phar composer.lock phpunit.xml /.idea +.phpunit.result.cache diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index e77bd9f..94e692a 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -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') diff --git a/Tests/Assetic/TwigFormulaLoaderTest.php b/Tests/Assetic/TwigFormulaLoaderTest.php index c55b419..73440b0 100644 --- a/Tests/Assetic/TwigFormulaLoaderTest.php +++ b/Tests/Assetic/TwigFormulaLoaderTest.php @@ -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'); diff --git a/Tests/CacheWarmer/TemplateFinderTest.php b/Tests/CacheWarmer/TemplateFinderTest.php index fcf054f..3bb9e8f 100644 --- a/Tests/CacheWarmer/TemplateFinderTest.php +++ b/Tests/CacheWarmer/TemplateFinderTest.php @@ -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'); diff --git a/Tests/CacheWarmer/TemplatePathsCacheWarmerTest.php b/Tests/CacheWarmer/TemplatePathsCacheWarmerTest.php index 8b3426a..9d600d3 100644 --- a/Tests/CacheWarmer/TemplatePathsCacheWarmerTest.php +++ b/Tests/CacheWarmer/TemplatePathsCacheWarmerTest.php @@ -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'; @@ -64,7 +64,7 @@ public function setUp() ->getMock(); } - protected function tearDown() + protected function tearDown(): void { parent::tearDown(); @unlink($this->templateCacheFile); diff --git a/Tests/Controller/ThemeControllerTest.php b/Tests/Controller/ThemeControllerTest.php index 45e136b..829ede5 100644 --- a/Tests/Controller/ThemeControllerTest.php +++ b/Tests/Controller/ThemeControllerTest.php @@ -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; @@ -112,7 +112,7 @@ public function testSwitchActionWithNotFoundTheme() $controller->switchAction($this->createRequestWithWrongTheme()); } - protected function setUp() + protected function setUp(): void { parent::setUp(); @@ -120,7 +120,7 @@ protected function setUp() ComparatorFactory::getInstance()->register($this->symfonyResponseComparator); } - protected function tearDown() + protected function tearDown(): void { ComparatorFactory::getInstance()->unregister($this->symfonyResponseComparator); $this->symfonyResponseComparator = null; @@ -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), @@ -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'); @@ -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; } diff --git a/Tests/DependencyInjection/Compiler/AsseticTwigFormulaPassTest.php b/Tests/DependencyInjection/Compiler/AsseticTwigFormulaPassTest.php index 3181e23..06eb289 100644 --- a/Tests/DependencyInjection/Compiler/AsseticTwigFormulaPassTest.php +++ b/Tests/DependencyInjection/Compiler/AsseticTwigFormulaPassTest.php @@ -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() diff --git a/Tests/EventListener/ThemeControllerListenerTest.php b/Tests/EventListener/ThemeControllerListenerTest.php index 5532186..5df97ae 100644 --- a/Tests/EventListener/ThemeControllerListenerTest.php +++ b/Tests/EventListener/ThemeControllerListenerTest.php @@ -27,7 +27,7 @@ class ThemeControllerListenerTest extends \PHPUnit\Framework\TestCase */ private $request; - protected function setUp() + protected function setUp(): void { $this->request = Request::create('/foo'); } diff --git a/Tests/Twig/Loader/FilesystemLoaderTest.php b/Tests/Twig/Loader/FilesystemLoaderTest.php index 72bf17c..aec5187 100644 --- a/Tests/Twig/Loader/FilesystemLoaderTest.php +++ b/Tests/Twig/Loader/FilesystemLoaderTest.php @@ -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); @@ -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); diff --git a/composer.json b/composer.json index 0d1b5d8..b953865 100644 --- a/composer.json +++ b/composer.json @@ -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\\": "" }