From 63485b4d56de444aedf67da18ec27e8700e90bdc Mon Sep 17 00:00:00 2001 From: matx132 Date: Fri, 26 Jul 2024 16:28:01 +0200 Subject: [PATCH] Corrected CS --- phpstan-baseline.neon | 5 ----- .../Events/Content/BeforeLoadContentEvent.php | 8 +++++++- tests/lib/Event/ContentServiceTest.php | 20 +++---------------- 3 files changed, 10 insertions(+), 23 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 32145a6105..43e60a3254 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -62664,8 +62664,3 @@ parameters: message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Specification\\\\Content\\\\ContentTypeSpecificationTest\\:\\:providerForIsSatisfiedBy\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 path: tests/lib/Specification/Content/ContentTypeSpecificationTest.php - - - - message: "#^Method Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Events\\\\Content\\\\BeforeLoadContentEvent\\:\\:getContent\\(\\) should return Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Content but returns Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Content\\|null\\.$#" - count: 1 - path: src/contracts/Repository/Events/Content/BeforeLoadContentEvent.php \ No newline at end of file diff --git a/src/contracts/Repository/Events/Content/BeforeLoadContentEvent.php b/src/contracts/Repository/Events/Content/BeforeLoadContentEvent.php index f92029d286..c8910b5279 100644 --- a/src/contracts/Repository/Events/Content/BeforeLoadContentEvent.php +++ b/src/contracts/Repository/Events/Content/BeforeLoadContentEvent.php @@ -66,7 +66,12 @@ public function getUseAlwaysAvailable(): bool public function getContent(): Content { if (!$this->hasContent()) { - throw new UnexpectedValueException(sprintf('Return value is not set or not of type %s. Check hasContent() or set it using setContent() before you call the getter.', Content::class)); + throw new UnexpectedValueException( + sprintf( + 'Return value is not set or not of type %s. Check hasContent() or set it using setContent() before you call the getter.', + Content::class + ) + ); } return $this->content; @@ -77,6 +82,7 @@ public function setContent(?Content $content): void $this->content = $content; } + /** @phpstan-assert-if-true !null $this->content */ public function hasContent(): bool { return $this->content instanceof Content; diff --git a/tests/lib/Event/ContentServiceTest.php b/tests/lib/Event/ContentServiceTest.php index f85d9919e1..84fd020e88 100644 --- a/tests/lib/Event/ContentServiceTest.php +++ b/tests/lib/Event/ContentServiceTest.php @@ -1162,19 +1162,12 @@ public function testLoadContentEvents(): void null ); - $parameters = [ - 2, - [], - null, - true, - ]; - $content = $this->createMock(Content::class); $innerServiceMock = $this->createMock(ContentServiceInterface::class); $innerServiceMock->method('loadContent')->willReturn($content); $service = new ContentService($innerServiceMock, $traceableEventDispatcher); - $result = $service->loadContent(...$parameters); + $result = $service->loadContent(2, []); $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); @@ -1209,7 +1202,7 @@ public function testReturnLoadContentResultInBeforeEvents(): void }, 10); $service = new ContentService($innerServiceMock, $traceableEventDispatcher); - $result = $service->loadContent(...$parameters); + $result = $service->loadContent(2, []); $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); @@ -1228,13 +1221,6 @@ public function testLoadContentStopPropagationInBeforeEvents(): void null ); - $parameters = [ - 2, - [], - null, - true, - ]; - $content = $this->createMock(Content::class); $eventContent = $this->createMock(Content::class); $innerServiceMock = $this->createMock(ContentServiceInterface::class); @@ -1246,7 +1232,7 @@ public function testLoadContentStopPropagationInBeforeEvents(): void }, 10); $service = new ContentService($innerServiceMock, $traceableEventDispatcher); - $result = $service->loadContent(...$parameters); + $result = $service->loadContent(2, []); $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners());