Skip to content

Commit 199f597

Browse files
author
Masiukevich Maksim
committed
update component
1 parent f1c393b commit 199f597

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

src/Configuration/Attributes/SagaAttributeBasedConfigurationLoader.php

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ final class SagaAttributeBasedConfigurationLoader implements SagaConfigurationLo
4444
public function __construct(
4545
EventListenerProcessorFactory $eventListenerProcessorFactory,
4646
?Reader $attributesReader = null
47-
)
48-
{
47+
) {
4948
$this->eventListenerProcessorFactory = $eventListenerProcessorFactory;
5049
$this->attributesReader = $attributesReader ?? new AttributesReader();
5150
}
@@ -76,7 +75,7 @@ classLevelAttributes: $attributes->classLevelCollection
7675
handlerCollection: $handlersCollection
7776
);
7877
}
79-
catch(\Throwable $throwable)
78+
catch (\Throwable $throwable)
8079
{
8180
throw InvalidSagaConfiguration::fromThrowable($throwable);
8281
}
@@ -90,15 +89,14 @@ classLevelAttributes: $attributes->classLevelCollection
9089
private function collectSagaEventHandlers(
9190
\SplObjectStorage $methodLevelAttributes,
9291
SagaMetadata $sagaMetadata
93-
): \SplObjectStorage
94-
{
92+
): \SplObjectStorage {
9593
/** @psalm-var \SplObjectStorage<MessageHandler, int> $handlersCollection */
9694
$handlersCollection = new \SplObjectStorage();
9795

9896
/** @var MethodLevel $methodLevelAttribute */
99-
foreach($methodLevelAttributes as $methodLevelAttribute)
97+
foreach ($methodLevelAttributes as $methodLevelAttribute)
10098
{
101-
if($methodLevelAttribute->attribute instanceof SagaEventListener)
99+
if ($methodLevelAttribute->attribute instanceof SagaEventListener)
102100
{
103101
$handlersCollection->attach(
104102
$this->createMessageHandler(
@@ -140,7 +138,7 @@ private function createMessageHandler(MethodLevel $methodLevelAttribute, SagaMet
140138

141139
$expectedMethodName = createEventListenerName($eventClass);
142140

143-
if($expectedMethodName === $eventListenerReflectionMethod->name)
141+
if ($expectedMethodName === $eventListenerReflectionMethod->name)
144142
{
145143
$reflectionMethod = $methodLevelAttribute->reflectionMethod;
146144

@@ -176,13 +174,13 @@ private function extractEventClass(\ReflectionMethod $reflectionMethod): string
176174
{
177175
$reflectionParameters = $reflectionMethod->getParameters();
178176

179-
if(\count($reflectionParameters) === 1)
177+
if (\count($reflectionParameters) === 1)
180178
{
181179
$firstArgumentType = isset($reflectionParameters[0]) && $reflectionParameters[0]->getType() !== null
182180
? $reflectionParameters[0]->getType()
183181
: null;
184182

185-
if($firstArgumentType !== null)
183+
if ($firstArgumentType !== null)
186184
{
187185
/** @var \ReflectionNamedType $reflectionType */
188186
$reflectionType = $reflectionParameters[0]->getType();
@@ -192,7 +190,8 @@ private function extractEventClass(\ReflectionMethod $reflectionMethod): string
192190
*/
193191
$eventClass = $reflectionType->getName();
194192

195-
if(\class_exists($eventClass))
193+
/** @psalm-suppress RedundantConditionGivenDocblockType */
194+
if (\class_exists($eventClass))
196195
{
197196
return $eventClass;
198197
}
@@ -213,7 +212,7 @@ private function extractEventClass(\ReflectionMethod $reflectionMethod): string
213212
*/
214213
private static function createSagaMetadata(string $sagaClass, SagaHeader $sagaHeader): SagaMetadata
215214
{
216-
if(\class_exists($sagaHeader->idClass) === false)
215+
if (\class_exists($sagaHeader->idClass) === false)
217216
{
218217
throw new \InvalidArgumentException(
219218
\sprintf(
@@ -225,7 +224,7 @@ private static function createSagaMetadata(string $sagaClass, SagaHeader $sagaHe
225224

226225
$containingIdentifierSource = SagaMetadata::CORRELATION_ID_SOURCE_EVENT;
227226

228-
if($sagaHeader->containingIdSource !== '')
227+
if ($sagaHeader->containingIdSource !== '')
229228
{
230229
$containingIdentifierSource = \strtolower($sagaHeader->containingIdSource);
231230
}
@@ -249,11 +248,11 @@ private static function createSagaMetadata(string $sagaClass, SagaHeader $sagaHe
249248
private static function searchSagaHeader(string $sagaClass, \SplObjectStorage $classLevelAttributes): SagaHeader
250249
{
251250
/** @var ClassLevel $attributes */
252-
foreach($classLevelAttributes as $attributes)
251+
foreach ($classLevelAttributes as $attributes)
253252
{
254253
$attributeObject = $attributes->attribute;
255254

256-
if($attributeObject instanceof SagaHeader)
255+
if ($attributeObject instanceof SagaHeader)
257256
{
258257
return $attributeObject;
259258
}

0 commit comments

Comments
 (0)