@@ -23,8 +23,7 @@ |
||
23 | 23 | * See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md |
24 | 24 | * for the full interface specification. |
25 | 25 | */ |
26 | -interface LoggerInterface |
|
27 | -{ |
|
26 | +interface LoggerInterface { |
|
28 | 27 | /** |
29 | 28 | * System is unusable. |
30 | 29 | * |
@@ -32,8 +32,7 @@ discard block |
||
32 | 32 | /** |
33 | 33 | * Class documentation |
34 | 34 | */ |
35 | -class Logger extends AbstractLogger |
|
36 | -{ |
|
35 | +class Logger extends AbstractLogger { |
|
37 | 36 | /** |
38 | 37 | * KLogger options |
39 | 38 | * Anything options not considered 'core' to the logging library should be |
@@ -115,28 +114,27 @@ discard block |
||
115 | 114 | * @internal param string $logFilePrefix The prefix for the log file name |
116 | 115 | * @internal param string $logFileExt The extension for the log file |
117 | 116 | */ |
118 | - public function __construct($logDirectory, $logLevelThreshold = LogLevel::DEBUG, array $options = array()) |
|
119 | - { |
|
117 | + public function __construct($logDirectory, $logLevelThreshold = LogLevel::DEBUG, array $options = array()) { |
|
120 | 118 | $this->logLevelThreshold = $logLevelThreshold; |
121 | 119 | $this->options = array_merge($this->options, $options); |
122 | 120 | |
123 | 121 | $logDirectory = rtrim($logDirectory, DIRECTORY_SEPARATOR); |
124 | - if ( ! file_exists($logDirectory)) { |
|
122 | + if ( ! file_exists($logDirectory)) { |
|
125 | 123 | mkdir($logDirectory, $this->defaultPermissions, true); |
126 | 124 | } |
127 | 125 | |
128 | - if(strpos($logDirectory, 'php://') === 0) { |
|
126 | + if(strpos($logDirectory, 'php://') === 0) { |
|
129 | 127 | $this->setLogToStdOut($logDirectory); |
130 | 128 | $this->setFileHandle('w+'); |
131 | - } else { |
|
129 | + } else { |
|
132 | 130 | $this->setLogFilePath($logDirectory); |
133 | - if(file_exists($this->logFilePath) && !is_writable($this->logFilePath)) { |
|
131 | + if(file_exists($this->logFilePath) && !is_writable($this->logFilePath)) { |
|
134 | 132 | throw new RuntimeException('The file could not be written to. Check that appropriate permissions have been set.'); |
135 | 133 | } |
136 | 134 | $this->setFileHandle('a'); |
137 | 135 | } |
138 | 136 | |
139 | - if ( ! $this->fileHandle) { |
|
137 | + if ( ! $this->fileHandle) { |
|
140 | 138 | throw new RuntimeException('The file could not be opened. Check permissions.'); |
141 | 139 | } |
142 | 140 | } |
@@ -144,22 +142,21 @@ discard block |
||
144 | 142 | /** |
145 | 143 | * @param string $stdOutPath |
146 | 144 | */ |
147 | - public function setLogToStdOut($stdOutPath) { |
|
145 | + public function setLogToStdOut($stdOutPath) { |
|
148 | 146 | $this->logFilePath = $stdOutPath; |
149 | 147 | } |
150 | 148 | |
151 | 149 | /** |
152 | 150 | * @param string $logDirectory |
153 | 151 | */ |
154 | - public function setLogFilePath($logDirectory) { |
|
155 | - if ($this->options['filename']) { |
|
156 | - if (strpos($this->options['filename'], '.log') !== false || strpos($this->options['filename'], '.txt') !== false) { |
|
152 | + public function setLogFilePath($logDirectory) { |
|
153 | + if ($this->options['filename']) { |
|
154 | + if (strpos($this->options['filename'], '.log') !== false || strpos($this->options['filename'], '.txt') !== false) { |
|
157 | 155 | $this->logFilePath = $logDirectory.DIRECTORY_SEPARATOR.$this->options['filename']; |
158 | - } |
|
159 | - else { |
|
156 | + } else { |
|
160 | 157 | $this->logFilePath = $logDirectory.DIRECTORY_SEPARATOR.$this->options['filename'].'.'.$this->options['extension']; |
161 | 158 | } |
162 | - } else { |
|
159 | + } else { |
|
163 | 160 | $this->logFilePath = $logDirectory.DIRECTORY_SEPARATOR.$this->options['prefix'].date('Y-m-d').'.'.$this->options['extension']; |
164 | 161 | } |
165 | 162 | } |
@@ -169,7 +166,7 @@ discard block |
||
169 | 166 | * |
170 | 167 | * @internal param resource $fileHandle |
171 | 168 | */ |
172 | - public function setFileHandle($writeMode) { |
|
169 | + public function setFileHandle($writeMode) { |
|
173 | 170 | $this->fileHandle = fopen($this->logFilePath, $writeMode); |
174 | 171 | } |
175 | 172 | |
@@ -177,9 +174,8 @@ discard block |
||
177 | 174 | /** |
178 | 175 | * Class destructor |
179 | 176 | */ |
180 | - public function __destruct() |
|
181 | - { |
|
182 | - if ($this->fileHandle) { |
|
177 | + public function __destruct() { |
|
178 | + if ($this->fileHandle) { |
|
183 | 179 | fclose($this->fileHandle); |
184 | 180 | } |
185 | 181 | } |
@@ -189,8 +185,7 @@ discard block |
||
189 | 185 | * |
190 | 186 | * @param string $dateFormat Valid format string for date() |
191 | 187 | */ |
192 | - public function setDateFormat($dateFormat) |
|
193 | - { |
|
188 | + public function setDateFormat($dateFormat) { |
|
194 | 189 | $this->options['dateFormat'] = $dateFormat; |
195 | 190 | } |
196 | 191 | |
@@ -199,8 +194,7 @@ discard block |
||
199 | 194 | * |
200 | 195 | * @param string $logLevelThreshold The log level threshold |
201 | 196 | */ |
202 | - public function setLogLevelThreshold($logLevelThreshold) |
|
203 | - { |
|
197 | + public function setLogLevelThreshold($logLevelThreshold) { |
|
204 | 198 | $this->logLevelThreshold = $logLevelThreshold; |
205 | 199 | } |
206 | 200 | |
@@ -212,9 +206,8 @@ discard block |
||
212 | 206 | * @param array $context |
213 | 207 | * @return null |
214 | 208 | */ |
215 | - public function log($level, $message, array $context = array()) |
|
216 | - { |
|
217 | - if ($this->logLevels[$this->logLevelThreshold] < $this->logLevels[$level]) { |
|
209 | + public function log($level, $message, array $context = array()) { |
|
210 | + if ($this->logLevels[$this->logLevelThreshold] < $this->logLevels[$level]) { |
|
218 | 211 | return; |
219 | 212 | } |
220 | 213 | $message = $this->formatMessage($level, $message, $context); |
@@ -227,16 +220,15 @@ discard block |
||
227 | 220 | * @param string $message Line to write to the log |
228 | 221 | * @return void |
229 | 222 | */ |
230 | - public function write($message) |
|
231 | - { |
|
232 | - if (null !== $this->fileHandle) { |
|
233 | - if (fwrite($this->fileHandle, $message) === false) { |
|
223 | + public function write($message) { |
|
224 | + if (null !== $this->fileHandle) { |
|
225 | + if (fwrite($this->fileHandle, $message) === false) { |
|
234 | 226 | throw new RuntimeException('The file could not be written to. Check that appropriate permissions have been set.'); |
235 | - } else { |
|
227 | + } else { |
|
236 | 228 | $this->lastLine = trim($message); |
237 | 229 | $this->logLineCount++; |
238 | 230 | |
239 | - if ($this->options['flushFrequency'] && $this->logLineCount % $this->options['flushFrequency'] === 0) { |
|
231 | + if ($this->options['flushFrequency'] && $this->logLineCount % $this->options['flushFrequency'] === 0) { |
|
240 | 232 | fflush($this->fileHandle); |
241 | 233 | } |
242 | 234 | } |
@@ -248,8 +240,7 @@ discard block |
||
248 | 240 | * |
249 | 241 | * @return string |
250 | 242 | */ |
251 | - public function getLogFilePath() |
|
252 | - { |
|
243 | + public function getLogFilePath() { |
|
253 | 244 | return $this->logFilePath; |
254 | 245 | } |
255 | 246 | |
@@ -258,8 +249,7 @@ discard block |
||
258 | 249 | * |
259 | 250 | * @return string |
260 | 251 | */ |
261 | - public function getLastLogLine() |
|
262 | - { |
|
252 | + public function getLastLogLine() { |
|
263 | 253 | return $this->lastLine; |
264 | 254 | } |
265 | 255 | |
@@ -271,9 +261,8 @@ discard block |
||
271 | 261 | * @param array $context The context |
272 | 262 | * @return string |
273 | 263 | */ |
274 | - protected function formatMessage($level, $message, $context) |
|
275 | - { |
|
276 | - if ($this->options['logFormat']) { |
|
264 | + protected function formatMessage($level, $message, $context) { |
|
265 | + if ($this->options['logFormat']) { |
|
277 | 266 | $parts = array( |
278 | 267 | 'date' => $this->getTimestamp(), |
279 | 268 | 'level' => strtoupper($level), |
@@ -283,15 +272,15 @@ discard block |
||
283 | 272 | 'context' => json_encode($context), |
284 | 273 | ); |
285 | 274 | $message = $this->options['logFormat']; |
286 | - foreach ($parts as $part => $value) { |
|
275 | + foreach ($parts as $part => $value) { |
|
287 | 276 | $message = str_replace('{'.$part.'}', $value, $message); |
288 | 277 | } |
289 | 278 | |
290 | - } else { |
|
279 | + } else { |
|
291 | 280 | $message = "[{$this->getTimestamp()}] [{$level}] {$message}"; |
292 | 281 | } |
293 | 282 | |
294 | - if ($this->options['appendContext'] && ! empty($context)) { |
|
283 | + if ($this->options['appendContext'] && ! empty($context)) { |
|
295 | 284 | $message .= PHP_EOL.$this->indent($this->contextToString($context)); |
296 | 285 | } |
297 | 286 | |
@@ -307,8 +296,7 @@ discard block |
||
307 | 296 | * |
308 | 297 | * @return string |
309 | 298 | */ |
310 | - private function getTimestamp() |
|
311 | - { |
|
299 | + private function getTimestamp() { |
|
312 | 300 | $originalTime = microtime(true); |
313 | 301 | $micro = sprintf("%06d", ($originalTime - floor($originalTime)) * 1000000); |
314 | 302 | $date = new DateTime(date('Y-m-d H:i:s.'.$micro, $originalTime)); |
@@ -322,10 +310,9 @@ discard block |
||
322 | 310 | * @param array $context The Context |
323 | 311 | * @return string |
324 | 312 | */ |
325 | - protected function contextToString($context) |
|
326 | - { |
|
313 | + protected function contextToString($context) { |
|
327 | 314 | $export = ''; |
328 | - foreach ($context as $key => $value) { |
|
315 | + foreach ($context as $key => $value) { |
|
329 | 316 | $export .= "{$key}: "; |
330 | 317 | $export .= preg_replace(array( |
331 | 318 | '/=>\s+([a-zA-Z])/im', |
@@ -348,8 +335,7 @@ discard block |
||
348 | 335 | * @param string $indent What to use as the indent. |
349 | 336 | * @return string |
350 | 337 | */ |
351 | - protected function indent($string, $indent = ' ') |
|
352 | - { |
|
338 | + protected function indent($string, $indent = ' ') { |
|
353 | 339 | return $indent.str_replace("\n", "\n".$indent, $string); |
354 | 340 | } |
355 | 341 | } |
@@ -19,8 +19,7 @@ discard block |
||
19 | 19 | * @psalm-immutable |
20 | 20 | * @psalm-consistent-constructor |
21 | 21 | */ |
22 | -abstract class Enum implements \JsonSerializable |
|
23 | -{ |
|
22 | +abstract class Enum implements \JsonSerializable { |
|
24 | 23 | /** |
25 | 24 | * Enum value |
26 | 25 | * |
@@ -62,8 +61,7 @@ discard block |
||
62 | 61 | * @psalm-param T $value |
63 | 62 | * @throws \UnexpectedValueException if incompatible type is given. |
64 | 63 | */ |
65 | - public function __construct($value) |
|
66 | - { |
|
64 | + public function __construct($value) { |
|
67 | 65 | if ($value instanceof static) { |
68 | 66 | /** @psalm-var T */ |
69 | 67 | $value = $value->getValue(); |
@@ -80,8 +78,7 @@ discard block |
||
80 | 78 | * This method exists only for the compatibility reason when deserializing a previously serialized version |
81 | 79 | * that didn't had the key property |
82 | 80 | */ |
83 | - public function __wakeup() |
|
84 | - { |
|
81 | + public function __wakeup() { |
|
85 | 82 | /** @psalm-suppress DocblockTypeContradiction key can be null when deserializing an enum without the key */ |
86 | 83 | if ($this->key === null) { |
87 | 84 | /** |
@@ -108,8 +105,7 @@ discard block |
||
108 | 105 | * @return mixed |
109 | 106 | * @psalm-return T |
110 | 107 | */ |
111 | - public function getValue() |
|
112 | - { |
|
108 | + public function getValue() { |
|
113 | 109 | return $this->value; |
114 | 110 | } |
115 | 111 | |
@@ -119,8 +115,7 @@ discard block |
||
119 | 115 | * @psalm-pure |
120 | 116 | * @return string |
121 | 117 | */ |
122 | - public function getKey() |
|
123 | - { |
|
118 | + public function getKey() { |
|
124 | 119 | return $this->key; |
125 | 120 | } |
126 | 121 | |
@@ -129,8 +124,7 @@ discard block |
||
129 | 124 | * @psalm-suppress InvalidCast |
130 | 125 | * @return string |
131 | 126 | */ |
132 | - public function __toString() |
|
133 | - { |
|
127 | + public function __toString() { |
|
134 | 128 | return (string)$this->value; |
135 | 129 | } |
136 | 130 | |
@@ -158,8 +152,7 @@ discard block |
||
158 | 152 | * @psalm-return list<string> |
159 | 153 | * @return array |
160 | 154 | */ |
161 | - public static function keys() |
|
162 | - { |
|
155 | + public static function keys() { |
|
163 | 156 | return \array_keys(static::toArray()); |
164 | 157 | } |
165 | 158 | |
@@ -170,8 +163,7 @@ discard block |
||
170 | 163 | * @psalm-return array<string, static> |
171 | 164 | * @return static[] Constant name in key, Enum instance in value |
172 | 165 | */ |
173 | - public static function values() |
|
174 | - { |
|
166 | + public static function values() { |
|
175 | 167 | $values = array(); |
176 | 168 | |
177 | 169 | /** @psalm-var T $value */ |
@@ -191,8 +183,7 @@ discard block |
||
191 | 183 | * @psalm-return array<string, mixed> |
192 | 184 | * @return array Constant name in key, constant value in value |
193 | 185 | */ |
194 | - public static function toArray() |
|
195 | - { |
|
186 | + public static function toArray() { |
|
196 | 187 | $class = static::class; |
197 | 188 | |
198 | 189 | if (!isset(static::$cache[$class])) { |
@@ -214,8 +205,7 @@ discard block |
||
214 | 205 | * @psalm-assert-if-true T $value |
215 | 206 | * @return bool |
216 | 207 | */ |
217 | - public static function isValid($value) |
|
218 | - { |
|
208 | + public static function isValid($value) { |
|
219 | 209 | return \in_array($value, static::toArray(), true); |
220 | 210 | } |
221 | 211 | |
@@ -256,8 +246,7 @@ discard block |
||
256 | 246 | * @psalm-pure |
257 | 247 | * @return bool |
258 | 248 | */ |
259 | - public static function isValidKey($key) |
|
260 | - { |
|
249 | + public static function isValidKey($key) { |
|
261 | 250 | $array = static::toArray(); |
262 | 251 | |
263 | 252 | return isset($array[$key]) || \array_key_exists($key, $array); |
@@ -272,8 +261,7 @@ discard block |
||
272 | 261 | * @psalm-pure |
273 | 262 | * @return string|false |
274 | 263 | */ |
275 | - public static function search($value) |
|
276 | - { |
|
264 | + public static function search($value) { |
|
277 | 265 | return \array_search($value, static::toArray(), true); |
278 | 266 | } |
279 | 267 | |
@@ -288,8 +276,7 @@ discard block |
||
288 | 276 | * |
289 | 277 | * @psalm-pure |
290 | 278 | */ |
291 | - public static function __callStatic($name, $arguments) |
|
292 | - { |
|
279 | + public static function __callStatic($name, $arguments) { |
|
293 | 280 | $class = static::class; |
294 | 281 | if (!isset(self::$instances[$class][$name])) { |
295 | 282 | $array = static::toArray(); |
@@ -311,8 +298,7 @@ discard block |
||
311 | 298 | * @psalm-pure |
312 | 299 | */ |
313 | 300 | #[\ReturnTypeWillChange] |
314 | - public function jsonSerialize() |
|
315 | - { |
|
301 | + public function jsonSerialize() { |
|
316 | 302 | return $this->getValue(); |
317 | 303 | } |
318 | 304 | } |
@@ -11,14 +11,12 @@ discard block |
||
11 | 11 | use Composer\IO\NullIO; |
12 | 12 | use PHPUnit\Framework\TestCase; |
13 | 13 | |
14 | -class StraussConfigTest extends TestCase |
|
15 | -{ |
|
14 | +class StraussConfigTest extends TestCase { |
|
16 | 15 | |
17 | 16 | /** |
18 | 17 | * With a full (at time of writing) config, test the getters. |
19 | 18 | */ |
20 | - public function testGetters() |
|
21 | - { |
|
19 | + public function testGetters() { |
|
22 | 20 | |
23 | 21 | $composerExtraStraussJson = <<<'EOD' |
24 | 22 | { |
@@ -78,8 +76,7 @@ discard block |
||
78 | 76 | * |
79 | 77 | * Turns out it just ignores it... good! |
80 | 78 | */ |
81 | - public function testExtraKey() |
|
82 | - { |
|
79 | + public function testExtraKey() { |
|
83 | 80 | |
84 | 81 | $composerExtraStraussJson = <<<'EOD' |
85 | 82 | { |
@@ -133,8 +130,7 @@ discard block |
||
133 | 130 | * |
134 | 131 | * If no target_dir is specified, used "strauss/" |
135 | 132 | */ |
136 | - public function testDefaultTargetDir() |
|
137 | - { |
|
133 | + public function testDefaultTargetDir() { |
|
138 | 134 | |
139 | 135 | $composerExtraStraussJson = <<<'EOD' |
140 | 136 | { |
@@ -176,8 +172,7 @@ discard block |
||
176 | 172 | /** |
177 | 173 | * When the namespace prefix isn't provided, use the PSR-4 autoload key name. |
178 | 174 | */ |
179 | - public function testDefaultNamespacePrefixFromAutoloaderPsr4() |
|
180 | - { |
|
175 | + public function testDefaultNamespacePrefixFromAutoloaderPsr4() { |
|
181 | 176 | |
182 | 177 | $composerExtraStraussJson = <<<'EOD' |
183 | 178 | { |
@@ -207,8 +202,7 @@ discard block |
||
207 | 202 | /** |
208 | 203 | * When the namespace prefix isn't provided, use the PSR-0 autoload key name. |
209 | 204 | */ |
210 | - public function testDefaultNamespacePrefixFromAutoloaderPsr0() |
|
211 | - { |
|
205 | + public function testDefaultNamespacePrefixFromAutoloaderPsr0() { |
|
212 | 206 | |
213 | 207 | $composerExtraStraussJson = <<<'EOD' |
214 | 208 | { |
@@ -239,8 +233,7 @@ discard block |
||
239 | 233 | * |
240 | 234 | * brianhenryie/strauss-config-test |
241 | 235 | */ |
242 | - public function testDefaultNamespacePrefixWithNoAutoloader() |
|
243 | - { |
|
236 | + public function testDefaultNamespacePrefixWithNoAutoloader() { |
|
244 | 237 | |
245 | 238 | $composerExtraStraussJson = <<<'EOD' |
246 | 239 | { |
@@ -264,8 +257,7 @@ discard block |
||
264 | 257 | /** |
265 | 258 | * When the classmap prefix isn't provided, use the PSR-4 autoload key name. |
266 | 259 | */ |
267 | - public function testDefaultClassmapPrefixFromAutoloaderPsr4() |
|
268 | - { |
|
260 | + public function testDefaultClassmapPrefixFromAutoloaderPsr4() { |
|
269 | 261 | |
270 | 262 | $composerExtraStraussJson = <<<'EOD' |
271 | 263 | { |
@@ -295,8 +287,7 @@ discard block |
||
295 | 287 | /** |
296 | 288 | * When the classmap prefix isn't provided, use the PSR-0 autoload key name. |
297 | 289 | */ |
298 | - public function testDefaultClassmapPrefixFromAutoloaderPsr0() |
|
299 | - { |
|
290 | + public function testDefaultClassmapPrefixFromAutoloaderPsr0() { |
|
300 | 291 | |
301 | 292 | $composerExtraStraussJson = <<<'EOD' |
302 | 293 | { |
@@ -328,8 +319,7 @@ discard block |
||
328 | 319 | * |
329 | 320 | * brianhenryie/strauss-config-test |
330 | 321 | */ |
331 | - public function testDefaultClassmapPrefixWithNoAutoloader() |
|
332 | - { |
|
322 | + public function testDefaultClassmapPrefixWithNoAutoloader() { |
|
333 | 323 | |
334 | 324 | $composerExtraStraussJson = <<<'EOD' |
335 | 325 | { |
@@ -353,8 +343,7 @@ discard block |
||
353 | 343 | /** |
354 | 344 | * When Strauss config has packages specified, obviously use them. |
355 | 345 | */ |
356 | - public function testGetPackagesFromConfig() |
|
357 | - { |
|
346 | + public function testGetPackagesFromConfig() { |
|
358 | 347 | |
359 | 348 | $composerExtraStraussJson = <<<'EOD' |
360 | 349 | { |
@@ -399,8 +388,7 @@ discard block |
||
399 | 388 | /** |
400 | 389 | * When Strauss config has no packages specified, use composer.json's require list. |
401 | 390 | */ |
402 | - public function testGetPackagesNoConfig() |
|
403 | - { |
|
391 | + public function testGetPackagesNoConfig() { |
|
404 | 392 | |
405 | 393 | $composerExtraStraussJson = <<<'EOD' |
406 | 394 | { |
@@ -441,8 +429,7 @@ discard block |
||
441 | 429 | /** |
442 | 430 | * For backwards compatibility, if a Mozart config is present, use it. |
443 | 431 | */ |
444 | - public function testMapMozartConfig() |
|
445 | - { |
|
432 | + public function testMapMozartConfig() { |
|
446 | 433 | |
447 | 434 | $composerExtraStraussJson = <<<'EOD' |
448 | 435 | { |
@@ -500,8 +487,7 @@ discard block |
||
500 | 487 | * |
501 | 488 | * @covers \BrianHenryIE\Strauss\Composer\Extra\StraussConfig::getNamespacePrefix |
502 | 489 | */ |
503 | - public function testNamespacePrefixHasNoSlash() |
|
504 | - { |
|
490 | + public function testNamespacePrefixHasNoSlash() { |
|
505 | 491 | |
506 | 492 | $composerExtraStraussJson = <<<'EOD' |
507 | 493 | { |
@@ -5,14 +5,12 @@ discard block |
||
5 | 5 | use BrianHenryIE\Strauss\Composer\ComposerPackage; |
6 | 6 | use PHPUnit\Framework\TestCase; |
7 | 7 | |
8 | -class ComposerPackageTest extends TestCase |
|
9 | -{ |
|
8 | +class ComposerPackageTest extends TestCase { |
|
10 | 9 | |
11 | 10 | /** |
12 | 11 | * A simple test to check the getters all work. |
13 | 12 | */ |
14 | - public function testParseJson() |
|
15 | - { |
|
13 | + public function testParseJson() { |
|
16 | 14 | |
17 | 15 | $testFile = __DIR__ . '/composerpackage-test-libmergepdf.json'; |
18 | 16 | |
@@ -28,8 +26,7 @@ discard block |
||
28 | 26 | /** |
29 | 27 | * Test the dependencies' names are returned. |
30 | 28 | */ |
31 | - public function testGetRequiresNames() |
|
32 | - { |
|
29 | + public function testGetRequiresNames() { |
|
33 | 30 | |
34 | 31 | $testFile = __DIR__ . '/composerpackage-test-libmergepdf.json'; |
35 | 32 | |
@@ -44,8 +41,7 @@ discard block |
||
44 | 41 | /** |
45 | 42 | * Test PHP and ext- are not returned, since we won't be dealing with them. |
46 | 43 | */ |
47 | - public function testGetRequiresNamesDoesNotContain() |
|
48 | - { |
|
44 | + public function testGetRequiresNamesDoesNotContain() { |
|
49 | 45 | |
50 | 46 | $testFile = __DIR__ . '/composerpackage-test-easypost-php.json'; |
51 | 47 | |
@@ -61,8 +57,7 @@ discard block |
||
61 | 57 | /** |
62 | 58 | * |
63 | 59 | */ |
64 | - public function testAutoloadPsr0() |
|
65 | - { |
|
60 | + public function testAutoloadPsr0() { |
|
66 | 61 | |
67 | 62 | $testFile = __DIR__ . '/composerpackage-test-easypost-php.json'; |
68 | 63 | |
@@ -78,8 +73,7 @@ discard block |
||
78 | 73 | /** |
79 | 74 | * |
80 | 75 | */ |
81 | - public function testAutoloadPsr4() |
|
82 | - { |
|
76 | + public function testAutoloadPsr4() { |
|
83 | 77 | |
84 | 78 | $testFile = __DIR__ . '/composerpackage-test-libmergepdf.json'; |
85 | 79 | |
@@ -95,8 +89,7 @@ discard block |
||
95 | 89 | /** |
96 | 90 | * |
97 | 91 | */ |
98 | - public function testAutoloadClassmap() |
|
99 | - { |
|
92 | + public function testAutoloadClassmap() { |
|
100 | 93 | |
101 | 94 | $testFile = __DIR__ . '/composerpackage-test-libmergepdf.json'; |
102 | 95 | |
@@ -112,8 +105,7 @@ discard block |
||
112 | 105 | /** |
113 | 106 | * |
114 | 107 | */ |
115 | - public function testAutoloadFiles() |
|
116 | - { |
|
108 | + public function testAutoloadFiles() { |
|
117 | 109 | |
118 | 110 | $testFile = __DIR__ . '/composerpackage-test-php-di.json'; |
119 | 111 | |
@@ -126,16 +118,14 @@ discard block |
||
126 | 118 | $this->assertIsArray($autoload['files']); |
127 | 119 | } |
128 | 120 | |
129 | - public function testOverrideAutoload() |
|
130 | - { |
|
121 | + public function testOverrideAutoload() { |
|
131 | 122 | $this->markTestIncomplete(); |
132 | 123 | } |
133 | 124 | |
134 | 125 | /** |
135 | 126 | * When composer.json is not where it was specified, what error message (via Exception) should be returned? |
136 | 127 | */ |
137 | - public function testMissingComposer() |
|
138 | - { |
|
128 | + public function testMissingComposer() { |
|
139 | 129 | $this->markTestIncomplete(); |
140 | 130 | } |
141 | 131 | } |
@@ -6,14 +6,12 @@ |
||
6 | 6 | use BrianHenryIE\Strauss\Composer\ProjectComposerPackage; |
7 | 7 | use PHPUnit\Framework\TestCase; |
8 | 8 | |
9 | -class ProjectComposerPackageTest extends TestCase |
|
10 | -{ |
|
9 | +class ProjectComposerPackageTest extends TestCase { |
|
11 | 10 | |
12 | 11 | /** |
13 | 12 | * A simple test to check the getters all work. |
14 | 13 | */ |
15 | - public function testParseJson() |
|
16 | - { |
|
14 | + public function testParseJson() { |
|
17 | 15 | |
18 | 16 | $testFile = __DIR__ . '/projectcomposerpackage-test-1.json'; |
19 | 17 |
@@ -9,8 +9,7 @@ discard block |
||
9 | 9 | use Composer\Composer; |
10 | 10 | use PHPUnit\Framework\TestCase; |
11 | 11 | |
12 | -class ChangeEnumeratorTest extends TestCase |
|
13 | -{ |
|
12 | +class ChangeEnumeratorTest extends TestCase { |
|
14 | 13 | |
15 | 14 | // PREG_BACKTRACK_LIMIT_ERROR |
16 | 15 | |
@@ -21,8 +20,7 @@ discard block |
||
21 | 20 | |
22 | 21 | |
23 | 22 | |
24 | - public function testSingleNamespace() |
|
25 | - { |
|
23 | + public function testSingleNamespace() { |
|
26 | 24 | |
27 | 25 | $validPhp = <<<'EOD' |
28 | 26 | <?php |
@@ -44,8 +42,7 @@ discard block |
||
44 | 42 | $this->assertNotContains('MyClass', $sut->getDiscoveredClasses()); |
45 | 43 | } |
46 | 44 | |
47 | - public function testGlobalNamespace() |
|
48 | - { |
|
45 | + public function testGlobalNamespace() { |
|
49 | 46 | |
50 | 47 | $validPhp = <<<'EOD' |
51 | 48 | <?php |
@@ -66,8 +63,7 @@ discard block |
||
66 | 63 | /** |
67 | 64 | * |
68 | 65 | */ |
69 | - public function testMultipleNamespace() |
|
70 | - { |
|
66 | + public function testMultipleNamespace() { |
|
71 | 67 | |
72 | 68 | $validPhp = <<<'EOD' |
73 | 69 | <?php |
@@ -93,8 +89,7 @@ discard block |
||
93 | 89 | /** |
94 | 90 | * |
95 | 91 | */ |
96 | - public function testMultipleNamespaceGlobalFirst() |
|
97 | - { |
|
92 | + public function testMultipleNamespaceGlobalFirst() { |
|
98 | 93 | |
99 | 94 | $validPhp = <<<'EOD' |
100 | 95 | <?php |
@@ -124,8 +119,7 @@ discard block |
||
124 | 119 | /** |
125 | 120 | * |
126 | 121 | */ |
127 | - public function testMultipleClasses() |
|
128 | - { |
|
122 | + public function testMultipleClasses() { |
|
129 | 123 | |
130 | 124 | $validPhp = <<<'EOD' |
131 | 125 | <?php |
@@ -149,8 +143,7 @@ discard block |
||
149 | 143 | * |
150 | 144 | * @author BrianHenryIE |
151 | 145 | */ |
152 | - public function test_it_does_not_treat_comments_as_classes() |
|
153 | - { |
|
146 | + public function test_it_does_not_treat_comments_as_classes() { |
|
154 | 147 | $contents = " |
155 | 148 | // A class as good as any. |
156 | 149 | class Whatever { |
@@ -170,8 +163,7 @@ discard block |
||
170 | 163 | * |
171 | 164 | * @author BrianHenryIE |
172 | 165 | */ |
173 | - public function test_it_does_not_treat_multiline_comments_as_classes() |
|
174 | - { |
|
166 | + public function test_it_does_not_treat_multiline_comments_as_classes() { |
|
175 | 167 | $contents = " |
176 | 168 | /** |
177 | 169 | * A class as good as any; class as. |
@@ -195,8 +187,7 @@ discard block |
||
195 | 187 | * |
196 | 188 | * @author BrianHenryIE |
197 | 189 | */ |
198 | - public function test_it_does_not_treat_multiline_comments_opening_line_as_classes() |
|
199 | - { |
|
190 | + public function test_it_does_not_treat_multiline_comments_opening_line_as_classes() { |
|
200 | 191 | $contents = " |
201 | 192 | /** A class as good as any; class as. |
202 | 193 | * |
@@ -218,8 +209,7 @@ discard block |
||
218 | 209 | * |
219 | 210 | * @author BrianHenryIE |
220 | 211 | */ |
221 | - public function test_it_does_not_treat_multiline_comments_on_one_line_as_classes() |
|
222 | - { |
|
212 | + public function test_it_does_not_treat_multiline_comments_on_one_line_as_classes() { |
|
223 | 213 | $contents = " |
224 | 214 | /** A class as good as any; class as. */ class Whatever_Trevor { |
225 | 215 | } |
@@ -240,8 +230,7 @@ discard block |
||
240 | 230 | * |
241 | 231 | * @test |
242 | 232 | */ |
243 | - public function test_it_does_not_treat_comments_with_semicolons_as_classes() |
|
244 | - { |
|
233 | + public function test_it_does_not_treat_comments_with_semicolons_as_classes() { |
|
245 | 234 | $contents = " |
246 | 235 | // A class as good as any; class as versatile as any. |
247 | 236 | class Whatever_Ever { |
@@ -260,8 +249,7 @@ discard block |
||
260 | 249 | /** |
261 | 250 | * @author BrianHenryIE |
262 | 251 | */ |
263 | - public function test_it_parses_classes_after_semicolon() |
|
264 | - { |
|
252 | + public function test_it_parses_classes_after_semicolon() { |
|
265 | 253 | |
266 | 254 | $contents = " |
267 | 255 | myvar = 123; class Pear { }; |
@@ -278,8 +266,7 @@ discard block |
||
278 | 266 | /** |
279 | 267 | * @author BrianHenryIE |
280 | 268 | */ |
281 | - public function test_it_parses_classes_followed_by_comment() |
|
282 | - { |
|
269 | + public function test_it_parses_classes_followed_by_comment() { |
|
283 | 270 | |
284 | 271 | $contents = <<<'EOD' |
285 | 272 | class WP_Dependency_Installer { |
@@ -325,8 +312,7 @@ discard block |
||
325 | 312 | $this->assertContains('B_Class', $changeEnumerator->getDiscoveredClasses()); |
326 | 313 | } |
327 | 314 | |
328 | - public function testExcludePackagesFromPrefix() |
|
329 | - { |
|
315 | + public function testExcludePackagesFromPrefix() { |
|
330 | 316 | |
331 | 317 | $config = $this->createMock(StraussConfig::class); |
332 | 318 | $config->method('getExcludePackagesFromPrefixing')->willReturn( |
@@ -345,8 +331,7 @@ discard block |
||
345 | 331 | } |
346 | 332 | |
347 | 333 | |
348 | - public function testExcludeFilePatternsFromPrefix() |
|
349 | - { |
|
334 | + public function testExcludeFilePatternsFromPrefix() { |
|
350 | 335 | $config = $this->createMock(StraussConfig::class); |
351 | 336 | $config->method('getExcludeFilePatternsFromPrefixing')->willReturn( |
352 | 337 | array('/to/') |
@@ -366,8 +351,7 @@ discard block |
||
366 | 351 | /** |
367 | 352 | * Test custom replacements |
368 | 353 | */ |
369 | - public function testNamespaceReplacementPatterns() |
|
370 | - { |
|
354 | + public function testNamespaceReplacementPatterns() { |
|
371 | 355 | |
372 | 356 | $contents = " |
373 | 357 | namespace BrianHenryIE\PdfHelpers { |
@@ -392,8 +376,7 @@ discard block |
||
392 | 376 | /** |
393 | 377 | * @see https://github.com/BrianHenryIE/strauss/issues/19 |
394 | 378 | */ |
395 | - public function testPhraseClassObjectIsNotMistaken() |
|
396 | - { |
|
379 | + public function testPhraseClassObjectIsNotMistaken() { |
|
397 | 380 | |
398 | 381 | $contents = <<<'EOD' |
399 | 382 | <?php |
@@ -20,8 +20,7 @@ discard block |
||
20 | 20 | * @package BrianHenryIE\Strauss |
21 | 21 | * @covers \BrianHenryIE\Strauss\Prefixer |
22 | 22 | */ |
23 | -class PrefixerTest extends TestCase |
|
24 | -{ |
|
23 | +class PrefixerTest extends TestCase { |
|
25 | 24 | |
26 | 25 | protected StraussConfig $config; |
27 | 26 | |
@@ -46,8 +45,7 @@ discard block |
||
46 | 45 | $this->config = new StraussConfig($composer); |
47 | 46 | } |
48 | 47 | |
49 | - public function testNamespaceReplacer() |
|
50 | - { |
|
48 | + public function testNamespaceReplacer() { |
|
51 | 49 | |
52 | 50 | $contents = <<<'EOD' |
53 | 51 | <?php |
@@ -137,8 +135,7 @@ discard block |
||
137 | 135 | } |
138 | 136 | |
139 | 137 | |
140 | - public function testClassnameReplacer() |
|
141 | - { |
|
138 | + public function testClassnameReplacer() { |
|
142 | 139 | |
143 | 140 | $contents = <<<'EOD' |
144 | 141 | <?php |
@@ -178,8 +175,7 @@ discard block |
||
178 | 175 | /** |
179 | 176 | * PHP 7.4 typed parameters were being prefixed. |
180 | 177 | */ |
181 | - public function testTypeFunctionParameter() |
|
182 | - { |
|
178 | + public function testTypeFunctionParameter() { |
|
183 | 179 | $this->markTestIncomplete(); |
184 | 180 | } |
185 | 181 | |
@@ -552,8 +548,7 @@ discard block |
||
552 | 548 | /** |
553 | 549 | * @author BrianHenryIE |
554 | 550 | */ |
555 | - public function test_it_doesnt_prefix_function_types_that_happen_to_match_the_namespace() |
|
556 | - { |
|
551 | + public function test_it_doesnt_prefix_function_types_that_happen_to_match_the_namespace() { |
|
557 | 552 | $namespace = 'Mpdf'; |
558 | 553 | $prefix = "Mozart"; |
559 | 554 | $contents = 'public function getServices( Mpdf $mpdf, LoggerInterface $logger, $config, )'; |
@@ -568,8 +563,7 @@ discard block |
||
568 | 563 | $this->assertEquals($expected, $result); |
569 | 564 | } |
570 | 565 | |
571 | - public function testLeadingSlashInString() |
|
572 | - { |
|
566 | + public function testLeadingSlashInString() { |
|
573 | 567 | $originalNamespace = "Strauss\\Test"; |
574 | 568 | $replacement = "Prefix\\Strauss\\Test"; |
575 | 569 | $contents = '$mentionedClass = "\\Strauss\\Test\\Classname";'; |
@@ -584,8 +578,7 @@ discard block |
||
584 | 578 | $this->assertEquals($expected, $result); |
585 | 579 | } |
586 | 580 | |
587 | - public function testDoubleLeadingSlashInString() |
|
588 | - { |
|
581 | + public function testDoubleLeadingSlashInString() { |
|
589 | 582 | $originalNamespace = "Strauss\\Test"; |
590 | 583 | $replacement = "Prefix\\Strauss\\Test"; |
591 | 584 | $contents = '$mentionedClass = "\\\\Strauss\\\\Test\\\\Classname";'; |
@@ -600,8 +593,7 @@ discard block |
||
600 | 593 | $this->assertEquals($expected, $result); |
601 | 594 | } |
602 | 595 | |
603 | - public function testItReplacesSlashedNamespaceInFunctionParameter() |
|
604 | - { |
|
596 | + public function testItReplacesSlashedNamespaceInFunctionParameter() { |
|
605 | 597 | |
606 | 598 | $originalNamespace = "net\\authorize\\api\\contract\\v1"; |
607 | 599 | $replacement = "Prefix\\net\\authorize\\api\\contract\\v1"; |
@@ -618,8 +610,7 @@ discard block |
||
618 | 610 | } |
619 | 611 | |
620 | 612 | |
621 | - public function testItReplacesNamespaceInFunctionParameterDefaultAgumentValue() |
|
622 | - { |
|
613 | + public function testItReplacesNamespaceInFunctionParameterDefaultAgumentValue() { |
|
623 | 614 | |
624 | 615 | $originalNamespace = "net\\authorize\\api\constants"; |
625 | 616 | $replacement = "Prefix\\net\\authorize\\api\constants"; |
@@ -636,8 +627,7 @@ discard block |
||
636 | 627 | } |
637 | 628 | |
638 | 629 | |
639 | - public function testItReplacesNamespaceConcatenatedStringConst() |
|
640 | - { |
|
630 | + public function testItReplacesNamespaceConcatenatedStringConst() { |
|
641 | 631 | |
642 | 632 | $originalNamespace = "net\\authorize\\api\\constants"; |
643 | 633 | $replacement = "Prefix\\net\\authorize\\api\\constants"; |
@@ -657,8 +647,7 @@ discard block |
||
657 | 647 | /** |
658 | 648 | * Another mpdf issue where the class "Mpdf" is in the namespace "Mpdf" and incorrect replacements are being made. |
659 | 649 | */ |
660 | - public function testClassnameNotConfusedWithNamespace() |
|
661 | - { |
|
650 | + public function testClassnameNotConfusedWithNamespace() { |
|
662 | 651 | |
663 | 652 | $contents = '$default_font_size = $mmsize * (Mpdf::SCALE);'; |
664 | 653 | $expected = $contents; |
@@ -671,8 +660,7 @@ discard block |
||
671 | 660 | $this->assertEquals($expected, $result); |
672 | 661 | } |
673 | 662 | |
674 | - public function testClassExtendsNamspacedClassIsPrefixed() |
|
675 | - { |
|
663 | + public function testClassExtendsNamspacedClassIsPrefixed() { |
|
676 | 664 | |
677 | 665 | $contents = 'class BarcodeException extends \Mpdf\MpdfException'; |
678 | 666 | $expected = 'class BarcodeException extends \BrianHenryIE\Strauss\Mpdf\MpdfException'; |
@@ -690,8 +678,7 @@ discard block |
||
690 | 678 | * |
691 | 679 | * @see https://github.com/BrianHenryIE/strauss/issues/11 |
692 | 680 | */ |
693 | - public function testNewNamespacedClassIsPrefixed() |
|
694 | - { |
|
681 | + public function testNewNamespacedClassIsPrefixed() { |
|
695 | 682 | |
696 | 683 | $contents = '$ioc->register( new \Carbon_Fields\Provider\Container_Condition_Provider() );'; |
697 | 684 | $expected = '$ioc->register( new \BrianHenryIE\Strauss\Carbon_Fields\Provider\Container_Condition_Provider() );'; |
@@ -711,8 +698,7 @@ discard block |
||
711 | 698 | * |
712 | 699 | * @see https://github.com/BrianHenryIE/strauss/issues/11 |
713 | 700 | */ |
714 | - public function testStaticNamespacedClassIsPrefixed() |
|
715 | - { |
|
701 | + public function testStaticNamespacedClassIsPrefixed() { |
|
716 | 702 | |
717 | 703 | $contents = '@method static \Carbon_Fields\Container\Comment_Meta_Container'; |
718 | 704 | $expected = '@method static \BrianHenryIE\Strauss\Carbon_Fields\Container\Comment_Meta_Container'; |
@@ -730,8 +716,7 @@ discard block |
||
730 | 716 | * |
731 | 717 | * @see https://github.com/BrianHenryIE/strauss/issues/11 |
732 | 718 | */ |
733 | - public function testReturnedNamespacedClassIsPrefixed() |
|
734 | - { |
|
719 | + public function testReturnedNamespacedClassIsPrefixed() { |
|
735 | 720 | |
736 | 721 | $contents = 'return \Carbon_Fields\Carbon_Fields::resolve'; |
737 | 722 | $expected = 'return \BrianHenryIE\Strauss\Carbon_Fields\Carbon_Fields::resolve'; |
@@ -749,8 +734,7 @@ discard block |
||
749 | 734 | * |
750 | 735 | * @see https://github.com/BrianHenryIE/strauss/issues/11 |
751 | 736 | */ |
752 | - public function testNamespacedStaticIsPrefixed() |
|
753 | - { |
|
737 | + public function testNamespacedStaticIsPrefixed() { |
|
754 | 738 | |
755 | 739 | $contents = " \\Carbon_Fields\\Carbon_Fields::service( 'legacy_storage' )->enable()"; |
756 | 740 | $expected = " \\BrianHenryIE\\Strauss\\Carbon_Fields\\Carbon_Fields::service( 'legacy_storage' )->enable()"; |
@@ -772,8 +756,7 @@ discard block |
||
772 | 756 | * |
773 | 757 | * @see https://github.com/BrianHenryIE/strauss/issues/15 |
774 | 758 | */ |
775 | - public function testDoNotReplaceInStringThatIsNotCode() |
|
776 | - { |
|
759 | + public function testDoNotReplaceInStringThatIsNotCode() { |
|
777 | 760 | $originalNamespace = "TrustedLogin"; |
778 | 761 | $replacement = "Prefix\\TrustedLogin"; |
779 | 762 | $contents = "esc_html__( 'Learn about TrustedLogin', 'trustedlogin' )"; |
@@ -795,8 +778,7 @@ discard block |
||
795 | 778 | * @see https://github.com/BrianHenryIE/strauss/issues/19 |
796 | 779 | * |
797 | 780 | */ |
798 | - public function testDoNotReplaceInVariableNames() |
|
799 | - { |
|
781 | + public function testDoNotReplaceInVariableNames() { |
|
800 | 782 | $originalClassname = 'object'; |
801 | 783 | $classnamePrefix = 'Strauss_Issue19_'; |
802 | 784 | $contents = "public static function objclone(\$object) {"; |
@@ -18,16 +18,14 @@ discard block |
||
18 | 18 | * @package BrianHenryIE\Strauss\Tests\Unit |
19 | 19 | * @coversDefaultClass \BrianHenryIE\Strauss\Licenser |
20 | 20 | */ |
21 | -class LicenserTest extends TestCase |
|
22 | -{ |
|
21 | +class LicenserTest extends TestCase { |
|
23 | 22 | |
24 | 23 | |
25 | 24 | /** |
26 | 25 | * @covers ::findLicenseFiles |
27 | 26 | * |
28 | 27 | */ |
29 | - public function testFindLicenceFilesPathsAreRelative() |
|
30 | - { |
|
28 | + public function testFindLicenceFilesPathsAreRelative() { |
|
31 | 29 | $config = $this->createStub(StraussConfig::class); |
32 | 30 | $workingDir = __DIR__ . DIRECTORY_SEPARATOR; |
33 | 31 | |
@@ -79,8 +77,7 @@ discard block |
||
79 | 77 | * |
80 | 78 | * @covers ::addChangeDeclarationToPhpString |
81 | 79 | */ |
82 | - public function testAppendHeaderCommentInformationNoHeader() |
|
83 | - { |
|
80 | + public function testAppendHeaderCommentInformationNoHeader() { |
|
84 | 81 | |
85 | 82 | $author = 'BrianHenryIE'; |
86 | 83 | |
@@ -166,8 +163,7 @@ discard block |
||
166 | 163 | * |
167 | 164 | * @covers ::addChangeDeclarationToPhpString |
168 | 165 | */ |
169 | - public function testWithTwoCommentsBeforeFirstCode() |
|
170 | - { |
|
166 | + public function testWithTwoCommentsBeforeFirstCode() { |
|
171 | 167 | |
172 | 168 | $config = $this->createStub(StraussConfig::class); |
173 | 169 | $author = 'BrianHenryIE'; |
@@ -227,8 +223,7 @@ discard block |
||
227 | 223 | /** |
228 | 224 | * @covers ::addChangeDeclarationToPhpString |
229 | 225 | */ |
230 | - public function testUnusualHeaderCommentStyle() |
|
231 | - { |
|
226 | + public function testUnusualHeaderCommentStyle() { |
|
232 | 227 | |
233 | 228 | $config = $this->createStub(StraussConfig::class); |
234 | 229 | $author = 'BrianHenryIE'; |
@@ -272,8 +267,7 @@ discard block |
||
272 | 267 | /** |
273 | 268 | * @covers ::addChangeDeclarationToPhpString |
274 | 269 | */ |
275 | - public function testCommentWithLicenseWord() |
|
276 | - { |
|
270 | + public function testCommentWithLicenseWord() { |
|
277 | 271 | |
278 | 272 | $config = $this->createStub(StraussConfig::class); |
279 | 273 | $author = 'BrianHenryIE'; |
@@ -331,8 +325,7 @@ discard block |
||
331 | 325 | * |
332 | 326 | * Seems files loaded are treated different to strings passed. |
333 | 327 | */ |
334 | - public function testIncorrectlyMatching() |
|
335 | - { |
|
328 | + public function testIncorrectlyMatching() { |
|
336 | 329 | |
337 | 330 | $config = $this->createStub(StraussConfig::class); |
338 | 331 | $author = 'BrianHenryIE'; |
@@ -401,8 +394,7 @@ discard block |
||
401 | 394 | /** |
402 | 395 | * The licence was being inserted after every `<?php` in the file. |
403 | 396 | */ |
404 | - public function testLicenseDetailsOnlyInsertedOncePerFile() |
|
405 | - { |
|
397 | + public function testLicenseDetailsOnlyInsertedOncePerFile() { |
|
406 | 398 | |
407 | 399 | $config = $this->createStub(StraussConfig::class); |
408 | 400 | $author = 'BrianHenryIE'; |