mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-03 09:50:49 +00:00
c2d3d4a3b4
55227be6c3
Removing SmartFileInfo (#2879)
26 lines
903 B
PHP
26 lines
903 B
PHP
<?php
|
|
|
|
declare (strict_types=1);
|
|
namespace Rector\Testing\Fixture;
|
|
|
|
use RectorPrefix202209\Nette\Utils\FileSystem;
|
|
final class FixtureFileUpdater
|
|
{
|
|
public static function updateFixtureContent(string $originalFilePath, string $changedContent, string $fixtureFilepath) : void
|
|
{
|
|
if (!\getenv('UPDATE_TESTS') && !\getenv('UT')) {
|
|
return;
|
|
}
|
|
$newOriginalContent = self::resolveNewFixtureContent($originalFilePath, $changedContent);
|
|
FileSystem::write($fixtureFilepath, $newOriginalContent);
|
|
}
|
|
private static function resolveNewFixtureContent(string $originalFilePath, string $changedContent) : string
|
|
{
|
|
$originalContent = FileSystem::read($originalFilePath);
|
|
if ($originalContent === $changedContent) {
|
|
return $originalContent;
|
|
}
|
|
return $originalContent . '-----' . \PHP_EOL . $changedContent;
|
|
}
|
|
}
|