Skip to content

Commit 699b499

Browse files
authored
Merge pull request #51 from villfa/fix/cs
Fix codestyle
2 parents 64fce93 + fff838f commit 699b499

27 files changed

+133
-128
lines changed

phpcs.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<ruleset name="phpDocumentor">
33
<description>The coding standard for phpDocumentor.</description>
44

5+
<config name="php_version" value="70200"/>
56
<file>src</file>
67
<file>tests/unit</file>
78
<file>tests/integration</file>

src/Finder.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ class Finder implements PluginInterface
3636
/**
3737
* Get the method name.
3838
*/
39-
public function getMethod() : string
39+
public function getMethod(): string
4040
{
4141
return 'find';
4242
}
4343

4444
/**
4545
* Set the Filesystem object.
4646
*/
47-
public function setFilesystem(FilesystemInterface $filesystem) : void
47+
public function setFilesystem(FilesystemInterface $filesystem): void
4848
{
4949
$this->filesystem = $filesystem;
5050
}
@@ -59,12 +59,14 @@ public function setFilesystem(FilesystemInterface $filesystem) : void
5959
*
6060
* @return Generator<mixed>
6161
*/
62-
public function handle(SpecificationInterface $specification) : Generator
62+
public function handle(SpecificationInterface $specification): Generator
6363
{
6464
foreach ($this->yieldFilesInPath($specification, '') as $path) {
65-
if (isset($path['type']) && $path['type'] === 'file') {
66-
yield $path;
65+
if (!isset($path['type']) || $path['type'] !== 'file') {
66+
continue;
6767
}
68+
69+
yield $path;
6870
}
6971
}
7072

@@ -77,10 +79,9 @@ public function handle(SpecificationInterface $specification) : Generator
7779
* by {@link handle()}.
7880
*
7981
* @return Generator<mixed>
80-
*
8182
* @psalm-return Generator<array{basename: string, path: string, stream: resource, dirname: string, type: string, extension: string}>
8283
*/
83-
private function yieldFilesInPath(SpecificationInterface $specification, string $path) : Generator
84+
private function yieldFilesInPath(SpecificationInterface $specification, string $path): Generator
8485
{
8586
$listContents = $this->filesystem->listContents($path);
8687
/** @psalm-var array{basename: string, path: string, stream: resource, dirname: string, type: string, extension: string} $location */
@@ -89,7 +90,8 @@ private function yieldFilesInPath(SpecificationInterface $specification, string
8990
yield $location;
9091
}
9192

92-
if ($location['type'] !== 'dir'
93+
if (
94+
$location['type'] !== 'dir'
9395
|| !CompositeSpecification::thatCanBeSatisfiedBySomethingBelow($specification, $location)
9496
) {
9597
continue;

src/Path.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function __construct(string $path)
3737
/**
3838
* returns a string representation of the path.
3939
*/
40-
public function __toString() : string
40+
public function __toString(): string
4141
{
4242
return $this->path;
4343
}

src/Specification/AndSpecification.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,20 @@ public function __construct(SpecificationInterface $one, SpecificationInterface
3636
/**
3737
* {@inheritDoc}
3838
*/
39-
public function isSatisfiedBy(array $value) : bool
39+
public function isSatisfiedBy(array $value): bool
4040
{
4141
return $this->one->isSatisfiedBy($value) && $this->other->isSatisfiedBy($value);
4242
}
4343

4444
/** {@inheritDoc} */
45-
public function canBeSatisfiedBySomethingBelow(array $value) : bool
45+
public function canBeSatisfiedBySomethingBelow(array $value): bool
4646
{
4747
return self::thatCanBeSatisfiedBySomethingBelow($this->one, $value)
4848
&& self::thatCanBeSatisfiedBySomethingBelow($this->other, $value);
4949
}
5050

5151
/** {@inheritDoc} */
52-
public function willBeSatisfiedByEverythingBelow(array $value) : bool
52+
public function willBeSatisfiedByEverythingBelow(array $value): bool
5353
{
5454
return self::thatWillBeSatisfiedByEverythingBelow($this->one, $value)
5555
&& self::thatWillBeSatisfiedByEverythingBelow($this->other, $value);

src/Specification/CompositeSpecification.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ abstract class CompositeSpecification implements SpecificationInterface, Prunabl
2424
* Returns a specification that satisfies the original specification
2525
* as well as the other specification
2626
*/
27-
public function andSpecification(SpecificationInterface $other) : AndSpecification
27+
public function andSpecification(SpecificationInterface $other): AndSpecification
2828
{
2929
return new AndSpecification($this, $other);
3030
}
@@ -33,7 +33,7 @@ public function andSpecification(SpecificationInterface $other) : AndSpecificati
3333
* Returns a specification that satisfies the original specification
3434
* or the other specification
3535
*/
36-
public function orSpecification(SpecificationInterface $other) : OrSpecification
36+
public function orSpecification(SpecificationInterface $other): OrSpecification
3737
{
3838
return new OrSpecification($this, $other);
3939
}
@@ -42,19 +42,19 @@ public function orSpecification(SpecificationInterface $other) : OrSpecification
4242
* Returns a specification that is the inverse of the original specification
4343
* i.e. does not meet the original criteria
4444
*/
45-
public function notSpecification() : NotSpecification
45+
public function notSpecification(): NotSpecification
4646
{
4747
return new NotSpecification($this);
4848
}
4949

5050
/** {@inheritDoc} */
51-
public function canBeSatisfiedBySomethingBelow(array $value) : bool
51+
public function canBeSatisfiedBySomethingBelow(array $value): bool
5252
{
5353
return true;
5454
}
5555

5656
/** {@inheritDoc} */
57-
public function willBeSatisfiedByEverythingBelow(array $value) : bool
57+
public function willBeSatisfiedByEverythingBelow(array $value): bool
5858
{
5959
return false;
6060
}
@@ -64,11 +64,11 @@ public function willBeSatisfiedByEverythingBelow(array $value) : bool
6464
* that don't implement PrunableInterface
6565
*
6666
* @param mixed[] $value
67-
*
6867
* @psalm-param array{basename: string, path: string, stream: resource, dirname: string, type: string, extension: string} $value
68+
*
6969
* @psalm-mutation-free
7070
*/
71-
public static function thatCanBeSatisfiedBySomethingBelow(SpecificationInterface $that, array $value) : bool
71+
public static function thatCanBeSatisfiedBySomethingBelow(SpecificationInterface $that, array $value): bool
7272
{
7373
return $that instanceof PrunableInterface
7474
? $that->canBeSatisfiedBySomethingBelow($value)
@@ -80,11 +80,11 @@ public static function thatCanBeSatisfiedBySomethingBelow(SpecificationInterface
8080
* that don't implement PrunableInterface
8181
*
8282
* @param mixed[] $value
83-
*
8483
* @psalm-param array{basename: string, path: string, stream: resource, dirname: string, type: string, extension: string} $value
84+
*
8585
* @psalm-mutation-free
8686
*/
87-
public static function thatWillBeSatisfiedByEverythingBelow(SpecificationInterface $that, array $value) : bool
87+
public static function thatWillBeSatisfiedByEverythingBelow(SpecificationInterface $that, array $value): bool
8888
{
8989
return $that instanceof PrunableInterface
9090
&& $that->willBeSatisfiedByEverythingBelow($value);

src/Specification/Glob.php

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
namespace Flyfinder\Specification;
1818

1919
use InvalidArgumentException;
20+
2021
use function array_slice;
2122
use function count;
2223
use function explode;
@@ -76,7 +77,7 @@ public function __construct(string $glob)
7677
/**
7778
* @inheritDoc
7879
*/
79-
public function isSatisfiedBy(array $value) : bool
80+
public function isSatisfiedBy(array $value): bool
8081
{
8182
//Flysystem paths are not absolute, so make it that way.
8283
$path = '/' . $value['path'];
@@ -101,7 +102,7 @@ public function isSatisfiedBy(array $value) : bool
101102
*
102103
* @psalm-pure
103104
*/
104-
private static function getStaticPrefix(string $glob) : string
105+
private static function getStaticPrefix(string $glob): string
105106
{
106107
self::assertValidGlob($glob);
107108
$prefix = '';
@@ -135,7 +136,7 @@ private static function getStaticPrefix(string $glob) : string
135136
return $prefix;
136137
}
137138

138-
private static function getBoundedPrefix(string $glob) : string
139+
private static function getBoundedPrefix(string $glob): string
139140
{
140141
self::assertValidGlob($glob);
141142
$prefix = '';
@@ -165,23 +166,23 @@ private static function getBoundedPrefix(string $glob) : string
165166
return $prefix;
166167
}
167168

168-
private static function getTotalPrefix(string $glob) : ?string
169+
private static function getTotalPrefix(string $glob): ?string
169170
{
170171
self::assertValidGlob($glob);
171172
$matches = [];
172173

173174
return preg_match('~(?<!\\\\)/\\*\\*(?:/\\*\\*?)+$~', $glob, $matches)
174-
? substr($glob, 0, strlen($glob)-strlen($matches[0]))
175+
? substr($glob, 0, strlen($glob) - strlen($matches[0]))
175176
: null;
176177
}
177178

178179
/**
179180
* @return mixed[]
180-
*
181181
* @psalm-return array{0: string, 1:int}
182+
*
182183
* @psalm-pure
183184
*/
184-
private static function scanBackslashSequence(string $glob, int $offset) : array
185+
private static function scanBackslashSequence(string $glob, int $offset): array
185186
{
186187
$startOffset = $offset;
187188
$result = '';
@@ -212,7 +213,7 @@ private static function scanBackslashSequence(string $glob, int $offset) : array
212213
*
213214
* @psalm-pure
214215
*/
215-
private static function assertValidGlob(string $glob) : void
216+
private static function assertValidGlob(string $glob): void
216217
{
217218
if (strpos($glob, '/') !== 0 && strpos($glob, '://') === false) {
218219
throw new InvalidArgumentException(sprintf(
@@ -227,7 +228,7 @@ private static function assertValidGlob(string $glob) : void
227228
*
228229
* @psalm-pure
229230
*/
230-
private static function isRecursiveWildcard(string $glob, int $i) : bool
231+
private static function isRecursiveWildcard(string $glob, int $i): bool
231232
{
232233
return isset($glob[$i + 3]) && $glob[$i + 1] . $glob[$i + 2] . $glob[$i + 3] === '**/';
233234
}
@@ -243,7 +244,7 @@ private static function isRecursiveWildcard(string $glob, int $i) : bool
243244
*
244245
* @psalm-pure
245246
*/
246-
private static function toRegEx(string $glob) : string
247+
private static function toRegEx(string $glob): string
247248
{
248249
$delimiter = '~';
249250
$inSquare = false;
@@ -357,13 +358,16 @@ private static function toRegEx(string $glob) : string
357358
}
358359

359360
/** @inheritDoc */
360-
public function canBeSatisfiedBySomethingBelow(array $value) : bool
361+
public function canBeSatisfiedBySomethingBelow(array $value): bool
361362
{
362363
$valueSegments = explode('/', '/' . $value['path']);
363364
$boundedPrefixSegments = explode('/', rtrim($this->boundedPrefix, '/'));
364365
$howManySegmentsToConsider = min(count($valueSegments), count($boundedPrefixSegments));
365366
$boundedPrefixGlob = implode('/', array_slice($boundedPrefixSegments, 0, $howManySegmentsToConsider));
366-
$valuePathPrefix = implode('/', array_slice($valueSegments, 1, max($howManySegmentsToConsider-1, 0)));
367+
$valuePathPrefix = implode(
368+
'/',
369+
array_slice($valueSegments, 1, max($howManySegmentsToConsider - 1, 0))
370+
);
367371
$prefixValue = $value;
368372
$prefixValue['path'] = $valuePathPrefix;
369373

@@ -377,7 +381,7 @@ public function canBeSatisfiedBySomethingBelow(array $value) : bool
377381
}
378382

379383
/** @inheritDoc */
380-
public function willBeSatisfiedByEverythingBelow(array $value) : bool
384+
public function willBeSatisfiedByEverythingBelow(array $value): bool
381385
{
382386
if ($this->totalPrefix === null) {
383387
return false;

src/Specification/HasExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function __construct(array $extensions)
3838
/**
3939
* {@inheritDoc}
4040
*/
41-
public function isSatisfiedBy(array $value) : bool
41+
public function isSatisfiedBy(array $value): bool
4242
{
4343
return isset($value['extension']) && in_array($value['extension'], $this->extensions, false);
4444
}

src/Specification/InPath.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
namespace Flyfinder\Specification;
1515

1616
use Flyfinder\Path;
17+
1718
use function array_slice;
1819
use function count;
1920
use function explode;
@@ -46,7 +47,7 @@ public function __construct(Path $path)
4647
/**
4748
* {@inheritDoc}
4849
*/
49-
public function isSatisfiedBy(array $value) : bool
50+
public function isSatisfiedBy(array $value): bool
5051
{
5152
if (in_array($this->path, ['', '.', './'], false)) {
5253
/*
@@ -90,7 +91,7 @@ public function isSatisfiedBy(array $value) : bool
9091
}
9192

9293
/** @inheritDoc */
93-
public function canBeSatisfiedBySomethingBelow(array $value) : bool
94+
public function canBeSatisfiedBySomethingBelow(array $value): bool
9495
{
9596
$pathSegments = explode('/', (string) $this->path);
9697
$valueSegments = explode('/', $value['path']);
@@ -101,7 +102,7 @@ public function canBeSatisfiedBySomethingBelow(array $value) : bool
101102
}
102103

103104
/** @inheritDoc */
104-
public function willBeSatisfiedByEverythingBelow(array $value) : bool
105+
public function willBeSatisfiedByEverythingBelow(array $value): bool
105106
{
106107
return $this->isSatisfiedBy($value);
107108
}

src/Specification/IsHidden.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class IsHidden extends CompositeSpecification
2525
/**
2626
* {@inheritDoc}
2727
*/
28-
public function isSatisfiedBy(array $value) : bool
28+
public function isSatisfiedBy(array $value): bool
2929
{
3030
return isset($value['basename']) && substr($value['basename'], 0, 1) === '.';
3131
}

src/Specification/NotSpecification.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,19 @@ public function __construct(SpecificationInterface $wrapped)
3232
/**
3333
* {@inheritDoc}
3434
*/
35-
public function isSatisfiedBy(array $value) : bool
35+
public function isSatisfiedBy(array $value): bool
3636
{
3737
return !$this->wrapped->isSatisfiedBy($value);
3838
}
3939

4040
/** @inheritDoc */
41-
public function canBeSatisfiedBySomethingBelow(array $value) : bool
41+
public function canBeSatisfiedBySomethingBelow(array $value): bool
4242
{
4343
return !self::thatWillBeSatisfiedByEverythingBelow($this->wrapped, $value);
4444
}
4545

4646
/** @inheritDoc */
47-
public function willBeSatisfiedByEverythingBelow(array $value) : bool
47+
public function willBeSatisfiedByEverythingBelow(array $value): bool
4848
{
4949
return !self::thatCanBeSatisfiedBySomethingBelow($this->wrapped, $value);
5050
}

0 commit comments

Comments
 (0)