@@ -16,15 +16,13 @@ |
||
16 | 16 | * |
17 | 17 | * @author Fabien Potencier <[email protected]> |
18 | 18 | */ |
19 | -class DateComparator extends Comparator |
|
20 | -{ |
|
19 | +class DateComparator extends Comparator { |
|
21 | 20 | /** |
22 | 21 | * @param string $test A comparison string |
23 | 22 | * |
24 | 23 | * @throws \InvalidArgumentException If the test is not understood |
25 | 24 | */ |
26 | - public function __construct(string $test) |
|
27 | - { |
|
25 | + public function __construct(string $test) { |
|
28 | 26 | if (!preg_match('#^\s*(==|!=|[<>]=?|after|since|before|until)?\s*(.+?)\s*$#i', $test, $matches)) { |
29 | 27 | throw new \InvalidArgumentException(sprintf('Don\'t understand "%s" as a date test.', $test)); |
30 | 28 | } |
@@ -32,15 +32,13 @@ |
||
32 | 32 | * |
33 | 33 | * @see http://physics.nist.gov/cuu/Units/binary.html |
34 | 34 | */ |
35 | -class NumberComparator extends Comparator |
|
36 | -{ |
|
35 | +class NumberComparator extends Comparator { |
|
37 | 36 | /** |
38 | 37 | * @param string|int $test A comparison string or an integer |
39 | 38 | * |
40 | 39 | * @throws \InvalidArgumentException If the test is not understood |
41 | 40 | */ |
42 | - public function __construct(?string $test) |
|
43 | - { |
|
41 | + public function __construct(?string $test) { |
|
44 | 42 | if (null === $test || !preg_match('#^\s*(==|!=|[<>]=?)?\s*([0-9\.]+)\s*([kmg]i?)?\s*$#i', $test, $matches)) { |
45 | 43 | throw new \InvalidArgumentException(sprintf('Don\'t understand "%s" as a number test.', $test ?? 'null')); |
46 | 44 | } |
@@ -16,8 +16,7 @@ discard block |
||
16 | 16 | * |
17 | 17 | * @author Fabien Potencier <[email protected]> |
18 | 18 | */ |
19 | -class Comparator |
|
20 | -{ |
|
19 | +class Comparator { |
|
21 | 20 | private $target; |
22 | 21 | private $operator = '=='; |
23 | 22 | |
@@ -26,13 +25,11 @@ discard block |
||
26 | 25 | * |
27 | 26 | * @return string The target value |
28 | 27 | */ |
29 | - public function getTarget() |
|
30 | - { |
|
28 | + public function getTarget() { |
|
31 | 29 | return $this->target; |
32 | 30 | } |
33 | 31 | |
34 | - public function setTarget(string $target) |
|
35 | - { |
|
32 | + public function setTarget(string $target) { |
|
36 | 33 | $this->target = $target; |
37 | 34 | } |
38 | 35 | |
@@ -41,8 +38,7 @@ discard block |
||
41 | 38 | * |
42 | 39 | * @return string The operator |
43 | 40 | */ |
44 | - public function getOperator() |
|
45 | - { |
|
41 | + public function getOperator() { |
|
46 | 42 | return $this->operator; |
47 | 43 | } |
48 | 44 | |
@@ -51,8 +47,7 @@ discard block |
||
51 | 47 | * |
52 | 48 | * @throws \InvalidArgumentException |
53 | 49 | */ |
54 | - public function setOperator(string $operator) |
|
55 | - { |
|
50 | + public function setOperator(string $operator) { |
|
56 | 51 | if ('' === $operator) { |
57 | 52 | $operator = '=='; |
58 | 53 | } |
@@ -71,8 +66,7 @@ discard block |
||
71 | 66 | * |
72 | 67 | * @return bool |
73 | 68 | */ |
74 | - public function test($test) |
|
75 | - { |
|
69 | + public function test($test) { |
|
76 | 70 | switch ($this->operator) { |
77 | 71 | case '>': |
78 | 72 | return $test > $this->target; |
@@ -16,8 +16,7 @@ discard block |
||
16 | 16 | * |
17 | 17 | * @author Fabien Potencier <[email protected]> |
18 | 18 | */ |
19 | -class SplFileInfo extends \SplFileInfo |
|
20 | -{ |
|
19 | +class SplFileInfo extends \SplFileInfo { |
|
21 | 20 | private $relativePath; |
22 | 21 | private $relativePathname; |
23 | 22 | |
@@ -26,8 +25,7 @@ discard block |
||
26 | 25 | * @param string $relativePath The relative path |
27 | 26 | * @param string $relativePathname The relative path name |
28 | 27 | */ |
29 | - public function __construct(string $file, string $relativePath, string $relativePathname) |
|
30 | - { |
|
28 | + public function __construct(string $file, string $relativePath, string $relativePathname) { |
|
31 | 29 | parent::__construct($file); |
32 | 30 | $this->relativePath = $relativePath; |
33 | 31 | $this->relativePathname = $relativePathname; |
@@ -40,8 +38,7 @@ discard block |
||
40 | 38 | * |
41 | 39 | * @return string the relative path |
42 | 40 | */ |
43 | - public function getRelativePath() |
|
44 | - { |
|
41 | + public function getRelativePath() { |
|
45 | 42 | return $this->relativePath; |
46 | 43 | } |
47 | 44 | |
@@ -52,8 +49,7 @@ discard block |
||
52 | 49 | * |
53 | 50 | * @return string the relative path name |
54 | 51 | */ |
55 | - public function getRelativePathname() |
|
56 | - { |
|
52 | + public function getRelativePathname() { |
|
57 | 53 | return $this->relativePathname; |
58 | 54 | } |
59 | 55 | |
@@ -71,8 +67,7 @@ discard block |
||
71 | 67 | * |
72 | 68 | * @throws \RuntimeException |
73 | 69 | */ |
74 | - public function getContents() |
|
75 | - { |
|
70 | + public function getContents() { |
|
76 | 71 | set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; }); |
77 | 72 | $content = file_get_contents($this->getPathname()); |
78 | 73 | restore_error_handler(); |
@@ -16,8 +16,7 @@ discard block |
||
16 | 16 | * |
17 | 17 | * @author Fabien Potencier <[email protected]> |
18 | 18 | */ |
19 | -class ExcludeDirectoryFilterIterator extends \FilterIterator implements \RecursiveIterator |
|
20 | -{ |
|
19 | +class ExcludeDirectoryFilterIterator extends \FilterIterator implements \RecursiveIterator { |
|
21 | 20 | private $iterator; |
22 | 21 | private $isRecursive; |
23 | 22 | private $excludedDirs = []; |
@@ -27,8 +26,7 @@ discard block |
||
27 | 26 | * @param \Iterator $iterator The Iterator to filter |
28 | 27 | * @param string[] $directories An array of directories to exclude |
29 | 28 | */ |
30 | - public function __construct(\Iterator $iterator, array $directories) |
|
31 | - { |
|
29 | + public function __construct(\Iterator $iterator, array $directories) { |
|
32 | 30 | $this->iterator = $iterator; |
33 | 31 | $this->isRecursive = $iterator instanceof \RecursiveIterator; |
34 | 32 | $patterns = []; |
@@ -53,8 +51,7 @@ discard block |
||
53 | 51 | * @return bool True if the value should be kept, false otherwise |
54 | 52 | */ |
55 | 53 | #[\ReturnTypeWillChange] |
56 | - public function accept() |
|
57 | - { |
|
54 | + public function accept() { |
|
58 | 55 | if ($this->isRecursive && isset($this->excludedDirs[$this->getFilename()]) && $this->isDir()) { |
59 | 56 | return false; |
60 | 57 | } |
@@ -73,8 +70,7 @@ discard block |
||
73 | 70 | * @return bool |
74 | 71 | */ |
75 | 72 | #[\ReturnTypeWillChange] |
76 | - public function hasChildren() |
|
77 | - { |
|
73 | + public function hasChildren() { |
|
78 | 74 | return $this->isRecursive && $this->iterator->hasChildren(); |
79 | 75 | } |
80 | 76 | |
@@ -82,8 +78,7 @@ discard block |
||
82 | 78 | * @return self |
83 | 79 | */ |
84 | 80 | #[\ReturnTypeWillChange] |
85 | - public function getChildren() |
|
86 | - { |
|
81 | + public function getChildren() { |
|
87 | 82 | $children = new self($this->iterator->getChildren(), []); |
88 | 83 | $children->excludedDirs = $this->excludedDirs; |
89 | 84 | $children->excludedPattern = $this->excludedPattern; |
@@ -17,16 +17,14 @@ discard block |
||
17 | 17 | * @author Fabien Potencier <[email protected]> |
18 | 18 | * @author Włodzimierz Gajda <[email protected]> |
19 | 19 | */ |
20 | -class FilecontentFilterIterator extends MultiplePcreFilterIterator |
|
21 | -{ |
|
20 | +class FilecontentFilterIterator extends MultiplePcreFilterIterator { |
|
22 | 21 | /** |
23 | 22 | * Filters the iterator values. |
24 | 23 | * |
25 | 24 | * @return bool true if the value should be kept, false otherwise |
26 | 25 | */ |
27 | 26 | #[\ReturnTypeWillChange] |
28 | - public function accept() |
|
29 | - { |
|
27 | + public function accept() { |
|
30 | 28 | if (!$this->matchRegexps && !$this->noMatchRegexps) { |
31 | 29 | return true; |
32 | 30 | } |
@@ -52,8 +50,7 @@ discard block |
||
52 | 50 | * |
53 | 51 | * @return string regexp corresponding to a given string or regexp |
54 | 52 | */ |
55 | - protected function toRegex(string $str) |
|
56 | - { |
|
53 | + protected function toRegex(string $str) { |
|
57 | 54 | return $this->isRegex($str) ? $str : '/'.preg_quote($str, '/').'/'; |
58 | 55 | } |
59 | 56 | } |
@@ -18,16 +18,14 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @author Fabien Potencier <[email protected]> |
20 | 20 | */ |
21 | -class FilenameFilterIterator extends MultiplePcreFilterIterator |
|
22 | -{ |
|
21 | +class FilenameFilterIterator extends MultiplePcreFilterIterator { |
|
23 | 22 | /** |
24 | 23 | * Filters the iterator values. |
25 | 24 | * |
26 | 25 | * @return bool true if the value should be kept, false otherwise |
27 | 26 | */ |
28 | 27 | #[\ReturnTypeWillChange] |
29 | - public function accept() |
|
30 | - { |
|
28 | + public function accept() { |
|
31 | 29 | return $this->isAccepted($this->current()->getFilename()); |
32 | 30 | } |
33 | 31 | |
@@ -41,8 +39,7 @@ discard block |
||
41 | 39 | * |
42 | 40 | * @return string regexp corresponding to a given glob or regexp |
43 | 41 | */ |
44 | - protected function toRegex(string $str) |
|
45 | - { |
|
42 | + protected function toRegex(string $str) { |
|
46 | 43 | return $this->isRegex($str) ? $str : Glob::toRegex($str); |
47 | 44 | } |
48 | 45 | } |
@@ -16,8 +16,7 @@ discard block |
||
16 | 16 | * |
17 | 17 | * @author Fabien Potencier <[email protected]> |
18 | 18 | */ |
19 | -class SortableIterator implements \IteratorAggregate |
|
20 | -{ |
|
19 | +class SortableIterator implements \IteratorAggregate { |
|
21 | 20 | public const SORT_BY_NONE = 0; |
22 | 21 | public const SORT_BY_NAME = 1; |
23 | 22 | public const SORT_BY_TYPE = 2; |
@@ -34,8 +33,7 @@ discard block |
||
34 | 33 | * |
35 | 34 | * @throws \InvalidArgumentException |
36 | 35 | */ |
37 | - public function __construct(\Traversable $iterator, $sort, bool $reverseOrder = false) |
|
38 | - { |
|
36 | + public function __construct(\Traversable $iterator, $sort, bool $reverseOrder = false) { |
|
39 | 37 | $this->iterator = $iterator; |
40 | 38 | $order = $reverseOrder ? -1 : 1; |
41 | 39 | |
@@ -82,8 +80,7 @@ discard block |
||
82 | 80 | * @return \Traversable |
83 | 81 | */ |
84 | 82 | #[\ReturnTypeWillChange] |
85 | - public function getIterator() |
|
86 | - { |
|
83 | + public function getIterator() { |
|
87 | 84 | if (1 === $this->sort) { |
88 | 85 | return $this->iterator; |
89 | 86 | } |
@@ -18,16 +18,14 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @author Fabien Potencier <[email protected]> |
20 | 20 | */ |
21 | -class DateRangeFilterIterator extends \FilterIterator |
|
22 | -{ |
|
21 | +class DateRangeFilterIterator extends \FilterIterator { |
|
23 | 22 | private $comparators = []; |
24 | 23 | |
25 | 24 | /** |
26 | 25 | * @param \Iterator $iterator The Iterator to filter |
27 | 26 | * @param DateComparator[] $comparators An array of DateComparator instances |
28 | 27 | */ |
29 | - public function __construct(\Iterator $iterator, array $comparators) |
|
30 | - { |
|
28 | + public function __construct(\Iterator $iterator, array $comparators) { |
|
31 | 29 | $this->comparators = $comparators; |
32 | 30 | |
33 | 31 | parent::__construct($iterator); |
@@ -39,8 +37,7 @@ discard block |
||
39 | 37 | * @return bool true if the value should be kept, false otherwise |
40 | 38 | */ |
41 | 39 | #[\ReturnTypeWillChange] |
42 | - public function accept() |
|
43 | - { |
|
40 | + public function accept() { |
|
44 | 41 | $fileinfo = $this->current(); |
45 | 42 | |
46 | 43 | if (!file_exists($fileinfo->getPathname())) { |