@@ -31,14 +31,17 @@ discard block |
||
| 31 | 31 | string $action, |
| 32 | 32 | array $parameters = ['options' => null, 'payload' => []], |
| 33 | 33 | ): string { |
| 34 | - if ($parameters['options'] === null) { |
|
| 34 | + if ($parameters['options'] === null) |
|
| 35 | + { |
|
| 35 | 36 | $parameters['options'] = new Options(); |
| 36 | 37 | } |
| 37 | 38 | |
| 38 | 39 | $tracer = $this->getTracer(); |
| 39 | 40 | |
| 40 | - if (\method_exists($parameters['options'], 'withHeader')) { |
|
| 41 | - foreach ($tracer->getContext() as $key => $data) { |
|
| 41 | + if (\method_exists($parameters['options'], 'withHeader')) |
|
| 42 | + { |
|
| 43 | + foreach ($tracer->getContext() as $key => $data) |
|
| 44 | + { |
|
| 42 | 45 | $parameters['options'] = $parameters['options']->withHeader($key, $data); |
| 43 | 46 | } |
| 44 | 47 | } |
@@ -58,9 +61,12 @@ discard block |
||
| 58 | 61 | |
| 59 | 62 | private function getTracer(): TracerInterface |
| 60 | 63 | { |
| 61 | - try { |
|
| 64 | + try |
|
| 65 | + { |
|
| 62 | 66 | return ContainerScope::getContainer()->get(TracerInterface::class); |
| 63 | - } catch (\Throwable $e) { |
|
| 67 | + } |
|
| 68 | + catch (\Throwable $e) |
|
| 69 | + { |
|
| 64 | 70 | return new NullTracer(); |
| 65 | 71 | } |
| 66 | 72 | } |
@@ -15,16 +15,22 @@ discard block |
||
| 15 | 15 | |
| 16 | 16 | public function getEnums(object|string|null $target = null): array |
| 17 | 17 | { |
| 18 | - if (!empty($target)) { |
|
| 18 | + if (!empty($target)) |
|
| 19 | + { |
|
| 19 | 20 | $target = new \ReflectionClass($target); |
| 20 | 21 | } |
| 21 | 22 | |
| 22 | 23 | $result = []; |
| 23 | - foreach ($this->availableEnums() as $enum) { |
|
| 24 | - try { |
|
| 24 | + foreach ($this->availableEnums() as $enum) |
|
| 25 | + { |
|
| 26 | + try |
|
| 27 | + { |
|
| 25 | 28 | $reflection = $this->enumReflection($enum); |
| 26 | - } catch (LocatorException $e) { |
|
| 27 | - if ($this->debug) { |
|
| 29 | + } |
|
| 30 | + catch (LocatorException $e) |
|
| 31 | + { |
|
| 32 | + if ($this->debug) |
|
| 33 | + { |
|
| 28 | 34 | throw $e; |
| 29 | 35 | } |
| 30 | 36 | |
@@ -32,7 +38,8 @@ discard block |
||
| 32 | 38 | continue; |
| 33 | 39 | } |
| 34 | 40 | |
| 35 | - if (!$this->isTargeted($reflection, $target) || $reflection->isInterface()) { |
|
| 41 | + if (!$this->isTargeted($reflection, $target) || $reflection->isInterface()) |
|
| 42 | + { |
|
| 36 | 43 | continue; |
| 37 | 44 | } |
| 38 | 45 | |
@@ -51,7 +58,8 @@ discard block |
||
| 51 | 58 | { |
| 52 | 59 | $enums = []; |
| 53 | 60 | |
| 54 | - foreach ($this->availableReflections() as $reflection) { |
|
| 61 | + foreach ($this->availableReflections() as $reflection) |
|
| 62 | + { |
|
| 55 | 63 | $enums = \array_merge($enums, $reflection->getEnums()); |
| 56 | 64 | } |
| 57 | 65 | |
@@ -65,11 +73,13 @@ discard block |
||
| 65 | 73 | */ |
| 66 | 74 | protected function isTargeted(\ReflectionEnum $enum, \ReflectionClass $target = null): bool |
| 67 | 75 | { |
| 68 | - if ($target === null) { |
|
| 76 | + if ($target === null) |
|
| 77 | + { |
|
| 69 | 78 | return true; |
| 70 | 79 | } |
| 71 | 80 | |
| 72 | - if (!$target->isTrait()) { |
|
| 81 | + if (!$target->isTrait()) |
|
| 82 | + { |
|
| 73 | 83 | //Target is interface or class |
| 74 | 84 | /** @psalm-suppress RedundantCondition https://github.com/vimeo/psalm/issues/9489 */ |
| 75 | 85 | return $enum->isSubclassOf($target) || $enum->getName() === $target->getName(); |