mirror of
https://github.com/rectorphp/rector.git
synced 2025-04-15 21:12:34 +02:00
Updated Rector to commit 1608ae8c9497bbfaf78ce54130ec304963ac6f2a
1608ae8c94
[Windows] Utilize Nette\Utils\FileSystem instead of Symfony\Component\Filesystem\Filesystem to write file (#5514)
This commit is contained in:
parent
691f25c420
commit
94c55b84c0
@ -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;
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -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("<?php declare(strict_types = 1);\n\nreturn %s;", $exported));
|
||||
$renameSuccess = @\rename($tmpPath, $filePath);
|
||||
if ($renameSuccess) {
|
||||
FileSystem::write($tmpPath, \sprintf("<?php declare(strict_types = 1);\n\nreturn %s;", $exported), null);
|
||||
$copySuccess = @\copy($tmpPath, $filePath);
|
||||
@\unlink($tmpPath);
|
||||
if ($copySuccess) {
|
||||
return;
|
||||
}
|
||||
@\unlink($tmpPath);
|
||||
if (\DIRECTORY_SEPARATOR === '/' || !\file_exists($filePath)) {
|
||||
throw new CachingException(\sprintf('Could not write data to cache file %s.', $filePath));
|
||||
}
|
||||
@ -88,7 +88,7 @@ final class FileCacheStorage implements CacheStorageInterface
|
||||
}
|
||||
public function clear() : void
|
||||
{
|
||||
$this->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
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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');
|
||||
|
@ -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('<comment>2 more steps to run Rector in CI:</comment>');
|
||||
@ -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();
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user