[General] PHP-CS-FIXER

This commit is contained in:
Carlos Buenosvinos
2022-03-12 16:13:36 +01:00
parent 97a12fa542
commit b104921c28
28 changed files with 41 additions and 53 deletions

View File

@@ -5,8 +5,8 @@ declare(strict_types=1);
namespace App\Controller\Chapter7;
use Cheeper\AllChapters\DomainModel\Author\AuthorDoesNotExist;
use Cheeper\Chapter7\Application\QueryBus;
use Cheeper\Chapter7\Application\Author\Query\CountFollowersQuery;
use Cheeper\Chapter7\Application\QueryBus;
use InvalidArgumentException;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;

View File

@@ -5,11 +5,9 @@ declare(strict_types=1);
namespace App\Controller\Chapter7;
use Cheeper\AllChapters\DomainModel\Author\AuthorDoesNotExist;
use Cheeper\Chapter7\Application\Author\Query\CountFollowersQuery;
use Cheeper\Chapter7\Application\Author\Query\TimelineQuery;
use Cheeper\Chapter7\Application\QueryBus;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

View File

@@ -8,13 +8,13 @@ use App\Messenger\CommandBus;
use Cheeper\AllChapters\DomainModel\Author\AuthorDoesNotExist;
use Cheeper\Chapter7\Application\Cheep\Command\PostCheepCommand;
use InvalidArgumentException;
use function Safe\json_decode;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\Routing\Annotation\Route;
use function Safe\json_decode;
//snippet chapter7-postcheep-controller
final class PostCheepController extends AbstractController
@@ -69,4 +69,4 @@ final class PostCheepController extends AbstractController
}
//end-ignore
}
//end-snippet
//end-snippet

View File

@@ -7,7 +7,6 @@ namespace App\Controller\Chapter8;
use Cheeper\Chapter7\Application\Author\Query\TimelineQuery;
use Cheeper\Chapter7\Application\QueryBus;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

View File

@@ -15,7 +15,9 @@ use Ramsey\Uuid\UuidInterface;
class PopularCheep
{
public function __construct(
#[ORM\Id, ORM\GeneratedValue(strategy: "NONE"), ORM\Column(type: UuidType::NAME)]
#[ORM\Id,
ORM\GeneratedValue(strategy: "NONE"),
ORM\Column(type: UuidType::NAME)]
private UuidInterface $id,
#[ORM\Column(type: UuidType::NAME)]
private UuidInterface $authorId,
@@ -45,4 +47,4 @@ class PopularCheep
{
return $this->createdAt;
}
}
}

View File

@@ -5,9 +5,7 @@ declare(strict_types=1);
namespace App;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
final class Kernel extends BaseKernel
{

View File

@@ -5,11 +5,9 @@ declare(strict_types=1);
namespace App\Repository;
use App\Entity\PopularCheep;
use Cheeper\Chapter7\DomainModel\Author\Author;
use Cheeper\Chapter7\DomainModel\Follow\Follow;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
use function Doctrine\ORM\QueryBuilder;
final class PopularCheepRepository extends ServiceEntityRepository
{
@@ -25,7 +23,7 @@ final class PopularCheepRepository extends ServiceEntityRepository
public function of(array $follows): array
{
return $this->findBy([
'id' => array_map(static fn(Follow $f) => $f->toAuthorId()->id(), $follows)
'id' => array_map(static fn (Follow $f) => $f->toAuthorId()->id(), $follows),
]);
}
}
}

View File

@@ -27,13 +27,15 @@ class Clock
return static::$instance;
}
public function now(): DateTimeImmutable {
public function now(): DateTimeImmutable
{
return $this->strategy->now();
}
public function changeStrategy(ClockStrategy $clockStrategy): self {
public function changeStrategy(ClockStrategy $clockStrategy): self
{
$this->strategy = $clockStrategy;
return $this;
}
}
}

View File

@@ -9,4 +9,4 @@ use DateTimeImmutable;
interface ClockStrategy
{
public function now(): DateTimeImmutable;
}
}

View File

@@ -12,8 +12,7 @@ class DateCollectionClockStrategy implements ClockStrategy
public function __construct(
private array $collection = []
)
{
) {
$this->iterator = 0;
}
@@ -28,4 +27,4 @@ class DateCollectionClockStrategy implements ClockStrategy
return $currentDate;
}
}
}

View File

@@ -8,7 +8,8 @@ use DateTimeImmutable;
class DefaultClockStrategy implements ClockStrategy
{
public function now(): DateTimeImmutable {
public function now(): DateTimeImmutable
{
return new DateTimeImmutable(
'now',
new \DateTimeZone(
@@ -16,4 +17,4 @@ class DefaultClockStrategy implements ClockStrategy
)
);
}
}
}

View File

@@ -11,9 +11,9 @@ use Cheeper\AllChapters\DomainModel\Author\EmailAddress;
use Cheeper\AllChapters\DomainModel\Author\UserName;
use Cheeper\AllChapters\DomainModel\Author\Website;
use Cheeper\Chapter4\Application\Author\Command\SignUpWithoutEvents\SignUpCommand;
use Cheeper\Chapter4\Application\EventBus;
use Cheeper\Chapter4\DomainModel\Author\Author;
use Cheeper\Chapter4\DomainModel\Author\AuthorRepository;
use Cheeper\Chapter4\Application\EventBus;
//snippet sign-up-handler-with-events
final class SignUpCommandHandler

View File

@@ -8,11 +8,11 @@ use Cheeper\AllChapters\DomainModel\Author\AuthorDoesNotExist;
use Cheeper\AllChapters\DomainModel\Author\AuthorId;
use Cheeper\AllChapters\DomainModel\Cheep\CheepId;
use Cheeper\AllChapters\DomainModel\Cheep\CheepMessage;
use Cheeper\Chapter4\Application\EventBus;
use Cheeper\Chapter4\DomainModel\Author\Author;
use Cheeper\Chapter4\DomainModel\Author\AuthorRepository;
use Cheeper\Chapter4\DomainModel\Cheep\Cheep;
use Cheeper\Chapter4\DomainModel\Cheep\CheepRepository;
use Cheeper\Chapter4\Application\EventBus;
//snippet post-cheep-handler
final class PostCheepCommandHandler

View File

@@ -34,8 +34,7 @@ final class Cheep
private string $cheepId,
private string $authorId,
private string $message,
)
{
) {
$this->date = Clock::instance()->now();
$this->setMessage($message);
$this->notifyDomainEvent(
@@ -68,7 +67,7 @@ final class Cheep
return CheepId::fromString($this->cheepId);
}
final public function recomposeWith(CheepMessage $cheepMessage): void
public function recomposeWith(CheepMessage $cheepMessage): void
{
$this->setMessage($cheepMessage->message());
}

View File

@@ -6,8 +6,8 @@ namespace Cheeper\Chapter4\DomainModel\Follow;
use Cheeper\AllChapters\DomainModel\Author\AuthorId;
use Cheeper\AllChapters\DomainModel\Follow\FollowId;
use Cheeper\Chapter4\DomainModel\TriggerEventsTrait;
use Cheeper\Chapter4\DomainModel\Author\AuthorFollowed;
use Cheeper\Chapter4\DomainModel\TriggerEventsTrait;
// snippet follow-entity-with-events
class Follow

View File

@@ -4,9 +4,9 @@ declare(strict_types=1);
namespace Cheeper\Chapter4\Infrastructure\DomainModel\Author;
use Cheeper\Chapter4\DomainModel\Author\Author;
use Cheeper\AllChapters\DomainModel\Author\AuthorId;
use Cheeper\AllChapters\DomainModel\Author\UserName;
use Cheeper\Chapter4\DomainModel\Author\Author;
use Cheeper\Chapter4\DomainModel\Author\AuthorRepository;
use Doctrine\ORM\EntityManagerInterface;

View File

@@ -16,8 +16,7 @@ final class CountFollowersQuery implements Query
private function __construct(
private string $authorId
)
{
) {
}
public function authorId(): string

View File

@@ -7,9 +7,9 @@ namespace Cheeper\Chapter5\Application\Author\Query\CountFollowersQueryHandler\W
use Cheeper\AllChapters\DomainModel\Author\AuthorDoesNotExist;
use Cheeper\AllChapters\DomainModel\Author\AuthorId;
use Cheeper\Chapter4\DomainModel\Author\AuthorRepository;
use Cheeper\Chapter4\DomainModel\Follow\FollowRepository;
use Cheeper\Chapter5\Application\Author\Query\CountFollowersQueryHandler\CountFollowersQuery;
use Cheeper\Chapter5\Application\Author\Query\CountFollowersQueryHandler\CountFollowersResponse;
use Cheeper\Chapter4\DomainModel\Follow\FollowRepository;
//snippet count-followers-handler
final class CountFollowersQueryHandler

View File

@@ -4,14 +4,14 @@ declare(strict_types=1);
namespace Cheeper\Chapter6\Application\Author\Command\WithDomainEvents;
use Cheeper\AllChapters\DomainModel\Follow\FollowDoesAlreadyExistException;
use Cheeper\Chapter6\Application\Author\Command\FollowCommand;
use Cheeper\AllChapters\DomainModel\Author\AuthorDoesNotExist;
use Cheeper\AllChapters\DomainModel\Author\AuthorId;
use Cheeper\Chapter4\DomainModel\Follow\FollowRepository;
use Cheeper\Chapter4\DomainModel\Author\AuthorRepository;
use Cheeper\AllChapters\DomainModel\Follow\FollowDoesAlreadyExistException;
use Cheeper\Chapter4\Application\EventBus;
use Cheeper\Chapter4\DomainModel\Author\Author;
use Cheeper\Chapter4\DomainModel\Author\AuthorRepository;
use Cheeper\Chapter4\DomainModel\Follow\FollowRepository;
use Cheeper\Chapter6\Application\Author\Command\FollowCommand;
//snippet follow-handler-with-event
final class FollowCommandHandler

View File

@@ -5,8 +5,8 @@ declare(strict_types=1);
namespace Cheeper\Chapter6\Infrastructure\Application\Author\Projection;
use Cheeper\Chapter4\DomainModel\Author\AuthorFollowed;
use Cheeper\Chapter6\Application\Author\Projection\CountFollowersProjectionHandler;
use Cheeper\Chapter6\Application\Author\Projection\CountFollowersProjection;
use Cheeper\Chapter6\Application\Author\Projection\CountFollowersProjectionHandler;
use Symfony\Component\Messenger\Handler\MessageSubscriberInterface;
//snippet symfony-author-followed-handler

View File

@@ -54,7 +54,7 @@ final class FollowCommandHandler
private function notifyEvents(FollowCommand $command, array $domainEvents): void
{
$stamppedEvents = array_map(
static fn($event) => $event->stampAsResponseTo($command),
static fn ($event) => $event->stampAsResponseTo($command),
$domainEvents
);

View File

@@ -6,8 +6,6 @@ namespace Cheeper\Chapter7\Application\Author\Event;
use Cheeper\Chapter7\Application\Author\Projection\CreateFollowersCounterProjection;
use Cheeper\Chapter7\Application\Author\Projection\CreateFollowersCounterProjectionHandlerInterface;
use Cheeper\Chapter7\Application\Author\Projection\CreateTimelineProjection;
use Cheeper\Chapter7\Application\Author\Projection\CreateTimelineProjectionHandlerInterface;
use Cheeper\Chapter7\DomainModel\Author\NewAuthorSigned;
//snippet new-author-signed-event-handler

View File

@@ -4,9 +4,6 @@ declare(strict_types=1);
namespace Cheeper\Chapter7\Application\Author\Query;
use Cheeper\AllChapters\DomainModel\Author\AuthorDoesNotExist;
use Cheeper\AllChapters\DomainModel\Author\AuthorId;
//snippet timeline-handler
final class TimelineQueryHandler
{

View File

@@ -44,8 +44,7 @@ final class CheepPosted implements DomainEvent
AuthorId $authorId,
CheepMessage $cheepMessage,
CheepDate $cheepDate,
): self
{
): self {
return new self(
$cheepId->toString(),
$authorId->toString(),

View File

@@ -38,7 +38,7 @@ final class TimelineQueryHandler
$cheeps[] = [
'cheep_id' => $popularCheep->getId()->toString(),
'cheep_message' => $popularCheep->getMessage(),
'cheep_date' => $popularCheep->getCreatedAt()->format(DateTimeInterface::ATOM)
'cheep_date' => $popularCheep->getCreatedAt()->format(DateTimeInterface::ATOM),
];
}
@@ -48,7 +48,7 @@ final class TimelineQueryHandler
usort(
$cheeps,
function(array $c1, array $c2): int {
function (array $c1, array $c2): int {
$date1 = DateTimeImmutable::createFromFormat(DateTimeInterface::ATOM, $c1['cheep_date']);
$date2 = DateTimeImmutable::createFromFormat(DateTimeInterface::ATOM, $c2['cheep_date']);
return $date1 <=> $date2;

View File

@@ -8,8 +8,8 @@ use Cheeper\AllChapters\DomainModel\Author\AuthorId;
use Cheeper\Chapter7\Application\Cheep\Projection\AddCheepToTimelineProjection;
use Cheeper\Chapter7\Application\ProjectionBus;
use Cheeper\Chapter7\DomainModel\Cheep\CheepPosted;
use Cheeper\Chapter8\DomainModel\Follow\FollowRepository;
use Cheeper\Chapter8\Application\Cheep\Projection\AddCheepToGlobalStoreProjection;
use Cheeper\Chapter8\DomainModel\Follow\FollowRepository;
use DateTimeImmutable;
use DateTimeInterface;

View File

@@ -19,4 +19,4 @@ final class AddCheepToGlobalStoreProjection implements Projection
) {
$this->stampAsNewMessage();
}
}
}

View File

@@ -13,8 +13,7 @@ final class AddCheepToGlobalStoreProjectionHandler
{
public function __construct(
private EntityManagerInterface $entityManager,
)
{
) {
}
public function __invoke(AddCheepToGlobalStoreProjection $projection): void
@@ -29,4 +28,4 @@ final class AddCheepToGlobalStoreProjectionHandler
$this->entityManager->persist($popularCheep);
$this->entityManager->flush();
}
}
}