mirror of https://github.com/rectorphp/rector.git
Updated Rector to commit 308178a058b057813283852029a7b2aaa026568a
308178a058
Adding collectors - step 3 (#5043)
This commit is contained in:
parent
931ab640df
commit
d7b6d352e5
|
@ -334,7 +334,6 @@ final class PhpDocInfo
|
|||
}
|
||||
/**
|
||||
* @deprecated Change doc block and print directly in the node instead
|
||||
* @internal
|
||||
* Should be handled by attributes of phpdoc node - if stard_and_end is missing in one of nodes, it has been changed
|
||||
*
|
||||
* @api
|
||||
|
|
|
@ -77,7 +77,6 @@ final class PropertyPromotionDocBlockMerger
|
|||
public function decorateParamWithPropertyPhpDocInfo(ClassMethod $classMethod, Property $property, Param $param, string $paramName) : void
|
||||
{
|
||||
$propertyPhpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property);
|
||||
$propertyPhpDocInfo->markAsChanged();
|
||||
$param->setAttribute(AttributeKey::PHP_DOC_INFO, $propertyPhpDocInfo);
|
||||
// make sure the docblock is useful
|
||||
if ($param->type === null) {
|
||||
|
|
|
@ -8,6 +8,7 @@ use PHPStan\AnalysedCodeException;
|
|||
use Rector\Caching\Detector\ChangedFilesDetector;
|
||||
use Rector\ChangesReporting\ValueObjectFactory\ErrorFactory;
|
||||
use Rector\ChangesReporting\ValueObjectFactory\FileDiffFactory;
|
||||
use Rector\Core\Application\Collector\CollectorProcessor;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\FileSystem\FilePathHelper;
|
||||
use Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace;
|
||||
|
@ -61,6 +62,11 @@ final class FileProcessor
|
|||
* @var \Rector\Core\FileSystem\FilePathHelper
|
||||
*/
|
||||
private $filePathHelper;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\Application\Collector\CollectorProcessor
|
||||
*/
|
||||
private $collectorProcessor;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\PostRector\Application\PostFileProcessor
|
||||
|
@ -81,7 +87,7 @@ final class FileProcessor
|
|||
* @see https://regex101.com/r/xP2MGa/1
|
||||
*/
|
||||
private const OPEN_TAG_SPACED_REGEX = '#^(?<open_tag_spaced>[^\\S\\r\\n]+\\<\\?php)#m';
|
||||
public function __construct(FormatPerservingPrinter $formatPerservingPrinter, RectorNodeTraverser $rectorNodeTraverser, SymfonyStyle $symfonyStyle, FileDiffFactory $fileDiffFactory, ChangedFilesDetector $changedFilesDetector, ErrorFactory $errorFactory, FilePathHelper $filePathHelper, PostFileProcessor $postFileProcessor, RectorParser $rectorParser, NodeScopeAndMetadataDecorator $nodeScopeAndMetadataDecorator)
|
||||
public function __construct(FormatPerservingPrinter $formatPerservingPrinter, RectorNodeTraverser $rectorNodeTraverser, SymfonyStyle $symfonyStyle, FileDiffFactory $fileDiffFactory, ChangedFilesDetector $changedFilesDetector, ErrorFactory $errorFactory, FilePathHelper $filePathHelper, CollectorProcessor $collectorProcessor, PostFileProcessor $postFileProcessor, RectorParser $rectorParser, NodeScopeAndMetadataDecorator $nodeScopeAndMetadataDecorator)
|
||||
{
|
||||
$this->formatPerservingPrinter = $formatPerservingPrinter;
|
||||
$this->rectorNodeTraverser = $rectorNodeTraverser;
|
||||
|
@ -90,6 +96,7 @@ final class FileProcessor
|
|||
$this->changedFilesDetector = $changedFilesDetector;
|
||||
$this->errorFactory = $errorFactory;
|
||||
$this->filePathHelper = $filePathHelper;
|
||||
$this->collectorProcessor = $collectorProcessor;
|
||||
$this->postFileProcessor = $postFileProcessor;
|
||||
$this->rectorParser = $rectorParser;
|
||||
$this->nodeScopeAndMetadataDecorator = $nodeScopeAndMetadataDecorator;
|
||||
|
@ -108,6 +115,8 @@ final class FileProcessor
|
|||
do {
|
||||
$file->changeHasChanged(\false);
|
||||
$newStmts = $this->rectorNodeTraverser->traverse($file->getNewStmts());
|
||||
// collect data
|
||||
$fileCollectedData = $this->collectorProcessor->process($newStmts);
|
||||
// apply post rectors
|
||||
$postNewStmts = $this->postFileProcessor->traverse($newStmts);
|
||||
// this is needed for new tokens added in "afterTraverse()"
|
||||
|
@ -130,7 +139,7 @@ final class FileProcessor
|
|||
$currentFileDiff = $this->fileDiffFactory->createFileDiffWithLineChanges($file, $file->getOriginalFileContent(), $file->getFileContent(), $rectorWithLineChanges);
|
||||
$file->setFileDiff($currentFileDiff);
|
||||
}
|
||||
return new FileProcessResult([], $file->getFileDiff(), []);
|
||||
return new FileProcessResult([], $file->getFileDiff(), $fileCollectedData);
|
||||
}
|
||||
private function parseFileAndDecorateNodes(File $file) : ?SystemError
|
||||
{
|
||||
|
|
|
@ -19,12 +19,12 @@ final class VersionResolver
|
|||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'e084356a6aa394a37db6ee1ef153cf8c860a1db5';
|
||||
public const PACKAGE_VERSION = '308178a058b057813283852029a7b2aaa026568a';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-09-18 16:36:51';
|
||||
public const RELEASE_DATE = '2023-09-18 19:09:10';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
|
|
@ -9,6 +9,8 @@ use RectorPrefix202309\Illuminate\Container\Container;
|
|||
use PhpParser\Lexer;
|
||||
use PHPStan\Analyser\NodeScopeResolver;
|
||||
use PHPStan\Analyser\ScopeFactory;
|
||||
use PHPStan\Collectors\Collector;
|
||||
use PHPStan\Collectors\Registry;
|
||||
use PHPStan\File\FileHelper;
|
||||
use PHPStan\Parser\Parser;
|
||||
use PHPStan\PhpDoc\TypeNodeResolver;
|
||||
|
@ -242,6 +244,8 @@ final class LazyContainerFactory
|
|||
{
|
||||
$rectorConfig = new RectorConfig();
|
||||
$rectorConfig->import(__DIR__ . '/../../config/config.php');
|
||||
// rector collectors
|
||||
$rectorConfig->when(Registry::class)->needs('$collectors')->giveTagged(Collector::class);
|
||||
$rectorConfig->singleton(Application::class, static function (Container $container) : Application {
|
||||
$application = $container->make(ConsoleApplication::class);
|
||||
$commandNamesToHide = ['list', 'completion', 'help'];
|
||||
|
|
|
@ -63,7 +63,7 @@ final class RectorNodeTraverser extends NodeTraverser
|
|||
}
|
||||
// filer out by version
|
||||
$activePhpRectors = $this->phpVersionedFilter->filter($this->rectors);
|
||||
$this->visitors = $this->visitors === [] ? $activePhpRectors : \array_merge($this->visitors, $activePhpRectors);
|
||||
$this->visitors = \array_merge($this->visitors, $activePhpRectors);
|
||||
$this->areNodeVisitorsPrepared = \true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
declare (strict_types=1);
|
||||
namespace Rector\Core\ValueObject;
|
||||
|
||||
use PHPStan\Collectors\CollectedData;
|
||||
use Rector\ChangesReporting\Output\ConsoleOutputFormatter;
|
||||
use RectorPrefix202309\Webmozart\Assert\Assert;
|
||||
final class Configuration
|
||||
|
@ -67,6 +68,14 @@ final class Configuration
|
|||
* @var bool
|
||||
*/
|
||||
private $isDebug = \false;
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $isSecondRun = \false;
|
||||
/**
|
||||
* @var CollectedData[]
|
||||
*/
|
||||
private $collectedData = [];
|
||||
/**
|
||||
* @param string[] $fileExtensions
|
||||
* @param string[] $paths
|
||||
|
@ -141,4 +150,34 @@ final class Configuration
|
|||
{
|
||||
return $this->isDebug;
|
||||
}
|
||||
/**
|
||||
* @api
|
||||
* @param CollectedData[] $collectedDatas
|
||||
*/
|
||||
public function setCollectedDatas(array $collectedDatas) : void
|
||||
{
|
||||
$this->collectedData = $collectedDatas;
|
||||
}
|
||||
/**
|
||||
* @api
|
||||
* @return CollectedData[]
|
||||
*/
|
||||
public function getCollectedDatas() : array
|
||||
{
|
||||
return $this->collectedData;
|
||||
}
|
||||
/**
|
||||
* @api
|
||||
*/
|
||||
public function enableSecondRun() : void
|
||||
{
|
||||
$this->isSecondRun = \true;
|
||||
}
|
||||
/**
|
||||
* @api
|
||||
*/
|
||||
public function isSecondRun() : bool
|
||||
{
|
||||
return $this->isSecondRun;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
|
|||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit62066db96b30e43209b6c691adcb2d06::getLoader();
|
||||
return ComposerAutoloaderInitfe52d60baf5fe3cb1eda5eb147e3a55d::getLoader();
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit62066db96b30e43209b6c691adcb2d06
|
||||
class ComposerAutoloaderInitfe52d60baf5fe3cb1eda5eb147e3a55d
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,17 +22,17 @@ class ComposerAutoloaderInit62066db96b30e43209b6c691adcb2d06
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit62066db96b30e43209b6c691adcb2d06', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInitfe52d60baf5fe3cb1eda5eb147e3a55d', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit62066db96b30e43209b6c691adcb2d06', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitfe52d60baf5fe3cb1eda5eb147e3a55d', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit62066db96b30e43209b6c691adcb2d06::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitfe52d60baf5fe3cb1eda5eb147e3a55d::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit62066db96b30e43209b6c691adcb2d06::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInitfe52d60baf5fe3cb1eda5eb147e3a55d::$files;
|
||||
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit62066db96b30e43209b6c691adcb2d06
|
||||
class ComposerStaticInitfe52d60baf5fe3cb1eda5eb147e3a55d
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
|
@ -2596,9 +2596,9 @@ class ComposerStaticInit62066db96b30e43209b6c691adcb2d06
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit62066db96b30e43209b6c691adcb2d06::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit62066db96b30e43209b6c691adcb2d06::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit62066db96b30e43209b6c691adcb2d06::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitfe52d60baf5fe3cb1eda5eb147e3a55d::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitfe52d60baf5fe3cb1eda5eb147e3a55d::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitfe52d60baf5fe3cb1eda5eb147e3a55d::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
|
@ -1873,12 +1873,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-phpunit.git",
|
||||
"reference": "c71ce2aa977e61bf875825f25ab5a7e8cd8bf7e6"
|
||||
"reference": "9c1997c835a5bded452626a24d2cfa56226c0ba8"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/c71ce2aa977e61bf875825f25ab5a7e8cd8bf7e6",
|
||||
"reference": "c71ce2aa977e61bf875825f25ab5a7e8cd8bf7e6",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/9c1997c835a5bded452626a24d2cfa56226c0ba8",
|
||||
"reference": "9c1997c835a5bded452626a24d2cfa56226c0ba8",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1889,26 +1889,26 @@
|
|||
},
|
||||
"require-dev": {
|
||||
"phpstan\/extension-installer": "^1.3",
|
||||
"phpstan\/phpstan": "^1.10.25",
|
||||
"phpstan\/phpstan": "^1.10.34",
|
||||
"phpstan\/phpstan-strict-rules": "^1.5",
|
||||
"phpstan\/phpstan-webmozart-assert": "^1.2.2",
|
||||
"phpunit\/phpunit": "^10.2",
|
||||
"rector\/phpstan-rules": "^0.6",
|
||||
"rector\/phpstan-rules": "^0.7",
|
||||
"rector\/rector-generator": "^0.7",
|
||||
"rector\/rector-src": "dev-main",
|
||||
"symplify\/easy-ci": "^11.2.0",
|
||||
"symplify\/easy-ci": "^11.3",
|
||||
"symplify\/easy-coding-standard": "^12.0",
|
||||
"symplify\/phpstan-extensions": "^11.2",
|
||||
"symplify\/phpstan-rules": "^11.4",
|
||||
"symplify\/rule-doc-generator": "^12.0",
|
||||
"symplify\/vendor-patches": "^11.2.0",
|
||||
"symplify\/vendor-patches": "^11.2",
|
||||
"tomasvotruba\/class-leak": "^0.1",
|
||||
"tomasvotruba\/cognitive-complexity": "^0.1",
|
||||
"tomasvotruba\/type-coverage": "^0.2",
|
||||
"tomasvotruba\/unused-public": "^0.3",
|
||||
"tracy\/tracy": "^2.10"
|
||||
},
|
||||
"time": "2023-09-18T15:18:13+00:00",
|
||||
"time": "2023-09-18T16:59:26+00:00",
|
||||
"default-branch": true,
|
||||
"type": "rector-extension",
|
||||
"extra": {
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
|
|||
*/
|
||||
final class GeneratedConfig
|
||||
{
|
||||
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => NULL, 'version' => 'dev-main 4b25180'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => NULL, 'version' => 'dev-main 3782784'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => NULL, 'version' => 'dev-main c71ce2a'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => NULL, 'version' => 'dev-main 09ddd39'));
|
||||
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => NULL, 'version' => 'dev-main 4b25180'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => NULL, 'version' => 'dev-main 3782784'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => NULL, 'version' => 'dev-main 9c1997c'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => NULL, 'version' => 'dev-main 09ddd39'));
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -9,17 +9,17 @@
|
|||
"require-dev": {
|
||||
"rector\/rector-src": "dev-main",
|
||||
"phpunit\/phpunit": "^10.2",
|
||||
"phpstan\/phpstan": "^1.10.25",
|
||||
"phpstan\/phpstan": "^1.10.34",
|
||||
"symplify\/phpstan-rules": "^11.4",
|
||||
"symplify\/phpstan-extensions": "^11.2",
|
||||
"symplify\/easy-coding-standard": "^12.0",
|
||||
"symplify\/rule-doc-generator": "^12.0",
|
||||
"rector\/phpstan-rules": "^0.6",
|
||||
"rector\/phpstan-rules": "^0.7",
|
||||
"phpstan\/extension-installer": "^1.3",
|
||||
"phpstan\/phpstan-strict-rules": "^1.5",
|
||||
"phpstan\/phpstan-webmozart-assert": "^1.2.2",
|
||||
"symplify\/vendor-patches": "^11.2.0",
|
||||
"symplify\/easy-ci": "^11.2.0",
|
||||
"symplify\/vendor-patches": "^11.2",
|
||||
"symplify\/easy-ci": "^11.3",
|
||||
"rector\/rector-generator": "^0.7",
|
||||
"tomasvotruba\/type-coverage": "^0.2",
|
||||
"tomasvotruba\/unused-public": "^0.3",
|
||||
|
|
Loading…
Reference in New Issue