Skip to content

Commit

Permalink
[TASK] Fix codestyle according to updated PHP-CS-Fixer ruleset
Browse files Browse the repository at this point in the history
  • Loading branch information
eliashaeussler committed Oct 29, 2024
1 parent a86b7c6 commit 0f8f6c3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 21 deletions.
10 changes: 3 additions & 7 deletions src/Filesystem/Directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@

namespace TYPO3\Tailor\Filesystem;

use FilesystemIterator;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;

/**
* Provide functionality for handling directories on the filesystem
*/
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/Filesystem/VersionReplacer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
18 changes: 7 additions & 11 deletions src/Service/VersionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -101,7 +97,7 @@ public function createZipArchiveFromPath(string $path): string

return true;
}),
RecursiveIteratorIterator::LEAVES_ONLY
\RecursiveIteratorIterator::LEAVES_ONLY
);

foreach ($files as $file) {
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions tests/Unit/Service/VersionServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 0f8f6c3

Please sign in to comment.