@@ -28,7 +28,7 @@ |
||
28 | 28 | /** |
29 | 29 | * @throws InvalidArgumentException |
30 | 30 | */ |
31 | - public function file(string|\Stringable $id): FileInterface; |
|
31 | + public function file(string | \Stringable $id): FileInterface; |
|
32 | 32 | |
33 | 33 | public function withDefault(string $name): self; |
34 | 34 | } |
@@ -55,7 +55,8 @@ discard block |
||
55 | 55 | { |
56 | 56 | $name ??= $this->default; |
57 | 57 | |
58 | - if (!isset($this->buckets[$name])) { |
|
58 | + if (!isset($this->buckets[$name])) |
|
59 | + { |
|
59 | 60 | throw new InvalidArgumentException(\sprintf(self::ERROR_NOT_FOUND, $name)); |
60 | 61 | } |
61 | 62 | |
@@ -71,7 +72,8 @@ discard block |
||
71 | 72 | |
72 | 73 | public function add(string $name, BucketInterface $storage, bool $overwrite = false): void |
73 | 74 | { |
74 | - if (!$overwrite && isset($this->buckets[$name])) { |
|
75 | + if (!$overwrite && isset($this->buckets[$name])) |
|
76 | + { |
|
75 | 77 | throw new \InvalidArgumentException(\sprintf(self::ERROR_REDEFINITION, $name)); |
76 | 78 | } |
77 | 79 | |
@@ -97,16 +99,19 @@ discard block |
||
97 | 99 | $uri = $this->uriToString($uri); |
98 | 100 | $result = \parse_url($uri); |
99 | 101 | |
100 | - if ($result === false) { |
|
102 | + if ($result === false) |
|
103 | + { |
|
101 | 104 | $message = 'URI argument must be a valid URI in "[STORAGE]://[PATH_TO_FILE]" format, but `%s` given'; |
102 | 105 | throw new InvalidArgumentException(\sprintf($message, $uri)); |
103 | 106 | } |
104 | 107 | |
105 | - if (!isset($result['scheme'])) { |
|
108 | + if (!isset($result['scheme'])) |
|
109 | + { |
|
106 | 110 | $result['scheme'] = $withScheme ? $this->default : null; |
107 | 111 | } |
108 | 112 | |
109 | - if (!isset($result['host'])) { |
|
113 | + if (!isset($result['host'])) |
|
114 | + { |
|
110 | 115 | $result['host'] = ''; |
111 | 116 | } |
112 | 117 |
@@ -55,14 +55,14 @@ discard block |
||
55 | 55 | { |
56 | 56 | $name ??= $this->default; |
57 | 57 | |
58 | - if (!isset($this->buckets[$name])) { |
|
58 | + if (!isset($this->buckets[$name])){ |
|
59 | 59 | throw new InvalidArgumentException(\sprintf(self::ERROR_NOT_FOUND, $name)); |
60 | 60 | } |
61 | 61 | |
62 | 62 | return $this->buckets[$name]; |
63 | 63 | } |
64 | 64 | |
65 | - public function file(string|\Stringable $id): FileInterface |
|
65 | + public function file(string | \Stringable $id): FileInterface |
|
66 | 66 | { |
67 | 67 | [$bucket, $file] = $this->parseUri($id); |
68 | 68 | |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | |
72 | 72 | public function add(string $name, BucketInterface $storage, bool $overwrite = false): void |
73 | 73 | { |
74 | - if (!$overwrite && isset($this->buckets[$name])) { |
|
74 | + if (!$overwrite && isset($this->buckets[$name])){ |
|
75 | 75 | throw new \InvalidArgumentException(\sprintf(self::ERROR_REDEFINITION, $name)); |
76 | 76 | } |
77 | 77 | |
@@ -92,35 +92,35 @@ discard block |
||
92 | 92 | * @return array{0: string|null, 1: string} |
93 | 93 | * @throws InvalidArgumentException |
94 | 94 | */ |
95 | - protected function parseUri(string|\Stringable $uri, bool $withScheme = true): array |
|
95 | + protected function parseUri(string | \Stringable $uri, bool $withScheme = true): array |
|
96 | 96 | { |
97 | 97 | $uri = $this->uriToString($uri); |
98 | 98 | $result = \parse_url($uri); |
99 | 99 | |
100 | - if ($result === false) { |
|
100 | + if ($result === false){ |
|
101 | 101 | $message = 'URI argument must be a valid URI in "[STORAGE]://[PATH_TO_FILE]" format, but `%s` given'; |
102 | 102 | throw new InvalidArgumentException(\sprintf($message, $uri)); |
103 | 103 | } |
104 | 104 | |
105 | - if (!isset($result['scheme'])) { |
|
105 | + if (!isset($result['scheme'])){ |
|
106 | 106 | $result['scheme'] = $withScheme ? $this->default : null; |
107 | 107 | } |
108 | 108 | |
109 | - if (!isset($result['host'])) { |
|
109 | + if (!isset($result['host'])){ |
|
110 | 110 | $result['host'] = ''; |
111 | 111 | } |
112 | 112 | |
113 | 113 | return [ |
114 | 114 | $result['scheme'] ?? null, |
115 | - $result['host'] . \rtrim($result['path'] ?? '', '/'), |
|
115 | + $result['host'].\rtrim($result['path'] ?? '', '/'), |
|
116 | 116 | ]; |
117 | 117 | } |
118 | 118 | |
119 | - private function uriToString(string|\Stringable $uri): string |
|
119 | + private function uriToString(string | \Stringable $uri): string |
|
120 | 120 | { |
121 | 121 | return match (true) { |
122 | 122 | \is_string($uri) => $uri, |
123 | - default => (string) $uri, |
|
123 | + default => (string)$uri, |
|
124 | 124 | }; |
125 | 125 | } |
126 | 126 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @throws FileOperationException |
24 | 24 | * @throws InvalidArgumentException |
25 | 25 | */ |
26 | - public function getContents(string|\Stringable $id): string; |
|
26 | + public function getContents(string | \Stringable $id): string; |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * {@see BucketInterface::getStream()} |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @throws FileOperationException |
33 | 33 | * @throws InvalidArgumentException |
34 | 34 | */ |
35 | - public function getStream(string|\Stringable $id); |
|
35 | + public function getStream(string | \Stringable $id); |
|
36 | 36 | |
37 | 37 | /** |
38 | 38 | * {@see BucketInterface::exists()} |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @throws FileOperationException |
41 | 41 | * @throws InvalidArgumentException |
42 | 42 | */ |
43 | - public function exists(string|\Stringable $id): bool; |
|
43 | + public function exists(string | \Stringable $id): bool; |
|
44 | 44 | |
45 | 45 | /** |
46 | 46 | * {@see BucketInterface::getLastModified()} |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @throws FileOperationException |
50 | 50 | * @throws InvalidArgumentException |
51 | 51 | */ |
52 | - public function getLastModified(string|\Stringable $id): int; |
|
52 | + public function getLastModified(string | \Stringable $id): int; |
|
53 | 53 | |
54 | 54 | /** |
55 | 55 | * {@see BucketInterface::getSize()} |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * @throws FileOperationException |
59 | 59 | * @throws InvalidArgumentException |
60 | 60 | */ |
61 | - public function getSize(string|\Stringable $id): int; |
|
61 | + public function getSize(string | \Stringable $id): int; |
|
62 | 62 | |
63 | 63 | /** |
64 | 64 | *{@see BucketInterface::getMimeType()} |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * @throws FileOperationException |
67 | 67 | * @throws InvalidArgumentException |
68 | 68 | */ |
69 | - public function getMimeType(string|\Stringable $id): string; |
|
69 | + public function getMimeType(string | \Stringable $id): string; |
|
70 | 70 | |
71 | 71 | /** |
72 | 72 | * {@see BucketInterface::getVisibility()} |
@@ -76,5 +76,5 @@ discard block |
||
76 | 76 | * @throws InvalidArgumentException |
77 | 77 | */ |
78 | 78 | #[ExpectedValues(valuesFromClass: Visibility::class)] |
79 | - public function getVisibility(string|\Stringable $id): string; |
|
79 | + public function getVisibility(string | \Stringable $id): string; |
|
80 | 80 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | protected function getStacktrace(\Throwable $e): array |
28 | 28 | { |
29 | 29 | $stacktrace = $e->getTrace(); |
30 | - if (empty($stacktrace)) { |
|
30 | + if (empty($stacktrace)){ |
|
31 | 31 | return []; |
32 | 32 | } |
33 | 33 | |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | 'line' => $e->getLine(), |
38 | 38 | ] + $stacktrace[0]; |
39 | 39 | |
40 | - if ($stacktrace[0] !== $header) { |
|
40 | + if ($stacktrace[0] !== $header){ |
|
41 | 41 | \array_unshift($stacktrace, $header); |
42 | 42 | } |
43 | 43 |
@@ -27,7 +27,8 @@ discard block |
||
27 | 27 | protected function getStacktrace(\Throwable $e): array |
28 | 28 | { |
29 | 29 | $stacktrace = $e->getTrace(); |
30 | - if (empty($stacktrace)) { |
|
30 | + if (empty($stacktrace)) |
|
31 | + { |
|
31 | 32 | return []; |
32 | 33 | } |
33 | 34 | |
@@ -37,7 +38,8 @@ discard block |
||
37 | 38 | 'line' => $e->getLine(), |
38 | 39 | ] + $stacktrace[0]; |
39 | 40 | |
40 | - if ($stacktrace[0] !== $header) { |
|
41 | + if ($stacktrace[0] !== $header) |
|
42 | + { |
|
41 | 43 | \array_unshift($stacktrace, $header); |
42 | 44 | } |
43 | 45 |
@@ -87,12 +87,14 @@ discard block |
||
87 | 87 | { |
88 | 88 | $style = $this->getStyle($token, $previous); |
89 | 89 | |
90 | - if (!\str_contains((string) $token[1], "\n")) { |
|
90 | + if (!\str_contains((string) $token[1], "\n")) |
|
91 | + { |
|
91 | 92 | return \sprintf($this->templates['token'], $style, $token[1]); |
92 | 93 | } |
93 | 94 | |
94 | 95 | $lines = []; |
95 | - foreach (\explode("\n", (string) $token[1]) as $line) { |
|
96 | + foreach (\explode("\n", (string) $token[1]) as $line) |
|
97 | + { |
|
96 | 98 | $lines[] = \sprintf($this->templates['token'], $style, $line); |
97 | 99 | } |
98 | 100 | |
@@ -113,16 +115,21 @@ discard block |
||
113 | 115 | */ |
114 | 116 | private function getStyle(array $token, array $previous): string |
115 | 117 | { |
116 | - if (!empty($previous)) { |
|
117 | - foreach ($this->style as $style => $tokens) { |
|
118 | - if (\in_array($previous[1] . $token[0], $tokens)) { |
|
118 | + if (!empty($previous)) |
|
119 | + { |
|
120 | + foreach ($this->style as $style => $tokens) |
|
121 | + { |
|
122 | + if (\in_array($previous[1] . $token[0], $tokens)) |
|
123 | + { |
|
119 | 124 | return $style; |
120 | 125 | } |
121 | 126 | } |
122 | 127 | } |
123 | 128 | |
124 | - foreach ($this->style as $style => $tokens) { |
|
125 | - if (\in_array($token[0], $tokens)) { |
|
129 | + foreach ($this->style as $style => $tokens) |
|
130 | + { |
|
131 | + if (\in_array($token[0], $tokens)) |
|
132 | + { |
|
126 | 133 | return $style; |
127 | 134 | } |
128 | 135 | } |
@@ -13,9 +13,9 @@ discard block |
||
13 | 13 | class ConsoleStyle implements StyleInterface |
14 | 14 | { |
15 | 15 | protected array $templates = [ |
16 | - 'token' => '%s%s' . Color::RESET, |
|
17 | - 'line' => Color::LIGHT_CYAN . ' %s ' . Color::RESET . " %s\n", |
|
18 | - 'active' => Color::BG_RED . ' ' . Color::LIGHT_WHITE . '%s ' . Color::RESET . " %s\n", |
|
16 | + 'token' => '%s%s'.Color::RESET, |
|
17 | + 'line' => Color::LIGHT_CYAN.' %s '.Color::RESET." %s\n", |
|
18 | + 'active' => Color::BG_RED.' '.Color::LIGHT_WHITE.'%s '.Color::RESET." %s\n", |
|
19 | 19 | ]; |
20 | 20 | protected array $style = [ |
21 | 21 | Color::YELLOW => [ |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | T_VARIABLE, |
78 | 78 | ], |
79 | 79 | Color::LIGHT_YELLOW => [ |
80 | - '->' . T_STRING, |
|
81 | - '::' . T_STRING, |
|
80 | + '->'.T_STRING, |
|
81 | + '::'.T_STRING, |
|
82 | 82 | ], |
83 | 83 | ]; |
84 | 84 | |
@@ -86,12 +86,12 @@ discard block |
||
86 | 86 | { |
87 | 87 | $style = $this->getStyle($token, $previous); |
88 | 88 | |
89 | - if (!\str_contains((string) $token[1], "\n")) { |
|
89 | + if (!\str_contains((string)$token[1], "\n")){ |
|
90 | 90 | return \sprintf($this->templates['token'], $style, $token[1]); |
91 | 91 | } |
92 | 92 | |
93 | 93 | $lines = []; |
94 | - foreach (\explode("\n", (string) $token[1]) as $line) { |
|
94 | + foreach (\explode("\n", (string)$token[1]) as $line){ |
|
95 | 95 | $lines[] = \sprintf($this->templates['token'], $style, $line); |
96 | 96 | } |
97 | 97 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | { |
103 | 103 | return \sprintf( |
104 | 104 | $this->templates[$target ? 'active' : 'line'], |
105 | - \str_pad((string) $number, 4, ' ', STR_PAD_LEFT), |
|
105 | + \str_pad((string)$number, 4, ' ', STR_PAD_LEFT), |
|
106 | 106 | $code, |
107 | 107 | ); |
108 | 108 | } |
@@ -112,16 +112,16 @@ discard block |
||
112 | 112 | */ |
113 | 113 | private function getStyle(array $token, array $previous): string |
114 | 114 | { |
115 | - if (!empty($previous)) { |
|
116 | - foreach ($this->style as $style => $tokens) { |
|
117 | - if (\in_array($previous[1] . $token[0], $tokens)) { |
|
115 | + if (!empty($previous)){ |
|
116 | + foreach ($this->style as $style => $tokens){ |
|
117 | + if (\in_array($previous[1].$token[0], $tokens)){ |
|
118 | 118 | return $style; |
119 | 119 | } |
120 | 120 | } |
121 | 121 | } |
122 | 122 | |
123 | - foreach ($this->style as $style => $tokens) { |
|
124 | - if (\in_array($token[0], $tokens)) { |
|
123 | + foreach ($this->style as $style => $tokens){ |
|
124 | + if (\in_array($token[0], $tokens)){ |
|
125 | 125 | return $style; |
126 | 126 | } |
127 | 127 | } |
@@ -42,15 +42,15 @@ |
||
42 | 42 | |
43 | 43 | $declaration |
44 | 44 | ->addConstant('PRIVATE', 123) |
45 | - ->setVisibility(Partial\Visibility::PRIVATE); |
|
45 | + ->setVisibility(Partial\Visibility::private); |
|
46 | 46 | |
47 | 47 | $declaration |
48 | 48 | ->addConstant('PROTECTED', 456) |
49 | - ->setVisibility(Partial\Visibility::PROTECTED); |
|
49 | + ->setVisibility(Partial\Visibility::protected); |
|
50 | 50 | |
51 | 51 | $declaration |
52 | 52 | ->addConstant('PUBLIC', 789) |
53 | - ->setVisibility(Partial\Visibility::PUBLIC); |
|
53 | + ->setVisibility(Partial\Visibility::public); |
|
54 | 54 | |
55 | 55 | $declaration |
56 | 56 | ->addConstant('WITH_COMMENT', 'foo') |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | final class MyClass extends Spiral\Tests\Reactor\ClassDeclarationTest implements Countable |
30 | 30 | { |
31 | - }'), \preg_replace('/\s+/', '', (string) $declaration)); |
|
31 | + }'), \preg_replace('/\s+/', '', (string)$declaration)); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | public function testClassDeclarationWithConstants(): void |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | |
76 | 76 | #[Foo\Cached(mode: true)] |
77 | 77 | public const WITH_ATTRIBUTE = \'attr\'; |
78 | - }'), \preg_replace('/\s+/', '', (string) $declaration)); |
|
78 | + }'), \preg_replace('/\s+/', '', (string)$declaration)); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | public function testClassDeclarationWithMethods(): void |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | { |
107 | 107 | return count($items ?: $this->items); |
108 | 108 | } |
109 | - }'), \preg_replace('/\s+/', '', (string) $declaration)); |
|
109 | + }'), \preg_replace('/\s+/', '', (string)$declaration)); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | public function testName(): void |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | { |
58 | 58 | $param = Parameter::fromElement($this->element->addParameter($name)); |
59 | 59 | |
60 | - if (\func_num_args() > 1) { |
|
60 | + if (\func_num_args() > 1){ |
|
61 | 61 | $param->setDefaultValue($defaultValue); |
62 | 62 | } |
63 | 63 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | { |
98 | 98 | $type = $this->element->getReturnType(false); |
99 | 99 | |
100 | - return $type === null ? null : (string) $type; |
|
100 | + return $type === null ? null : (string)$type; |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | public function setReturnReference(bool $state = true): static |
@@ -57,7 +57,8 @@ |
||
57 | 57 | { |
58 | 58 | $param = Parameter::fromElement($this->element->addParameter($name)); |
59 | 59 | |
60 | - if (\func_num_args() > 1) { |
|
60 | + if (\func_num_args() > 1) |
|
61 | + { |
|
61 | 62 | $param->setDefaultValue($defaultValue); |
62 | 63 | } |
63 | 64 |
@@ -9,10 +9,10 @@ |
||
9 | 9 | */ |
10 | 10 | trait CommentAware |
11 | 11 | { |
12 | - public function setComment(array|string|null $comment): static |
|
12 | + public function setComment(array | string | null $comment): static |
|
13 | 13 | { |
14 | - if (\is_array($comment)) { |
|
15 | - foreach ($comment as $value) { |
|
14 | + if (\is_array($comment)){ |
|
15 | + foreach ($comment as $value){ |
|
16 | 16 | $this->element->addComment($value); |
17 | 17 | } |
18 | 18 |
@@ -11,8 +11,10 @@ |
||
11 | 11 | { |
12 | 12 | public function setComment(array|string|null $comment): static |
13 | 13 | { |
14 | - if (\is_array($comment)) { |
|
15 | - foreach ($comment as $value) { |
|
14 | + if (\is_array($comment)) |
|
15 | + { |
|
16 | + foreach ($comment as $value) |
|
17 | + { |
|
16 | 18 | $this->element->addComment($value); |
17 | 19 | } |
18 | 20 |
@@ -25,37 +25,37 @@ |
||
25 | 25 | |
26 | 26 | public function setPublic(): static |
27 | 27 | { |
28 | - $this->setVisibility(Visibility::PUBLIC); |
|
28 | + $this->setVisibility(Visibility::public); |
|
29 | 29 | |
30 | 30 | return $this; |
31 | 31 | } |
32 | 32 | |
33 | 33 | public function isPublic(): bool |
34 | 34 | { |
35 | - return $this->getVisibility() === Visibility::PUBLIC; |
|
35 | + return $this->getVisibility() === Visibility::public; |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | public function setProtected(): static |
39 | 39 | { |
40 | - $this->setVisibility(Visibility::PROTECTED); |
|
40 | + $this->setVisibility(Visibility::protected); |
|
41 | 41 | |
42 | 42 | return $this; |
43 | 43 | } |
44 | 44 | |
45 | 45 | public function isProtected(): bool |
46 | 46 | { |
47 | - return $this->getVisibility() === Visibility::PROTECTED; |
|
47 | + return $this->getVisibility() === Visibility::protected; |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | public function setPrivate(): static |
51 | 51 | { |
52 | - $this->setVisibility(Visibility::PRIVATE); |
|
52 | + $this->setVisibility(Visibility::private); |
|
53 | 53 | |
54 | 54 | return $this; |
55 | 55 | } |
56 | 56 | |
57 | 57 | public function isPrivate(): bool |
58 | 58 | { |
59 | - return $this->getVisibility() === Visibility::PRIVATE; |
|
59 | + return $this->getVisibility() === Visibility::private; |
|
60 | 60 | } |
61 | 61 | } |
@@ -20,7 +20,7 @@ |
||
20 | 20 | |
21 | 21 | public function getVisibility(): ?Visibility |
22 | 22 | { |
23 | - return Visibility::tryFrom((string) $this->element->getVisibility()); |
|
23 | + return Visibility::tryFrom((string)$this->element->getVisibility()); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | public function setPublic(): static |