Skip to content

Commit abc5571

Browse files
Merge branch '4.4' into 5.2
* 4.4: Leverage str_contains/str_starts_with Leverage str_ends_with
2 parents f1b7140 + 030c59d commit abc5571

File tree

6 files changed

+8
-7
lines changed

6 files changed

+8
-7
lines changed

Gitignore.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,6 @@ private static function lineToRegex(string $gitignoreLine): string
7878

7979
return ($isAbsolute ? '' : '(?:[^/]+/)*')
8080
.$regex
81-
.('/' !== substr($gitignoreLine, -1) ? '(?:$|/)' : '');
81+
.(!str_ends_with($gitignoreLine, '/') ? '(?:$|/)' : '');
8282
}
8383
}

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;

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
}
1717
],
1818
"require": {
19-
"php": ">=7.2.5"
19+
"php": ">=7.2.5",
20+
"symfony/polyfill-php80": "^1.16"
2021
},
2122
"autoload": {
2223
"psr-4": { "Symfony\\Component\\Finder\\": "" },

0 commit comments

Comments
 (0)