diff --git a/component/File.php b/component/File.php index f83b8ce..1681fd4 100644 --- a/component/File.php +++ b/component/File.php @@ -52,7 +52,8 @@ public static function cleanFilename(string $fileName): string $fileName = str_replace('\'', ' ', $fileName); $fileName = preg_replace('/\s+/', ' ', $fileName); $fileName = trim($fileName); - $fileName = preg_replace(['/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'], ['_', '.', ''], $fileName); + $fileName = preg_replace('/\.+/', '.', $fileName); + $fileName = preg_replace('/[^\w\s_\.\-]/', '', $fileName); $extension = strtolower($extension); $extension = trim($extension); diff --git a/composer.json b/composer.json index cb82354..efb77b6 100644 --- a/composer.json +++ b/composer.json @@ -14,8 +14,8 @@ }, "require-dev": { "friendsofphp/php-cs-fixer": "3.*", - "phpstan/phpstan": "1.*", - "phpunit/phpunit": "9.*" + "phpstan/phpstan": "2.*", + "phpunit/phpunit": "11.*" }, "scripts": { "lint": "vendor/bin/php-cs-fixer fix ./ --rules=@PSR12", diff --git a/test/CsvTest.php b/test/CsvTest.php index dc89181..52b73c4 100644 --- a/test/CsvTest.php +++ b/test/CsvTest.php @@ -5,7 +5,6 @@ namespace Test\Service; use PHPUnit\Framework\TestCase; - use Phant\File\Csv; final class CsvTest extends TestCase diff --git a/test/FileTest.php b/test/FileTest.php index 10ed854..23bfce0 100644 --- a/test/FileTest.php +++ b/test/FileTest.php @@ -5,7 +5,6 @@ namespace Test\Service; use PHPUnit\Framework\TestCase; - use Phant\File\File; final class FileTest extends TestCase @@ -68,12 +67,12 @@ public function testCleanFilename(): void $result = File::cleanFilename(' µ \' û '); $this->assertIsString($result); - $this->assertEquals('u_u', $result); + $this->assertEquals('u u', $result); - $result = File::cleanFilename(' µ û . Jpg'); + $result = File::cleanFilename(' µ û .. Jpg'); $this->assertIsString($result); - $this->assertEquals('u_u.jpg', $result); + $this->assertEquals('u u.jpg', $result); } public function testDownload(): void diff --git a/test/ZipTest.php b/test/ZipTest.php index 1f10f6d..73d7e00 100644 --- a/test/ZipTest.php +++ b/test/ZipTest.php @@ -5,7 +5,6 @@ namespace Test\Service; use PHPUnit\Framework\TestCase; - use Phant\File\Zip; final class ZipTest extends TestCase