diff --git a/bin/add-phpstan-self-replace.php b/bin/add-phpstan-self-replace.php index 4b8b6c282e9..a5d8503fa20 100644 --- a/bin/add-phpstan-self-replace.php +++ b/bin/add-phpstan-self-replace.php @@ -11,5 +11,5 @@ $composerJsonFileContents = FileSystem::read(__DIR__ . '/../composer.json'); $composerJson = Json::decode($composerJsonFileContents, Json::FORCE_ARRAY); $composerJson['replace']['phpstan/phpstan'] = $composerJson['require']['phpstan/phpstan']; $modifiedComposerJsonFileContents = Json::encode($composerJson, Json::PRETTY); -FileSystem::write(__DIR__ . '/../composer.json', $modifiedComposerJsonFileContents); +FileSystem::write(__DIR__ . '/../composer.json', $modifiedComposerJsonFileContents, null); echo 'Done!' . \PHP_EOL; diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index b12ddff5b40..b115d7dc4e2 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -19,12 +19,12 @@ final class VersionResolver * @api * @var string */ - public const PACKAGE_VERSION = 'e17f878d5adb301fda0de8f9da2d94d898a363c3'; + public const PACKAGE_VERSION = '1608ae8c9497bbfaf78ce54130ec304963ac6f2a'; /** * @api * @var string */ - public const RELEASE_DATE = '2024-01-29 03:51:07'; + public const RELEASE_DATE = '2024-01-29 05:39:29'; /** * @var int */ diff --git a/src/Caching/ValueObject/Storage/FileCacheStorage.php b/src/Caching/ValueObject/Storage/FileCacheStorage.php index 56fb64b752a..d7201a6aeb6 100644 --- a/src/Caching/ValueObject/Storage/FileCacheStorage.php +++ b/src/Caching/ValueObject/Storage/FileCacheStorage.php @@ -69,12 +69,12 @@ final class FileCacheStorage implements CacheStorageInterface throw new CachingException(\sprintf('Error occurred while saving item %s (%s) to cache: %s', $key, $variableKey, $errorAfter['message'])); } // for performance reasons we don't use SmartFileSystem - FileSystem::write($tmpPath, \sprintf("filesystem->remove($this->directory); + FileSystem::delete($this->directory); } private function processRemoveCacheFilePath(CacheFilePaths $cacheFilePaths) : void { @@ -96,7 +96,7 @@ final class FileCacheStorage implements CacheStorageInterface if (!$this->filesystem->exists($filePath)) { return; } - $this->filesystem->remove($filePath); + FileSystem::delete($filePath); } private function processRemoveEmptyDirectory(string $directory) : void { @@ -106,7 +106,7 @@ final class FileCacheStorage implements CacheStorageInterface if ($this->isNotEmptyDirectory($directory)) { return; } - $this->filesystem->remove($directory); + FileSystem::delete($directory); } private function isNotEmptyDirectory(string $directory) : bool { diff --git a/src/Configuration/ConfigInitializer.php b/src/Configuration/ConfigInitializer.php index 47921ce28b4..cebf9db21ce 100644 --- a/src/Configuration/ConfigInitializer.php +++ b/src/Configuration/ConfigInitializer.php @@ -57,7 +57,7 @@ final class ConfigInitializer $configContents = FileSystem::read(__DIR__ . '/../../templates/rector.php.dist'); $configContents = $this->replacePhpLevelContents($configContents); $configContents = $this->replacePathsContents($configContents, $projectDirectory); - FileSystem::write($commonRectorConfigPath, $configContents); + FileSystem::write($commonRectorConfigPath, $configContents, null); $this->symfonyStyle->success('The config is added now. Re-run command to make Rector do the work!'); } public function areSomeRectorsLoaded() : bool diff --git a/src/Console/Command/CustomRuleCommand.php b/src/Console/Command/CustomRuleCommand.php index 3f47ab778e0..1e2a479990a 100644 --- a/src/Console/Command/CustomRuleCommand.php +++ b/src/Console/Command/CustomRuleCommand.php @@ -66,7 +66,7 @@ final class CustomRuleCommand extends Command // replace __Name__ with $rectorName $newContent = $this->replaceNameVariable($rectorName, $fileInfo->getContents()); $newFilePath = $this->replaceNameVariable($rectorName, $fileInfo->getRelativePathname()); - FileSystem::write(\getcwd() . '/' . $newFilePath, $newContent); + FileSystem::write(\getcwd() . '/' . $newFilePath, $newContent, null); $generatedFilePaths[] = $newFilePath; } $this->symfonyStyle->title('Generated files'); diff --git a/src/Console/Command/SetupCICommand.php b/src/Console/Command/SetupCICommand.php index b609c3e12b3..345777a5edd 100644 --- a/src/Console/Command/SetupCICommand.php +++ b/src/Console/Command/SetupCICommand.php @@ -59,7 +59,7 @@ final class SetupCICommand extends Command { $workflowTemplate = FileSystem::read(__DIR__ . '/../../../templates/rector-github-action-check.yaml'); $workflowContents = \strtr($workflowTemplate, ['__CURRENT_REPOSITORY__' => $currentRepository]); - FileSystem::write($targetWorkflowFilePath, $workflowContents); + FileSystem::write($targetWorkflowFilePath, $workflowContents, null); $this->symfonyStyle->newLine(); $this->symfonyStyle->success('The ".github/workflows/rector.yaml" file was added'); $this->symfonyStyle->writeln('2 more steps to run Rector in CI:'); @@ -72,7 +72,7 @@ final class SetupCICommand extends Command private function addGitlabFile(string $targetGitlabFilePath) : void { $gitlabTemplate = FileSystem::read(__DIR__ . '/../../../templates/rector-gitlab-check.yaml'); - FileSystem::write($targetGitlabFilePath, $gitlabTemplate); + FileSystem::write($targetGitlabFilePath, $gitlabTemplate, null); $this->symfonyStyle->newLine(); $this->symfonyStyle->success('The "gitlab/rector.yaml" file was added'); $this->symfonyStyle->newLine(); diff --git a/src/FileSystem/JsonFileSystem.php b/src/FileSystem/JsonFileSystem.php index e22b97d088e..9c0aab617d6 100644 --- a/src/FileSystem/JsonFileSystem.php +++ b/src/FileSystem/JsonFileSystem.php @@ -21,6 +21,6 @@ final class JsonFileSystem public static function writeFile(string $filePath, array $data) : void { $json = Json::encode($data, Json::PRETTY); - FileSystem::write($filePath, $json); + FileSystem::write($filePath, $json, null); } } diff --git a/src/PhpParser/Printer/FormatPerservingPrinter.php b/src/PhpParser/Printer/FormatPerservingPrinter.php index 64d7a71e7bc..490b74a52b9 100644 --- a/src/PhpParser/Printer/FormatPerservingPrinter.php +++ b/src/PhpParser/Printer/FormatPerservingPrinter.php @@ -3,9 +3,9 @@ declare (strict_types=1); namespace Rector\PhpParser\Printer; +use RectorPrefix202401\Nette\Utils\FileSystem; use PhpParser\Node; use Rector\ValueObject\Application\File; -use RectorPrefix202401\Symfony\Component\Filesystem\Filesystem; /** * @see \Rector\Tests\PhpParser\Printer\FormatPerservingPrinterTest */ @@ -16,15 +16,9 @@ final class FormatPerservingPrinter * @var \Rector\PhpParser\Printer\BetterStandardPrinter */ private $betterStandardPrinter; - /** - * @readonly - * @var \Symfony\Component\Filesystem\Filesystem - */ - private $filesystem; - public function __construct(\Rector\PhpParser\Printer\BetterStandardPrinter $betterStandardPrinter, Filesystem $filesystem) + public function __construct(\Rector\PhpParser\Printer\BetterStandardPrinter $betterStandardPrinter) { $this->betterStandardPrinter = $betterStandardPrinter; - $this->filesystem = $filesystem; } /** * @api tests @@ -45,6 +39,6 @@ final class FormatPerservingPrinter } public function dumpFile(string $filePath, string $newContent) : void { - $this->filesystem->dumpFile($filePath, $newContent); + FileSystem::write($filePath, $newContent, null); } } diff --git a/src/Testing/Fixture/FixtureFileUpdater.php b/src/Testing/Fixture/FixtureFileUpdater.php index 998b96dc61d..580f334e934 100644 --- a/src/Testing/Fixture/FixtureFileUpdater.php +++ b/src/Testing/Fixture/FixtureFileUpdater.php @@ -15,7 +15,7 @@ final class FixtureFileUpdater return; } $newOriginalContent = self::resolveNewFixtureContent($originalContent, $changedContent); - FileSystem::write($fixtureFilePath, $newOriginalContent); + FileSystem::write($fixtureFilePath, $newOriginalContent, null); } private static function resolveNewFixtureContent(string $originalContent, string $changedContent) : string { diff --git a/src/Testing/Fixture/FixtureTempFileDumper.php b/src/Testing/Fixture/FixtureTempFileDumper.php index cdbde081000..3dff6c5aff2 100644 --- a/src/Testing/Fixture/FixtureTempFileDumper.php +++ b/src/Testing/Fixture/FixtureTempFileDumper.php @@ -17,7 +17,7 @@ final class FixtureTempFileDumper { // the "php" suffix is important, because that will hook into \Rector\Application\FileProcessor\PhpFileProcessor $temporaryFileName = \sys_get_temp_dir() . self::TEMP_FIXTURE_DIRECTORY . '/' . \md5($fileContents) . '.' . $suffix; - FileSystem::write($temporaryFileName, $fileContents); + FileSystem::write($temporaryFileName, $fileContents, null); return $temporaryFileName; } } diff --git a/src/Testing/PHPUnit/AbstractRectorTestCase.php b/src/Testing/PHPUnit/AbstractRectorTestCase.php index 5308d28bef3..0055c8469d0 100644 --- a/src/Testing/PHPUnit/AbstractRectorTestCase.php +++ b/src/Testing/PHPUnit/AbstractRectorTestCase.php @@ -133,7 +133,7 @@ abstract class AbstractRectorTestCase extends \Rector\Testing\PHPUnit\AbstractLa throw new ShouldNotHappenException('Fixture file and input file cannot be the same: ' . $fixtureFilePath); } // write temp file - FileSystem::write($inputFilePath, $inputFileContents); + FileSystem::write($inputFilePath, $inputFileContents, null); $this->doTestFileMatchesExpectedContent($inputFilePath, $inputFileContents, $expectedFileContents, $fixtureFilePath); } protected function forgetRectorsRulesAndCollectors() : void