@@ -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 | ); |
@@ -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 | } |
@@ -9,7 +9,7 @@ |
||
9 | 9 | public function __construct( |
10 | 10 | string $key, |
11 | 11 | public readonly mixed $value |
12 | - ) { |
|
12 | + ){ |
|
13 | 13 | parent::__construct($key); |
14 | 14 | } |
15 | 15 | } |
@@ -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 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | |
30 | 30 | public function __construct( |
31 | 31 | private readonly ConfiguratorInterface $config |
32 | - ) { |
|
32 | + ){ |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | public function registerTypeAlias(string $storageClass, string $alias): void |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | ): CacheManager { |
56 | 56 | $manager = new CacheManager($config, $factory, $dispatcher); |
57 | 57 | |
58 | - foreach ($config->getAliases() as $alias => $storageName) { |
|
58 | + foreach ($config->getAliases() as $alias => $storageName){ |
|
59 | 59 | $binder->bind( |
60 | 60 | $alias, |
61 | 61 | static fn (CacheManager $manager): CacheInterface => $manager->storage($storageName) |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | ], |
79 | 79 | 'file' => [ |
80 | 80 | 'type' => 'file', |
81 | - 'path' => $dirs->get('runtime') . 'cache', |
|
81 | + 'path' => $dirs->get('runtime').'cache', |
|
82 | 82 | ], |
83 | 83 | ], |
84 | 84 | 'typeAliases' => [ |
@@ -55,7 +55,8 @@ |
||
55 | 55 | ): CacheManager { |
56 | 56 | $manager = new CacheManager($config, $factory, $dispatcher); |
57 | 57 | |
58 | - foreach ($config->getAliases() as $alias => $storageName) { |
|
58 | + foreach ($config->getAliases() as $alias => $storageName) |
|
59 | + { |
|
59 | 60 | $binder->bind( |
60 | 61 | $alias, |
61 | 62 | static fn (CacheManager $manager): CacheInterface => $manager->storage($storageName) |
@@ -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 | } |
@@ -90,14 +90,17 @@ |
||
90 | 90 | |
91 | 91 | private function resolveSession(ContainerInterface $container): SessionInterface |
92 | 92 | { |
93 | - try { |
|
93 | + try |
|
94 | + { |
|
94 | 95 | /** @var ServerRequestInterface $request */ |
95 | 96 | $request = $container->get(ServerRequestInterface::class); |
96 | 97 | return $request->getAttribute(SessionMiddleware::ATTRIBUTE) ?? throw new ContextualObjectNotFoundException( |
97 | 98 | SessionInterface::class, |
98 | 99 | SessionMiddleware::ATTRIBUTE, |
99 | 100 | ); |
100 | - } catch (InvalidRequestScopeException $e) { |
|
101 | + } |
|
102 | + catch (InvalidRequestScopeException $e) |
|
103 | + { |
|
101 | 104 | throw new InvalidRequestScopeException(SessionInterface::class, previous: $e); |
102 | 105 | } |
103 | 106 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | { |
27 | 27 | public function __construct( |
28 | 28 | private readonly BinderInterface $binder, |
29 | - ) { |
|
29 | + ){ |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | public function defineBindings(): array |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | 'handler' => new Autowire( |
72 | 72 | FileHandler::class, |
73 | 73 | [ |
74 | - 'directory' => $directories->get('runtime') . 'session', |
|
74 | + 'directory' => $directories->get('runtime').'session', |
|
75 | 75 | 'lifetime' => 86400, |
76 | 76 | ] |
77 | 77 | ), |
@@ -90,14 +90,14 @@ discard block |
||
90 | 90 | |
91 | 91 | private function resolveSession(ContainerInterface $container): SessionInterface |
92 | 92 | { |
93 | - try { |
|
93 | + try{ |
|
94 | 94 | /** @var ServerRequestInterface $request */ |
95 | 95 | $request = $container->get(ServerRequestInterface::class); |
96 | 96 | return $request->getAttribute(SessionMiddleware::ATTRIBUTE) ?? throw new ContextualObjectNotFoundException( |
97 | 97 | SessionInterface::class, |
98 | 98 | SessionMiddleware::ATTRIBUTE, |
99 | 99 | ); |
100 | - } catch (InvalidRequestScopeException $e) { |
|
100 | + }catch (InvalidRequestScopeException $e){ |
|
101 | 101 | throw new InvalidRequestScopeException(SessionInterface::class, previous: $e); |
102 | 102 | } |
103 | 103 | } |
@@ -19,9 +19,9 @@ |
||
19 | 19 | { |
20 | 20 | public function __construct( |
21 | 21 | string $id, |
22 | - string|Container|null $scopeOrContainer = null, |
|
23 | - \Throwable|null $previous = null, |
|
24 | - ) { |
|
22 | + string | Container | null $scopeOrContainer = null, |
|
23 | + \Throwable | null $previous = null, |
|
24 | + ){ |
|
25 | 25 | parent::__construct($id, $scopeOrContainer, Spiral::HttpRequest->value, $previous); |
26 | 26 | } |
27 | 27 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | public function __construct( |
23 | 23 | private readonly ConfiguratorInterface $config, |
24 | 24 | private readonly BinderInterface $binder, |
25 | - ) { |
|
25 | + ){ |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | public function defineBindings(): array |
@@ -54,12 +54,12 @@ discard block |
||
54 | 54 | |
55 | 55 | private function cookieQueue(ServerRequestInterface $request): CookieQueue |
56 | 56 | { |
57 | - try { |
|
57 | + try{ |
|
58 | 58 | return $request->getAttribute(CookieQueue::ATTRIBUTE) ?? throw new ContextualObjectNotFoundException( |
59 | 59 | CookieQueue::class, |
60 | 60 | CookieQueue::ATTRIBUTE, |
61 | 61 | ); |
62 | - } catch (InvalidRequestScopeException $e) { |
|
62 | + }catch (InvalidRequestScopeException $e){ |
|
63 | 63 | throw new InvalidRequestScopeException(CookieQueue::class, previous: $e); |
64 | 64 | } |
65 | 65 | } |
@@ -54,12 +54,15 @@ |
||
54 | 54 | |
55 | 55 | private function cookieQueue(ServerRequestInterface $request): CookieQueue |
56 | 56 | { |
57 | - try { |
|
57 | + try |
|
58 | + { |
|
58 | 59 | return $request->getAttribute(CookieQueue::ATTRIBUTE) ?? throw new ContextualObjectNotFoundException( |
59 | 60 | CookieQueue::class, |
60 | 61 | CookieQueue::ATTRIBUTE, |
61 | 62 | ); |
62 | - } catch (InvalidRequestScopeException $e) { |
|
63 | + } |
|
64 | + catch (InvalidRequestScopeException $e) |
|
65 | + { |
|
63 | 66 | throw new InvalidRequestScopeException(CookieQueue::class, previous: $e); |
64 | 67 | } |
65 | 68 | } |