@@ -28,10 +28,10 @@ discard block |
||
28 | 28 | { |
29 | 29 | $scope = self::getAccessor($container)->scope; |
30 | 30 | $result = []; |
31 | - do { |
|
31 | + do{ |
|
32 | 32 | $result[] = $scope->getScopeName(); |
33 | 33 | $scope = $scope->getParentScope(); |
34 | - } while ($scope !== null); |
|
34 | + }while ($scope !== null); |
|
35 | 35 | |
36 | 36 | return $result; |
37 | 37 | } |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | Proxy::isProxy($container) => ContainerScope::getContainer() ?? throw new \RuntimeException( |
47 | 47 | 'Container Proxy is out of scope.', |
48 | 48 | ), |
49 | - default => throw new \InvalidArgumentException('Container must be an instance of ' . Container::class), |
|
49 | + default => throw new \InvalidArgumentException('Container must be an instance of '.Container::class), |
|
50 | 50 | }; |
51 | 51 | |
52 | 52 | $container ??= ContainerScope::getContainer(); |
53 | 53 | |
54 | - if (!$container instanceof Container) { |
|
54 | + if (!$container instanceof Container){ |
|
55 | 55 | throw new \RuntimeException('Container is not available.'); |
56 | 56 | } |
57 | 57 |
@@ -28,7 +28,8 @@ discard block |
||
28 | 28 | { |
29 | 29 | $scope = self::getAccessor($container)->scope; |
30 | 30 | $result = []; |
31 | - do { |
|
31 | + do |
|
32 | + { |
|
32 | 33 | $result[] = $scope->getScopeName(); |
33 | 34 | $scope = $scope->getParentScope(); |
34 | 35 | } while ($scope !== null); |
@@ -51,7 +52,8 @@ discard block |
||
51 | 52 | |
52 | 53 | $container ??= ContainerScope::getContainer(); |
53 | 54 | |
54 | - if (!$container instanceof Container) { |
|
55 | + if (!$container instanceof Container) |
|
56 | + { |
|
55 | 57 | throw new \RuntimeException('Container is not available.'); |
56 | 58 | } |
57 | 59 |
@@ -40,9 +40,9 @@ |
||
40 | 40 | public function defineDirectories(string $root): array |
41 | 41 | { |
42 | 42 | return [ |
43 | - 'app' => __DIR__ . '/fixtures', |
|
44 | - 'cache' => __DIR__ . '/cache', |
|
45 | - 'config' => __DIR__ . '/config', |
|
43 | + 'app' => __DIR__.'/fixtures', |
|
44 | + 'cache' => __DIR__.'/cache', |
|
45 | + 'config' => __DIR__.'/config', |
|
46 | 46 | ] + parent::defineDirectories($root); |
47 | 47 | } |
48 | 48 |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | public function addListener(callable $listener): self |
16 | 16 | { |
17 | - if (!\in_array($listener, $this->listeners, true)) { |
|
17 | + if (!\in_array($listener, $this->listeners, true)){ |
|
18 | 18 | $this->listeners[] = $listener; |
19 | 19 | } |
20 | 20 | |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | public function removeListener(callable $listener): void |
25 | 25 | { |
26 | 26 | $key = \array_search($listener, $this->listeners, true); |
27 | - if ($key !== false) { |
|
27 | + if ($key !== false){ |
|
28 | 28 | unset($this->listeners[$key]); |
29 | 29 | } |
30 | 30 | } |
@@ -14,7 +14,8 @@ discard block |
||
14 | 14 | |
15 | 15 | public function addListener(callable $listener): self |
16 | 16 | { |
17 | - if (!\in_array($listener, $this->listeners, true)) { |
|
17 | + if (!\in_array($listener, $this->listeners, true)) |
|
18 | + { |
|
18 | 19 | $this->listeners[] = $listener; |
19 | 20 | } |
20 | 21 | |
@@ -24,7 +25,8 @@ discard block |
||
24 | 25 | public function removeListener(callable $listener): void |
25 | 26 | { |
26 | 27 | $key = \array_search($listener, $this->listeners, true); |
27 | - if ($key !== false) { |
|
28 | + if ($key !== false) |
|
29 | + { |
|
28 | 30 | unset($this->listeners[$key]); |
29 | 31 | } |
30 | 32 | } |
@@ -86,13 +86,15 @@ discard block |
||
86 | 86 | |
87 | 87 | protected function coreHandler(ContainerInterface $container): CoreHandler |
88 | 88 | { |
89 | - if ($this->handler !== null) { |
|
89 | + if ($this->handler !== null) |
|
90 | + { |
|
90 | 91 | return $this->handler; |
91 | 92 | } |
92 | 93 | |
93 | 94 | $scope = Proxy::create(new \ReflectionClass(ScopeInterface::class), null, new \Spiral\Core\Attribute\Proxy()); |
94 | 95 | |
95 | - try { |
|
96 | + try |
|
97 | + { |
|
96 | 98 | // construct on demand |
97 | 99 | $this->handler = new CoreHandler( |
98 | 100 | match (false) { |
@@ -106,7 +108,9 @@ discard block |
||
106 | 108 | ); |
107 | 109 | |
108 | 110 | return $this->handler; |
109 | - } catch (ContainerExceptionInterface $e) { |
|
111 | + } |
|
112 | + catch (ContainerExceptionInterface $e) |
|
113 | + { |
|
110 | 114 | throw new TargetException($e->getMessage(), $e->getCode(), $e); |
111 | 115 | } |
112 | 116 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | // Automatically prepend HTTP verb to all action names. |
28 | 28 | public const RESTFUL = 1; |
29 | 29 | |
30 | - private HandlerInterface|CoreInterface|null $pipeline = null; |
|
30 | + private HandlerInterface | CoreInterface | null $pipeline = null; |
|
31 | 31 | private ?CoreHandler $handler = null; |
32 | 32 | private bool $verbActions; |
33 | 33 | |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | private array $constrains, |
37 | 37 | int $options = 0, |
38 | 38 | private string $defaultAction = 'index', |
39 | - ) { |
|
39 | + ){ |
|
40 | 40 | $this->verbActions = ($options & self::RESTFUL) === self::RESTFUL; |
41 | 41 | } |
42 | 42 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @mutation-free |
55 | 55 | * @deprecated Use {@see withHandler()} instead. |
56 | 56 | */ |
57 | - public function withCore(HandlerInterface|CoreInterface $core): TargetInterface |
|
57 | + public function withCore(HandlerInterface | CoreInterface $core): TargetInterface |
|
58 | 58 | { |
59 | 59 | $target = clone $this; |
60 | 60 | $target->pipeline = $core; |
@@ -86,13 +86,13 @@ discard block |
||
86 | 86 | |
87 | 87 | protected function coreHandler(ContainerInterface $container): CoreHandler |
88 | 88 | { |
89 | - if ($this->handler !== null) { |
|
89 | + if ($this->handler !== null){ |
|
90 | 90 | return $this->handler; |
91 | 91 | } |
92 | 92 | |
93 | 93 | $scope = Proxy::create(new \ReflectionClass(ScopeInterface::class), null, new \Spiral\Core\Attribute\Proxy()); |
94 | 94 | |
95 | - try { |
|
95 | + try{ |
|
96 | 96 | // construct on demand |
97 | 97 | $this->handler = new CoreHandler( |
98 | 98 | match (false) { |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | ); |
107 | 107 | |
108 | 108 | return $this->handler; |
109 | - } catch (ContainerExceptionInterface $e) { |
|
109 | + }catch (ContainerExceptionInterface $e){ |
|
110 | 110 | throw new TargetException($e->getMessage(), $e->getCode(), $e); |
111 | 111 | } |
112 | 112 | } |
@@ -16,7 +16,7 @@ |
||
16 | 16 | { |
17 | 17 | public function __construct( |
18 | 18 | #[Proxy] private ScopeInterface $scope, |
19 | - ) {} |
|
19 | + ){} |
|
20 | 20 | |
21 | 21 | public function process( |
22 | 22 | ServerRequestInterface $request, |
@@ -16,7 +16,8 @@ |
||
16 | 16 | { |
17 | 17 | public function __construct( |
18 | 18 | #[Proxy] private ScopeInterface $scope, |
19 | - ) {} |
|
19 | + ) { |
|
20 | +} |
|
20 | 21 | |
21 | 22 | public function process( |
22 | 23 | ServerRequestInterface $request, |
@@ -30,29 +30,37 @@ |
||
30 | 30 | { |
31 | 31 | $filename = $this->getFilename($section); |
32 | 32 | |
33 | - if (!\file_exists($filename)) { |
|
33 | + if (!\file_exists($filename)) |
|
34 | + { |
|
34 | 35 | return null; |
35 | 36 | } |
36 | 37 | |
37 | 38 | $fp = false; |
38 | 39 | $lock = false; |
39 | 40 | |
40 | - try { |
|
41 | + try |
|
42 | + { |
|
41 | 43 | $fp = \fopen($filename, 'r'); |
42 | - if ($fp === false) { |
|
44 | + if ($fp === false) |
|
45 | + { |
|
43 | 46 | return null; |
44 | 47 | } |
45 | 48 | |
46 | 49 | $lock = \flock($fp, \LOCK_SH | \LOCK_NB); |
47 | 50 | |
48 | - if ($lock === false) { |
|
51 | + if ($lock === false) |
|
52 | + { |
|
49 | 53 | return null; |
50 | 54 | } |
51 | 55 | |
52 | 56 | return include($filename); |
53 | - } catch (\Throwable) { |
|
57 | + } |
|
58 | + catch (\Throwable) |
|
59 | + { |
|
54 | 60 | return null; |
55 | - } finally { |
|
61 | + } |
|
62 | + finally |
|
63 | + { |
|
56 | 64 | $lock === false or \flock($fp, \LOCK_UN); |
57 | 65 | $fp === false or \fclose($fp); |
58 | 66 | } |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | public function __construct( |
20 | 20 | string $directory, |
21 | 21 | private readonly FilesInterface $files, |
22 | - ) { |
|
22 | + ){ |
|
23 | 23 | $this->directory = \rtrim($directory, '/'); |
24 | 24 | } |
25 | 25 | |
@@ -30,29 +30,29 @@ discard block |
||
30 | 30 | { |
31 | 31 | $filename = $this->getFilename($section); |
32 | 32 | |
33 | - if (!\file_exists($filename)) { |
|
33 | + if (!\file_exists($filename)){ |
|
34 | 34 | return null; |
35 | 35 | } |
36 | 36 | |
37 | 37 | $fp = false; |
38 | 38 | $lock = false; |
39 | 39 | |
40 | - try { |
|
40 | + try{ |
|
41 | 41 | $fp = \fopen($filename, 'r'); |
42 | - if ($fp === false) { |
|
42 | + if ($fp === false){ |
|
43 | 43 | return null; |
44 | 44 | } |
45 | 45 | |
46 | 46 | $lock = \flock($fp, \LOCK_SH | \LOCK_NB); |
47 | 47 | |
48 | - if ($lock === false) { |
|
48 | + if ($lock === false){ |
|
49 | 49 | return null; |
50 | 50 | } |
51 | 51 | |
52 | 52 | return include($filename); |
53 | - } catch (\Throwable) { |
|
53 | + }catch (\Throwable){ |
|
54 | 54 | return null; |
55 | - } finally { |
|
55 | + }finally{ |
|
56 | 56 | $lock === false or \flock($fp, \LOCK_UN); |
57 | 57 | $fp === false or \fclose($fp); |
58 | 58 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | { |
63 | 63 | $this->files->write( |
64 | 64 | $this->getFilename($section), |
65 | - '<?php return ' . \var_export($data, true) . ';', |
|
65 | + '<?php return '.\var_export($data, true).';', |
|
66 | 66 | FilesInterface::RUNTIME, |
67 | 67 | true, |
68 | 68 | ); |
@@ -7,7 +7,7 @@ |
||
7 | 7 | public function __construct( |
8 | 8 | string $key, |
9 | 9 | public readonly mixed $value, |
10 | - ) { |
|
10 | + ){ |
|
11 | 11 | parent::__construct($key); |
12 | 12 | } |
13 | 13 | } |
@@ -7,7 +7,7 @@ |
||
7 | 7 | public function __construct( |
8 | 8 | string $key, |
9 | 9 | public readonly mixed $value, |
10 | - ) { |
|
10 | + ){ |
|
11 | 11 | parent::__construct($key); |
12 | 12 | } |
13 | 13 | } |
@@ -7,7 +7,7 @@ |
||
7 | 7 | public function __construct( |
8 | 8 | string $key, |
9 | 9 | public readonly mixed $value, |
10 | - ) { |
|
10 | + ){ |
|
11 | 11 | parent::__construct($key); |
12 | 12 | } |
13 | 13 | } |