Skip to content

Commit 030c59d

Browse files
derrabusnicolas-grekas
authored andcommitted
Leverage str_contains/str_starts_with
Signed-off-by: Alexander M. Turek <me@derrabus.de>
1 parent dcbdc31 commit 030c59d

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

Iterator/ExcludeDirectoryFilterIterator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function __construct(\Iterator $iterator, array $directories)
3434
$patterns = [];
3535
foreach ($directories as $directory) {
3636
$directory = rtrim($directory, '/');
37-
if (!$this->isRecursive || false !== strpos($directory, '/')) {
37+
if (!$this->isRecursive || str_contains($directory, '/')) {
3838
$patterns[] = preg_quote($directory, '#');
3939
} else {
4040
$this->excludedDirs[$directory] = true;

Tests/FinderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,7 @@ public function testSortAcrossDirectories()
869869
public function testFilter()
870870
{
871871
$finder = $this->buildFinder();
872-
$this->assertSame($finder, $finder->filter(function (\SplFileInfo $f) { return false !== strpos($f, 'test'); }));
872+
$this->assertSame($finder, $finder->filter(function (\SplFileInfo $f) { return str_contains($f, 'test'); }));
873873
$this->assertIterator($this->toAbsolute(['test.php', 'test.py']), $finder->in(self::$tmpDir)->getIterator());
874874
}
875875

Tests/Iterator/CustomFilterIteratorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function getAcceptData()
3737
{
3838
return [
3939
[[function (\SplFileInfo $fileinfo) { return false; }], []],
40-
[[function (\SplFileInfo $fileinfo) { return 0 === strpos($fileinfo, 'test'); }], ['test.php', 'test.py']],
40+
[[function (\SplFileInfo $fileinfo) { return str_starts_with($fileinfo, 'test'); }], ['test.php', 'test.py']],
4141
[['is_dir'], []],
4242
];
4343
}

Tests/Iterator/MockSplFileInfo.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function __construct($param)
5151
public function isFile(): bool
5252
{
5353
if (null === $this->type) {
54-
return false !== strpos($this->getFilename(), 'file');
54+
return str_contains($this->getFilename(), 'file');
5555
}
5656

5757
return self::TYPE_FILE === $this->type;
@@ -60,7 +60,7 @@ public function isFile(): bool
6060
public function isDir(): bool
6161
{
6262
if (null === $this->type) {
63-
return false !== strpos($this->getFilename(), 'directory');
63+
return str_contains($this->getFilename(), 'directory');
6464
}
6565

6666
return self::TYPE_DIRECTORY === $this->type;

0 commit comments

Comments
 (0)