From f2583a15f10882a665034900027ada43d465613e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20H=C3=A4u=C3=9Fler?= Date: Sat, 16 Nov 2024 10:51:03 +0100 Subject: [PATCH] [TASK] Fix codestyle according to updated PHP-CS-Fixer ruleset --- src/Filesystem/Directory.php | 10 +++------- src/Filesystem/VersionReplacer.php | 2 +- src/Service/VersionService.php | 18 +++++++----------- tests/Unit/Service/VersionServiceTest.php | 3 +-- 4 files changed, 12 insertions(+), 21 deletions(-) diff --git a/src/Filesystem/Directory.php b/src/Filesystem/Directory.php index e83ed31..8ce9162 100644 --- a/src/Filesystem/Directory.php +++ b/src/Filesystem/Directory.php @@ -12,10 +12,6 @@ namespace TYPO3\Tailor\Filesystem; -use FilesystemIterator; -use RecursiveDirectoryIterator; -use RecursiveIteratorIterator; - /** * Provide functionality for handling directories on the filesystem */ @@ -42,9 +38,9 @@ public function create(string $path, int $mode = 0777): bool public function remove(string $directory): bool { $directory = realpath($directory); - $iterator = new RecursiveIteratorIterator( - new RecursiveDirectoryIterator($directory, FilesystemIterator::SKIP_DOTS), - RecursiveIteratorIterator::CHILD_FIRST + $iterator = new \RecursiveIteratorIterator( + new \RecursiveDirectoryIterator($directory, \FilesystemIterator::SKIP_DOTS), + \RecursiveIteratorIterator::CHILD_FIRST ); foreach ($iterator as $file) { diff --git a/src/Filesystem/VersionReplacer.php b/src/Filesystem/VersionReplacer.php index 6c2b009..fd64263 100644 --- a/src/Filesystem/VersionReplacer.php +++ b/src/Filesystem/VersionReplacer.php @@ -43,7 +43,7 @@ public function setVersion(string $filePath, string $pattern, int $versionPartsT if ($fileContents === false) { throw new \InvalidArgumentException('The file ' . $filePath . ' could not be opened', 1605741968); } - $updatedFileContents = preg_replace_callback('/' . $pattern . '/u', static function($matches) use ($newVersion) { + $updatedFileContents = preg_replace_callback('/' . $pattern . '/u', static function ($matches) use ($newVersion) { return str_replace($matches[1], $newVersion, $matches[0]); }, $fileContents); file_put_contents($filePath, $updatedFileContents); diff --git a/src/Service/VersionService.php b/src/Service/VersionService.php index 69d7316..c6b36f5 100644 --- a/src/Service/VersionService.php +++ b/src/Service/VersionService.php @@ -12,10 +12,6 @@ namespace TYPO3\Tailor\Service; -use FilesystemIterator; -use RecursiveCallbackFilterIterator; -use RecursiveDirectoryIterator; -use RecursiveIteratorIterator; use TYPO3\Tailor\Environment\Variables; use TYPO3\Tailor\Exception\FormDataProcessingException; use TYPO3\Tailor\Exception\RequiredConfigurationMissing; @@ -64,14 +60,14 @@ public function createZipArchiveFromPath(string $path): string throw new FormDataProcessingException('Path is not valid.', 1605562741); } - $zipArchive = new ZipArchive(); - $zipArchive->open($this->getVersionFilename(), ZipArchive::CREATE | ZipArchive::OVERWRITE); + $zipArchive = new \ZipArchive(); + $zipArchive->open($this->getVersionFilename(), \ZipArchive::CREATE | \ZipArchive::OVERWRITE); $emConfValid = false; - $iterator = new RecursiveDirectoryIterator($fullPath, FilesystemIterator::SKIP_DOTS); - $files = new RecursiveIteratorIterator( - new RecursiveCallbackFilterIterator($iterator, function($current) use ($fullPath) { + $iterator = new \RecursiveDirectoryIterator($fullPath, \FilesystemIterator::SKIP_DOTS); + $files = new \RecursiveIteratorIterator( + new \RecursiveCallbackFilterIterator($iterator, function ($current) use ($fullPath) { // @todo Find a more performant way for filtering $filepath = $current->getRealPath(); @@ -101,7 +97,7 @@ public function createZipArchiveFromPath(string $path): string return true; }), - RecursiveIteratorIterator::LEAVES_ONLY + \RecursiveIteratorIterator::LEAVES_ONLY ); foreach ($files as $file) { @@ -157,7 +153,7 @@ public function createZipArchiveFromArtefact(string $filename): string if (!is_file($filename)) { throw new FormDataProcessingException('No such file.', 1605562482); } - $zipArchive = new ZipArchive(); + $zipArchive = new \ZipArchive(); $zipFile = $zipArchive->open($filename); if (!$zipFile || $zipArchive->numFiles <= 0) { throw new FormDataProcessingException('No files in given directory.', 1605562663); diff --git a/tests/Unit/Service/VersionServiceTest.php b/tests/Unit/Service/VersionServiceTest.php index 13a90f9..771cfd2 100644 --- a/tests/Unit/Service/VersionServiceTest.php +++ b/tests/Unit/Service/VersionServiceTest.php @@ -13,7 +13,6 @@ namespace TYPO3\Tailor\Tests\Unit\Service; use PHPUnit\Framework\TestCase; -use ReflectionMethod; use TYPO3\Tailor\Exception\RequiredConfigurationMissing; use TYPO3\Tailor\Service\VersionService; @@ -135,7 +134,7 @@ protected function invokeMethod(string $methodName, array $arguments) ->setConstructorArgs(['1.0.0', 'my_ext', '/dummyPath']) ->getMock(); - $method = new ReflectionMethod(VersionService::class, $methodName); + $method = new \ReflectionMethod(VersionService::class, $methodName); $method->setAccessible(true); return $method->invokeArgs($mock, $arguments);