@@ -11,8 +11,7 @@ |
||
11 | 11 | |
12 | 12 | namespace Symfony\Component\String\Inflector; |
13 | 13 | |
14 | -final class EnglishInflector implements InflectorInterface |
|
15 | -{ |
|
14 | +final class EnglishInflector implements InflectorInterface { |
|
16 | 15 | /** |
17 | 16 | * Map English plural to singular suffixes. |
18 | 17 | * |
@@ -14,6 +14,5 @@ |
||
14 | 14 | /** |
15 | 15 | * @author Christian Flothmann <[email protected]> |
16 | 16 | */ |
17 | -class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface |
|
18 | -{ |
|
17 | +class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface { |
|
19 | 18 | } |
@@ -17,10 +17,8 @@ |
||
17 | 17 | * @author Fabien Potencier <[email protected]> |
18 | 18 | * @author Christian Gärtner <[email protected]> |
19 | 19 | */ |
20 | -class FileNotFoundException extends IOException |
|
21 | -{ |
|
22 | - public function __construct(string $message = null, int $code = 0, \Throwable $previous = null, string $path = null) |
|
23 | - { |
|
20 | +class FileNotFoundException extends IOException { |
|
21 | + public function __construct(string $message = null, int $code = 0, \Throwable $previous = null, string $path = null) { |
|
24 | 22 | if (null === $message) { |
25 | 23 | if (null === $path) { |
26 | 24 | $message = 'File could not be found.'; |
@@ -16,6 +16,5 @@ |
||
16 | 16 | * |
17 | 17 | * @author Romain Neutron <[email protected]> |
18 | 18 | */ |
19 | -interface ExceptionInterface extends \Throwable |
|
20 | -{ |
|
19 | +interface ExceptionInterface extends \Throwable { |
|
21 | 20 | } |
@@ -18,12 +18,10 @@ discard block |
||
18 | 18 | * @author Christian Gärtner <[email protected]> |
19 | 19 | * @author Fabien Potencier <[email protected]> |
20 | 20 | */ |
21 | -class IOException extends \RuntimeException implements IOExceptionInterface |
|
22 | -{ |
|
21 | +class IOException extends \RuntimeException implements IOExceptionInterface { |
|
23 | 22 | private $path; |
24 | 23 | |
25 | - public function __construct(string $message, int $code = 0, \Throwable $previous = null, string $path = null) |
|
26 | - { |
|
24 | + public function __construct(string $message, int $code = 0, \Throwable $previous = null, string $path = null) { |
|
27 | 25 | $this->path = $path; |
28 | 26 | |
29 | 27 | parent::__construct($message, $code, $previous); |
@@ -32,8 +30,7 @@ discard block |
||
32 | 30 | /** |
33 | 31 | * {@inheritdoc} |
34 | 32 | */ |
35 | - public function getPath() |
|
36 | - { |
|
33 | + public function getPath() { |
|
37 | 34 | return $this->path; |
38 | 35 | } |
39 | 36 | } |
@@ -16,8 +16,7 @@ |
||
16 | 16 | * |
17 | 17 | * @author Christian Gärtner <[email protected]> |
18 | 18 | */ |
19 | -interface IOExceptionInterface extends ExceptionInterface |
|
20 | -{ |
|
19 | +interface IOExceptionInterface extends ExceptionInterface { |
|
21 | 20 | /** |
22 | 21 | * Returns the associated path for the exception. |
23 | 22 | * |
@@ -20,8 +20,7 @@ discard block |
||
20 | 20 | * |
21 | 21 | * @author Fabien Potencier <[email protected]> |
22 | 22 | */ |
23 | -class Filesystem |
|
24 | -{ |
|
23 | +class Filesystem { |
|
25 | 24 | private static $lastError; |
26 | 25 | |
27 | 26 | /** |
@@ -34,8 +33,7 @@ discard block |
||
34 | 33 | * @throws FileNotFoundException When originFile doesn't exist |
35 | 34 | * @throws IOException When copy fails |
36 | 35 | */ |
37 | - public function copy(string $originFile, string $targetFile, bool $overwriteNewerFiles = false) |
|
38 | - { |
|
36 | + public function copy(string $originFile, string $targetFile, bool $overwriteNewerFiles = false) { |
|
39 | 37 | $originIsLocal = stream_is_local($originFile) || 0 === stripos($originFile, 'file://'); |
40 | 38 | if ($originIsLocal && !is_file($originFile)) { |
41 | 39 | throw new FileNotFoundException(sprintf('Failed to copy "%s" because file does not exist.', $originFile), 0, null, $originFile); |
@@ -86,8 +84,7 @@ discard block |
||
86 | 84 | * |
87 | 85 | * @throws IOException On any directory creation failure |
88 | 86 | */ |
89 | - public function mkdir($dirs, int $mode = 0777) |
|
90 | - { |
|
87 | + public function mkdir($dirs, int $mode = 0777) { |
|
91 | 88 | foreach ($this->toIterable($dirs) as $dir) { |
92 | 89 | if (is_dir($dir)) { |
93 | 90 | continue; |
@@ -106,8 +103,7 @@ discard block |
||
106 | 103 | * |
107 | 104 | * @return bool true if the file exists, false otherwise |
108 | 105 | */ |
109 | - public function exists($files) |
|
110 | - { |
|
106 | + public function exists($files) { |
|
111 | 107 | $maxPathLength = \PHP_MAXPATHLEN - 2; |
112 | 108 | |
113 | 109 | foreach ($this->toIterable($files) as $file) { |
@@ -132,8 +128,7 @@ discard block |
||
132 | 128 | * |
133 | 129 | * @throws IOException When touch fails |
134 | 130 | */ |
135 | - public function touch($files, int $time = null, int $atime = null) |
|
136 | - { |
|
131 | + public function touch($files, int $time = null, int $atime = null) { |
|
137 | 132 | foreach ($this->toIterable($files) as $file) { |
138 | 133 | if (!($time ? self::box('touch', $file, $time, $atime) : self::box('touch', $file))) { |
139 | 134 | throw new IOException(sprintf('Failed to touch "%s": ', $file).self::$lastError, 0, null, $file); |
@@ -148,8 +143,7 @@ discard block |
||
148 | 143 | * |
149 | 144 | * @throws IOException When removal fails |
150 | 145 | */ |
151 | - public function remove($files) |
|
152 | - { |
|
146 | + public function remove($files) { |
|
153 | 147 | if ($files instanceof \Traversable) { |
154 | 148 | $files = iterator_to_array($files, false); |
155 | 149 | } elseif (!\is_array($files)) { |
@@ -215,8 +209,7 @@ discard block |
||
215 | 209 | * |
216 | 210 | * @throws IOException When the change fails |
217 | 211 | */ |
218 | - public function chmod($files, int $mode, int $umask = 0000, bool $recursive = false) |
|
219 | - { |
|
212 | + public function chmod($files, int $mode, int $umask = 0000, bool $recursive = false) { |
|
220 | 213 | foreach ($this->toIterable($files) as $file) { |
221 | 214 | if ((\PHP_VERSION_ID < 80000 || \is_int($mode)) && !self::box('chmod', $file, $mode & ~$umask)) { |
222 | 215 | throw new IOException(sprintf('Failed to chmod file "%s": ', $file).self::$lastError, 0, null, $file); |
@@ -236,8 +229,7 @@ discard block |
||
236 | 229 | * |
237 | 230 | * @throws IOException When the change fails |
238 | 231 | */ |
239 | - public function chown($files, $user, bool $recursive = false) |
|
240 | - { |
|
232 | + public function chown($files, $user, bool $recursive = false) { |
|
241 | 233 | foreach ($this->toIterable($files) as $file) { |
242 | 234 | if ($recursive && is_dir($file) && !is_link($file)) { |
243 | 235 | $this->chown(new \FilesystemIterator($file), $user, true); |
@@ -263,8 +255,7 @@ discard block |
||
263 | 255 | * |
264 | 256 | * @throws IOException When the change fails |
265 | 257 | */ |
266 | - public function chgrp($files, $group, bool $recursive = false) |
|
267 | - { |
|
258 | + public function chgrp($files, $group, bool $recursive = false) { |
|
268 | 259 | foreach ($this->toIterable($files) as $file) { |
269 | 260 | if ($recursive && is_dir($file) && !is_link($file)) { |
270 | 261 | $this->chgrp(new \FilesystemIterator($file), $group, true); |
@@ -287,8 +278,7 @@ discard block |
||
287 | 278 | * @throws IOException When target file or directory already exists |
288 | 279 | * @throws IOException When origin cannot be renamed |
289 | 280 | */ |
290 | - public function rename(string $origin, string $target, bool $overwrite = false) |
|
291 | - { |
|
281 | + public function rename(string $origin, string $target, bool $overwrite = false) { |
|
292 | 282 | // we check that target does not exist |
293 | 283 | if (!$overwrite && $this->isReadable($target)) { |
294 | 284 | throw new IOException(sprintf('Cannot rename because the target "%s" already exists.', $target), 0, null, $target); |
@@ -327,8 +317,7 @@ discard block |
||
327 | 317 | * |
328 | 318 | * @throws IOException When symlink fails |
329 | 319 | */ |
330 | - public function symlink(string $originDir, string $targetDir, bool $copyOnWindows = false) |
|
331 | - { |
|
320 | + public function symlink(string $originDir, string $targetDir, bool $copyOnWindows = false) { |
|
332 | 321 | if ('\\' === \DIRECTORY_SEPARATOR) { |
333 | 322 | $originDir = strtr($originDir, '/', '\\'); |
334 | 323 | $targetDir = strtr($targetDir, '/', '\\'); |
@@ -362,8 +351,7 @@ discard block |
||
362 | 351 | * @throws FileNotFoundException When original file is missing or not a file |
363 | 352 | * @throws IOException When link fails, including if link already exists |
364 | 353 | */ |
365 | - public function hardlink(string $originFile, $targetFiles) |
|
366 | - { |
|
354 | + public function hardlink(string $originFile, $targetFiles) { |
|
367 | 355 | if (!$this->exists($originFile)) { |
368 | 356 | throw new FileNotFoundException(null, 0, null, $originFile); |
369 | 357 | } |
@@ -389,8 +377,7 @@ discard block |
||
389 | 377 | /** |
390 | 378 | * @param string $linkType Name of the link type, typically 'symbolic' or 'hard' |
391 | 379 | */ |
392 | - private function linkException(string $origin, string $target, string $linkType) |
|
393 | - { |
|
380 | + private function linkException(string $origin, string $target, string $linkType) { |
|
394 | 381 | if (self::$lastError) { |
395 | 382 | if ('\\' === \DIRECTORY_SEPARATOR && str_contains(self::$lastError, 'error code(1314)')) { |
396 | 383 | throw new IOException(sprintf('Unable to create "%s" link due to error code 1314: \'A required privilege is not held by the client\'. Do you have the required Administrator-rights?', $linkType), 0, null, $target); |
@@ -412,8 +399,7 @@ discard block |
||
412 | 399 | * |
413 | 400 | * @return string|null |
414 | 401 | */ |
415 | - public function readlink(string $path, bool $canonicalize = false) |
|
416 | - { |
|
402 | + public function readlink(string $path, bool $canonicalize = false) { |
|
417 | 403 | if (!$canonicalize && !is_link($path)) { |
418 | 404 | return null; |
419 | 405 | } |
@@ -442,8 +428,7 @@ discard block |
||
442 | 428 | * |
443 | 429 | * @return string Path of target relative to starting path |
444 | 430 | */ |
445 | - public function makePathRelative(string $endPath, string $startPath) |
|
446 | - { |
|
431 | + public function makePathRelative(string $endPath, string $startPath) { |
|
447 | 432 | if (!$this->isAbsolutePath($startPath)) { |
448 | 433 | throw new InvalidArgumentException(sprintf('The start path "%s" is not absolute.', $startPath)); |
449 | 434 | } |
@@ -530,8 +515,7 @@ discard block |
||
530 | 515 | * |
531 | 516 | * @throws IOException When file type is unknown |
532 | 517 | */ |
533 | - public function mirror(string $originDir, string $targetDir, \Traversable $iterator = null, array $options = []) |
|
534 | - { |
|
518 | + public function mirror(string $originDir, string $targetDir, \Traversable $iterator = null, array $options = []) { |
|
535 | 519 | $targetDir = rtrim($targetDir, '/\\'); |
536 | 520 | $originDir = rtrim($originDir, '/\\'); |
537 | 521 | $originDirLen = \strlen($originDir); |
@@ -591,8 +575,7 @@ discard block |
||
591 | 575 | * |
592 | 576 | * @return bool |
593 | 577 | */ |
594 | - public function isAbsolutePath(string $file) |
|
595 | - { |
|
578 | + public function isAbsolutePath(string $file) { |
|
596 | 579 | return '' !== $file && (strspn($file, '/\\', 0, 1) |
597 | 580 | || (\strlen($file) > 3 && ctype_alpha($file[0]) |
598 | 581 | && ':' === $file[1] |
@@ -611,8 +594,7 @@ discard block |
||
611 | 594 | * |
612 | 595 | * @return string The new temporary filename (with path), or throw an exception on failure |
613 | 596 | */ |
614 | - public function tempnam(string $dir, string $prefix/*, string $suffix = ''*/) |
|
615 | - { |
|
597 | + public function tempnam(string $dir, string $prefix/*, string $suffix = ''*/) { |
|
616 | 598 | $suffix = \func_num_args() > 2 ? func_get_arg(2) : ''; |
617 | 599 | [$scheme, $hierarchy] = $this->getSchemeAndHierarchy($dir); |
618 | 600 | |
@@ -657,8 +639,7 @@ discard block |
||
657 | 639 | * |
658 | 640 | * @throws IOException if the file cannot be written to |
659 | 641 | */ |
660 | - public function dumpFile(string $filename, $content) |
|
661 | - { |
|
642 | + public function dumpFile(string $filename, $content) { |
|
662 | 643 | if (\is_array($content)) { |
663 | 644 | throw new \TypeError(sprintf('Argument 2 passed to "%s()" must be string or resource, array given.', __METHOD__)); |
664 | 645 | } |
@@ -695,8 +676,7 @@ discard block |
||
695 | 676 | * |
696 | 677 | * @throws IOException If the file is not writable |
697 | 678 | */ |
698 | - public function appendToFile(string $filename, $content) |
|
699 | - { |
|
679 | + public function appendToFile(string $filename, $content) { |
|
700 | 680 | if (\is_array($content)) { |
701 | 681 | throw new \TypeError(sprintf('Argument 2 passed to "%s()" must be string or resource, array given.', __METHOD__)); |
702 | 682 | } |
@@ -732,8 +712,7 @@ discard block |
||
732 | 712 | * |
733 | 713 | * @return mixed |
734 | 714 | */ |
735 | - private static function box(callable $func, ...$args) |
|
736 | - { |
|
715 | + private static function box(callable $func, ...$args) { |
|
737 | 716 | self::$lastError = null; |
738 | 717 | set_error_handler(__CLASS__.'::handleError'); |
739 | 718 | try { |
@@ -751,8 +730,7 @@ discard block |
||
751 | 730 | /** |
752 | 731 | * @internal |
753 | 732 | */ |
754 | - public static function handleError(int $type, string $msg) |
|
755 | - { |
|
733 | + public static function handleError(int $type, string $msg) { |
|
756 | 734 | self::$lastError = $msg; |
757 | 735 | } |
758 | 736 | } |
@@ -14,6 +14,5 @@ |
||
14 | 14 | /** |
15 | 15 | * @author Andreas Erhard <[email protected]> |
16 | 16 | */ |
17 | -class DirectoryNotFoundException extends \InvalidArgumentException |
|
18 | -{ |
|
17 | +class DirectoryNotFoundException extends \InvalidArgumentException { |
|
19 | 18 | } |
@@ -14,6 +14,5 @@ |
||
14 | 14 | /** |
15 | 15 | * @author Jean-François Simon <[email protected]> |
16 | 16 | */ |
17 | -class AccessDeniedException extends \UnexpectedValueException |
|
18 | -{ |
|
17 | +class AccessDeniedException extends \UnexpectedValueException { |
|
19 | 18 | } |