Skip to content

Commit

Permalink
add cs and update file headers
Browse files Browse the repository at this point in the history
  • Loading branch information
yceruto committed Aug 4, 2024
1 parent f849e7d commit 8d82f04
Show file tree
Hide file tree
Showing 40 changed files with 447 additions and 38 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/vendor/
composer.lock
/.phpunit.result.cache
/.php-cs-fixer.cache
24 changes: 24 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

$header = <<<EOF
This file is part of Option Type package.
(c) Yonel Ceruto <open@yceruto.dev>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
EOF;

$finder = (new PhpCsFixer\Finder())
->in(__DIR__.'/src')
->in(__DIR__.'/tests')
;

return (new PhpCsFixer\Config())
->setRules([
'@Symfony' => true,
'header_comment' => ['header' => $header],
'declare_strict_types' => true,
])
->setFinder($finder)
;
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023-present Yonel Ceruto Gonzalez
Copyright (c) 2024-present Yonel Ceruto Gonzalez

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
26 changes: 14 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@
"email": "open@yceruto.dev"
}
],
"autoload": {
"psr-4": {
"OpenSolid\\Bus\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"OpenSolid\\Tests\\Bus\\": "tests/"
}
},
"require": {
"php": ">=8.2",
"psr/container": "^2.0",
Expand All @@ -20,20 +30,12 @@
"phpunit/phpunit": "^10.0",
"psalm/plugin-phpunit": "^0.18",
"symfony/dependency-injection": "^7.0",
"doctrine/orm": "^3.1"
},
"autoload": {
"psr-4": {
"OpenSolid\\Bus\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"OpenSolid\\Tests\\Bus\\": "tests/"
}
"doctrine/orm": "^3.1",
"friendsofphp/php-cs-fixer": "^3.54"
},
"scripts": {
"test": "vendor/bin/phpunit tests",
"psalm": "vendor/bin/psalm --show-info=true"
"psalm": "vendor/bin/psalm --show-info=true",
"cs": "vendor/bin/php-cs-fixer fix --allow-risky=yes"
}
}
11 changes: 11 additions & 0 deletions src/Bridge/Doctrine/Middleware/DoctrineTransactionMiddleware.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?php

declare(strict_types=1);

/*
* This file is part of Option Type package.
*
* (c) Yonel Ceruto <open@yceruto.dev>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace OpenSolid\Bus\Bridge\Doctrine\Middleware;

use Doctrine\ORM\EntityManagerInterface;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?php

declare(strict_types=1);

/*
* This file is part of Option Type package.
*
* (c) Yonel Ceruto <open@yceruto.dev>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace OpenSolid\Bus\Bridge\Symfony\DependencyInjection\CompilerPass;

use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Symfony package.
* This file is part of Option Type package.
*
* (c) Fabien Potencier <fabien@symfony.com>
* (c) Yonel Ceruto <open@yceruto.dev>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down Expand Up @@ -109,7 +111,7 @@ private function findAndSortTaggedServices(string|TaggedIteratorArgument $tagNam
if (null === $index) {
$refs[] = $reference;
} elseif ($allowMultiple) {
/** @psalm-suppress UndefinedMethod */
/* @psalm-suppress UndefinedMethod */
$refs[$index][] = $reference;

Check warning on line 115 in src/Bridge/Symfony/DependencyInjection/CompilerPass/PriorityTaggedServiceTrait.php

View workflow job for this annotation

GitHub Actions / Psalm

UndefinedMethod

src/Bridge/Symfony/DependencyInjection/CompilerPass/PriorityTaggedServiceTrait.php:115:17: UndefinedMethod: Method Symfony\Component\DependencyInjection\Reference::offsetSet does not exist (see https://psalm.dev/022)
} else {
$refs[$index] = $reference;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
<?php

declare(strict_types=1);

/*
* This file is part of Option Type package.
*
* (c) Yonel Ceruto <open@yceruto.dev>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace OpenSolid\Bus\Bridge\Symfony\DependencyInjection\Configurator;

use ReflectionNamedType;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;

Expand Down Expand Up @@ -32,7 +42,7 @@ function (ChildDefinition $definition, object $attribute, \Reflector $reflector)

$type = $reflectionMethod->getParameters()[0]->getType();

if (!$type instanceof ReflectionNamedType || $type->isBuiltin()) {
if (!$type instanceof \ReflectionNamedType || $type->isBuiltin()) {
return;
}

Expand Down
11 changes: 11 additions & 0 deletions src/Envelope/Envelope.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?php

declare(strict_types=1);

/*
* This file is part of Option Type package.
*
* (c) Yonel Ceruto <open@yceruto.dev>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace OpenSolid\Bus\Envelope;

use OpenSolid\Bus\Envelope\Stamp\HandledStamp;
Expand Down
13 changes: 12 additions & 1 deletion src/Envelope/Message.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
<?php

declare(strict_types=1);

/*
* This file is part of Option Type package.
*
* (c) Yonel Ceruto <open@yceruto.dev>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace OpenSolid\Bus\Envelope;

readonly abstract class Message
abstract readonly class Message
{
}
11 changes: 11 additions & 0 deletions src/Envelope/Stamp/HandledStamp.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?php

declare(strict_types=1);

/*
* This file is part of Option Type package.
*
* (c) Yonel Ceruto <open@yceruto.dev>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace OpenSolid\Bus\Envelope\Stamp;

final readonly class HandledStamp extends Stamp
Expand Down
13 changes: 12 additions & 1 deletion src/Envelope/Stamp/Stamp.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
<?php

declare(strict_types=1);

/*
* This file is part of Option Type package.
*
* (c) Yonel Ceruto <open@yceruto.dev>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace OpenSolid\Bus\Envelope\Stamp;

readonly abstract class Stamp
abstract readonly class Stamp
{
}
11 changes: 11 additions & 0 deletions src/Envelope/Stamp/Stamps.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?php

declare(strict_types=1);

/*
* This file is part of Option Type package.
*
* (c) Yonel Ceruto <open@yceruto.dev>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace OpenSolid\Bus\Envelope\Stamp;

final class Stamps implements \Countable
Expand Down
13 changes: 12 additions & 1 deletion src/Error/MultipleHandlersForMessage.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
<?php

declare(strict_types=1);

/*
* This file is part of Option Type package.
*
* (c) Yonel Ceruto <open@yceruto.dev>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace OpenSolid\Bus\Error;

final class MultipleHandlersForMessage extends \LogicException
{
public static function from(string $class, \Throwable $previous = null, int $code = 0): self
public static function from(string $class, ?\Throwable $previous = null, int $code = 0): self
{
return new self(sprintf('Message of type "%s" was handled multiple times. Only one handler is expected.', $class), $code, $previous);
}
Expand Down
13 changes: 12 additions & 1 deletion src/Error/NoHandlerForMessage.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
<?php

declare(strict_types=1);

/*
* This file is part of Option Type package.
*
* (c) Yonel Ceruto <open@yceruto.dev>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace OpenSolid\Bus\Error;

final class NoHandlerForMessage extends \LogicException
{
public static function from(string $class, \Throwable $previous = null, int $code = 0): self
public static function from(string $class, ?\Throwable $previous = null, int $code = 0): self
{
return new self(sprintf('No handler for message of type "%s".', $class), $code, $previous);
}
Expand Down
11 changes: 11 additions & 0 deletions src/FlushableMessageBus.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?php

declare(strict_types=1);

/*
* This file is part of Option Type package.
*
* (c) Yonel Ceruto <open@yceruto.dev>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace OpenSolid\Bus;

/**
Expand Down
11 changes: 11 additions & 0 deletions src/Handler/MessageHandlersCountPolicy.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?php

declare(strict_types=1);

/*
* This file is part of Option Type package.
*
* (c) Yonel Ceruto <open@yceruto.dev>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace OpenSolid\Bus\Handler;

enum MessageHandlersCountPolicy
Expand Down
13 changes: 12 additions & 1 deletion src/Handler/MessageHandlersLocator.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
<?php

declare(strict_types=1);

/*
* This file is part of Option Type package.
*
* (c) Yonel Ceruto <open@yceruto.dev>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace OpenSolid\Bus\Handler;

use Psr\Container\ContainerInterface;
use OpenSolid\Bus\Error\NoHandlerForMessage;
use Psr\Container\ContainerInterface;

/**
* Maps a message class to a list of handlers.
Expand Down
11 changes: 11 additions & 0 deletions src/LazyMessageMessageBus.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?php

declare(strict_types=1);

/*
* This file is part of Option Type package.
*
* (c) Yonel Ceruto <open@yceruto.dev>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace OpenSolid\Bus;

use OpenSolid\Bus\Envelope\Message;
Expand Down
11 changes: 11 additions & 0 deletions src/MessageBus.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?php

declare(strict_types=1);

/*
* This file is part of Option Type package.
*
* (c) Yonel Ceruto <open@yceruto.dev>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace OpenSolid\Bus;

use OpenSolid\Bus\Envelope\Message;
Expand Down
Loading

0 comments on commit 8d82f04

Please sign in to comment.