From 39b8f3aed1fa8867b957a15a8d3738b4ce463f05 Mon Sep 17 00:00:00 2001 From: Mykhailo Shtanko Date: Sun, 3 Mar 2024 14:28:58 +0200 Subject: [PATCH] [TransactionalMessenger] Update dependencies, drop support for symfony 5.* version, refactor, update CodeStyle, drop support for php 8.1 --- .php-cs-fixer.dist.php | 66 ++++++++++++++----- Attribute/Transactional.php | 11 ++++ Enum/CommitType.php | 13 ++++ Event/DispatchFailedEvent.php | 14 +++- Event/DispatchSucceedEvent.php | 14 +++- ...ansactionOnMessageHandledEventListener.php | 14 +++- ...mmitTransactionOnResponseEventListener.php | 14 +++- ...mitTransactionOnTerminateEventListener.php | 14 +++- ...TransactionOnConsoleErrorEventListener.php | 14 +++- ...ransactionOnConsoleSignalEventListener.php | 14 +++- ...ackTransactionOnExceptionEventListener.php | 14 +++- ...ransactionOnMessageFailedEventListener.php | 14 +++- Exception/DispatchException.php | 11 ++++ Exception/MessageBusException.php | 11 ++++ Helper/AttributeHelper.php | 25 ++++--- Helper/ClassHelper.php | 23 +++++-- Helper/EnvelopeHelper.php | 15 ++++- Helper/TransactionHelper.php | 25 ++++--- MessageBus/CommitTransactionInterface.php | 11 ++++ MessageBus/DispatchTransactionInterface.php | 15 ++++- MessageBus/RollbackTransactionInterface.php | 11 ++++ MessageBus/TransactionalMessageBus.php | 14 +++- .../TransactionalMessageBusInterface.php | 15 ++++- Resources/bundles.php | 20 +++++- Storage/Storage.php | 25 ++++--- Storage/StorageInterface.php | 11 ++++ Tests/Stub/Kernel.php | 11 ++++ .../Message/AbstractTransactionalMessage.php | 15 ++++- .../Message/ExtendedTransactionalMessage.php | 15 ++++- .../Stub/Message/NonTransactionalMessage.php | 15 ++++- .../Message/TransactionalOnHandledMessage.php | 15 ++++- .../TransactionalOnResponseMessage.php | 15 ++++- .../TransactionalOnTerminateMessage.php | 15 ++++- Tests/Stub/ValueObject/MappedTestObject.php | 14 +++- Tests/Stub/ValueObject/TestObject.php | 11 ++++ .../CommitTransactionEventListenerTest.php | 11 ++++ .../RollbackTransactionEventListenerTest.php | 11 ++++ Tests/Unit/Helper/AttributeHelperTest.php | 21 ++++-- Tests/Unit/Helper/ClassHelperTest.php | 58 +++++++++------- Tests/Unit/Helper/EnvelopeHelperTest.php | 15 ++++- Tests/Unit/Helper/TransactionHelperTest.php | 22 +++++-- .../TransactionalMessageBusCommitTest.php | 11 ++++ .../TransactionalMessageBusDispatchTest.php | 11 ++++ .../TransactionalMessageBusRollbackTest.php | 11 ++++ Tests/Unit/Resources/BundlesTest.php | 11 ++++ Tests/Unit/Storage/StorageTest.php | 11 ++++ Tests/Unit/ValueObject/FailedEnvelopeTest.php | 11 ++++ .../Unit/ValueObject/PendingEnvelopeTest.php | 11 ++++ .../Unit/ValueObject/SucceedEnvelopeTest.php | 11 ++++ TransactionalMessengerBundle.php | 11 ++++ TransactionalMessengerExtension.php | 11 ++++ ValueObject/FailedEnvelope.php | 11 ++++ ValueObject/PendingEnvelope.php | 14 +++- ValueObject/SucceedEnvelope.php | 14 +++- composer.json | 20 +++--- phpunit.xml.dist | 6 +- 56 files changed, 728 insertions(+), 159 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index f6a5540..59c0473 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -1,14 +1,40 @@ exclude('var') - ->exclude('vendor') - ->exclude('Documentation') - ->notPath('#Enum#') - ->in(__DIR__) -; +use PhpCsFixer\Config; +use PhpCsFixer\Finder; + + +$owner = 'Mykhailo Shtanko'; +$email = 'fractalzombie@gmail.com'; +$year = date('Y'); +$projectDirectory = __DIR__; + +$header = <<<'EOF' +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + +Copyright (c) {{YEAR}} {{OWNER}} {{EMAIL}} + +For the full copyright and license information, please view the LICENSE.MD +file that was distributed with this source code. +EOF; + +$finder = Finder::create() + ->exclude([ + 'var', + 'vendor', + '.github', + '.docker', + 'Documentation', + ]) + ->notName('*Configuration.*') + ->ignoreDotFiles(true) + ->in(__DIR__); $rules = [ '@PSR2' => true, @@ -17,20 +43,30 @@ '@Symfony:risky' => true, '@PhpCsFixer' => true, '@PHP80Migration' => true, + '@PHP81Migration' => true, '@PHP80Migration:risky' => true, '@PHPUnit84Migration:risky' => true, - 'phpdoc_line_span' => ['const' => 'single', 'property' => 'single', 'method' => 'single'], - 'comment_to_phpdoc' => ['ignored_tags' => ['scrutinizer']], - 'phpdoc_to_comment' => ['ignored_tags' => ['scrutinizer']], 'date_time_immutable' => true, - 'nullable_type_declaration_for_default_null_value' => ['use_nullable_type_declaration' => true], + 'single_line_throw' => true, + 'php_unit_internal_class' => false, + 'phpdoc_align' => ['align' => 'left'], 'php_unit_test_case_static_method_calls' => false, 'php_unit_test_class_requires_covers' => false, - 'php_unit_internal_class' => false, + 'phpdoc_line_span' => ['const' => 'single', 'property' => 'single', 'method' => 'single'], + 'nullable_type_declaration_for_default_null_value' => ['use_nullable_type_declaration' => true], + 'header_comment' => [ + 'comment_type' => 'PHPDoc', + 'header' => str_replace( + ['{{YEAR}}', '{{OWNER}}', '{{EMAIL}}'], + [$year, $owner, $email], + $header, + ), + 'location' => 'after_declare_strict', + 'separate' => 'top', + ], ]; -return (new PhpCsFixer\Config()) +return (new Config()) ->setRiskyAllowed(true) ->setRules($rules) - ->setFinder($finder) -; + ->setFinder($finder); diff --git a/Attribute/Transactional.php b/Attribute/Transactional.php index 8e2f9c3..9584395 100644 --- a/Attribute/Transactional.php +++ b/Attribute/Transactional.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2024 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\TransactionalMessenger\Attribute; use FRZB\Component\TransactionalMessenger\Enum\CommitType; diff --git a/Enum/CommitType.php b/Enum/CommitType.php index 61eaa56..5fb3204 100644 --- a/Enum/CommitType.php +++ b/Enum/CommitType.php @@ -1,5 +1,18 @@ firstElement() @@ -43,11 +52,11 @@ public static function getAttribute(string|object $target, string $attributeClas * * @return array */ - public static function getAttributes(string|object $target, string $attributeClass): array + public static function getAttributes(object|string $target, string $attributeClass): array { return ArrayList::collect(self::getReflectionAttributes($target, $attributeClass)) ->map(static fn (\ReflectionAttribute $a) => $a->newInstance()) - ->toArray() + ->toList() ; } @@ -58,7 +67,7 @@ public static function getAttributes(string|object $target, string $attributeCla * * @return array<\ReflectionAttribute> */ - public static function getReflectionAttributes(string|object $target, string $attributeClass): array + public static function getReflectionAttributes(object|string $target, string $attributeClass): array { return Option::fromNullable(ClassHelper::getReflectionClass($target)) ->map( diff --git a/Helper/ClassHelper.php b/Helper/ClassHelper.php index fb7e620..2a1eb7f 100644 --- a/Helper/ClassHelper.php +++ b/Helper/ClassHelper.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2024 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\TransactionalMessenger\Helper; use JetBrains\PhpStorm\Immutable; @@ -12,11 +23,9 @@ final class ClassHelper { final public const DEFAULT_SHORT_NAME = 'InvalidClassName'; - private function __construct() - { - } + private function __construct() {} - public static function getShortName(string|object $target): string + public static function getShortName(object|string $target): string { return self::getReflectionClass($target)?->getShortName() ?? self::DEFAULT_SHORT_NAME; } @@ -28,7 +37,7 @@ public static function getShortName(string|object $target): string * * @return null|\ReflectionClass */ - public static function getReflectionClass(string|object $target): ?\ReflectionClass + public static function getReflectionClass(object|string $target): ?\ReflectionClass { try { return $target instanceof \ReflectionClass ? $target : new \ReflectionClass($target); @@ -44,7 +53,7 @@ public static function getReflectionClass(string|object $target): ?\ReflectionCl * * @return null|\ReflectionClass */ - public static function getParentReflectionClass(string|object $target): ?\ReflectionClass + public static function getParentReflectionClass(object|string $target): ?\ReflectionClass { return self::getReflectionClass($target)?->getParentClass() ?: null; } @@ -56,7 +65,7 @@ public static function getParentReflectionClass(string|object $target): ?\Reflec * * @return \Iterator<\ReflectionAttribute> */ - public static function getReflectionAttributes(string|object $target, string $attributeClass): iterable + public static function getReflectionAttributes(object|string $target, string $attributeClass): iterable { return self::getReflectionClass($target)?->getAttributes($attributeClass, \ReflectionAttribute::IS_INSTANCEOF) ?? []; } diff --git a/Helper/EnvelopeHelper.php b/Helper/EnvelopeHelper.php index 8ae86c4..b985590 100644 --- a/Helper/EnvelopeHelper.php +++ b/Helper/EnvelopeHelper.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2024 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\TransactionalMessenger\Helper; use JetBrains\PhpStorm\Immutable; @@ -12,9 +23,7 @@ #[Immutable] final class EnvelopeHelper { - private function __construct() - { - } + private function __construct() {} public static function wrap(object $message): Envelope { diff --git a/Helper/TransactionHelper.php b/Helper/TransactionHelper.php index 0784579..4623bbf 100644 --- a/Helper/TransactionHelper.php +++ b/Helper/TransactionHelper.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2024 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\TransactionalMessenger\Helper; use Fp\Collections\ArrayList; @@ -13,26 +24,24 @@ #[Immutable] final class TransactionHelper { - private function __construct() - { - } + private function __construct() {} - public static function isTransactional(string|object $target): bool + public static function isTransactional(object|string $target): bool { return AttributeHelper::hasAttribute($target, Transactional::class); } - public static function getTransactional(string|object $target): array + public static function getTransactional(object|string $target): array { return AttributeHelper::getAttributes($target, Transactional::class); } - public static function isDispatchable(string|object $target, CommitType ...$commitTypes): bool + public static function isDispatchable(object|string $target, CommitType ...$commitTypes): bool { return ArrayList::collect(self::getTransactional($target)) ->map(static fn (Transactional $t) => $t->commitTypes) - ->reduce(array_merge(...)) - ->toArrayList(static fn (array $cts) => ArrayList::collect($cts)) + ->flatten() + ->toArrayList() ->every(static fn (CommitType $ct) => \in_array($ct, $commitTypes, true)) ; } diff --git a/MessageBus/CommitTransactionInterface.php b/MessageBus/CommitTransactionInterface.php index ad6ddb4..ba9deb0 100644 --- a/MessageBus/CommitTransactionInterface.php +++ b/MessageBus/CommitTransactionInterface.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2024 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\TransactionalMessenger\MessageBus; use FRZB\Component\DependencyInjection\Attribute\AsAlias; diff --git a/MessageBus/DispatchTransactionInterface.php b/MessageBus/DispatchTransactionInterface.php index 4152cd9..3e23d0c 100644 --- a/MessageBus/DispatchTransactionInterface.php +++ b/MessageBus/DispatchTransactionInterface.php @@ -2,12 +2,21 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2024 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\TransactionalMessenger\MessageBus; use FRZB\Component\DependencyInjection\Attribute\AsAlias; use Symfony\Component\Messenger\MessageBusInterface; #[AsAlias(TransactionalMessageBus::class)] -interface DispatchTransactionInterface extends MessageBusInterface -{ -} +interface DispatchTransactionInterface extends MessageBusInterface {} diff --git a/MessageBus/RollbackTransactionInterface.php b/MessageBus/RollbackTransactionInterface.php index 831cb11..ba81ba9 100644 --- a/MessageBus/RollbackTransactionInterface.php +++ b/MessageBus/RollbackTransactionInterface.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2024 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\TransactionalMessenger\MessageBus; use FRZB\Component\DependencyInjection\Attribute\AsAlias; diff --git a/MessageBus/TransactionalMessageBus.php b/MessageBus/TransactionalMessageBus.php index 9134eec..6a15a1b 100644 --- a/MessageBus/TransactionalMessageBus.php +++ b/MessageBus/TransactionalMessageBus.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2024 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\TransactionalMessenger\MessageBus; use Fp\Collections\ArrayList; @@ -48,7 +59,6 @@ public function __construct( $this->failedStorage = $failedStorage ?? new StorageImpl(); } - /** {@inheritdoc} */ public function dispatch(object $message, array $stamps = []): Envelope { $envelope = EnvelopeHelper::wrap($message); @@ -60,7 +70,6 @@ public function dispatch(object $message, array $stamps = []): Envelope return $envelope; } - /** {@inheritdoc} */ public function commit(CommitType ...$commitTypes): void { try { @@ -72,7 +81,6 @@ public function commit(CommitType ...$commitTypes): void } } - /** {@inheritdoc} */ public function rollback(\Throwable $exception): void { ArrayList::collect($this->pendingStorage->iterate()) diff --git a/MessageBus/TransactionalMessageBusInterface.php b/MessageBus/TransactionalMessageBusInterface.php index 8854b7f..3bec2e9 100644 --- a/MessageBus/TransactionalMessageBusInterface.php +++ b/MessageBus/TransactionalMessageBusInterface.php @@ -2,11 +2,20 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2024 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\TransactionalMessenger\MessageBus; use FRZB\Component\DependencyInjection\Attribute\AsAlias; #[AsAlias(TransactionalMessageBus::class)] -interface TransactionalMessageBusInterface extends DispatchTransactionInterface, CommitTransactionInterface, RollbackTransactionInterface -{ -} +interface TransactionalMessageBusInterface extends DispatchTransactionInterface, CommitTransactionInterface, RollbackTransactionInterface {} diff --git a/Resources/bundles.php b/Resources/bundles.php index 59c2988..01a8841 100644 --- a/Resources/bundles.php +++ b/Resources/bundles.php @@ -2,8 +2,22 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2024 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ +use FRZB\Component\DependencyInjection\DependencyInjectionBundle; +use FRZB\Component\TransactionalMessenger\MessageBus\TransactionalMessageBus; +use Symfony\Bundle\FrameworkBundle\FrameworkBundle; + return [ - Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], - FRZB\Component\DependencyInjection\DependencyInjectionBundle::class => ['all' => true], - FRZB\Component\TransactionalMessenger\MessageBus\TransactionalMessageBus::class => ['all' => true], + FrameworkBundle::class => ['all' => true], + DependencyInjectionBundle::class => ['all' => true], + TransactionalMessageBus::class => ['all' => true], ]; diff --git a/Storage/Storage.php b/Storage/Storage.php index d78e9d7..032d835 100644 --- a/Storage/Storage.php +++ b/Storage/Storage.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2024 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\TransactionalMessenger\Storage; /** @@ -14,10 +25,8 @@ class Storage implements StorageInterface public function __construct( /** @param \Iterator $items */ private iterable $items = [], - ) { - } + ) {} - /** {@inheritdoc} */ public function init(iterable|StorageInterface $storage): static { $this->items = $storage instanceof StorageInterface ? $storage->list() : $storage; @@ -25,7 +34,6 @@ public function init(iterable|StorageInterface $storage): static return $this; } - /** {@inheritdoc} */ public function append(object ...$items): static { array_push($this->items, ...$items); @@ -33,7 +41,6 @@ public function append(object ...$items): static return $this; } - /** {@inheritdoc} */ public function prepend(object ...$items): static { array_unshift($this->items, ...$items); @@ -41,13 +48,11 @@ public function prepend(object ...$items): static return $this; } - /** {@inheritdoc} */ public function next(): ?object { return array_shift($this->items); } - /** {@inheritdoc} */ public function iterate(): iterable { while ($item = $this->next()) { @@ -55,19 +60,16 @@ public function iterate(): iterable } } - /** {@inheritdoc} */ public function map(callable $callback): static { return new static(array_map($callback, $this->items)); } - /** {@inheritdoc} */ public function filter(callable $callback): static { return new static(array_filter($this->items, $callback)); } - /** {@inheritdoc} */ public function merge(iterable|StorageInterface $storage): static { $this->items = [...$this->items, ...$storage instanceof StorageInterface ? $storage->list() : $storage]; @@ -75,7 +77,6 @@ public function merge(iterable|StorageInterface $storage): static return $this; } - /** {@inheritdoc} */ public function clear(): static { $this->items = []; @@ -83,13 +84,11 @@ public function clear(): static return $this; } - /** {@inheritdoc} */ public function list(): iterable { return $this->items; } - /** {@inheritdoc} */ public function count(): int { return \count($this->items); diff --git a/Storage/StorageInterface.php b/Storage/StorageInterface.php index 5517402..0e3995f 100644 --- a/Storage/StorageInterface.php +++ b/Storage/StorageInterface.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2024 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\TransactionalMessenger\Storage; /** diff --git a/Tests/Stub/Kernel.php b/Tests/Stub/Kernel.php index a63fc68..cc67636 100644 --- a/Tests/Stub/Kernel.php +++ b/Tests/Stub/Kernel.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2024 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\TransactionalMessenger\Tests\Stub; use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; diff --git a/Tests/Stub/Message/AbstractTransactionalMessage.php b/Tests/Stub/Message/AbstractTransactionalMessage.php index 40f1c60..c508554 100644 --- a/Tests/Stub/Message/AbstractTransactionalMessage.php +++ b/Tests/Stub/Message/AbstractTransactionalMessage.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2024 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\TransactionalMessenger\Tests\Stub\Message; use FRZB\Component\TransactionalMessenger\Attribute\Transactional; @@ -9,6 +20,4 @@ /** @internal */ #[Transactional(CommitType::OnTerminate)] -abstract class AbstractTransactionalMessage -{ -} +abstract class AbstractTransactionalMessage {} diff --git a/Tests/Stub/Message/ExtendedTransactionalMessage.php b/Tests/Stub/Message/ExtendedTransactionalMessage.php index 95fe246..f056259 100644 --- a/Tests/Stub/Message/ExtendedTransactionalMessage.php +++ b/Tests/Stub/Message/ExtendedTransactionalMessage.php @@ -2,8 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2024 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\TransactionalMessenger\Tests\Stub\Message; -class ExtendedTransactionalMessage extends AbstractTransactionalMessage -{ -} +class ExtendedTransactionalMessage extends AbstractTransactionalMessage {} diff --git a/Tests/Stub/Message/NonTransactionalMessage.php b/Tests/Stub/Message/NonTransactionalMessage.php index 6db6773..8330628 100644 --- a/Tests/Stub/Message/NonTransactionalMessage.php +++ b/Tests/Stub/Message/NonTransactionalMessage.php @@ -2,9 +2,18 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2024 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\TransactionalMessenger\Tests\Stub\Message; /** @internal */ -final class NonTransactionalMessage -{ -} +final class NonTransactionalMessage {} diff --git a/Tests/Stub/Message/TransactionalOnHandledMessage.php b/Tests/Stub/Message/TransactionalOnHandledMessage.php index ebf77f4..94d9642 100644 --- a/Tests/Stub/Message/TransactionalOnHandledMessage.php +++ b/Tests/Stub/Message/TransactionalOnHandledMessage.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2024 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\TransactionalMessenger\Tests\Stub\Message; use FRZB\Component\TransactionalMessenger\Attribute\Transactional; @@ -9,6 +20,4 @@ /** @internal */ #[Transactional(CommitType::OnHandled)] -final class TransactionalOnHandledMessage -{ -} +final class TransactionalOnHandledMessage {} diff --git a/Tests/Stub/Message/TransactionalOnResponseMessage.php b/Tests/Stub/Message/TransactionalOnResponseMessage.php index 7c364e9..f135708 100644 --- a/Tests/Stub/Message/TransactionalOnResponseMessage.php +++ b/Tests/Stub/Message/TransactionalOnResponseMessage.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2024 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\TransactionalMessenger\Tests\Stub\Message; use FRZB\Component\TransactionalMessenger\Attribute\Transactional; @@ -9,6 +20,4 @@ /** @internal */ #[Transactional(CommitType::OnResponse)] -final class TransactionalOnResponseMessage -{ -} +final class TransactionalOnResponseMessage {} diff --git a/Tests/Stub/Message/TransactionalOnTerminateMessage.php b/Tests/Stub/Message/TransactionalOnTerminateMessage.php index 4409057..5de1b7e 100644 --- a/Tests/Stub/Message/TransactionalOnTerminateMessage.php +++ b/Tests/Stub/Message/TransactionalOnTerminateMessage.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2024 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\TransactionalMessenger\Tests\Stub\Message; use FRZB\Component\TransactionalMessenger\Attribute\Transactional; @@ -9,6 +20,4 @@ /** @internal */ #[Transactional(CommitType::OnTerminate)] -final class TransactionalOnTerminateMessage -{ -} +final class TransactionalOnTerminateMessage {} diff --git a/Tests/Stub/ValueObject/MappedTestObject.php b/Tests/Stub/ValueObject/MappedTestObject.php index a8df3b0..afda6b3 100644 --- a/Tests/Stub/ValueObject/MappedTestObject.php +++ b/Tests/Stub/ValueObject/MappedTestObject.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2024 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\TransactionalMessenger\Tests\Stub\ValueObject; /** @internal */ @@ -9,8 +20,7 @@ final class MappedTestObject { public function __construct( public readonly TestObject $testObject, - ) { - } + ) {} public static function fromTestObject(TestObject $testObject): self { diff --git a/Tests/Stub/ValueObject/TestObject.php b/Tests/Stub/ValueObject/TestObject.php index 278f4b1..c94268c 100644 --- a/Tests/Stub/ValueObject/TestObject.php +++ b/Tests/Stub/ValueObject/TestObject.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2024 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\TransactionalMessenger\Tests\Stub\ValueObject; /** @internal */ diff --git a/Tests/Unit/EventListener/CommitTransactionEventListenerTest.php b/Tests/Unit/EventListener/CommitTransactionEventListenerTest.php index e442530..3249f90 100644 --- a/Tests/Unit/EventListener/CommitTransactionEventListenerTest.php +++ b/Tests/Unit/EventListener/CommitTransactionEventListenerTest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2024 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\TransactionalMessenger\Tests\Unit\EventListener; use FRZB\Component\TransactionalMessenger\EventListener\CommitTransactionOnMessageHandledEventListener; diff --git a/Tests/Unit/EventListener/RollbackTransactionEventListenerTest.php b/Tests/Unit/EventListener/RollbackTransactionEventListenerTest.php index 0f2bb33..b7cffe5 100644 --- a/Tests/Unit/EventListener/RollbackTransactionEventListenerTest.php +++ b/Tests/Unit/EventListener/RollbackTransactionEventListenerTest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2024 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\TransactionalMessenger\Tests\Unit\EventListener; use FRZB\Component\TransactionalMessenger\EventListener\RollbackTransactionOnExceptionEventListener; diff --git a/Tests/Unit/Helper/AttributeHelperTest.php b/Tests/Unit/Helper/AttributeHelperTest.php index f3d610c..1c9910d 100644 --- a/Tests/Unit/Helper/AttributeHelperTest.php +++ b/Tests/Unit/Helper/AttributeHelperTest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2024 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\TransactionalMessenger\Tests\Unit\Helper; use FRZB\Component\TransactionalMessenger\Attribute\Transactional; @@ -52,27 +63,27 @@ public function testHasAttributeMethod(string $className, bool $hasAttributes): public static function dataProvider(): iterable { - yield sprintf('%s', ClassHelper::getShortName(TransactionalOnTerminateMessage::class)) => [ + yield ClassHelper::getShortName(TransactionalOnTerminateMessage::class) => [ 'class_name' => TransactionalOnTerminateMessage::class, 'has_attributes' => true, ]; - yield sprintf('%s', ClassHelper::getShortName(TransactionalOnResponseMessage::class)) => [ + yield ClassHelper::getShortName(TransactionalOnResponseMessage::class) => [ 'class_name' => TransactionalOnResponseMessage::class, 'has_attributes' => true, ]; - yield sprintf('%s', ClassHelper::getShortName(TransactionalOnHandledMessage::class)) => [ + yield ClassHelper::getShortName(TransactionalOnHandledMessage::class) => [ 'class_name' => TransactionalOnHandledMessage::class, 'has_attributes' => true, ]; - yield sprintf('%s', ClassHelper::getShortName(ExtendedTransactionalMessage::class)) => [ + yield ClassHelper::getShortName(ExtendedTransactionalMessage::class) => [ 'class_name' => ExtendedTransactionalMessage::class, 'has_attributes' => true, ]; - yield sprintf('%s', ClassHelper::getShortName(NonTransactionalMessage::class)) => [ + yield ClassHelper::getShortName(NonTransactionalMessage::class) => [ 'class_name' => NonTransactionalMessage::class, 'has_attributes' => false, ]; diff --git a/Tests/Unit/Helper/ClassHelperTest.php b/Tests/Unit/Helper/ClassHelperTest.php index 20ce83f..2cedbeb 100644 --- a/Tests/Unit/Helper/ClassHelperTest.php +++ b/Tests/Unit/Helper/ClassHelperTest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2024 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\TransactionalMessenger\Tests\Unit\Helper; use FRZB\Component\TransactionalMessenger\Attribute\Transactional; @@ -30,8 +41,7 @@ public function testGetReflectionClassMethod(string $className, bool $isNull): v { $isNull ? self::assertNull(ClassHelper::getReflectionClass($className)) - : self::assertNotNull(ClassHelper::getReflectionClass($className)) - ; + : self::assertNotNull(ClassHelper::getReflectionClass($className)); } #[DataProvider('parentReflectionProvider')] @@ -39,8 +49,7 @@ public function testGetParentReflectionClassMethod(string $className, bool $isNu { $isNull ? self::assertNull(ClassHelper::getParentReflectionClass($className)) - : self::assertNotNull(ClassHelper::getParentReflectionClass($className)) - ; + : self::assertNotNull(ClassHelper::getParentReflectionClass($className)); } #[DataProvider('reflectionAttributesProvider')] @@ -48,28 +57,27 @@ public function testGetReflectionAttributesClassMethod(string $className, bool $ { $isEmpty ? self::assertEmpty(ClassHelper::getReflectionAttributes($className, Transactional::class)) - : self::assertNotEmpty(ClassHelper::getReflectionAttributes($className, Transactional::class)) - ; + : self::assertNotEmpty(ClassHelper::getReflectionAttributes($className, Transactional::class)); } public static function shortNameProvider(): iterable { - yield sprintf('%s', ClassHelper::getShortName(TransactionalOnTerminateMessage::class)) => [ + yield ClassHelper::getShortName(TransactionalOnTerminateMessage::class) => [ 'class_name' => TransactionalOnTerminateMessage::class, 'short_class_name' => 'TransactionalOnTerminateMessage', ]; - yield sprintf('%s', ClassHelper::getShortName(TransactionalOnResponseMessage::class)) => [ + yield ClassHelper::getShortName(TransactionalOnResponseMessage::class) => [ 'class_name' => TransactionalOnResponseMessage::class, 'short_class_name' => 'TransactionalOnResponseMessage', ]; - yield sprintf('%s', ClassHelper::getShortName(TransactionalOnHandledMessage::class)) => [ + yield ClassHelper::getShortName(TransactionalOnHandledMessage::class) => [ 'class_name' => TransactionalOnHandledMessage::class, 'short_class_name' => 'TransactionalOnHandledMessage', ]; - yield sprintf('%s', ClassHelper::getShortName(NonTransactionalMessage::class)) => [ + yield ClassHelper::getShortName(NonTransactionalMessage::class) => [ 'class_name' => NonTransactionalMessage::class, 'short_class_name' => 'NonTransactionalMessage', ]; @@ -82,27 +90,27 @@ public static function shortNameProvider(): iterable public static function reflectionProvider(): iterable { - yield sprintf('%s', ClassHelper::getShortName(TransactionalOnTerminateMessage::class)) => [ + yield ClassHelper::getShortName(TransactionalOnTerminateMessage::class) => [ 'class_name' => TransactionalOnTerminateMessage::class, 'is_null' => false, ]; - yield sprintf('%s', ClassHelper::getShortName(TransactionalOnResponseMessage::class)) => [ + yield ClassHelper::getShortName(TransactionalOnResponseMessage::class) => [ 'class_name' => TransactionalOnResponseMessage::class, 'is_null' => false, ]; - yield sprintf('%s', ClassHelper::getShortName(TransactionalOnHandledMessage::class)) => [ + yield ClassHelper::getShortName(TransactionalOnHandledMessage::class) => [ 'class_name' => TransactionalOnHandledMessage::class, 'is_null' => false, ]; - yield sprintf('%s', ClassHelper::getShortName(ExtendedTransactionalMessage::class)) => [ + yield ClassHelper::getShortName(ExtendedTransactionalMessage::class) => [ 'class_name' => ExtendedTransactionalMessage::class, 'is_null' => false, ]; - yield sprintf('%s', ClassHelper::getShortName(NonTransactionalMessage::class)) => [ + yield ClassHelper::getShortName(NonTransactionalMessage::class) => [ 'class_name' => NonTransactionalMessage::class, 'is_null' => false, ]; @@ -115,27 +123,27 @@ public static function reflectionProvider(): iterable public static function parentReflectionProvider(): iterable { - yield sprintf('%s', ClassHelper::getShortName(TransactionalOnTerminateMessage::class)) => [ + yield ClassHelper::getShortName(TransactionalOnTerminateMessage::class) => [ 'class_name' => TransactionalOnTerminateMessage::class, 'is_null' => true, ]; - yield sprintf('%s', ClassHelper::getShortName(TransactionalOnResponseMessage::class)) => [ + yield ClassHelper::getShortName(TransactionalOnResponseMessage::class) => [ 'class_name' => TransactionalOnResponseMessage::class, 'is_null' => true, ]; - yield sprintf('%s', ClassHelper::getShortName(TransactionalOnHandledMessage::class)) => [ + yield ClassHelper::getShortName(TransactionalOnHandledMessage::class) => [ 'class_name' => TransactionalOnHandledMessage::class, 'is_null' => true, ]; - yield sprintf('%s', ClassHelper::getShortName(ExtendedTransactionalMessage::class)) => [ + yield ClassHelper::getShortName(ExtendedTransactionalMessage::class) => [ 'class_name' => ExtendedTransactionalMessage::class, 'is_null' => false, ]; - yield sprintf('%s', ClassHelper::getShortName(NonTransactionalMessage::class)) => [ + yield ClassHelper::getShortName(NonTransactionalMessage::class) => [ 'class_name' => NonTransactionalMessage::class, 'is_null' => true, ]; @@ -148,27 +156,27 @@ public static function parentReflectionProvider(): iterable public static function reflectionAttributesProvider(): iterable { - yield sprintf('%s', ClassHelper::getShortName(TransactionalOnTerminateMessage::class)) => [ + yield ClassHelper::getShortName(TransactionalOnTerminateMessage::class) => [ 'class_name' => TransactionalOnTerminateMessage::class, 'is_empty' => false, ]; - yield sprintf('%s', ClassHelper::getShortName(TransactionalOnResponseMessage::class)) => [ + yield ClassHelper::getShortName(TransactionalOnResponseMessage::class) => [ 'class_name' => TransactionalOnResponseMessage::class, 'is_empty' => false, ]; - yield sprintf('%s', ClassHelper::getShortName(TransactionalOnHandledMessage::class)) => [ + yield ClassHelper::getShortName(TransactionalOnHandledMessage::class) => [ 'class_name' => TransactionalOnHandledMessage::class, 'is_empty' => false, ]; - yield sprintf('%s', ClassHelper::getShortName(ExtendedTransactionalMessage::class)) => [ + yield ClassHelper::getShortName(ExtendedTransactionalMessage::class) => [ 'class_name' => ExtendedTransactionalMessage::class, 'is_empty' => true, ]; - yield sprintf('%s', ClassHelper::getShortName(NonTransactionalMessage::class)) => [ + yield ClassHelper::getShortName(NonTransactionalMessage::class) => [ 'class_name' => NonTransactionalMessage::class, 'is_empty' => true, ]; diff --git a/Tests/Unit/Helper/EnvelopeHelperTest.php b/Tests/Unit/Helper/EnvelopeHelperTest.php index 48ba0a4..7ddecda 100644 --- a/Tests/Unit/Helper/EnvelopeHelperTest.php +++ b/Tests/Unit/Helper/EnvelopeHelperTest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2024 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\TransactionalMessenger\Tests\Unit\Helper; use FRZB\Component\TransactionalMessenger\Helper\ClassHelper; @@ -30,12 +41,12 @@ public function testWrapMethod(object $target): void public static function dataProvider(): iterable { - yield sprintf('%s', ClassHelper::getShortName(TransactionalOnTerminateMessage::class)) => [ + yield ClassHelper::getShortName(TransactionalOnTerminateMessage::class) => [ 'target' => new TransactionalOnTerminateMessage(), 'has_attributes' => true, ]; - yield sprintf('%s', ClassHelper::getShortName(Envelope::class)) => [ + yield ClassHelper::getShortName(Envelope::class) => [ 'target' => Envelope::wrap(new TransactionalOnTerminateMessage()), 'has_attributes' => false, ]; diff --git a/Tests/Unit/Helper/TransactionHelperTest.php b/Tests/Unit/Helper/TransactionHelperTest.php index c139aa0..a4374d9 100644 --- a/Tests/Unit/Helper/TransactionHelperTest.php +++ b/Tests/Unit/Helper/TransactionHelperTest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2024 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\TransactionalMessenger\Tests\Unit\Helper; use FRZB\Component\TransactionalMessenger\Enum\CommitType; @@ -30,8 +41,7 @@ public function getTransactionalMethod(string $className, bool $isTransactional) { $isTransactional ? self::assertNotEmpty(TransactionHelper::getTransactional($className)) - : self::assertEmpty(TransactionHelper::getTransactional($className)) - ; + : self::assertEmpty(TransactionHelper::getTransactional($className)); } #[DataProvider('dispatchableProvider')] @@ -42,22 +52,22 @@ public function getIsDispatchableMethod(string $className, bool $isAllowed, arra public static function transactionalProvider(): iterable { - yield sprintf('%s', ClassHelper::getShortName(TransactionalOnTerminateMessage::class)) => [ + yield ClassHelper::getShortName(TransactionalOnTerminateMessage::class) => [ 'class_name' => TransactionalOnTerminateMessage::class, 'is_transactional' => true, ]; - yield sprintf('%s', ClassHelper::getShortName(TransactionalOnResponseMessage::class)) => [ + yield ClassHelper::getShortName(TransactionalOnResponseMessage::class) => [ 'class_name' => TransactionalOnResponseMessage::class, 'is_transactional' => true, ]; - yield sprintf('%s', ClassHelper::getShortName(TransactionalOnHandledMessage::class)) => [ + yield ClassHelper::getShortName(TransactionalOnHandledMessage::class) => [ 'class_name' => TransactionalOnHandledMessage::class, 'is_transactional' => true, ]; - yield sprintf('%s', ClassHelper::getShortName(NonTransactionalMessage::class)) => [ + yield ClassHelper::getShortName(NonTransactionalMessage::class) => [ 'class_name' => NonTransactionalMessage::class, 'is_transactional' => false, ]; diff --git a/Tests/Unit/MessageBus/TransactionalMessageBusCommitTest.php b/Tests/Unit/MessageBus/TransactionalMessageBusCommitTest.php index 4176352..f0e0626 100644 --- a/Tests/Unit/MessageBus/TransactionalMessageBusCommitTest.php +++ b/Tests/Unit/MessageBus/TransactionalMessageBusCommitTest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2024 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\TransactionalMessenger\Tests\Unit\MessageBus; use FRZB\Component\TransactionalMessenger\Attribute\Transactional; diff --git a/Tests/Unit/MessageBus/TransactionalMessageBusDispatchTest.php b/Tests/Unit/MessageBus/TransactionalMessageBusDispatchTest.php index b56036a..703d2ea 100644 --- a/Tests/Unit/MessageBus/TransactionalMessageBusDispatchTest.php +++ b/Tests/Unit/MessageBus/TransactionalMessageBusDispatchTest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2024 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\TransactionalMessenger\Tests\Unit\MessageBus; use FRZB\Component\TransactionalMessenger\Helper\ClassHelper; diff --git a/Tests/Unit/MessageBus/TransactionalMessageBusRollbackTest.php b/Tests/Unit/MessageBus/TransactionalMessageBusRollbackTest.php index 0ad2354..7d92ee7 100644 --- a/Tests/Unit/MessageBus/TransactionalMessageBusRollbackTest.php +++ b/Tests/Unit/MessageBus/TransactionalMessageBusRollbackTest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2024 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\TransactionalMessenger\Tests\Unit\MessageBus; use FRZB\Component\TransactionalMessenger\Event\DispatchFailedEvent; diff --git a/Tests/Unit/Resources/BundlesTest.php b/Tests/Unit/Resources/BundlesTest.php index 68207fb..8cd581d 100644 --- a/Tests/Unit/Resources/BundlesTest.php +++ b/Tests/Unit/Resources/BundlesTest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2024 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\TransactionalMessenger\Tests\Unit\Resources; use FRZB\Component\DependencyInjection\DependencyInjectionBundle; diff --git a/Tests/Unit/Storage/StorageTest.php b/Tests/Unit/Storage/StorageTest.php index 75e619c..454bd52 100644 --- a/Tests/Unit/Storage/StorageTest.php +++ b/Tests/Unit/Storage/StorageTest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2024 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\TransactionalMessenger\Tests\Unit\Storage; use FRZB\Component\TransactionalMessenger\Storage\Storage as StorageImpl; diff --git a/Tests/Unit/ValueObject/FailedEnvelopeTest.php b/Tests/Unit/ValueObject/FailedEnvelopeTest.php index dfb055e..d83ed17 100644 --- a/Tests/Unit/ValueObject/FailedEnvelopeTest.php +++ b/Tests/Unit/ValueObject/FailedEnvelopeTest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2024 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\TransactionalMessenger\Tests\Unit\ValueObject; use FRZB\Component\TransactionalMessenger\Exception\DispatchException; diff --git a/Tests/Unit/ValueObject/PendingEnvelopeTest.php b/Tests/Unit/ValueObject/PendingEnvelopeTest.php index 65ed26d..46d5fee 100644 --- a/Tests/Unit/ValueObject/PendingEnvelopeTest.php +++ b/Tests/Unit/ValueObject/PendingEnvelopeTest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2024 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\TransactionalMessenger\Tests\Unit\ValueObject; use FRZB\Component\TransactionalMessenger\Enum\CommitType; diff --git a/Tests/Unit/ValueObject/SucceedEnvelopeTest.php b/Tests/Unit/ValueObject/SucceedEnvelopeTest.php index 6c1f26f..e5af3a3 100644 --- a/Tests/Unit/ValueObject/SucceedEnvelopeTest.php +++ b/Tests/Unit/ValueObject/SucceedEnvelopeTest.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2024 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\TransactionalMessenger\Tests\Unit\ValueObject; use FRZB\Component\TransactionalMessenger\Helper\EnvelopeHelper; diff --git a/TransactionalMessengerBundle.php b/TransactionalMessengerBundle.php index 6f847dd..76cb55e 100644 --- a/TransactionalMessengerBundle.php +++ b/TransactionalMessengerBundle.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2024 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\TransactionalMessenger; use Symfony\Component\DependencyInjection\ContainerBuilder; diff --git a/TransactionalMessengerExtension.php b/TransactionalMessengerExtension.php index cf4f2ed..2fcbdb3 100644 --- a/TransactionalMessengerExtension.php +++ b/TransactionalMessengerExtension.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2024 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\TransactionalMessenger; use Symfony\Component\Config\FileLocator; diff --git a/ValueObject/FailedEnvelope.php b/ValueObject/FailedEnvelope.php index 0d7e756..d2b3a1d 100644 --- a/ValueObject/FailedEnvelope.php +++ b/ValueObject/FailedEnvelope.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2024 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\TransactionalMessenger\ValueObject; use FRZB\Component\TransactionalMessenger\Exception\DispatchException; diff --git a/ValueObject/PendingEnvelope.php b/ValueObject/PendingEnvelope.php index 63358a8..169ea8f 100644 --- a/ValueObject/PendingEnvelope.php +++ b/ValueObject/PendingEnvelope.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2024 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\TransactionalMessenger\ValueObject; use FRZB\Component\TransactionalMessenger\Enum\CommitType; @@ -16,8 +27,7 @@ final class PendingEnvelope public function __construct( public readonly Envelope $envelope, public readonly \DateTimeImmutable $whenPended = new \DateTimeImmutable(), - ) { - } + ) {} public function getMessageClass(): string { diff --git a/ValueObject/SucceedEnvelope.php b/ValueObject/SucceedEnvelope.php index ce14b83..1cc8277 100644 --- a/ValueObject/SucceedEnvelope.php +++ b/ValueObject/SucceedEnvelope.php @@ -2,6 +2,17 @@ declare(strict_types=1); +/** + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * + * Copyright (c) 2024 Mykhailo Shtanko fractalzombie@gmail.com + * + * For the full copyright and license information, please view the LICENSE.MD + * file that was distributed with this source code. + */ + namespace FRZB\Component\TransactionalMessenger\ValueObject; use JetBrains\PhpStorm\Immutable; @@ -14,6 +25,5 @@ final class SucceedEnvelope public function __construct( public readonly Envelope $envelope, public readonly \DateTimeImmutable $whenDispatched = new \DateTimeImmutable(), - ) { - } + ) {} } diff --git a/composer.json b/composer.json index 14b5913..ec708e0 100644 --- a/composer.json +++ b/composer.json @@ -22,19 +22,19 @@ } ], "require": { - "php": ">=8.1", - "fp4php/functional": "^4.20|^6", - "symfony/http-kernel": "^5.4|^6|^7", - "symfony/framework-bundle": "^5.4|^6|^7", - "symfony/event-dispatcher": "^5.4|^6|^7", - "frzb/dependency-injection": "^1.8", - "symfony/yaml": "^5.4|^6|^7", - "symfony/messenger": "^5.4|^6|^7" + "php": ">=8.2", + "fp4php/functional": "^6.0", + "symfony/http-kernel": "^6|^7", + "symfony/framework-bundle": "^6|^7", + "symfony/event-dispatcher": "^6|^7", + "frzb/dependency-injection": "^2.1", + "symfony/yaml": "^6|^7", + "symfony/messenger": "^6|^7" }, "require-dev": { "phpunit/phpunit": "^10.5", - "phpunit/php-code-coverage": "^10.0", - "symfony/phpunit-bridge": "^5.4|^6|^7", + "phpunit/php-code-coverage": "^10.1", + "symfony/phpunit-bridge": "^6|^7", "friendsofphp/php-cs-fixer": "^3.41", "symfony/test-pack": "^1.0.10" }, diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 8022227..3a2eddd 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,7 +1,7 @@ ./Tests/Unit/ - + ./ @@ -36,5 +36,5 @@ ./TransactionalMessengerBundle.php ./TransactionalMessengerExtension.php - +