@@ -25,13 +25,13 @@ discard block |
||
25 | 25 | public function __construct( |
26 | 26 | array $values = [], |
27 | 27 | private readonly bool $overwrite = false |
28 | - ) { |
|
28 | + ){ |
|
29 | 29 | $this->values = $values + $_ENV + $_SERVER; |
30 | 30 | } |
31 | 31 | |
32 | 32 | public function getID(): string |
33 | 33 | { |
34 | - if (empty($this->id)) { |
|
34 | + if (empty($this->id)){ |
|
35 | 35 | $this->id = \md5(\serialize($this->values)); |
36 | 36 | } |
37 | 37 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | public function set(string $name, mixed $value): self |
42 | 42 | { |
43 | - if (\array_key_exists($name, $this->values) && !$this->overwrite) { |
|
43 | + if (\array_key_exists($name, $this->values) && !$this->overwrite){ |
|
44 | 44 | return $this; |
45 | 45 | } |
46 | 46 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | |
55 | 55 | public function get(string $name, mixed $default = null): mixed |
56 | 56 | { |
57 | - if (isset($this->values[$name])) { |
|
57 | + if (isset($this->values[$name])){ |
|
58 | 58 | return $this->normalize($this->values[$name]); |
59 | 59 | } |
60 | 60 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | { |
69 | 69 | $result = []; |
70 | 70 | |
71 | - foreach ($this->values as $key => $value) { |
|
71 | + foreach ($this->values as $key => $value){ |
|
72 | 72 | $result[$key] = $this->normalize($value); |
73 | 73 | } |
74 | 74 | |
@@ -77,12 +77,12 @@ discard block |
||
77 | 77 | |
78 | 78 | protected function normalize(mixed $value): mixed |
79 | 79 | { |
80 | - if (!\is_string($value)) { |
|
80 | + if (!\is_string($value)){ |
|
81 | 81 | return $value; |
82 | 82 | } |
83 | 83 | |
84 | 84 | $alias = \strtolower($value); |
85 | - if (isset(self::VALUE_MAP[$alias])) { |
|
85 | + if (isset(self::VALUE_MAP[$alias])){ |
|
86 | 86 | return self::VALUE_MAP[$alias]; |
87 | 87 | } |
88 | 88 |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public function __construct(array $items = []) |
28 | 28 | { |
29 | - foreach ($items as $item) { |
|
29 | + foreach ($items as $item){ |
|
30 | 30 | $this->addItem($item); |
31 | 31 | } |
32 | 32 | } |
@@ -41,9 +41,9 @@ discard block |
||
41 | 41 | $header = new static(); |
42 | 42 | |
43 | 43 | $parts = \explode(',', $raw); |
44 | - foreach ($parts as $part) { |
|
44 | + foreach ($parts as $part){ |
|
45 | 45 | $part = \trim($part); |
46 | - if ($part !== '') { |
|
46 | + if ($part !== ''){ |
|
47 | 47 | $header->addItem($part); |
48 | 48 | } |
49 | 49 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | return $header; |
52 | 52 | } |
53 | 53 | |
54 | - public function add(AcceptHeaderItem|string $item): self |
|
54 | + public function add(AcceptHeaderItem | string $item): self |
|
55 | 55 | { |
56 | 56 | $header = clone $this; |
57 | 57 | $header->addItem($item); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function getAll(): array |
76 | 76 | { |
77 | - if (!$this->sorted) { |
|
77 | + if (!$this->sorted){ |
|
78 | 78 | /** |
79 | 79 | * Sort item in descending order. |
80 | 80 | */ |
@@ -89,14 +89,14 @@ discard block |
||
89 | 89 | /** |
90 | 90 | * Add new item to list. |
91 | 91 | */ |
92 | - private function addItem(AcceptHeaderItem|string $item): void |
|
92 | + private function addItem(AcceptHeaderItem | string $item): void |
|
93 | 93 | { |
94 | - if (\is_string($item)) { |
|
94 | + if (\is_string($item)){ |
|
95 | 95 | $item = AcceptHeaderItem::fromString($item); |
96 | 96 | } |
97 | 97 | |
98 | - $value = \strtolower((string) $item->getValue()); |
|
99 | - if ($value !== '' && (!$this->has($value) || self::compare($item, $this->get($value)) === 1)) { |
|
98 | + $value = \strtolower((string)$item->getValue()); |
|
99 | + if ($value !== '' && (!$this->has($value) || self::compare($item, $this->get($value)) === 1)){ |
|
100 | 100 | $this->sorted = false; |
101 | 101 | $this->items[$value] = $item; |
102 | 102 | } |
@@ -106,11 +106,11 @@ discard block |
||
106 | 106 | * Compare to header items, witch one is preferable. |
107 | 107 | * Return 1 if first value preferable or -1 if second, 0 in case of same weight. |
108 | 108 | */ |
109 | - private static function compare(AcceptHeaderItem|string $a, AcceptHeaderItem|string $b): int |
|
109 | + private static function compare(AcceptHeaderItem | string $a, AcceptHeaderItem | string $b): int |
|
110 | 110 | { |
111 | - if ($a->getQuality() === $b->getQuality()) { |
|
111 | + if ($a->getQuality() === $b->getQuality()){ |
|
112 | 112 | // If quality are same value with more params has more weight. |
113 | - if (\count($a->getParams()) === \count($b->getParams())) { |
|
113 | + if (\count($a->getParams()) === \count($b->getParams())){ |
|
114 | 114 | // If quality and params then check for specific type or subtype. |
115 | 115 | // Means */* or * has less weight. |
116 | 116 | return static::compareValue($a->getValue(), $b->getValue()); |
@@ -129,11 +129,11 @@ discard block |
||
129 | 129 | private static function compareValue(string $a, string $b): int |
130 | 130 | { |
131 | 131 | // Check "Accept" headers values with it is type and subtype. |
132 | - if (\str_contains($a, '/') && \str_contains($b, '/')) { |
|
132 | + if (\str_contains($a, '/') && \str_contains($b, '/')){ |
|
133 | 133 | [$typeA, $subtypeA] = \explode('/', $a, 2); |
134 | 134 | [$typeB, $subtypeB] = \explode('/', $b, 2); |
135 | 135 | |
136 | - if ($typeA === $typeB) { |
|
136 | + if ($typeA === $typeB){ |
|
137 | 137 | return static::compareAtomic($subtypeA, $subtypeB); |
138 | 138 | } |
139 | 139 | |
@@ -145,23 +145,23 @@ discard block |
||
145 | 145 | |
146 | 146 | private static function compareAtomic(string $a, string $b): int |
147 | 147 | { |
148 | - if (\mb_strpos($a, '*/') === 0) { |
|
148 | + if (\mb_strpos($a, '*/') === 0){ |
|
149 | 149 | $a = '*'; |
150 | 150 | } |
151 | 151 | |
152 | - if (\mb_strpos($b, '*/') === 0) { |
|
152 | + if (\mb_strpos($b, '*/') === 0){ |
|
153 | 153 | $b = '*'; |
154 | 154 | } |
155 | 155 | |
156 | - if (\strtolower($a) === \strtolower($b)) { |
|
156 | + if (\strtolower($a) === \strtolower($b)){ |
|
157 | 157 | return 0; |
158 | 158 | } |
159 | 159 | |
160 | - if ($a === '*') { |
|
160 | + if ($a === '*'){ |
|
161 | 161 | return -1; |
162 | 162 | } |
163 | 163 | |
164 | - if ($b === '*') { |
|
164 | + if ($b === '*'){ |
|
165 | 165 | return 1; |
166 | 166 | } |
167 | 167 |
@@ -26,7 +26,8 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public function __construct(array $items = []) |
28 | 28 | { |
29 | - foreach ($items as $item) { |
|
29 | + foreach ($items as $item) |
|
30 | + { |
|
30 | 31 | $this->addItem($item); |
31 | 32 | } |
32 | 33 | } |
@@ -41,9 +42,11 @@ discard block |
||
41 | 42 | $header = new static(); |
42 | 43 | |
43 | 44 | $parts = \explode(',', $raw); |
44 | - foreach ($parts as $part) { |
|
45 | + foreach ($parts as $part) |
|
46 | + { |
|
45 | 47 | $part = \trim($part); |
46 | - if ($part !== '') { |
|
48 | + if ($part !== '') |
|
49 | + { |
|
47 | 50 | $header->addItem($part); |
48 | 51 | } |
49 | 52 | } |
@@ -74,7 +77,8 @@ discard block |
||
74 | 77 | */ |
75 | 78 | public function getAll(): array |
76 | 79 | { |
77 | - if (!$this->sorted) { |
|
80 | + if (!$this->sorted) |
|
81 | + { |
|
78 | 82 | /** |
79 | 83 | * Sort item in descending order. |
80 | 84 | */ |
@@ -91,12 +95,14 @@ discard block |
||
91 | 95 | */ |
92 | 96 | private function addItem(AcceptHeaderItem|string $item): void |
93 | 97 | { |
94 | - if (\is_string($item)) { |
|
98 | + if (\is_string($item)) |
|
99 | + { |
|
95 | 100 | $item = AcceptHeaderItem::fromString($item); |
96 | 101 | } |
97 | 102 | |
98 | 103 | $value = \strtolower((string) $item->getValue()); |
99 | - if ($value !== '' && (!$this->has($value) || self::compare($item, $this->get($value)) === 1)) { |
|
104 | + if ($value !== '' && (!$this->has($value) || self::compare($item, $this->get($value)) === 1)) |
|
105 | + { |
|
100 | 106 | $this->sorted = false; |
101 | 107 | $this->items[$value] = $item; |
102 | 108 | } |
@@ -108,9 +114,11 @@ discard block |
||
108 | 114 | */ |
109 | 115 | private static function compare(AcceptHeaderItem|string $a, AcceptHeaderItem|string $b): int |
110 | 116 | { |
111 | - if ($a->getQuality() === $b->getQuality()) { |
|
117 | + if ($a->getQuality() === $b->getQuality()) |
|
118 | + { |
|
112 | 119 | // If quality are same value with more params has more weight. |
113 | - if (\count($a->getParams()) === \count($b->getParams())) { |
|
120 | + if (\count($a->getParams()) === \count($b->getParams())) |
|
121 | + { |
|
114 | 122 | // If quality and params then check for specific type or subtype. |
115 | 123 | // Means */* or * has less weight. |
116 | 124 | return static::compareValue($a->getValue(), $b->getValue()); |
@@ -129,11 +137,13 @@ discard block |
||
129 | 137 | private static function compareValue(string $a, string $b): int |
130 | 138 | { |
131 | 139 | // Check "Accept" headers values with it is type and subtype. |
132 | - if (\str_contains($a, '/') && \str_contains($b, '/')) { |
|
140 | + if (\str_contains($a, '/') && \str_contains($b, '/')) |
|
141 | + { |
|
133 | 142 | [$typeA, $subtypeA] = \explode('/', $a, 2); |
134 | 143 | [$typeB, $subtypeB] = \explode('/', $b, 2); |
135 | 144 | |
136 | - if ($typeA === $typeB) { |
|
145 | + if ($typeA === $typeB) |
|
146 | + { |
|
137 | 147 | return static::compareAtomic($subtypeA, $subtypeB); |
138 | 148 | } |
139 | 149 | |
@@ -145,23 +155,28 @@ discard block |
||
145 | 155 | |
146 | 156 | private static function compareAtomic(string $a, string $b): int |
147 | 157 | { |
148 | - if (\mb_strpos($a, '*/') === 0) { |
|
158 | + if (\mb_strpos($a, '*/') === 0) |
|
159 | + { |
|
149 | 160 | $a = '*'; |
150 | 161 | } |
151 | 162 | |
152 | - if (\mb_strpos($b, '*/') === 0) { |
|
163 | + if (\mb_strpos($b, '*/') === 0) |
|
164 | + { |
|
153 | 165 | $b = '*'; |
154 | 166 | } |
155 | 167 | |
156 | - if (\strtolower($a) === \strtolower($b)) { |
|
168 | + if (\strtolower($a) === \strtolower($b)) |
|
169 | + { |
|
157 | 170 | return 0; |
158 | 171 | } |
159 | 172 | |
160 | - if ($a === '*') { |
|
173 | + if ($a === '*') |
|
174 | + { |
|
161 | 175 | return -1; |
162 | 176 | } |
163 | 177 | |
164 | - if ($b === '*') { |
|
178 | + if ($b === '*') |
|
179 | + { |
|
165 | 180 | return 1; |
166 | 181 | } |
167 | 182 |
@@ -10,7 +10,7 @@ |
||
10 | 10 | { |
11 | 11 | public function __construct( |
12 | 12 | private readonly DebugMode $debugMode |
13 | - ) { |
|
13 | + ){ |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | public function suppressed(): bool |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | public function __construct( |
23 | 23 | private readonly array $allowed, |
24 | 24 | private array $elements = [] |
25 | - ) { |
|
25 | + ){ |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | /** |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function has(string $name): bool |
62 | 62 | { |
63 | - foreach ($this->elements as $element) { |
|
64 | - if ($element instanceof NamedInterface && $element->getName() === $name) { |
|
63 | + foreach ($this->elements as $element){ |
|
64 | + if ($element instanceof NamedInterface && $element->getName() === $name){ |
|
65 | 65 | return true; |
66 | 66 | } |
67 | 67 | } |
@@ -79,15 +79,15 @@ discard block |
||
79 | 79 | $reflector = new \ReflectionObject($element); |
80 | 80 | |
81 | 81 | $allowed = false; |
82 | - foreach ($this->allowed as $class) { |
|
82 | + foreach ($this->allowed as $class){ |
|
83 | 83 | /** @psalm-suppress RedundantCondition https://github.com/vimeo/psalm/issues/9489 */ |
84 | - if ($reflector->isSubclassOf($class) || $element::class === $class) { |
|
84 | + if ($reflector->isSubclassOf($class) || $element::class === $class){ |
|
85 | 85 | $allowed = true; |
86 | 86 | break; |
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
90 | - if (!$allowed) { |
|
90 | + if (!$allowed){ |
|
91 | 91 | $type = $element::class; |
92 | 92 | throw new ReactorException(\sprintf("Elements with type '%s' are not allowed", $type)); |
93 | 93 | } |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | */ |
118 | 118 | public function remove(string $name): self |
119 | 119 | { |
120 | - foreach ($this->elements as $index => $element) { |
|
121 | - if ($element instanceof NamedInterface && $element->getName() === $name) { |
|
120 | + foreach ($this->elements as $index => $element){ |
|
121 | + if ($element instanceof NamedInterface && $element->getName() === $name){ |
|
122 | 122 | unset($this->elements[$index]); |
123 | 123 | } |
124 | 124 | } |
@@ -170,8 +170,8 @@ discard block |
||
170 | 170 | */ |
171 | 171 | protected function find(string $name): AggregableInterface |
172 | 172 | { |
173 | - foreach ($this->elements as $element) { |
|
174 | - if ($element instanceof NamedInterface && $element->getName() === $name) { |
|
173 | + foreach ($this->elements as $element){ |
|
174 | + if ($element instanceof NamedInterface && $element->getName() === $name){ |
|
175 | 175 | return $element; |
176 | 176 | } |
177 | 177 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $class = $this->classify($name); |
69 | 69 | $postfix = $this->elementPostfix($element); |
70 | 70 | |
71 | - return \str_ends_with($class, $postfix) ? $class : $class . $postfix; |
|
71 | + return \str_ends_with($class, $postfix) ? $class : $class.$postfix; |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -76,18 +76,18 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function classNamespace(string $element, string $name = ''): string |
78 | 78 | { |
79 | - $localNamespace = \trim((string) $this->getOption($element, 'namespace', ''), '\\'); |
|
79 | + $localNamespace = \trim((string)$this->getOption($element, 'namespace', ''), '\\'); |
|
80 | 80 | ['namespace' => $namespace] = $this->parseName($name); |
81 | 81 | |
82 | - if (!empty($namespace)) { |
|
83 | - $localNamespace .= '\\' . $this->classify($namespace); |
|
82 | + if (!empty($namespace)){ |
|
83 | + $localNamespace .= '\\'.$this->classify($namespace); |
|
84 | 84 | } |
85 | 85 | |
86 | - if (empty($this->baseNamespace($element))) { |
|
86 | + if (empty($this->baseNamespace($element))){ |
|
87 | 87 | return $localNamespace; |
88 | 88 | } |
89 | 89 | |
90 | - return \trim($this->baseNamespace($element) . '\\' . $localNamespace, '\\'); |
|
90 | + return \trim($this->baseNamespace($element).'\\'.$localNamespace, '\\'); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | return $this->joinPathChunks([ |
105 | 105 | $this->declarationDirectory($element), |
106 | 106 | \str_replace('\\', '/', $elementNamespace), |
107 | - $this->className($element, $name) . '.php', |
|
107 | + $this->className($element, $name).'.php', |
|
108 | 108 | ], '/'); |
109 | 109 | } |
110 | 110 | |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | { |
118 | 118 | $class = $this->getOption($element, 'class'); |
119 | 119 | |
120 | - if (empty($class)) { |
|
120 | + if (empty($class)){ |
|
121 | 121 | throw new ScaffolderException( |
122 | 122 | \sprintf("Unable to scaffold '%s', no declaration class found", $element), |
123 | 123 | ); |
@@ -165,11 +165,11 @@ discard block |
||
165 | 165 | { |
166 | 166 | $declaration = $this->getDeclaration($element); |
167 | 167 | |
168 | - if ($declaration === []) { |
|
168 | + if ($declaration === []){ |
|
169 | 169 | throw new ScaffolderException(\sprintf("Undefined declaration '%s'.", $element)); |
170 | 170 | } |
171 | 171 | |
172 | - if (\array_key_exists($section, $declaration)) { |
|
172 | + if (\array_key_exists($section, $declaration)){ |
|
173 | 173 | return $declaration[$section]; |
174 | 174 | } |
175 | 175 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | { |
188 | 188 | $name = \str_replace('/', '\\', $name); |
189 | 189 | |
190 | - if (str_contains($name, '\\')) { |
|
190 | + if (str_contains($name, '\\')){ |
|
191 | 191 | $names = \explode('\\', $name); |
192 | 192 | $class = \array_pop($names); |
193 | 193 | |
@@ -205,23 +205,23 @@ discard block |
||
205 | 205 | { |
206 | 206 | $declaration = $this->getDeclaration($element); |
207 | 207 | |
208 | - if (\array_key_exists('baseNamespace', $declaration)) { |
|
208 | + if (\array_key_exists('baseNamespace', $declaration)){ |
|
209 | 209 | return \trim((string)$this->getOption($element, 'baseNamespace', ''), '\\'); |
210 | 210 | } |
211 | 211 | |
212 | - return \trim((string) $this->config['namespace'], '\\'); |
|
212 | + return \trim((string)$this->config['namespace'], '\\'); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | private function joinPathChunks(array $chunks, string $joint): string |
216 | 216 | { |
217 | 217 | $firstChunkIterated = false; |
218 | 218 | $joinedPath = ''; |
219 | - foreach ($chunks as $chunk) { |
|
220 | - if (!$firstChunkIterated) { |
|
219 | + foreach ($chunks as $chunk){ |
|
220 | + if (!$firstChunkIterated){ |
|
221 | 221 | $firstChunkIterated = true; |
222 | 222 | $joinedPath = $chunk; |
223 | - } else { |
|
224 | - $joinedPath = \rtrim((string) $joinedPath, $joint) . $joint . \ltrim((string) $chunk, $joint); |
|
223 | + }else{ |
|
224 | + $joinedPath = \rtrim((string)$joinedPath, $joint).$joint.\ltrim((string)$chunk, $joint); |
|
225 | 225 | } |
226 | 226 | } |
227 | 227 |
@@ -79,11 +79,13 @@ discard block |
||
79 | 79 | $localNamespace = \trim((string) $this->getOption($element, 'namespace', ''), '\\'); |
80 | 80 | ['namespace' => $namespace] = $this->parseName($name); |
81 | 81 | |
82 | - if (!empty($namespace)) { |
|
82 | + if (!empty($namespace)) |
|
83 | + { |
|
83 | 84 | $localNamespace .= '\\' . $this->classify($namespace); |
84 | 85 | } |
85 | 86 | |
86 | - if (empty($this->baseNamespace($element))) { |
|
87 | + if (empty($this->baseNamespace($element))) |
|
88 | + { |
|
87 | 89 | return $localNamespace; |
88 | 90 | } |
89 | 91 | |
@@ -117,7 +119,8 @@ discard block |
||
117 | 119 | { |
118 | 120 | $class = $this->getOption($element, 'class'); |
119 | 121 | |
120 | - if (empty($class)) { |
|
122 | + if (empty($class)) |
|
123 | + { |
|
121 | 124 | throw new ScaffolderException( |
122 | 125 | \sprintf("Unable to scaffold '%s', no declaration class found", $element), |
123 | 126 | ); |
@@ -165,11 +168,13 @@ discard block |
||
165 | 168 | { |
166 | 169 | $declaration = $this->getDeclaration($element); |
167 | 170 | |
168 | - if ($declaration === []) { |
|
171 | + if ($declaration === []) |
|
172 | + { |
|
169 | 173 | throw new ScaffolderException(\sprintf("Undefined declaration '%s'.", $element)); |
170 | 174 | } |
171 | 175 | |
172 | - if (\array_key_exists($section, $declaration)) { |
|
176 | + if (\array_key_exists($section, $declaration)) |
|
177 | + { |
|
173 | 178 | return $declaration[$section]; |
174 | 179 | } |
175 | 180 | |
@@ -187,7 +192,8 @@ discard block |
||
187 | 192 | { |
188 | 193 | $name = \str_replace('/', '\\', $name); |
189 | 194 | |
190 | - if (str_contains($name, '\\')) { |
|
195 | + if (str_contains($name, '\\')) |
|
196 | + { |
|
191 | 197 | $names = \explode('\\', $name); |
192 | 198 | $class = \array_pop($names); |
193 | 199 | |
@@ -205,7 +211,8 @@ discard block |
||
205 | 211 | { |
206 | 212 | $declaration = $this->getDeclaration($element); |
207 | 213 | |
208 | - if (\array_key_exists('baseNamespace', $declaration)) { |
|
214 | + if (\array_key_exists('baseNamespace', $declaration)) |
|
215 | + { |
|
209 | 216 | return \trim((string)$this->getOption($element, 'baseNamespace', ''), '\\'); |
210 | 217 | } |
211 | 218 | |
@@ -216,11 +223,15 @@ discard block |
||
216 | 223 | { |
217 | 224 | $firstChunkIterated = false; |
218 | 225 | $joinedPath = ''; |
219 | - foreach ($chunks as $chunk) { |
|
220 | - if (!$firstChunkIterated) { |
|
226 | + foreach ($chunks as $chunk) |
|
227 | + { |
|
228 | + if (!$firstChunkIterated) |
|
229 | + { |
|
221 | 230 | $firstChunkIterated = true; |
222 | 231 | $joinedPath = $chunk; |
223 | - } else { |
|
232 | + } |
|
233 | + else |
|
234 | + { |
|
224 | 235 | $joinedPath = \rtrim((string) $joinedPath, $joint) . $joint . \ltrim((string) $chunk, $joint); |
225 | 236 | } |
226 | 237 | } |
@@ -39,14 +39,14 @@ |
||
39 | 39 | { |
40 | 40 | $declaration = $this->createDeclaration(CommandDeclaration::class, [ |
41 | 41 | 'description' => $this->description, |
42 | - 'alias' => $this->alias ?? \strtolower((string) \preg_replace('/(?<!^)[A-Z]/', ':$0', $this->name)), |
|
42 | + 'alias' => $this->alias ?? \strtolower((string)\preg_replace('/(?<!^)[A-Z]/', ':$0', $this->name)), |
|
43 | 43 | ]); |
44 | 44 | |
45 | - foreach ($this->arguments as $argument) { |
|
45 | + foreach ($this->arguments as $argument){ |
|
46 | 46 | $declaration->addArgument($argument); |
47 | 47 | } |
48 | 48 | |
49 | - foreach ($this->options as $option) { |
|
49 | + foreach ($this->options as $option){ |
|
50 | 50 | $declaration->addOption($option); |
51 | 51 | } |
52 | 52 |
@@ -42,11 +42,13 @@ |
||
42 | 42 | 'alias' => $this->alias ?? \strtolower((string) \preg_replace('/(?<!^)[A-Z]/', ':$0', $this->name)), |
43 | 43 | ]); |
44 | 44 | |
45 | - foreach ($this->arguments as $argument) { |
|
45 | + foreach ($this->arguments as $argument) |
|
46 | + { |
|
46 | 47 | $declaration->addArgument($argument); |
47 | 48 | } |
48 | 49 | |
49 | - foreach ($this->options as $option) { |
|
50 | + foreach ($this->options as $option) |
|
51 | + { |
|
50 | 52 | $declaration->addOption($option); |
51 | 53 | } |
52 | 54 |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | { |
14 | 14 | public function __construct( |
15 | 15 | private readonly StyleInterface $renderer |
16 | - ) { |
|
16 | + ){ |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | /** |
@@ -24,9 +24,9 @@ discard block |
||
24 | 24 | $lines = \explode("\n", \str_replace("\r\n", "\n", $this->highlight($source))); |
25 | 25 | |
26 | 26 | $result = ''; |
27 | - foreach ($lines as $number => $code) { |
|
27 | + foreach ($lines as $number => $code){ |
|
28 | 28 | $human = $number + 1; |
29 | - if (!empty($around) && ($human < $line - $around || $human >= $line + $around + 1)) { |
|
29 | + if (!empty($around) && ($human < $line - $around || $human >= $line + $around + 1)){ |
|
30 | 30 | //Not included in a range |
31 | 31 | continue; |
32 | 32 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | { |
45 | 45 | $result = ''; |
46 | 46 | $previous = []; |
47 | - foreach ($this->getTokens($source) as $token) { |
|
47 | + foreach ($this->getTokens($source) as $token){ |
|
48 | 48 | $result .= $this->renderer->token($token, $previous); |
49 | 49 | $previous = $token; |
50 | 50 | } |
@@ -60,12 +60,12 @@ discard block |
||
60 | 60 | $tokens = []; |
61 | 61 | $line = 0; |
62 | 62 | |
63 | - foreach (\token_get_all($source) as $token) { |
|
64 | - if (isset($token[2])) { |
|
63 | + foreach (\token_get_all($source) as $token){ |
|
64 | + if (isset($token[2])){ |
|
65 | 65 | $line = $token[2]; |
66 | 66 | } |
67 | 67 | |
68 | - if (!\is_array($token)) { |
|
68 | + if (!\is_array($token)){ |
|
69 | 69 | $token = [$token, $token, $line]; |
70 | 70 | } |
71 | 71 |
@@ -12,7 +12,7 @@ |
||
12 | 12 | { |
13 | 13 | public function __construct( |
14 | 14 | private readonly LoggerInterface $logger = new NullLogger() |
15 | - ) { |
|
15 | + ){ |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | public function report(\Throwable $exception): void |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | private readonly Verbosity $verbosity, |
20 | 20 | private readonly ExceptionRendererInterface $renderer, |
21 | 21 | private readonly FilesInterface $files |
22 | - ) { |
|
22 | + ){ |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | public function create(\Throwable $e): SnapshotInterface |
@@ -55,12 +55,12 @@ discard block |
||
55 | 55 | ); |
56 | 56 | |
57 | 57 | $count = 0; |
58 | - foreach ($finder as $file) { |
|
58 | + foreach ($finder as $file){ |
|
59 | 59 | $count++; |
60 | - if ($count > $this->maxFiles) { |
|
61 | - try { |
|
60 | + if ($count > $this->maxFiles){ |
|
61 | + try{ |
|
62 | 62 | $this->files->delete($file->getRealPath()); |
63 | - } catch (FilesException) { |
|
63 | + }catch (FilesException){ |
|
64 | 64 | // ignore |
65 | 65 | } |
66 | 66 | } |