From fc935136dfc6d6736bb1b36a3d1df4c1524f5c46 Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Mon, 15 Jul 2024 15:27:27 +0200 Subject: [PATCH 1/5] Fix ThemeCollector Symfony 7 compatibility --- tests/Collector/ThemeCollectorTest.php | 54 ++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 tests/Collector/ThemeCollectorTest.php diff --git a/tests/Collector/ThemeCollectorTest.php b/tests/Collector/ThemeCollectorTest.php new file mode 100644 index 0000000..2b24781 --- /dev/null +++ b/tests/Collector/ThemeCollectorTest.php @@ -0,0 +1,54 @@ +createThemeCollector(); + + $this->assertNull($themeCollector->getUsedTheme()); + } + + private function createThemeCollector(): ThemeCollector + { + $themeLoader = new class () implements ThemeLoaderInterface { + public function load(): array + { + return []; + } + }; + + $themeRepository = new InMemoryThemeRepository($themeLoader); + $themeContext = new EmptyThemeContext(); + $themeHierarchyProvider = new NoopThemeHierarchyProvider(); + + return new ThemeCollector( + $themeRepository, + $themeContext, + $themeHierarchyProvider, + ); + } +} From cbdfa3897a7ceb6d421849aa87d663ab7713a9e5 Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Mon, 15 Jul 2024 15:28:34 +0200 Subject: [PATCH 2/5] Add test case with ThemeCollector --- src/Collector/ThemeCollector.php | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/Collector/ThemeCollector.php b/src/Collector/ThemeCollector.php index f5debd2..284ce7d 100644 --- a/src/Collector/ThemeCollector.php +++ b/src/Collector/ThemeCollector.php @@ -21,6 +21,10 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\DataCollector\DataCollector; +/** + * @property $data array{used_theme: ?ThemeInterface, used_themes: ThemeInterface[], themes: ThemeInterface[]} + + */ final class ThemeCollector extends DataCollector { private ThemeRepositoryInterface $themeRepository; @@ -29,15 +33,6 @@ final class ThemeCollector extends DataCollector private ThemeHierarchyProviderInterface $themeHierarchyProvider; - /** - * @var array - * - * @psalm-var array{used_theme: ?ThemeInterface, used_themes: ThemeInterface[], themes: ThemeInterface[]} - * - * @psalm-suppress NonInvariantDocblockPropertyType - */ - protected $data; - public function __construct( ThemeRepositoryInterface $themeRepository, ThemeContextInterface $themeContext, From bcf4eaf1d620c26cf04e795687dd192327b5e508 Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Mon, 15 Jul 2024 15:36:06 +0200 Subject: [PATCH 3/5] Fix PHPDoc for getUsedThemes --- src/Collector/ThemeCollector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Collector/ThemeCollector.php b/src/Collector/ThemeCollector.php index 284ce7d..a464e9c 100644 --- a/src/Collector/ThemeCollector.php +++ b/src/Collector/ThemeCollector.php @@ -55,7 +55,7 @@ public function getUsedTheme(): ?ThemeInterface } /** - * @return array|ThemeInterface[] + * @return ThemeInterface[] */ public function getUsedThemes(): array { From 288b7bb6d2a973322f3da6dbbb8af732be5a2f3c Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Mon, 15 Jul 2024 16:25:09 +0200 Subject: [PATCH 4/5] Lint building of container --- composer.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f5e5c36..70018c4 100644 --- a/composer.json +++ b/composer.json @@ -80,7 +80,9 @@ "@composer validate --strict", "vendor/bin/ecs check spec src tests || true", "vendor/bin/psalm", - "vendor/bin/rector process --dry-run" + "vendor/bin/rector process --dry-run", + "tests/Application/bin/console lint:container --env dev", + "tests/Application/bin/console lint:container --env prod" ], "fix": [ "vendor/bin/rector process", From f14350171517019409546a7177a39fd9b4d3e3a4 Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Thu, 18 Jul 2024 13:31:27 +0200 Subject: [PATCH 5/5] Apply suggestions from code review Co-authored-by: Grzegorz Sadowski --- src/Collector/ThemeCollector.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Collector/ThemeCollector.php b/src/Collector/ThemeCollector.php index a464e9c..6be3ae7 100644 --- a/src/Collector/ThemeCollector.php +++ b/src/Collector/ThemeCollector.php @@ -23,7 +23,6 @@ /** * @property $data array{used_theme: ?ThemeInterface, used_themes: ThemeInterface[], themes: ThemeInterface[]} - */ final class ThemeCollector extends DataCollector {