[Core] Remove is_string() check on glob loop data (#2267)

* [Core] Remove is_string() check on glob loop data

* clean up

* clean up

* clean up
This commit is contained in:
Abdul Malik Ikhsan 2022-05-09 06:18:42 +07:00 committed by GitHub
parent 60708d4501
commit 97a33aa694
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -64,16 +64,8 @@ final class FilesystemTweaker
*/
private function findDirectoriesInGlob(string $directory): array
{
$foundDirectories = [];
foreach ((array) glob($directory, GLOB_ONLYDIR) as $foundDirectory) {
if (! is_string($foundDirectory)) {
continue;
}
$foundDirectories[] = $foundDirectory;
}
/** @var string[] $foundDirectories */
$foundDirectories = (array) glob($directory, GLOB_ONLYDIR);
return $foundDirectories;
}
@ -82,20 +74,9 @@ final class FilesystemTweaker
*/
private function foundInGlob(string $path): array
{
$foundPaths = [];
/** @var string[] $paths */
$paths = (array) glob($path);
foreach ((array) glob($path) as $foundPath) {
if (! is_string($foundPath)) {
continue;
}
if (! file_exists($foundPath)) {
continue;
}
$foundPaths[] = $foundPath;
}
return $foundPaths;
return array_filter($paths, fn (string $path): bool => file_exists($path));
}
}