Updated Rector to commit 55227be6c338823f47f3fe6d4b1e48a4d8291740

55227be6c3 Removing SmartFileInfo (#2879)
This commit is contained in:
Tomas Votruba 2022-09-01 11:24:29 +00:00
parent f271725ce6
commit c2d3d4a3b4
29 changed files with 42 additions and 107 deletions

View File

@ -24,6 +24,7 @@ spl_autoload_register(function (string $class): void {
}
}
// @deprecated, to be removed
if ($class === 'Symplify\SmartFileSystem\SmartFileInfo') {
$filePath = __DIR__ . '/vendor/symplify/smart-file-system/src/SmartFileInfo.php';
if (file_exists($filePath)) {

View File

@ -6,7 +6,6 @@ namespace Utils\Rector\Tests\Rector\RenameSimpleRector;
use Iterator;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
use Symplify\SmartFileSystem\SmartFileInfo;
final class RenameSimpleRectorTest extends AbstractRectorTestCase
{

View File

@ -46,10 +46,9 @@ final class InvalidNameNodeReporter
$message = \sprintf('Pick more specific node than "%s", e.g. "$node->name"', \get_class($node));
$file = $this->currentFileProvider->getFile();
if ($file instanceof File) {
// $smartFileInfo = $file->getFilePath(); // getSmartFileInfo();
$message .= \PHP_EOL . \PHP_EOL;
$relatilveFilePath = $this->filePathHelper->relativePath($file->getFilePath());
$message .= \sprintf('Caused in "%s" file on line %d on code "%s"', $relatilveFilePath, $node->getStartLine(), $this->nodePrinter->print($node));
$relativeFilePath = $this->filePathHelper->relativePath($file->getFilePath());
$message .= \sprintf('Caused in "%s" file on line %d on code "%s"', $relativeFilePath, $node->getStartLine(), $this->nodePrinter->print($node));
}
$backtrace = \debug_backtrace();
$rectorBacktrace = $this->matchRectorBacktraceCall($backtrace);
@ -57,8 +56,8 @@ final class InvalidNameNodeReporter
// issues to find the file in prefixed
if (\file_exists($rectorBacktrace[self::FILE])) {
$filePath = $rectorBacktrace[self::FILE];
$relatilveFilePath = $this->filePathHelper->relativePath($filePath);
$fileAndLine = $relatilveFilePath . ':' . $rectorBacktrace['line'];
$relativeFilePath = $this->filePathHelper->relativePath($filePath);
$fileAndLine = $relativeFilePath . ':' . $rectorBacktrace['line'];
} else {
$fileAndLine = $rectorBacktrace[self::FILE] . ':' . $rectorBacktrace['line'];
}

View File

@ -81,6 +81,6 @@ final class PostFileProcessor
if (!$file instanceof File) {
return \false;
}
return $this->skipper->shouldSkipElementAndFileInfo($postRector, $file->getFilePath());
return $this->skipper->shouldSkipElementAndFilePath($postRector, $file->getFilePath());
}
}

View File

@ -17,10 +17,10 @@ use Rector\Core\Exception\ShouldNotHappenException;
use Rector\Core\PhpParser\Comparing\NodeComparator;
use Rector\Core\PhpParser\Node\BetterNodeFinder;
use Rector\Core\Provider\CurrentFileProvider;
use Rector\Core\ValueObject\Application\File;
use Rector\NodeRemoval\BreakingRemovalGuard;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\PostRector\Contract\Collector\NodeCollectorInterface;
use Symplify\SmartFileSystem\SmartFileInfo;
final class NodesToRemoveCollector implements NodeCollectorInterface
{
/**
@ -76,8 +76,7 @@ final class NodesToRemoveCollector implements NodeCollectorInterface
$this->breakingRemovalGuard->ensureNodeCanBeRemove($node);
}
$file = $this->currentFileProvider->getFile();
// /** @var SmartFileInfo|null $fileInfo */
if ($file !== null) {
if ($file instanceof File) {
$this->affectedFilesCollector->addFile($file);
}
/** @var Stmt $node */

View File

@ -3,7 +3,6 @@
declare (strict_types=1);
namespace Rector\Skipper\Contract;
use Symplify\SmartFileSystem\SmartFileInfo;
interface SkipVoterInterface
{
/**
@ -12,7 +11,6 @@ interface SkipVoterInterface
public function match($element) : bool;
/**
* @param string|object $element
* @param string|\Symplify\SmartFileSystem\SmartFileInfo $file
*/
public function shouldSkip($element, $file) : bool;
public function shouldSkip($element, string $filePath) : bool;
}

View File

@ -5,7 +5,6 @@ namespace Rector\Skipper\Matcher;
use Rector\Skipper\FileSystem\FnMatchPathNormalizer;
use Rector\Skipper\Fnmatcher;
use Symplify\SmartFileSystem\SmartFileInfo;
final class FileInfoMatcher
{
/**
@ -25,12 +24,11 @@ final class FileInfoMatcher
}
/**
* @param string[] $filePatterns
* @param \Symplify\SmartFileSystem\SmartFileInfo|string $file
*/
public function doesFileInfoMatchPatterns($file, array $filePatterns) : bool
public function doesFileInfoMatchPatterns(string $filePath, array $filePatterns) : bool
{
foreach ($filePatterns as $filePattern) {
if ($this->doesFileMatchPattern($file, $filePattern)) {
if ($this->doesFileMatchPattern($filePath, $filePattern)) {
return \true;
}
}
@ -38,11 +36,9 @@ final class FileInfoMatcher
}
/**
* Supports both relative and absolute $file path. They differ for PHP-CS-Fixer and PHP_CodeSniffer.
* @param \Symplify\SmartFileSystem\SmartFileInfo|string $file
*/
private function doesFileMatchPattern($file, string $ignoredPath) : bool
private function doesFileMatchPattern(string $filePath, string $ignoredPath) : bool
{
$filePath = $file instanceof SmartFileInfo ? $file->getRealPath() : $file;
// in ecs.php, the path can be absolute
if ($filePath === $ignoredPath) {
return \true;

View File

@ -7,7 +7,6 @@ use Rector\Skipper\Contract\SkipVoterInterface;
use Rector\Skipper\SkipCriteriaResolver\SkippedClassResolver;
use Rector\Skipper\Skipper\SkipSkipper;
use RectorPrefix202209\Symplify\PackageBuilder\Reflection\ClassLikeExistenceChecker;
use Symplify\SmartFileSystem\SmartFileInfo;
final class ClassSkipVoter implements SkipVoterInterface
{
/**
@ -43,11 +42,10 @@ final class ClassSkipVoter implements SkipVoterInterface
}
/**
* @param string|object $element
* @param \Symplify\SmartFileSystem\SmartFileInfo|string $file
*/
public function shouldSkip($element, $file) : bool
public function shouldSkip($element, string $filePath) : bool
{
$skippedClasses = $this->skippedClassResolver->resolve();
return $this->skipSkipper->doesMatchSkip($element, $file, $skippedClasses);
return $this->skipSkipper->doesMatchSkip($element, $filePath, $skippedClasses);
}
}

View File

@ -6,7 +6,6 @@ namespace Rector\Skipper\SkipVoter;
use Rector\Skipper\Contract\SkipVoterInterface;
use Rector\Skipper\Matcher\FileInfoMatcher;
use Rector\Skipper\SkipCriteriaResolver\SkippedPathsResolver;
use Symplify\SmartFileSystem\SmartFileInfo;
final class PathSkipVoter implements SkipVoterInterface
{
/**
@ -33,11 +32,10 @@ final class PathSkipVoter implements SkipVoterInterface
}
/**
* @param string|object $element
* @param \Symplify\SmartFileSystem\SmartFileInfo|string $file
*/
public function shouldSkip($element, $file) : bool
public function shouldSkip($element, string $filePath) : bool
{
$skippedPaths = $this->skippedPathsResolver->resolve();
return $this->fileInfoMatcher->doesFileInfoMatchPatterns($file, $skippedPaths);
return $this->fileInfoMatcher->doesFileInfoMatchPatterns($filePath, $skippedPaths);
}
}

View File

@ -4,7 +4,6 @@ declare (strict_types=1);
namespace Rector\Skipper\Skipper;
use Rector\Skipper\Matcher\FileInfoMatcher;
use Symplify\SmartFileSystem\SmartFileInfo;
final class SkipSkipper
{
/**
@ -19,9 +18,8 @@ final class SkipSkipper
/**
* @param array<string, string[]|null> $skippedClasses
* @param object|string $checker
* @param \Symplify\SmartFileSystem\SmartFileInfo|string $file
*/
public function doesMatchSkip($checker, $file, array $skippedClasses) : bool
public function doesMatchSkip($checker, string $filePath, array $skippedClasses) : bool
{
foreach ($skippedClasses as $skippedClass => $skippedFiles) {
if (!\is_a($checker, $skippedClass, \true)) {
@ -31,7 +29,7 @@ final class SkipSkipper
if (!\is_array($skippedFiles)) {
return \true;
}
if ($this->fileInfoMatcher->doesFileInfoMatchPatterns($file, $skippedFiles)) {
if ($this->fileInfoMatcher->doesFileInfoMatchPatterns($filePath, $skippedFiles)) {
return \true;
}
}

View File

@ -4,7 +4,6 @@ declare (strict_types=1);
namespace Rector\Skipper\Skipper;
use Rector\Skipper\Contract\SkipVoterInterface;
use Symplify\SmartFileSystem\SmartFileInfo;
/**
* @api
* @see \Rector\Tests\Skipper\Skipper\Skipper\SkipperTest
@ -32,28 +31,22 @@ final class Skipper
*/
public function shouldSkipElement($element) : bool
{
$fileInfo = new SmartFileInfo(__FILE__);
return $this->shouldSkipElementAndFileInfo($element, $fileInfo);
}
public function shouldSkipFileInfo(SmartFileInfo $smartFileInfo) : bool
{
return $this->shouldSkipElementAndFileInfo(self::FILE_ELEMENT, $smartFileInfo);
return $this->shouldSkipElementAndFilePath($element, __FILE__);
}
public function shouldSkipFilePath(string $filePath) : bool
{
return $this->shouldSkipElementAndFileInfo(self::FILE_ELEMENT, $filePath);
return $this->shouldSkipElementAndFilePath(self::FILE_ELEMENT, $filePath);
}
/**
* @param string|object $element
* @param \Symplify\SmartFileSystem\SmartFileInfo|string $smartFileInfo
*/
public function shouldSkipElementAndFileInfo($element, $smartFileInfo) : bool
public function shouldSkipElementAndFilePath($element, string $filePath) : bool
{
foreach ($this->skipVoters as $skipVoter) {
if (!$skipVoter->match($element)) {
continue;
}
return $skipVoter->shouldSkip($element, $smartFileInfo);
return $skipVoter->shouldSkip($element, $filePath);
}
return \false;
}

View File

@ -4,12 +4,9 @@ declare (strict_types=1);
namespace Rector\Testing\Fixture;
use Iterator;
use RectorPrefix202209\Nette\Utils\Strings;
use Rector\Core\Exception\ShouldNotHappenException;
use RectorPrefix202209\Symfony\Component\Finder\Finder;
use RectorPrefix202209\Symfony\Component\Finder\SplFileInfo;
use Symplify\SmartFileSystem\SmartFileInfo;
use RectorPrefix202209\Symplify\SmartFileSystem\Exception\FileNotFoundException;
final class FixtureFileFinder
{
/**
@ -23,7 +20,7 @@ final class FixtureFileFinder
}
}
/**
* @return Iterator<array<int, SmartFileInfo>>
* @deprecated
*/
public static function yieldDirectory(string $directory, string $suffix = '*.php.inc') : Iterator
{

View File

@ -4,42 +4,19 @@ declare (strict_types=1);
namespace Rector\Testing\Fixture;
use RectorPrefix202209\Nette\Utils\FileSystem;
use Symplify\SmartFileSystem\SmartFileInfo;
use RectorPrefix202209\Symplify\SmartFileSystem\SmartFileSystem;
final class FixtureFileUpdater
{
/**
* @param \Symplify\SmartFileSystem\SmartFileInfo|string $originalFileInfo
*/
public static function updateFixtureContent($originalFileInfo, string $changedContent, string $fixtureFilepath) : void
public static function updateFixtureContent(string $originalFilePath, string $changedContent, string $fixtureFilepath) : void
{
if (!\getenv('UPDATE_TESTS') && !\getenv('UT')) {
return;
}
$newOriginalContent = self::resolveNewFixtureContent($originalFileInfo, $changedContent);
$newOriginalContent = self::resolveNewFixtureContent($originalFilePath, $changedContent);
FileSystem::write($fixtureFilepath, $newOriginalContent);
}
public static function updateExpectedFixtureContent(string $newOriginalContent, SmartFileInfo $expectedFixtureFileInfo) : void
private static function resolveNewFixtureContent(string $originalFilePath, string $changedContent) : string
{
if (!\getenv('UPDATE_TESTS') && !\getenv('UT')) {
return;
}
self::getSmartFileSystem()->dumpFile($expectedFixtureFileInfo->getRealPath(), $newOriginalContent);
}
private static function getSmartFileSystem() : SmartFileSystem
{
return new SmartFileSystem();
}
/**
* @param \Symplify\SmartFileSystem\SmartFileInfo|string $originalFileInfo
*/
private static function resolveNewFixtureContent($originalFileInfo, string $changedContent) : string
{
if ($originalFileInfo instanceof SmartFileInfo) {
$originalContent = $originalFileInfo->getContents();
} else {
$originalContent = $originalFileInfo;
}
$originalContent = FileSystem::read($originalFilePath);
if ($originalContent === $changedContent) {
return $originalContent;
}

View File

@ -4,7 +4,6 @@ declare (strict_types=1);
namespace Rector\Testing\Fixture;
use RectorPrefix202209\Nette\Utils\FileSystem;
use Symplify\SmartFileSystem\SmartFileInfo;
final class FixtureTempFileDumper
{
/**

View File

@ -80,7 +80,6 @@ abstract class AbstractRectorTestCase extends \Rector\Testing\PHPUnit\AbstractTe
}
/**
* @deprecated Use \Rector\Testing\PHPUnit\AbstractRectorTestCase::yieldFilePathsFromDirectory() instead
* @return Iterator<<SmartFileInfo>>
*/
protected function yieldFilesFromDirectory(string $directory, string $suffix = '*.php.inc') : Iterator
{

View File

@ -34,7 +34,6 @@ final class FileInfoDeletionAnalyzer
{
$className = (string) $this->nodeNameResolver->getName($classLike);
$filePath = $file->getFilePath();
// getSmartFileInfo();
$basename = \pathinfo($filePath, \PATHINFO_BASENAME);
$baseFileName = $this->clearNameFromTestingPrefix($basename);
$classShortName = $this->classNaming->getShortName($className);

View File

@ -58,8 +58,6 @@ CODE_SAMPLE
}
$classShortName = $this->nodeNameResolver->getShortName($className);
$filePath = $this->file->getFilePath();
// getSmartFileInfo();
// matches
$basename = \pathinfo($filePath, \PATHINFO_BASENAME);
if ($classShortName === $basename) {
return null;

View File

@ -188,7 +188,6 @@ final class ApplicationFileProcessor
private function printFile(File $file) : void
{
$filePath = $file->getFilePath();
// $smartFileInfo = $file->getFilePath() getSmartFileInfo();
$this->filesystem->dumpFile($filePath, $file->getFileContent());
// @todo how to keep original chmod rights?
// $this->filesystem->chmod($filePath, $smartFileInfo->getPerms());
@ -280,8 +279,6 @@ final class ApplicationFileProcessor
$phpFilePaths = [];
foreach ($files as $file) {
$filePath = $file->getFilePath();
// $smartFileInfo = $file->getSmartFileInfo();
// $pathname = $smartFileInfo->getPathname();
if (\substr_compare($filePath, '.php', -\strlen('.php')) === 0) {
$phpFilePaths[] = $filePath;
}

View File

@ -163,7 +163,6 @@ final class PhpFileProcessor implements FileProcessorInterface
private function printFile(File $file, Configuration $configuration) : void
{
$filePath = $file->getFilePath();
// getSmartFileInfo();
if ($this->removedAndAddedFilesCollector->isFileRemoved($filePath)) {
// skip, because this file exists no more
return;

View File

@ -17,12 +17,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '6a7faa26fba9ab70d2af08c4d8f36aba398d0f8b';
public const PACKAGE_VERSION = '55227be6c338823f47f3fe6d4b1e48a4d8291740';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2022-09-01 11:38:30';
public const RELEASE_DATE = '2022-09-01 13:20:16';
/**
* @var int
*/

View File

@ -58,11 +58,9 @@ final class NonPhpFileProcessor implements FileProcessorInterface
}
public function supports(File $file, Configuration $configuration) : bool
{
// $smartFileInfo = $file->getFilePath();
// early assign to variable for increase performance
// @see https://3v4l.org/FM3vY#focus=8.0.7 vs https://3v4l.org/JZW7b#focus=8.0.7
$filePath = $file->getFilePath();
// $smartFileInfo->getPathname();
// bug in path extension
foreach ($this->getSupportedFileExtensions() as $fileExtension) {
if (\substr_compare($filePath, '.' . $fileExtension, -\strlen('.' . $fileExtension)) === 0) {

View File

@ -313,7 +313,6 @@ final class AstResolver
if ($stmts === []) {
return null;
}
//$smartFileInfo = new SmartFileInfo($fileName);
$file = new File($fileName, FileSystem::read($fileName));
return $this->nodeScopeAndMetadataDecorator->decorateNodesFromFile($file, $stmts);
}

View File

@ -247,9 +247,6 @@ final class ValueResolver
throw new ShouldNotHappenException();
}
return $file->getFilePath();
//
// $smartFileInfo = $file->getSmartFileInfo();
// return $smartFileInfo->getPathname();
}
/**
* @return string|mixed

View File

@ -39,7 +39,6 @@ final class RectifiedAnalyzer
if ($this->hasCreatedByRule($rectorClass, $node, $originalNode)) {
return new RectifiedNode($rectorClass, $node);
}
// $realPath = $smartFileInfo->getRealPath();
if (!isset($this->previousFileWithNodes[$filePath])) {
$this->previousFileWithNodes[$filePath] = new RectifiedNode($rectorClass, $node);
return null;

View File

@ -342,8 +342,7 @@ CODE_SAMPLE;
return \true;
}
$filePath = $this->file->getFilePath();
// getSmartFileInfo();
if ($this->skipper->shouldSkipElementAndFileInfo($this, $filePath)) {
if ($this->skipper->shouldSkipElementAndFilePath($this, $filePath)) {
return \true;
}
$rectifiedNode = $this->rectifiedAnalyzer->verify(static::class, $node, $this->file->getFilePath());

View File

@ -59,7 +59,6 @@ final class File
public function getFilePath() : string
{
return $this->filepath;
// smartFileInfo->getRealPath();
}
public function getFileContent() : string
{

2
vendor/autoload.php vendored
View File

@ -9,4 +9,4 @@ if (PHP_VERSION_ID < 50600) {
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInita9cc425567d813f5d3ef9725ca18aa3a::getLoader();
return ComposerAutoloaderInit065859c5b000ad3f146cbc4cffc1d9c8::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInita9cc425567d813f5d3ef9725ca18aa3a
class ComposerAutoloaderInit065859c5b000ad3f146cbc4cffc1d9c8
{
private static $loader;
@ -22,19 +22,19 @@ class ComposerAutoloaderInita9cc425567d813f5d3ef9725ca18aa3a
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInita9cc425567d813f5d3ef9725ca18aa3a', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit065859c5b000ad3f146cbc4cffc1d9c8', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInita9cc425567d813f5d3ef9725ca18aa3a', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit065859c5b000ad3f146cbc4cffc1d9c8', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInita9cc425567d813f5d3ef9725ca18aa3a::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit065859c5b000ad3f146cbc4cffc1d9c8::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$includeFiles = \Composer\Autoload\ComposerStaticInita9cc425567d813f5d3ef9725ca18aa3a::$files;
$includeFiles = \Composer\Autoload\ComposerStaticInit065859c5b000ad3f146cbc4cffc1d9c8::$files;
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequirea9cc425567d813f5d3ef9725ca18aa3a($fileIdentifier, $file);
composerRequire065859c5b000ad3f146cbc4cffc1d9c8($fileIdentifier, $file);
}
return $loader;
@ -46,7 +46,7 @@ class ComposerAutoloaderInita9cc425567d813f5d3ef9725ca18aa3a
* @param string $file
* @return void
*/
function composerRequirea9cc425567d813f5d3ef9725ca18aa3a($fileIdentifier, $file)
function composerRequire065859c5b000ad3f146cbc4cffc1d9c8($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInita9cc425567d813f5d3ef9725ca18aa3a
class ComposerStaticInit065859c5b000ad3f146cbc4cffc1d9c8
{
public static $files = array (
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
@ -3139,9 +3139,9 @@ class ComposerStaticInita9cc425567d813f5d3ef9725ca18aa3a
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInita9cc425567d813f5d3ef9725ca18aa3a::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInita9cc425567d813f5d3ef9725ca18aa3a::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInita9cc425567d813f5d3ef9725ca18aa3a::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit065859c5b000ad3f146cbc4cffc1d9c8::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit065859c5b000ad3f146cbc4cffc1d9c8::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit065859c5b000ad3f146cbc4cffc1d9c8::$classMap;
}, null, ClassLoader::class);
}