@@ -13,13 +13,13 @@ |
||
13 | 13 | /** |
14 | 14 | * @throws ClassNotFoundException |
15 | 15 | */ |
16 | - public function canInitialize(BootloaderInterface|string $bootloader, ?BootloadConfig $config = null): bool |
|
16 | + public function canInitialize(BootloaderInterface | string $bootloader, ?BootloadConfig $config = null): bool |
|
17 | 17 | { |
18 | - if (!\is_string($bootloader)) { |
|
18 | + if (!\is_string($bootloader)){ |
|
19 | 19 | return true; |
20 | 20 | } |
21 | 21 | |
22 | - if (!\class_exists($bootloader)) { |
|
22 | + if (!\class_exists($bootloader)){ |
|
23 | 23 | throw new ClassNotFoundException(\sprintf('Bootloader class `%s` does not exist.', $bootloader)); |
24 | 24 | } |
25 | 25 |
@@ -15,11 +15,13 @@ |
||
15 | 15 | */ |
16 | 16 | public function canInitialize(BootloaderInterface|string $bootloader, ?BootloadConfig $config = null): bool |
17 | 17 | { |
18 | - if (!\is_string($bootloader)) { |
|
18 | + if (!\is_string($bootloader)) |
|
19 | + { |
|
19 | 20 | return true; |
20 | 21 | } |
21 | 22 | |
22 | - if (!\class_exists($bootloader)) { |
|
23 | + if (!\class_exists($bootloader)) |
|
24 | + { |
|
23 | 25 | throw new ClassNotFoundException(\sprintf('Bootloader class `%s` does not exist.', $bootloader)); |
24 | 26 | } |
25 | 27 |
@@ -124,7 +124,8 @@ |
||
124 | 124 | $reflection = $target->getReflection(); |
125 | 125 | self::assertSame($hasReflection, $reflection !== null); |
126 | 126 | self::assertNull($target->getObject()); |
127 | - if ($hasReflection) { |
|
127 | + if ($hasReflection) |
|
128 | + { |
|
128 | 129 | self::assertInstanceOf(\ReflectionMethod::class, $reflection); |
129 | 130 | self::assertSame($action, $reflection->getName()); |
130 | 131 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | $target = Target::fromReflectionFunction($reflection, ['print_r-path']); |
37 | 37 | |
38 | 38 | self::assertSame($reflection, $target->getReflection()); |
39 | - self::assertSame('print_r-path', (string) $target); |
|
39 | + self::assertSame('print_r-path', (string)$target); |
|
40 | 40 | self::assertNull($target->getObject()); |
41 | 41 | } |
42 | 42 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | $target = Target::fromClosure(\print_r(...), ['print_r-path']); |
46 | 46 | |
47 | 47 | self::assertNotNull($target->getReflection()); |
48 | - self::assertSame('print_r-path', (string) $target); |
|
48 | + self::assertSame('print_r-path', (string)$target); |
|
49 | 49 | self::assertNull($target->getObject()); |
50 | 50 | } |
51 | 51 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $target = Target::fromClosure($this->{__FUNCTION__}(...), ['print_r-path']); |
55 | 55 | |
56 | 56 | self::assertNotNull($target->getReflection()); |
57 | - self::assertSame('print_r-path', (string) $target); |
|
57 | + self::assertSame('print_r-path', (string)$target); |
|
58 | 58 | self::assertNull($target->getObject()); |
59 | 59 | } |
60 | 60 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | $target = Target::fromReflectionMethod($reflection, self::class); |
66 | 66 | |
67 | 67 | self::assertSame($reflection, $target->getReflection()); |
68 | - self::assertSame(self::class . '->' . __FUNCTION__, (string) $target); |
|
68 | + self::assertSame(self::class.'->'.__FUNCTION__, (string)$target); |
|
69 | 69 | self::assertNull($target->getObject()); |
70 | 70 | } |
71 | 71 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | $target = Target::fromReflectionMethod($reflection, $this); |
77 | 77 | |
78 | 78 | self::assertSame($reflection, $target->getReflection()); |
79 | - self::assertSame(self::class . '->' . __FUNCTION__, (string) $target); |
|
79 | + self::assertSame(self::class.'->'.__FUNCTION__, (string)$target); |
|
80 | 80 | self::assertNotNull($target->getObject()); |
81 | 81 | } |
82 | 82 | |
@@ -89,10 +89,10 @@ discard block |
||
89 | 89 | // Immutability |
90 | 90 | self::assertNotSame($target, $target2); |
91 | 91 | self::assertSame(['bar', 'baz'], $target2->getPath()); |
92 | - self::assertSame('bar.baz', (string) $target2); |
|
92 | + self::assertSame('bar.baz', (string)$target2); |
|
93 | 93 | // First target is not changed |
94 | 94 | self::assertSame(['foo', 'bar', 'baz'], $target->getPath()); |
95 | - self::assertSame($str, (string) $target); |
|
95 | + self::assertSame($str, (string)$target); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | #[DataProvider('providePathChunks')] |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $target = Target::fromPathString($str, $separator); |
103 | 103 | |
104 | 104 | self::assertSame($chunks, $target->getPath()); |
105 | - self::assertSame($str, (string) $target); |
|
105 | + self::assertSame($str, (string)$target); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | #[DataProvider('providePathChunks')] |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $target = Target::fromPathArray($chunks, $separator); |
113 | 113 | |
114 | 114 | self::assertSame($chunks, $target->getPath()); |
115 | - self::assertSame($str, (string) $target); |
|
115 | + self::assertSame($str, (string)$target); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | #[DataProvider('providePairs')] |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | $reflection = $target->getReflection(); |
125 | 125 | self::assertSame($hasReflection, $reflection !== null); |
126 | 126 | self::assertNull($target->getObject()); |
127 | - if ($hasReflection) { |
|
127 | + if ($hasReflection){ |
|
128 | 128 | self::assertInstanceOf(\ReflectionMethod::class, $reflection); |
129 | 129 | self::assertSame($action, $reflection->getName()); |
130 | 130 | } |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | $target = Target::fromPathString($str); |
149 | 149 | |
150 | 150 | self::assertSame(['foo', 'bar', 'baz'], $target->getPath()); |
151 | - self::assertSame($str, (string) $target); |
|
151 | + self::assertSame($str, (string)$target); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | public function testPrivateConstructor(): void |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | public function testInterceptorCallingEventShouldBeDispatched(): void |
21 | 21 | { |
22 | 22 | $context = $this->createPathContext(['test', 'test2']); |
23 | - $interceptor = new class implements InterceptorInterface { |
|
23 | + $interceptor = new class implements InterceptorInterface{ |
|
24 | 24 | public function intercept(CallContextInterface $context, HandlerInterface $handler): mixed |
25 | 25 | { |
26 | 26 | return null; |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | $pipeline = $this->createPipeline(interceptors: [$interceptor], dispatcher: $dispatcher); |
40 | 40 | |
41 | 41 | $pipeline->withHandler( |
42 | - new class implements HandlerInterface { |
|
42 | + new class implements HandlerInterface{ |
|
43 | 43 | public function handle(CallContextInterface $context): mixed |
44 | 44 | { |
45 | 45 | return null; |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | */ |
126 | 126 | private function createPipeline( |
127 | 127 | array $interceptors = [], |
128 | - HandlerInterface|null $lastHandler = null, |
|
129 | - EventDispatcherInterface|null $dispatcher = null, |
|
128 | + HandlerInterface | null $lastHandler = null, |
|
129 | + EventDispatcherInterface | null $dispatcher = null, |
|
130 | 130 | ): InterceptorPipeline { |
131 | 131 | $pipeline = new InterceptorPipeline($dispatcher); |
132 | 132 |
@@ -20,7 +20,8 @@ discard block |
||
20 | 20 | public function testInterceptorCallingEventShouldBeDispatched(): void |
21 | 21 | { |
22 | 22 | $context = $this->createPathContext(['test', 'test2']); |
23 | - $interceptor = new class implements InterceptorInterface { |
|
23 | + $interceptor = new class implements InterceptorInterface |
|
24 | + { |
|
24 | 25 | public function intercept(CallContextInterface $context, HandlerInterface $handler): mixed |
25 | 26 | { |
26 | 27 | return null; |
@@ -39,7 +40,8 @@ discard block |
||
39 | 40 | $pipeline = $this->createPipeline(interceptors: [$interceptor], dispatcher: $dispatcher); |
40 | 41 | |
41 | 42 | $pipeline->withHandler( |
42 | - new class implements HandlerInterface { |
|
43 | + new class implements HandlerInterface |
|
44 | + { |
|
43 | 45 | public function handle(CallContextInterface $context): mixed |
44 | 46 | { |
45 | 47 | return null; |
@@ -19,10 +19,10 @@ discard block |
||
19 | 19 | */ |
20 | 20 | public static function pathToReflection(string $controller, string $action): \ReflectionMethod |
21 | 21 | { |
22 | - try { |
|
22 | + try{ |
|
23 | 23 | /** @psalm-suppress ArgumentTypeCoercion */ |
24 | 24 | $method = new \ReflectionMethod($controller, $action); |
25 | - } catch (\ReflectionException $e) { |
|
25 | + }catch (\ReflectionException $e){ |
|
26 | 26 | throw new TargetCallException( |
27 | 27 | \sprintf('Invalid action `%s`->`%s`', $controller, $action), |
28 | 28 | TargetCallException::BAD_ACTION, |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public static function validateControllerMethod(\ReflectionMethod $method, mixed $controller = null): void |
41 | 41 | { |
42 | - if ($method->isStatic() || !$method->isPublic()) { |
|
42 | + if ($method->isStatic() || !$method->isPublic()){ |
|
43 | 43 | throw new TargetCallException( |
44 | 44 | \sprintf( |
45 | 45 | 'Invalid action `%s`->`%s`', |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | ); |
51 | 51 | } |
52 | 52 | |
53 | - if ($controller === null) { |
|
53 | + if ($controller === null){ |
|
54 | 54 | return; |
55 | 55 | } |
56 | 56 | |
57 | - if (!\is_object($controller) || !$method->getDeclaringClass()->isInstance($controller)) { |
|
57 | + if (!\is_object($controller) || !$method->getDeclaringClass()->isInstance($controller)){ |
|
58 | 58 | throw new TargetCallException( |
59 | 59 | \sprintf( |
60 | 60 | 'Invalid controller. Expected instance of `%s`, got `%s`.', |
@@ -19,10 +19,13 @@ discard block |
||
19 | 19 | */ |
20 | 20 | public static function pathToReflection(string $controller, string $action): \ReflectionMethod |
21 | 21 | { |
22 | - try { |
|
22 | + try |
|
23 | + { |
|
23 | 24 | /** @psalm-suppress ArgumentTypeCoercion */ |
24 | 25 | $method = new \ReflectionMethod($controller, $action); |
25 | - } catch (\ReflectionException $e) { |
|
26 | + } |
|
27 | + catch (\ReflectionException $e) |
|
28 | + { |
|
26 | 29 | throw new TargetCallException( |
27 | 30 | \sprintf('Invalid action `%s`->`%s`', $controller, $action), |
28 | 31 | TargetCallException::BAD_ACTION, |
@@ -39,7 +42,8 @@ discard block |
||
39 | 42 | */ |
40 | 43 | public static function validateControllerMethod(\ReflectionMethod $method, mixed $controller = null): void |
41 | 44 | { |
42 | - if ($method->isStatic() || !$method->isPublic()) { |
|
45 | + if ($method->isStatic() || !$method->isPublic()) |
|
46 | + { |
|
43 | 47 | throw new TargetCallException( |
44 | 48 | \sprintf( |
45 | 49 | 'Invalid action `%s`->`%s`', |
@@ -50,11 +54,13 @@ discard block |
||
50 | 54 | ); |
51 | 55 | } |
52 | 56 | |
53 | - if ($controller === null) { |
|
57 | + if ($controller === null) |
|
58 | + { |
|
54 | 59 | return; |
55 | 60 | } |
56 | 61 | |
57 | - if (!\is_object($controller) || !$method->getDeclaringClass()->isInstance($controller)) { |
|
62 | + if (!\is_object($controller) || !$method->getDeclaringClass()->isInstance($controller)) |
|
63 | + { |
|
58 | 64 | throw new TargetCallException( |
59 | 65 | \sprintf( |
60 | 66 | 'Invalid controller. Expected instance of `%s`, got `%s`.', |
@@ -15,7 +15,7 @@ |
||
15 | 15 | private TargetInterface $target, |
16 | 16 | private array $arguments = [], |
17 | 17 | array $attributes = [], |
18 | - ) { |
|
18 | + ){ |
|
19 | 19 | $this->attributes = $attributes; |
20 | 20 | } |
21 | 21 |
@@ -58,5 +58,5 @@ |
||
58 | 58 | * |
59 | 59 | * @return callable|array{class-string, non-empty-string}|null |
60 | 60 | */ |
61 | - public function getCallable(): callable|array|null; |
|
61 | + public function getCallable(): callable | array | null; |
|
62 | 62 | } |
@@ -31,7 +31,8 @@ |
||
31 | 31 | public function withInterceptors(CoreInterceptorInterface|InterceptorInterface ...$interceptors): static |
32 | 32 | { |
33 | 33 | $clone = clone $this; |
34 | - foreach ($interceptors as $interceptor) { |
|
34 | + foreach ($interceptors as $interceptor) |
|
35 | + { |
|
35 | 36 | $clone->pipeline->addInterceptor($interceptor); |
36 | 37 | } |
37 | 38 |
@@ -23,17 +23,17 @@ |
||
23 | 23 | $this->pipeline = new InterceptorPipeline($dispatcher); |
24 | 24 | } |
25 | 25 | |
26 | - public function withInterceptors(CoreInterceptorInterface|InterceptorInterface ...$interceptors): static |
|
26 | + public function withInterceptors(CoreInterceptorInterface | InterceptorInterface ...$interceptors): static |
|
27 | 27 | { |
28 | 28 | $clone = clone $this; |
29 | - foreach ($interceptors as $interceptor) { |
|
29 | + foreach ($interceptors as $interceptor){ |
|
30 | 30 | $clone->pipeline->addInterceptor($interceptor); |
31 | 31 | } |
32 | 32 | |
33 | 33 | return $clone; |
34 | 34 | } |
35 | 35 | |
36 | - public function build(HandlerInterface|CoreInterface $handler): InterceptorPipeline |
|
36 | + public function build(HandlerInterface | CoreInterface $handler): InterceptorPipeline |
|
37 | 37 | { |
38 | 38 | /** @psalm-suppress InvalidArgument */ |
39 | 39 | return $handler instanceof HandlerInterface |
@@ -7,7 +7,7 @@ |
||
7 | 7 | // Load the original class to make an alias |
8 | 8 | use Spiral\Interceptors\Exception\TargetCallException; |
9 | 9 | |
10 | -if (!\class_exists(TargetCallException::class)) { |
|
10 | +if (!\class_exists(TargetCallException::class)){ |
|
11 | 11 | /** |
12 | 12 | * Unable to perform user action or find controller. |
13 | 13 | * |
@@ -7,7 +7,8 @@ |
||
7 | 7 | // Load the original class to make an alias |
8 | 8 | use Spiral\Interceptors\Exception\TargetCallException; |
9 | 9 | |
10 | -if (!\class_exists(TargetCallException::class)) { |
|
10 | +if (!\class_exists(TargetCallException::class)) |
|
11 | +{ |
|
11 | 12 | /** |
12 | 13 | * Unable to perform user action or find controller. |
13 | 14 | * |
@@ -5,7 +5,8 @@ |
||
5 | 5 | namespace Spiral\Core\Exception; |
6 | 6 | |
7 | 7 | // Load the original class to make an alias |
8 | -if (!\class_exists(\Spiral\Interceptors\Exception\InterceptorException::class)) { |
|
8 | +if (!\class_exists(\Spiral\Interceptors\Exception\InterceptorException::class)) |
|
9 | +{ |
|
9 | 10 | /** |
10 | 11 | * @deprecated will be removed in Spiral v4.0 |
11 | 12 | * Use {@see \Spiral\Interceptors\Exception\InterceptorException} instead. |
@@ -5,10 +5,10 @@ |
||
5 | 5 | namespace Spiral\Core\Exception; |
6 | 6 | |
7 | 7 | // Load the original class to make an alias |
8 | -if (!\class_exists(\Spiral\Interceptors\Exception\InterceptorException::class)) { |
|
8 | +if (!\class_exists(\Spiral\Interceptors\Exception\InterceptorException::class)){ |
|
9 | 9 | /** |
10 | 10 | * @deprecated will be removed in Spiral v4.0 |
11 | 11 | * Use {@see \Spiral\Interceptors\Exception\InterceptorException} instead. |
12 | 12 | */ |
13 | - class InterceptorException extends \RuntimeException {} |
|
13 | + class InterceptorException extends \RuntimeException{} |
|
14 | 14 | } |