Updated Rector to commit 0ff8cb0a99db5de31bb999977a5a417bb282e4d2

0ff8cb0a99 [DX] Warn about run on /vendor directory (#5525)
This commit is contained in:
Tomas Votruba 2024-01-30 16:58:24 +00:00
parent a8e493082a
commit e3df11f1c1
8 changed files with 29 additions and 34 deletions

View File

@ -144,12 +144,6 @@ $node = new String_('hello world!');
// prints node to string, as PHP code displays it
print_node($node);
// dump nested node object with nested properties
dump_node($node);
// 2nd argument is how deep the nesting is - this makes sure the dump is short and useful
dump_node($node, 1);
```
<br>

View File

@ -9,6 +9,7 @@ use Rector\Configuration\Option;
use Rector\Configuration\Parameter\SimpleParameterProvider;
use Rector\Parallel\Application\ParallelFileProcessor;
use Rector\Provider\CurrentFileProvider;
use Rector\Skipper\FileSystem\PathNormalizer;
use Rector\Testing\PHPUnit\StaticPHPUnitEnvironment;
use Rector\Util\ArrayParametersMerger;
use Rector\ValueObject\Application\File;
@ -94,6 +95,10 @@ final class ApplicationFileProcessor
public function run(Configuration $configuration, InputInterface $input) : ProcessResult
{
$filePaths = $this->fileFactory->findFilesInPaths($configuration->getPaths(), $configuration);
if ($this->containsVendorPath($filePaths)) {
$this->symfonyStyle->warning(\sprintf('Rector is running on your "/vendor" directory. This is not necessary, as Rector access /vendor by composer autoload. It will cause Rector tu run much slower and possibly with errors.%sRemove "/vendor" from Rector paths and run again.', \PHP_EOL . \PHP_EOL));
\sleep(3);
}
// no files found
if ($filePaths === []) {
return new ProcessResult([], []);
@ -240,4 +245,16 @@ final class ApplicationFileProcessor
}
return $potentialRectorBinaryPath;
}
/**
* @param string[] $filePaths
*/
private function containsVendorPath(array $filePaths) : bool
{
foreach ($filePaths as $filePath) {
if (\strpos(PathNormalizer::normalize($filePath), '/vendor/') !== \false) {
return \true;
}
}
return \false;
}
}

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '6edf23f6b6cdc2982618ac311c6b7936d3fdcf16';
public const PACKAGE_VERSION = '0ff8cb0a99db5de31bb999977a5a417bb282e4d2';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2024-01-30 17:14:19';
public const RELEASE_DATE = '2024-01-30 17:56:03';
/**
* @var int
*/

View File

@ -4,6 +4,7 @@ declare (strict_types=1);
namespace Rector\FileSystem;
use RectorPrefix202401\Nette\Utils\Strings;
use Rector\Skipper\FileSystem\PathNormalizer;
use RectorPrefix202401\Symfony\Component\Filesystem\Filesystem;
use RectorPrefix202401\Webmozart\Assert\Assert;
/**
@ -55,25 +56,21 @@ final class FilePathHelper
$scheme = self::SCHEME_UNDEFINED;
$path = $originalPath;
}
$normalizedPath = \str_replace('\\', '/', (string) $path);
$normalizedPath = PathNormalizer::normalize((string) $path);
$path = Strings::replace($normalizedPath, self::TWO_AND_MORE_SLASHES_REGEX, '/');
$pathRoot = \strncmp($path, '/', \strlen('/')) === 0 ? $directorySeparator : '';
$pathParts = \explode('/', \trim($path, '/'));
$normalizedPathParts = $this->normalizePathParts($pathParts, $scheme);
$pathStart = $scheme !== self::SCHEME_UNDEFINED ? $scheme . '://' : '';
return $this->normalizePath($pathStart . $pathRoot . \implode($directorySeparator, $normalizedPathParts));
return PathNormalizer::normalize($pathStart . $pathRoot . \implode($directorySeparator, $normalizedPathParts));
}
private function relativeFilePathFromDirectory(string $fileRealPath, string $directory) : string
{
Assert::directory($directory);
$normalizedFileRealPath = $this->normalizePath($fileRealPath);
$normalizedFileRealPath = PathNormalizer::normalize($fileRealPath);
$relativeFilePath = $this->filesystem->makePathRelative($normalizedFileRealPath, $directory);
return \rtrim($relativeFilePath, '/');
}
private function normalizePath(string $filePath) : string
{
return \str_replace('\\', '/', $filePath);
}
/**
* @param string[] $pathParts
* @return string[]

View File

@ -5,18 +5,6 @@ namespace RectorPrefix202401;
use PhpParser\Node;
use PhpParser\PrettyPrinter\Standard;
// @deprecated, use dump() or dd() instead
if (!\function_exists('dump_node')) {
/**
* @return never
* @param mixed $variable
*/
function dump_node($variable, int $depth = 2)
{
\trigger_error('This function is deprecated, to avoid enforcing of Rector debug package. Use your own favorite debugging package instead');
exit;
}
}
if (!\function_exists('print_node')) {
/**
* @param Node|Node[] $node

View File

@ -504,8 +504,8 @@
},
{
"name": "illuminate\/container",
"version": "v10.42.0",
"version_normalized": "10.42.0.0",
"version": "v10.43.0",
"version_normalized": "10.43.0.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/illuminate\/container.git",
@ -561,8 +561,8 @@
},
{
"name": "illuminate\/contracts",
"version": "v10.42.0",
"version_normalized": "10.42.0.0",
"version": "v10.43.0",
"version_normalized": "10.43.0.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/illuminate\/contracts.git",

File diff suppressed because one or more lines are too long

View File

@ -14,7 +14,7 @@ $loader = (static function () {
// Restore the backup and ensure the excluded files are properly marked as loaded
$GLOBALS['__composer_autoload_files'] = \array_merge(
$existingComposerAutoloadFiles,
\array_fill_keys(['0e6d7bf4a5811bfa5cf40c5ccd6fae6a', '5928a00fa978807cf85d90ec3f4b0147'], true)
\array_fill_keys(['5928a00fa978807cf85d90ec3f4b0147', '0e6d7bf4a5811bfa5cf40c5ccd6fae6a'], true)
);
return $loader;
@ -35,7 +35,6 @@ humbug_phpscoper_expose_class('Product', 'RectorPrefix202401\Product');
// Function aliases. For more information see:
// https://github.com/humbug/php-scoper/blob/master/docs/further-reading.md#function-aliases
if (!function_exists('dump_node')) { function dump_node() { return \RectorPrefix202401\dump_node(...func_get_args()); } }
if (!function_exists('formatErrorMessage')) { function formatErrorMessage() { return \RectorPrefix202401\formatErrorMessage(...func_get_args()); } }
if (!function_exists('mb_check_encoding')) { function mb_check_encoding() { return \RectorPrefix202401\mb_check_encoding(...func_get_args()); } }
if (!function_exists('mb_chr')) { function mb_chr() { return \RectorPrefix202401\mb_chr(...func_get_args()); } }