Skip to content

Commit

Permalink
Corrected CS
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszdebinski committed Jul 26, 2024
1 parent a94c6b8 commit 63485b4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 23 deletions.
5 changes: 0 additions & 5 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
20 changes: 3 additions & 17 deletions tests/lib/Event/ContentServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down Expand Up @@ -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());

Expand All @@ -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);
Expand All @@ -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());
Expand Down

0 comments on commit 63485b4

Please sign in to comment.