diff --git a/src/ZipArchive/ZipArchiveAdapter.php b/src/ZipArchive/ZipArchiveAdapter.php index c73ca55cc..0826dd90e 100644 --- a/src/ZipArchive/ZipArchiveAdapter.php +++ b/src/ZipArchive/ZipArchiveAdapter.php @@ -155,7 +155,7 @@ public function deleteDirectory(string $path): void $itemPath = $stats['name']; - if (strpos($itemPath, $prefixedPath) !== 0) { + if (!str_starts_with($itemPath, $prefixedPath)) { continue; } @@ -299,7 +299,7 @@ public function listContents(string $path, bool $deep): iterable if ( $location === $itemPath - || ($deep && $location !== '' && strpos($itemPath, $location) !== 0) + || ($deep && $location !== '' && !str_starts_with($itemPath, $location)) || ($deep === false && ! $this->isAtRootDirectory($location, $itemPath)) ) { continue; @@ -412,7 +412,7 @@ private function ensureDirectoryExists(string $dirname, Config $config): void private function isDirectoryPath(string $path): bool { - return substr($path, -1) === '/'; + return str_ends_with($path, '/'); } private function isAtRootDirectory(string $directoryRoot, string $path): bool