Skip to content

Commit

Permalink
Fix phpstan issues
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-schranz committed Dec 3, 2022
1 parent 6b08021 commit c021552
Show file tree
Hide file tree
Showing 19 changed files with 114 additions and 198 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test-application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
dependency-versions: 'highest'
php-extensions: 'ctype, iconv, mysql, imagick'
tools: 'composer:v2'
phpstan: true
phpstan: false
lint: false
env:
SYMFONY_DEPRECATIONS_HELPER: weak
Expand All @@ -66,7 +66,7 @@ jobs:
dependency-versions: 'highest'
php-extensions: 'ctype, iconv, mysql, imagick'
tools: 'composer:v2'
phpstan: false
phpstan: true
lint: true
env:
SYMFONY_DEPRECATIONS_HELPER: weak
Expand Down
10 changes: 5 additions & 5 deletions Application/Message/ApplyWorkflowTransitionArticleMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
class ApplyWorkflowTransitionArticleMessage
{
/**
* @param array{
* uuid?: string
* } $identifier
* @var array{
* uuid?: string,
* }
*/
private $identifier;

Expand All @@ -43,9 +43,9 @@ public function __construct(array $identifier, string $locale, string $transitio
}

/**
* @param array{
* @return array{
* uuid?: string
* } $identifier
* }
*/
public function getIdentifier(): array
{
Expand Down
8 changes: 4 additions & 4 deletions Application/Message/CopyLocaleArticleMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
class CopyLocaleArticleMessage
{
/**
* @param array{
* @var array{
* uuid?: string
* } $identifier
* }
*/
private $identifier;

Expand All @@ -34,9 +34,9 @@ public function __construct($identifier, string $sourceLocale, string $targetLoc
}

/**
* @param array{
* @return array{
* uuid?: string
* } $identifier
* }
*/
public function getIdentifier()
{
Expand Down
15 changes: 14 additions & 1 deletion Application/Message/CreateArticleMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,28 @@ class CreateArticleMessage
*/
private $data;

/**
* @var string|null
*/
private $uuid;

/**
* @param mixed[] $data
*/
public function __construct(array $data)
{
$uuid = $data['uuid'] ?? null;

Assert::string($data['locale'] ?? null, 'Expected a "locale" string given.');
Assert::nullOrString($data['uuid'] ?? null, 'Expected "uuid" to be a string.');
Assert::nullOrString($uuid, 'Expected "uuid" to be a string.');

$this->data = $data;
$this->uuid = $uuid;
}

public function getUuid(): ?string
{
return $this->uuid;
}

/**
Expand Down
10 changes: 5 additions & 5 deletions Application/Message/ModifyArticleMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
class ModifyArticleMessage
{
/**
* @param array{
* @var array{
* uuid?: string
* } $identifier
* }
*/
private $identifier;

Expand All @@ -45,17 +45,17 @@ public function __construct(array $identifier, array $data)
}

/**
* @param array{
* @return array{
* uuid?: string
* } $identifier
* }
*/
public function getIdentifier(): array
{
return $this->identifier;
}

/**
* @var mixed[]
* @return mixed[]
*/
public function getData(): array
{
Expand Down
8 changes: 4 additions & 4 deletions Application/Message/RemoveArticleMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
class RemoveArticleMessage
{
/**
* @param array{
* @var array{
* uuid?: string
* } $identifier
* }
*/
private $identifier;

Expand All @@ -34,9 +34,9 @@ public function __construct(array $identifier)
}

/**
* @param array{
* @return array{
* uuid?: string
* } $identifier
* }
*/
public function getIdentifier(): array
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function __construct(

public function __invoke(CopyLocaleArticleMessage $message): void
{
$article = $this->articleRepository->findOneBy($message->getIdentifier());
$article = $this->articleRepository->getOneBy($message->getIdentifier());

$this->contentCopier->copy(
$article,
Expand Down
5 changes: 4 additions & 1 deletion Application/MessageHandler/CreateArticleMessageHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ final class CreateArticleMessageHandler
*/
private $articleMappers;

/**
* @param iterable<ArticleMapperInterface> $articleMappers
*/
public function __construct(
ArticleRepositoryInterface $articleRepository,
iterable $articleMappers
Expand All @@ -45,7 +48,7 @@ public function __construct(
public function __invoke(CreateArticleMessage $message): ArticleInterface
{
$data = $message->getData();
$article = $this->articleRepository->createNew($data['uuid'] ?? null);
$article = $this->articleRepository->createNew($message->getUuid());

foreach ($this->articleMappers as $articleMapper) {
$articleMapper->mapArticleData($article, $data);
Expand Down
5 changes: 4 additions & 1 deletion Application/MessageHandler/ModifyArticleMessageHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ final class ModifyArticleMessageHandler
*/
private $articleMappers;

/**
* @param iterable<ArticleMapperInterface> $articleMappers
*/
public function __construct(
ArticleRepositoryInterface $articleRepository,
iterable $articleMappers
Expand All @@ -46,7 +49,7 @@ public function __invoke(ModifyArticleMessage $message): ArticleInterface
{
$identifier = $message->getIdentifier();
$data = $message->getData();
$article = $this->articleRepository->findOneBy($identifier);
$article = $this->articleRepository->getOneBy($identifier);

foreach ($this->articleMappers as $articleMapper) {
$articleMapper->mapArticleData($article, $data);
Expand Down
64 changes: 0 additions & 64 deletions Common/MessageBus/Middleware/DoctrineFlushMiddleware.php

This file was deleted.

25 changes: 0 additions & 25 deletions Common/MessageBus/Stamps/EnableFlushStamp.php

This file was deleted.

Loading

0 comments on commit c021552

Please sign in to comment.