Skip to content

Commit

Permalink
Fix phpstan errors
Browse files Browse the repository at this point in the history
  • Loading branch information
LeikoDmitry committed Nov 20, 2023
1 parent dc1e9d4 commit 8defdf6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/Listener/ApiExceptionListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ class ApiExceptionListener
{
public function __construct(
private readonly ExceptionMappingResolver $exceptionMappingResolver,
private readonly LoggerInterface $logger,
private readonly SerializerInterface $serializer,
private readonly bool $isDebug,
private readonly LoggerInterface $logger,
private readonly SerializerInterface $serializer,
private readonly bool $isDebug,
) {
}

Expand All @@ -43,7 +43,7 @@ public function __invoke(ExceptionEvent $exceptionEvent): void
}

$message = $mapping->isHidden() ? Response::$statusTexts[$mapping->getCode()] : $throwable->getMessage();
$details = $this->isDebug && !$mapping->isLoggable() ? new ErrorDebugDetails($throwable->getTraceAsString()): null;
$details = $this->isDebug && !$mapping->isLoggable() ? new ErrorDebugDetails($throwable->getTraceAsString()) : null;

$data = $this->serializer->serialize(data: new ErrorResponse($message, $details), format: JsonEncoder::FORMAT);

Expand Down
1 change: 0 additions & 1 deletion src/Model/ErrorResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Nelmio\ApiDocBundle\Annotation\Model;
use OpenApi\Annotations as OA;
use App\Model\ErrorDebugDetails;

readonly class ErrorResponse
{
Expand Down
6 changes: 3 additions & 3 deletions tests/Controller/SubscriberControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class SubscriberControllerTest extends AbstractControllerTestCase
{
public function testSubscribe()
public function testSubscribe(): void
{
$this->kernelBrowser->request(
method: 'POST',
Expand All @@ -18,7 +18,7 @@ public function testSubscribe()
$this->assertResponseIsSuccessful();
}

public function testSubscribeNotAgreed()
public function testSubscribeNotAgreed(): void
{
$this->kernelBrowser->request(
method: 'POST',
Expand All @@ -35,7 +35,7 @@ public function testSubscribeNotAgreed()
PHP_EOL,
PHP_EOL
),
'$.details' => null
'$.details' => null,
]);
}
}
12 changes: 6 additions & 6 deletions tests/Service/SubscriberServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,30 @@ protected function setUp(): void
}

public function testSubscribeAlreadyExist(): void
{
{
$this->expectException(SubscriberFoundException::class);

$this->subscriberRepository->expects($this->once())
$this->subscriberRepository->expects($this->once()) /** @phpstan-ignore-line */
->method('findOneBy')
->with(['email' => static::EMAIL])
->willReturn((new Subscriber())->setEmail(static::EMAIL)->setId(1));

(new SubscriberService($this->subscriberRepository, $this->entityManager))
->subscribe(new SubscriberRequest(email: static::EMAIL, agreed: false));
}
}

public function testSubscribe(): void
{
$this->subscriberRepository->expects($this->once())
$this->subscriberRepository->expects($this->once()) /** @phpstan-ignore-line */
->method('findOneBy')
->with(['email' => static::EMAIL])
->willReturn(null);

$expectedSubscriber = new Subscriber();
$expectedSubscriber->setEmail(static::EMAIL);

$this->entityManager->expects($this->once())->method('persist')->with($expectedSubscriber);
$this->entityManager->expects($this->once())->method('flush');
$this->entityManager->expects($this->once())->method('persist')->with($expectedSubscriber); /** @phpstan-ignore-line */
$this->entityManager->expects($this->once())->method('flush'); /** @phpstan-ignore-line */

(new SubscriberService($this->subscriberRepository, $this->entityManager))
->subscribe(new SubscriberRequest(email: static::EMAIL, agreed: false));
Expand Down

0 comments on commit 8defdf6

Please sign in to comment.