Updated Rector to commit 4f13982aab

4f13982aab [DX] Make progress bar less verbose on CI (#1797)
This commit is contained in:
Tomas Votruba 2022-02-11 12:13:24 +00:00
parent a5a202b286
commit 7247d62498
29 changed files with 323 additions and 182 deletions

View File

@ -29,13 +29,13 @@ use Rector\BetterPhpDocParser\PhpDocParser\BetterTypeParser;
use Rector\Caching\Cache;
use Rector\Caching\CacheFactory;
use Rector\Core\Console\ConsoleApplication;
use Rector\Core\Console\Style\RectorConsoleOutputStyle;
use Rector\Core\Console\Style\RectorConsoleOutputStyleFactory;
use Rector\Core\Validation\Collector\EmptyConfigurableRectorCollector;
use Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory;
use Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocator\IntermediateSourceLocator;
use Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocatorProvider\DynamicSourceLocatorProvider;
use RectorPrefix20220211\Symfony\Component\Console\Application;
use RectorPrefix20220211\Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use function RectorPrefix20220211\Symfony\Component\DependencyInjection\Loader\Configurator\service;
use RectorPrefix20220211\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser;
@ -62,7 +62,7 @@ return static function (\Symfony\Component\DependencyInjection\Loader\Configurat
$services->set(\PhpParser\BuilderFactory::class);
$services->set(\PhpParser\NodeVisitor\CloningVisitor::class);
$services->set(\PhpParser\NodeFinder::class);
$services->set(\RectorPrefix20220211\Symfony\Component\Console\Style\SymfonyStyle::class)->factory([\RectorPrefix20220211\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\Core\Console\Style\RectorConsoleOutputStyleFactory::class), 'create']);
$services->set(\Rector\Core\Console\Style\RectorConsoleOutputStyle::class)->factory([\RectorPrefix20220211\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\Core\Console\Style\RectorConsoleOutputStyleFactory::class), 'create']);
$services->set(\PHPStan\Parser\Parser::class)->factory([\RectorPrefix20220211\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createPHPStanParser']);
$services->set(\PhpParser\Lexer::class)->factory([\RectorPrefix20220211\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createEmulativeLexer']);
// symplify/package-builder

View File

@ -134,8 +134,8 @@ final class PhpDocInfoFactory
return;
}
$phpDocChildNodes = $phpDocNode->children;
$lastChildNode = \array_pop($phpDocChildNodes);
$startAndEnd = $lastChildNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END);
$phpDocChildNode = \array_pop($phpDocChildNodes);
$startAndEnd = $phpDocChildNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END);
if ($startAndEnd instanceof \Rector\BetterPhpDocParser\ValueObject\StartAndEnd) {
$phpDocNode->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::LAST_PHP_DOC_TOKEN_POSITION, $startAndEnd->getEnd());
}

View File

@ -26,15 +26,15 @@ final class ConsoleOutputFormatter implements \Rector\ChangesReporting\Contract\
* @readonly
* @var \Rector\Core\Contract\Console\OutputStyleInterface
*/
private $outputStyle;
private $rectorOutputStyle;
/**
* @readonly
* @var \Rector\ChangesReporting\Annotation\RectorsChangelogResolver
*/
private $rectorsChangelogResolver;
public function __construct(\Rector\Core\Contract\Console\OutputStyleInterface $outputStyle, \Rector\ChangesReporting\Annotation\RectorsChangelogResolver $rectorsChangelogResolver)
public function __construct(\Rector\Core\Contract\Console\OutputStyleInterface $rectorOutputStyle, \Rector\ChangesReporting\Annotation\RectorsChangelogResolver $rectorsChangelogResolver)
{
$this->outputStyle = $outputStyle;
$this->rectorOutputStyle = $rectorOutputStyle;
$this->rectorsChangelogResolver = $rectorsChangelogResolver;
}
public function report(\Rector\Core\ValueObject\ProcessResult $processResult, \Rector\Core\ValueObject\Configuration $configuration) : void
@ -49,10 +49,10 @@ final class ConsoleOutputFormatter implements \Rector\ChangesReporting\Contract\
}
// to keep space between progress bar and success message
if ($configuration->shouldShowProgressBar() && $processResult->getFileDiffs() === []) {
$this->outputStyle->newline();
$this->rectorOutputStyle->newLine();
}
$message = $this->createSuccessMessage($processResult, $configuration);
$this->outputStyle->success($message);
$this->rectorOutputStyle->success($message);
}
public function getName() : string
{
@ -69,7 +69,7 @@ final class ConsoleOutputFormatter implements \Rector\ChangesReporting\Contract\
// normalize
\ksort($fileDiffs);
$message = \sprintf('%d file%s with changes', \count($fileDiffs), \count($fileDiffs) === 1 ? '' : 's');
$this->outputStyle->title($message);
$this->rectorOutputStyle->title($message);
$i = 0;
foreach ($fileDiffs as $fileDiff) {
$relativeFilePath = $fileDiff->getRelativeFilePath();
@ -79,14 +79,14 @@ final class ConsoleOutputFormatter implements \Rector\ChangesReporting\Contract\
$relativeFilePath .= ':' . $firstLineNumber;
}
$message = \sprintf('<options=bold>%d) %s</>', ++$i, $relativeFilePath);
$this->outputStyle->writeln($message);
$this->outputStyle->newline();
$this->outputStyle->writeln($fileDiff->getDiffConsoleFormatted());
$this->rectorOutputStyle->writeln($message);
$this->rectorOutputStyle->newLine();
$this->rectorOutputStyle->writeln($fileDiff->getDiffConsoleFormatted());
$rectorsChangelogsLines = $this->createRectorChangelogLines($fileDiff);
if ($fileDiff->getRectorChanges() !== []) {
$this->outputStyle->writeln('<options=underscore>Applied rules:</>');
$this->outputStyle->listing($rectorsChangelogsLines);
$this->outputStyle->newline();
$this->rectorOutputStyle->writeln('<options=underscore>Applied rules:</>');
$this->rectorOutputStyle->listing($rectorsChangelogsLines);
$this->rectorOutputStyle->newLine();
}
}
}
@ -102,18 +102,18 @@ final class ConsoleOutputFormatter implements \Rector\ChangesReporting\Contract\
if ($error->getLine() !== null) {
$message .= ' On line: ' . $error->getLine();
}
$this->outputStyle->error($message);
$this->rectorOutputStyle->error($message);
}
}
private function reportRemovedFilesAndNodes(\Rector\Core\ValueObject\ProcessResult $processResult) : void
{
if ($processResult->getAddedFilesCount() !== 0) {
$message = \sprintf('%d files were added', $processResult->getAddedFilesCount());
$this->outputStyle->note($message);
$this->rectorOutputStyle->note($message);
}
if ($processResult->getRemovedFilesCount() !== 0) {
$message = \sprintf('%d files were removed', $processResult->getRemovedFilesCount());
$this->outputStyle->note($message);
$this->rectorOutputStyle->note($message);
}
$this->reportRemovedNodes($processResult);
}
@ -129,7 +129,7 @@ final class ConsoleOutputFormatter implements \Rector\ChangesReporting\Contract\
return;
}
$message = \sprintf('%d nodes were removed', $processResult->getRemovedNodeCount());
$this->outputStyle->warning($message);
$this->rectorOutputStyle->warning($message);
}
private function createSuccessMessage(\Rector\Core\ValueObject\ProcessResult $processResult, \Rector\Core\ValueObject\Configuration $configuration) : string
{

View File

@ -10,7 +10,6 @@ use Rector\Core\Logging\CurrentRectorProvider;
use Rector\Core\Provider\CurrentFileProvider;
use Rector\Core\ValueObject\Application\File;
use Rector\PostRector\Contract\Rector\PostRectorInterface;
use RectorPrefix20220211\Symfony\Component\Console\Style\SymfonyStyle;
use RectorPrefix20220211\Symplify\Skipper\Skipper\Skipper;
final class PostFileProcessor
{
@ -33,20 +32,14 @@ final class PostFileProcessor
* @var \Rector\Core\Logging\CurrentRectorProvider
*/
private $currentRectorProvider;
/**
* @readonly
* @var \Symfony\Component\Console\Style\SymfonyStyle
*/
private $symfonyStyle;
/**
* @param PostRectorInterface[] $postRectors
*/
public function __construct(\RectorPrefix20220211\Symplify\Skipper\Skipper\Skipper $skipper, \Rector\Core\Provider\CurrentFileProvider $currentFileProvider, \Rector\Core\Logging\CurrentRectorProvider $currentRectorProvider, \RectorPrefix20220211\Symfony\Component\Console\Style\SymfonyStyle $symfonyStyle, array $postRectors)
public function __construct(\RectorPrefix20220211\Symplify\Skipper\Skipper\Skipper $skipper, \Rector\Core\Provider\CurrentFileProvider $currentFileProvider, \Rector\Core\Logging\CurrentRectorProvider $currentRectorProvider, array $postRectors)
{
$this->skipper = $skipper;
$this->currentFileProvider = $currentFileProvider;
$this->currentRectorProvider = $currentRectorProvider;
$this->symfonyStyle = $symfonyStyle;
$this->postRectors = $this->sortByPriority($postRectors);
}
/**
@ -60,7 +53,6 @@ final class PostFileProcessor
continue;
}
$this->currentRectorProvider->changeCurrentRector($postRector);
$this->notifyPostRector($postRector);
$nodeTraverser = new \PhpParser\NodeTraverser();
$nodeTraverser->addVisitor($postRector);
$stmts = $nodeTraverser->traverse($stmts);
@ -92,12 +84,4 @@ final class PostFileProcessor
$smartFileInfo = $file->getSmartFileInfo();
return $this->skipper->shouldSkipElementAndFileInfo($postRector, $smartFileInfo);
}
private function notifyPostRector(\Rector\PostRector\Contract\Rector\PostRectorInterface $postRector) : void
{
if (!$this->symfonyStyle->isVerbose()) {
return;
}
$message = \sprintf(' [%s] %s', 'post rector', \get_class($postRector));
$this->symfonyStyle->writeln($message);
}
}

View File

@ -5,10 +5,10 @@ namespace Rector\VersionBonding\Application;
use RectorPrefix20220211\Nette\Utils\Strings;
use PHPStan\Php\PhpVersion;
use Rector\Core\Contract\Console\OutputStyleInterface;
use Rector\Core\Contract\Rector\RectorInterface;
use Rector\Core\Php\PhpVersionProvider;
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
use RectorPrefix20220211\Symfony\Component\Console\Style\SymfonyStyle;
final class MissedRectorDueVersionChecker
{
/**
@ -18,13 +18,13 @@ final class MissedRectorDueVersionChecker
private $phpVersionProvider;
/**
* @readonly
* @var \Symfony\Component\Console\Style\SymfonyStyle
* @var \Rector\Core\Contract\Console\OutputStyleInterface
*/
private $symfonyStyle;
public function __construct(\Rector\Core\Php\PhpVersionProvider $phpVersionProvider, \RectorPrefix20220211\Symfony\Component\Console\Style\SymfonyStyle $symfonyStyle)
private $rectorOutputStyle;
public function __construct(\Rector\Core\Php\PhpVersionProvider $phpVersionProvider, \Rector\Core\Contract\Console\OutputStyleInterface $rectorOutputStyle)
{
$this->phpVersionProvider = $phpVersionProvider;
$this->symfonyStyle = $symfonyStyle;
$this->rectorOutputStyle = $rectorOutputStyle;
}
/**
* @param RectorInterface[] $rectors
@ -39,7 +39,7 @@ final class MissedRectorDueVersionChecker
$this->reportWarningMessage($minProjectPhpVersion, $missedRectors);
$this->reportMissedRectors($missedRectors);
$solutionMessage = \sprintf('Do you want to run them? Make "require" > "php" in `composer.json` higher,%sor add "Option::PHP_VERSION_FEATURES" parameter to your `rector.php`.', \PHP_EOL);
$this->symfonyStyle->note($solutionMessage);
$this->rectorOutputStyle->note($solutionMessage);
}
/**
* @param RectorInterface[] $rectors
@ -65,14 +65,14 @@ final class MissedRectorDueVersionChecker
*/
private function reportMissedRectors(array $minPhpVersions) : void
{
if (!$this->symfonyStyle->isVerbose()) {
if (!$this->rectorOutputStyle->isVerbose()) {
return;
}
foreach ($minPhpVersions as $minPhpVersion) {
$phpVersion = new \PHPStan\Php\PhpVersion($minPhpVersion->provideMinPhpVersion());
$shortRectorClass = \RectorPrefix20220211\Nette\Utils\Strings::after(\get_class($minPhpVersion), '\\', -1);
$rectorMessage = \sprintf(' * [%s] %s', $phpVersion->getVersionString(), $shortRectorClass);
$this->symfonyStyle->writeln($rectorMessage);
$this->rectorOutputStyle->writeln($rectorMessage);
}
}
/**
@ -82,6 +82,6 @@ final class MissedRectorDueVersionChecker
{
$phpVersion = new \PHPStan\Php\PhpVersion($minProjectPhpVersion);
$warningMessage = \sprintf('Your project requires min PHP version "%s". %s%d Rector rules defined in your configuration require higher PHP version and will not run,%sto avoid breaking your codebase, use -vvv for detailed info.', $phpVersion->getVersionString(), \PHP_EOL . \PHP_EOL, \count($missedRectors), \PHP_EOL);
$this->symfonyStyle->warning($warningMessage);
$this->rectorOutputStyle->warning($warningMessage);
}
}

View File

@ -7,6 +7,7 @@ use PHPStan\Analyser\NodeScopeResolver;
use Rector\Core\Application\FileDecorator\FileDiffFileDecorator;
use Rector\Core\Application\FileSystem\RemovedAndAddedFilesProcessor;
use Rector\Core\Configuration\Option;
use Rector\Core\Contract\Console\OutputStyleInterface;
use Rector\Core\Contract\Processor\FileProcessorInterface;
use Rector\Core\ValueObject\Application\File;
use Rector\Core\ValueObject\Configuration;
@ -17,7 +18,6 @@ use Rector\FileFormatter\FileFormatter;
use Rector\Parallel\Application\ParallelFileProcessor;
use Rector\Parallel\ValueObject\Bridge;
use RectorPrefix20220211\Symfony\Component\Console\Input\InputInterface;
use RectorPrefix20220211\Symfony\Component\Console\Style\SymfonyStyle;
use RectorPrefix20220211\Symplify\EasyParallel\CpuCoreCountProvider;
use RectorPrefix20220211\Symplify\EasyParallel\Exception\ParallelShouldNotHappenException;
use RectorPrefix20220211\Symplify\EasyParallel\FileSystem\FilePathNormalizer;
@ -59,9 +59,9 @@ final class ApplicationFileProcessor
private $removedAndAddedFilesProcessor;
/**
* @readonly
* @var \Symfony\Component\Console\Style\SymfonyStyle
* @var \Rector\Core\Contract\Console\OutputStyleInterface
*/
private $symfonyStyle;
private $rectorOutputStyle;
/**
* @readonly
* @var \Rector\Core\ValueObjectFactory\Application\FileFactory
@ -110,13 +110,13 @@ final class ApplicationFileProcessor
/**
* @param FileProcessorInterface[] $fileProcessors
*/
public function __construct(\RectorPrefix20220211\Symplify\SmartFileSystem\SmartFileSystem $smartFileSystem, \Rector\Core\Application\FileDecorator\FileDiffFileDecorator $fileDiffFileDecorator, \Rector\FileFormatter\FileFormatter $fileFormatter, \Rector\Core\Application\FileSystem\RemovedAndAddedFilesProcessor $removedAndAddedFilesProcessor, \RectorPrefix20220211\Symfony\Component\Console\Style\SymfonyStyle $symfonyStyle, \Rector\Core\ValueObjectFactory\Application\FileFactory $fileFactory, \PHPStan\Analyser\NodeScopeResolver $nodeScopeResolver, \RectorPrefix20220211\Symplify\PackageBuilder\Yaml\ParametersMerger $parametersMerger, \Rector\Parallel\Application\ParallelFileProcessor $parallelFileProcessor, \RectorPrefix20220211\Symplify\PackageBuilder\Parameter\ParameterProvider $parameterProvider, \RectorPrefix20220211\Symplify\EasyParallel\ScheduleFactory $scheduleFactory, \RectorPrefix20220211\Symplify\EasyParallel\FileSystem\FilePathNormalizer $filePathNormalizer, \RectorPrefix20220211\Symplify\EasyParallel\CpuCoreCountProvider $cpuCoreCountProvider, array $fileProcessors = [])
public function __construct(\RectorPrefix20220211\Symplify\SmartFileSystem\SmartFileSystem $smartFileSystem, \Rector\Core\Application\FileDecorator\FileDiffFileDecorator $fileDiffFileDecorator, \Rector\FileFormatter\FileFormatter $fileFormatter, \Rector\Core\Application\FileSystem\RemovedAndAddedFilesProcessor $removedAndAddedFilesProcessor, \Rector\Core\Contract\Console\OutputStyleInterface $rectorOutputStyle, \Rector\Core\ValueObjectFactory\Application\FileFactory $fileFactory, \PHPStan\Analyser\NodeScopeResolver $nodeScopeResolver, \RectorPrefix20220211\Symplify\PackageBuilder\Yaml\ParametersMerger $parametersMerger, \Rector\Parallel\Application\ParallelFileProcessor $parallelFileProcessor, \RectorPrefix20220211\Symplify\PackageBuilder\Parameter\ParameterProvider $parameterProvider, \RectorPrefix20220211\Symplify\EasyParallel\ScheduleFactory $scheduleFactory, \RectorPrefix20220211\Symplify\EasyParallel\FileSystem\FilePathNormalizer $filePathNormalizer, \RectorPrefix20220211\Symplify\EasyParallel\CpuCoreCountProvider $cpuCoreCountProvider, array $fileProcessors = [])
{
$this->smartFileSystem = $smartFileSystem;
$this->fileDiffFileDecorator = $fileDiffFileDecorator;
$this->fileFormatter = $fileFormatter;
$this->removedAndAddedFilesProcessor = $removedAndAddedFilesProcessor;
$this->symfonyStyle = $symfonyStyle;
$this->rectorOutputStyle = $rectorOutputStyle;
$this->fileFactory = $fileFactory;
$this->nodeScopeResolver = $nodeScopeResolver;
$this->parametersMerger = $parametersMerger;
@ -164,7 +164,7 @@ final class ApplicationFileProcessor
{
if ($configuration->shouldShowProgressBar()) {
$fileCount = \count($files);
$this->symfonyStyle->progressStart($fileCount);
$this->rectorOutputStyle->progressStart($fileCount);
}
$systemErrorsAndFileDiffs = [\Rector\Parallel\ValueObject\Bridge::SYSTEM_ERRORS => [], \Rector\Parallel\ValueObject\Bridge::FILE_DIFFS => []];
foreach ($files as $file) {
@ -177,7 +177,7 @@ final class ApplicationFileProcessor
}
// progress bar +1
if ($configuration->shouldShowProgressBar()) {
$this->symfonyStyle->progressAdvance();
$this->rectorOutputStyle->progressAdvance();
}
}
$this->removedAndAddedFilesProcessor->run($configuration);
@ -244,10 +244,10 @@ final class ApplicationFileProcessor
}
if (!$isProgressBarStarted) {
$fileCount = \count($filePaths);
$this->symfonyStyle->progressStart($fileCount);
$this->rectorOutputStyle->progressStart($fileCount);
$isProgressBarStarted = \true;
}
$this->symfonyStyle->progressAdvance($stepCount);
$this->rectorOutputStyle->progressAdvance($stepCount);
// running in parallel here → nothing else to do
};
$mainScript = $this->resolveCalledRectorBinary();

View File

@ -8,6 +8,7 @@ use Rector\ChangesReporting\ValueObjectFactory\ErrorFactory;
use Rector\Core\Application\FileDecorator\FileDiffFileDecorator;
use Rector\Core\Application\FileProcessor;
use Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector;
use Rector\Core\Contract\Console\OutputStyleInterface;
use Rector\Core\Contract\Processor\FileProcessorInterface;
use Rector\Core\Enum\ApplicationPhase;
use Rector\Core\Exception\ShouldNotHappenException;
@ -20,7 +21,6 @@ use Rector\Core\ValueObject\Reporting\FileDiff;
use Rector\Parallel\ValueObject\Bridge;
use Rector\PostRector\Application\PostFileProcessor;
use Rector\Testing\PHPUnit\StaticPHPUnitEnvironment;
use RectorPrefix20220211\Symfony\Component\Console\Style\SymfonyStyle;
use Throwable;
final class PhpFileProcessor implements \Rector\Core\Contract\Processor\FileProcessorInterface
{
@ -41,9 +41,9 @@ final class PhpFileProcessor implements \Rector\Core\Contract\Processor\FileProc
private $removedAndAddedFilesCollector;
/**
* @readonly
* @var \Symfony\Component\Console\Style\SymfonyStyle
* @var \Rector\Core\Contract\Console\OutputStyleInterface
*/
private $symfonyStyle;
private $rectorOutputStyle;
/**
* @readonly
* @var \Rector\Core\Application\FileDecorator\FileDiffFileDecorator
@ -64,12 +64,12 @@ final class PhpFileProcessor implements \Rector\Core\Contract\Processor\FileProc
* @var \Rector\ChangesReporting\ValueObjectFactory\ErrorFactory
*/
private $errorFactory;
public function __construct(\Rector\Core\PhpParser\Printer\FormatPerservingPrinter $formatPerservingPrinter, \Rector\Core\Application\FileProcessor $fileProcessor, \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector $removedAndAddedFilesCollector, \RectorPrefix20220211\Symfony\Component\Console\Style\SymfonyStyle $symfonyStyle, \Rector\Core\Application\FileDecorator\FileDiffFileDecorator $fileDiffFileDecorator, \Rector\Core\Provider\CurrentFileProvider $currentFileProvider, \Rector\PostRector\Application\PostFileProcessor $postFileProcessor, \Rector\ChangesReporting\ValueObjectFactory\ErrorFactory $errorFactory)
public function __construct(\Rector\Core\PhpParser\Printer\FormatPerservingPrinter $formatPerservingPrinter, \Rector\Core\Application\FileProcessor $fileProcessor, \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector $removedAndAddedFilesCollector, \Rector\Core\Contract\Console\OutputStyleInterface $rectorOutputStyle, \Rector\Core\Application\FileDecorator\FileDiffFileDecorator $fileDiffFileDecorator, \Rector\Core\Provider\CurrentFileProvider $currentFileProvider, \Rector\PostRector\Application\PostFileProcessor $postFileProcessor, \Rector\ChangesReporting\ValueObjectFactory\ErrorFactory $errorFactory)
{
$this->formatPerservingPrinter = $formatPerservingPrinter;
$this->fileProcessor = $fileProcessor;
$this->removedAndAddedFilesCollector = $removedAndAddedFilesCollector;
$this->symfonyStyle = $symfonyStyle;
$this->rectorOutputStyle = $rectorOutputStyle;
$this->fileDiffFileDecorator = $fileDiffFileDecorator;
$this->currentFileProvider = $currentFileProvider;
$this->postFileProcessor = $postFileProcessor;
@ -149,7 +149,7 @@ final class PhpFileProcessor implements \Rector\Core\Contract\Processor\FileProc
$autoloadSystemError = $this->errorFactory->createAutoloadError($analysedCodeException, $file->getSmartFileInfo());
return [$autoloadSystemError];
} catch (\Throwable $throwable) {
if ($this->symfonyStyle->isVerbose() || \Rector\Testing\PHPUnit\StaticPHPUnitEnvironment::isPHPUnitRun()) {
if ($this->rectorOutputStyle->isVerbose() || \Rector\Testing\PHPUnit\StaticPHPUnitEnvironment::isPHPUnitRun()) {
throw $throwable;
}
$systemError = new \Rector\Core\ValueObject\Error\SystemError($throwable->getMessage(), $file->getRelativeFilePath(), $throwable->getLine());
@ -170,12 +170,12 @@ final class PhpFileProcessor implements \Rector\Core\Contract\Processor\FileProc
}
private function notifyPhase(\Rector\Core\ValueObject\Application\File $file, \Rector\Core\Enum\ApplicationPhase $applicationPhase) : void
{
if (!$this->symfonyStyle->isVerbose()) {
if (!$this->rectorOutputStyle->isVerbose()) {
return;
}
$smartFileInfo = $file->getSmartFileInfo();
$relativeFilePath = $smartFileInfo->getRelativeFilePathFromDirectory(\getcwd());
$message = \sprintf('[%s] %s', $applicationPhase, $relativeFilePath);
$this->symfonyStyle->writeln($message);
$this->rectorOutputStyle->writeln($message);
}
}

View File

@ -3,9 +3,9 @@
declare (strict_types=1);
namespace Rector\Core\Application\FileSystem;
use Rector\Core\Contract\Console\OutputStyleInterface;
use Rector\Core\PhpParser\Printer\NodesWithFileDestinationPrinter;
use Rector\Core\ValueObject\Configuration;
use RectorPrefix20220211\Symfony\Component\Console\Style\SymfonyStyle;
use RectorPrefix20220211\Symplify\SmartFileSystem\SmartFileSystem;
/**
* Adds and removes scheduled file
@ -29,15 +29,15 @@ final class RemovedAndAddedFilesProcessor
private $removedAndAddedFilesCollector;
/**
* @readonly
* @var \Symfony\Component\Console\Style\SymfonyStyle
* @var \Rector\Core\Contract\Console\OutputStyleInterface
*/
private $symfonyStyle;
public function __construct(\RectorPrefix20220211\Symplify\SmartFileSystem\SmartFileSystem $smartFileSystem, \Rector\Core\PhpParser\Printer\NodesWithFileDestinationPrinter $nodesWithFileDestinationPrinter, \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector $removedAndAddedFilesCollector, \RectorPrefix20220211\Symfony\Component\Console\Style\SymfonyStyle $symfonyStyle)
private $rectorOutputStyle;
public function __construct(\RectorPrefix20220211\Symplify\SmartFileSystem\SmartFileSystem $smartFileSystem, \Rector\Core\PhpParser\Printer\NodesWithFileDestinationPrinter $nodesWithFileDestinationPrinter, \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector $removedAndAddedFilesCollector, \Rector\Core\Contract\Console\OutputStyleInterface $rectorOutputStyle)
{
$this->smartFileSystem = $smartFileSystem;
$this->nodesWithFileDestinationPrinter = $nodesWithFileDestinationPrinter;
$this->removedAndAddedFilesCollector = $removedAndAddedFilesCollector;
$this->symfonyStyle = $symfonyStyle;
$this->rectorOutputStyle = $rectorOutputStyle;
}
public function run(\Rector\Core\ValueObject\Configuration $configuration) : void
{
@ -52,10 +52,10 @@ final class RemovedAndAddedFilesProcessor
$relativePath = $removedFile->getRelativeFilePathFromDirectory(\getcwd());
if ($configuration->isDryRun()) {
$message = \sprintf('File "%s" will be removed', $relativePath);
$this->symfonyStyle->warning($message);
$this->rectorOutputStyle->warning($message);
} else {
$message = \sprintf('File "%s" was removed', $relativePath);
$this->symfonyStyle->warning($message);
$this->rectorOutputStyle->warning($message);
$this->smartFileSystem->remove($removedFile->getPathname());
}
}
@ -65,11 +65,11 @@ final class RemovedAndAddedFilesProcessor
foreach ($this->removedAndAddedFilesCollector->getAddedFilesWithContent() as $addedFileWithContent) {
if ($configuration->isDryRun()) {
$message = \sprintf('File "%s" will be added', $addedFileWithContent->getFilePath());
$this->symfonyStyle->note($message);
$this->rectorOutputStyle->note($message);
} else {
$this->smartFileSystem->dumpFile($addedFileWithContent->getFilePath(), $addedFileWithContent->getFileContent());
$message = \sprintf('File "%s" was added', $addedFileWithContent->getFilePath());
$this->symfonyStyle->note($message);
$this->rectorOutputStyle->note($message);
}
}
}
@ -79,11 +79,11 @@ final class RemovedAndAddedFilesProcessor
$fileContent = $this->nodesWithFileDestinationPrinter->printNodesWithFileDestination($addedFileWithNode);
if ($configuration->isDryRun()) {
$message = \sprintf('File "%s" will be added', $addedFileWithNode->getFilePath());
$this->symfonyStyle->note($message);
$this->rectorOutputStyle->note($message);
} else {
$this->smartFileSystem->dumpFile($addedFileWithNode->getFilePath(), $fileContent);
$message = \sprintf('File "%s" was added', $addedFileWithNode->getFilePath());
$this->symfonyStyle->note($message);
$this->rectorOutputStyle->note($message);
}
}
}
@ -93,12 +93,12 @@ final class RemovedAndAddedFilesProcessor
$fileContent = $this->nodesWithFileDestinationPrinter->printNodesWithFileDestination($movedFile);
if ($configuration->isDryRun()) {
$message = \sprintf('File "%s" will be moved to "%s"', $movedFile->getFilePath(), $movedFile->getNewFilePath());
$this->symfonyStyle->note($message);
$this->rectorOutputStyle->note($message);
} else {
$this->smartFileSystem->dumpFile($movedFile->getNewFilePath(), $fileContent);
$this->smartFileSystem->remove($movedFile->getFilePath());
$message = \sprintf('File "%s" was moved to "%s"', $movedFile->getFilePath(), $movedFile->getNewFilePath());
$this->symfonyStyle->note($message);
$this->rectorOutputStyle->note($message);
}
}
}

View File

@ -16,11 +16,11 @@ final class VersionResolver
/**
* @var string
*/
public const PACKAGE_VERSION = '03ce06db764aacd8000a2e12818ec33f61f4e2d9';
public const PACKAGE_VERSION = '4f13982aab22c1c904ae5cb46fa6a6338030e768';
/**
* @var string
*/
public const RELEASE_DATE = '2022-02-11 09:31:25';
public const RELEASE_DATE = '2022-02-11 12:06:34';
public static function resolvePackageVersion() : string
{
$process = new \RectorPrefix20220211\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);

View File

@ -4,9 +4,9 @@ declare (strict_types=1);
namespace Rector\Core\Configuration;
use Rector\ChangesReporting\Output\ConsoleOutputFormatter;
use Rector\Core\Contract\Console\OutputStyleInterface;
use Rector\Core\ValueObject\Configuration;
use RectorPrefix20220211\Symfony\Component\Console\Input\InputInterface;
use RectorPrefix20220211\Symfony\Component\Console\Style\SymfonyStyle;
use RectorPrefix20220211\Symplify\PackageBuilder\Parameter\ParameterProvider;
final class ConfigurationFactory
{
@ -17,13 +17,13 @@ final class ConfigurationFactory
private $parameterProvider;
/**
* @readonly
* @var \Symfony\Component\Console\Style\SymfonyStyle
* @var \Rector\Core\Contract\Console\OutputStyleInterface
*/
private $symfonyStyle;
public function __construct(\RectorPrefix20220211\Symplify\PackageBuilder\Parameter\ParameterProvider $parameterProvider, \RectorPrefix20220211\Symfony\Component\Console\Style\SymfonyStyle $symfonyStyle)
private $rectorOutputStyle;
public function __construct(\RectorPrefix20220211\Symplify\PackageBuilder\Parameter\ParameterProvider $parameterProvider, \Rector\Core\Contract\Console\OutputStyleInterface $rectorOutputStyle)
{
$this->parameterProvider = $parameterProvider;
$this->symfonyStyle = $symfonyStyle;
$this->rectorOutputStyle = $rectorOutputStyle;
}
/**
* @param string[] $paths
@ -58,7 +58,7 @@ final class ConfigurationFactory
if ($noProgressBar) {
return \false;
}
if ($this->symfonyStyle->isVerbose()) {
if ($this->rectorOutputStyle->isVerbose()) {
return \false;
}
return $outputFormat === \Rector\ChangesReporting\Output\ConsoleOutputFormatter::NAME;

View File

@ -5,6 +5,7 @@ namespace Rector\Core\Console\Command;
use RectorPrefix20220211\Nette\Utils\Strings;
use Rector\Core\Configuration\Option;
use Rector\Core\Contract\Console\OutputStyleInterface;
use Rector\Core\Contract\Template\TemplateResolverInterface;
use Rector\Core\Exception\Template\TemplateTypeNotFoundException;
use Rector\Core\Php\PhpVersionProvider;
@ -14,7 +15,6 @@ use RectorPrefix20220211\Symfony\Component\Console\Command\Command;
use RectorPrefix20220211\Symfony\Component\Console\Input\InputInterface;
use RectorPrefix20220211\Symfony\Component\Console\Input\InputOption;
use RectorPrefix20220211\Symfony\Component\Console\Output\OutputInterface;
use RectorPrefix20220211\Symfony\Component\Console\Style\SymfonyStyle;
use RectorPrefix20220211\Symplify\SmartFileSystem\FileSystemGuard;
use RectorPrefix20220211\Symplify\SmartFileSystem\SmartFileSystem;
final class InitCommand extends \RectorPrefix20220211\Symfony\Component\Console\Command\Command
@ -31,9 +31,9 @@ final class InitCommand extends \RectorPrefix20220211\Symfony\Component\Console\
private $smartFileSystem;
/**
* @readonly
* @var \Symfony\Component\Console\Style\SymfonyStyle
* @var \Rector\Core\Contract\Console\OutputStyleInterface
*/
private $symfonyStyle;
private $rectorOutputStyle;
/**
* @var TemplateResolverInterface[]
* @readonly
@ -47,11 +47,11 @@ final class InitCommand extends \RectorPrefix20220211\Symfony\Component\Console\
/**
* @param TemplateResolverInterface[] $templateResolvers
*/
public function __construct(\RectorPrefix20220211\Symplify\SmartFileSystem\FileSystemGuard $fileSystemGuard, \RectorPrefix20220211\Symplify\SmartFileSystem\SmartFileSystem $smartFileSystem, \RectorPrefix20220211\Symfony\Component\Console\Style\SymfonyStyle $symfonyStyle, array $templateResolvers, \Rector\Core\Php\PhpVersionProvider $phpVersionProvider)
public function __construct(\RectorPrefix20220211\Symplify\SmartFileSystem\FileSystemGuard $fileSystemGuard, \RectorPrefix20220211\Symplify\SmartFileSystem\SmartFileSystem $smartFileSystem, \Rector\Core\Contract\Console\OutputStyleInterface $rectorOutputStyle, array $templateResolvers, \Rector\Core\Php\PhpVersionProvider $phpVersionProvider)
{
$this->fileSystemGuard = $fileSystemGuard;
$this->smartFileSystem = $smartFileSystem;
$this->symfonyStyle = $symfonyStyle;
$this->rectorOutputStyle = $rectorOutputStyle;
$this->templateResolvers = $templateResolvers;
$this->phpVersionProvider = $phpVersionProvider;
parent::__construct();
@ -69,7 +69,7 @@ final class InitCommand extends \RectorPrefix20220211\Symfony\Component\Console\
$rectorRootFilePath = \getcwd() . '/rector.php';
$doesFileExist = $this->smartFileSystem->exists($rectorRootFilePath);
if ($doesFileExist) {
$this->symfonyStyle->warning('Config file "rector.php" already exists');
$this->rectorOutputStyle->warning('Config file "rector.php" already exists');
} else {
$this->smartFileSystem->copy($rectorTemplateFilePath, $rectorRootFilePath);
$fullPHPVersion = (string) $this->phpVersionProvider->provide();
@ -77,7 +77,7 @@ final class InitCommand extends \RectorPrefix20220211\Symfony\Component\Console\
$fileContent = $this->smartFileSystem->readFile($rectorRootFilePath);
$fileContent = \str_replace('LevelSetList::UP_TO_PHP_XY', \sprintf('LevelSetList::UP_TO_PHP_%d', $phpVersion), $fileContent);
$this->smartFileSystem->dumpFile($rectorRootFilePath, $fileContent);
$this->symfonyStyle->success('"rector.php" config file was added');
$this->rectorOutputStyle->success('"rector.php" config file was added');
}
return \RectorPrefix20220211\Symfony\Component\Console\Command\Command::SUCCESS;
}

View File

@ -10,6 +10,7 @@ use Rector\Core\Autoloading\AdditionalAutoloader;
use Rector\Core\Autoloading\BootstrapFilesIncluder;
use Rector\Core\Configuration\Option;
use Rector\Core\Console\Output\OutputFormatterCollector;
use Rector\Core\Contract\Console\OutputStyleInterface;
use Rector\Core\Contract\Rector\RectorInterface;
use Rector\Core\Exception\ShouldNotHappenException;
use Rector\Core\Reporting\MissingRectorRulesReporter;
@ -24,7 +25,6 @@ use RectorPrefix20220211\Symfony\Component\Console\Application;
use RectorPrefix20220211\Symfony\Component\Console\Command\Command;
use RectorPrefix20220211\Symfony\Component\Console\Input\InputInterface;
use RectorPrefix20220211\Symfony\Component\Console\Output\OutputInterface;
use RectorPrefix20220211\Symfony\Component\Console\Style\SymfonyStyle;
use RectorPrefix20220211\Symplify\PackageBuilder\Console\Command\CommandNaming;
final class ProcessCommand extends \Rector\Core\Console\Command\AbstractProcessCommand
{
@ -80,9 +80,9 @@ final class ProcessCommand extends \Rector\Core\Console\Command\AbstractProcessC
private $outputFormatterCollector;
/**
* @readonly
* @var \Symfony\Component\Console\Style\SymfonyStyle
* @var \Rector\Core\Contract\Console\OutputStyleInterface
*/
private $symfonyStyle;
private $rectorOutputStyle;
/**
* @readonly
* @var \Rector\Core\Util\MemoryLimiter
@ -96,7 +96,7 @@ final class ProcessCommand extends \Rector\Core\Console\Command\AbstractProcessC
/**
* @param RectorInterface[] $rectors
*/
public function __construct(\Rector\Core\Autoloading\AdditionalAutoloader $additionalAutoloader, \Rector\Caching\Detector\ChangedFilesDetector $changedFilesDetector, \Rector\Core\Reporting\MissingRectorRulesReporter $missingRectorRulesReporter, \Rector\Core\Application\ApplicationFileProcessor $applicationFileProcessor, \Rector\Core\Autoloading\BootstrapFilesIncluder $bootstrapFilesIncluder, \Rector\Core\ValueObjectFactory\ProcessResultFactory $processResultFactory, \Rector\Core\StaticReflection\DynamicSourceLocatorDecorator $dynamicSourceLocatorDecorator, \Rector\VersionBonding\Application\MissedRectorDueVersionChecker $missedRectorDueVersionChecker, \Rector\Core\Validation\EmptyConfigurableRectorChecker $emptyConfigurableRectorChecker, \Rector\Core\Console\Output\OutputFormatterCollector $outputFormatterCollector, \RectorPrefix20220211\Symfony\Component\Console\Style\SymfonyStyle $symfonyStyle, \Rector\Core\Util\MemoryLimiter $memoryLimiter, array $rectors)
public function __construct(\Rector\Core\Autoloading\AdditionalAutoloader $additionalAutoloader, \Rector\Caching\Detector\ChangedFilesDetector $changedFilesDetector, \Rector\Core\Reporting\MissingRectorRulesReporter $missingRectorRulesReporter, \Rector\Core\Application\ApplicationFileProcessor $applicationFileProcessor, \Rector\Core\Autoloading\BootstrapFilesIncluder $bootstrapFilesIncluder, \Rector\Core\ValueObjectFactory\ProcessResultFactory $processResultFactory, \Rector\Core\StaticReflection\DynamicSourceLocatorDecorator $dynamicSourceLocatorDecorator, \Rector\VersionBonding\Application\MissedRectorDueVersionChecker $missedRectorDueVersionChecker, \Rector\Core\Validation\EmptyConfigurableRectorChecker $emptyConfigurableRectorChecker, \Rector\Core\Console\Output\OutputFormatterCollector $outputFormatterCollector, \Rector\Core\Contract\Console\OutputStyleInterface $rectorOutputStyle, \Rector\Core\Util\MemoryLimiter $memoryLimiter, array $rectors)
{
$this->additionalAutoloader = $additionalAutoloader;
$this->changedFilesDetector = $changedFilesDetector;
@ -108,7 +108,7 @@ final class ProcessCommand extends \Rector\Core\Console\Command\AbstractProcessC
$this->missedRectorDueVersionChecker = $missedRectorDueVersionChecker;
$this->emptyConfigurableRectorChecker = $emptyConfigurableRectorChecker;
$this->outputFormatterCollector = $outputFormatterCollector;
$this->symfonyStyle = $symfonyStyle;
$this->rectorOutputStyle = $rectorOutputStyle;
$this->memoryLimiter = $memoryLimiter;
$this->rectors = $rectors;
parent::__construct();
@ -129,7 +129,7 @@ final class ProcessCommand extends \Rector\Core\Console\Command\AbstractProcessC
$this->memoryLimiter->adjust($configuration);
// disable console output in case of json output formatter
if ($configuration->getOutputFormat() === \Rector\ChangesReporting\Output\JsonOutputFormatter::NAME) {
$this->symfonyStyle->setVerbosity(\RectorPrefix20220211\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_QUIET);
$this->rectorOutputStyle->setVerbosity(\RectorPrefix20220211\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_QUIET);
}
// register autoloaded and included files
$this->bootstrapFilesIncluder->includeBootstrapFiles();

View File

@ -3,8 +3,8 @@
declare (strict_types=1);
namespace Rector\Core\Console\Output;
use Rector\Core\Console\Style\RectorConsoleOutputStyle;
use Rector\Core\Contract\Console\OutputStyleInterface;
use RectorPrefix20220211\Symfony\Component\Console\Style\SymfonyStyle;
/**
* This services helps to abstract from Symfony, and allow custom output formatters to use this Rector internal class.
* It is very helpful while scoping Rector from analysed project.
@ -13,46 +13,66 @@ final class RectorOutputStyle implements \Rector\Core\Contract\Console\OutputSty
{
/**
* @readonly
* @var \Symfony\Component\Console\Style\SymfonyStyle
* @var \Rector\Core\Console\Style\RectorConsoleOutputStyle
*/
private $symfonyStyle;
public function __construct(\RectorPrefix20220211\Symfony\Component\Console\Style\SymfonyStyle $symfonyStyle)
private $rectorConsoleOutputStyle;
public function __construct(\Rector\Core\Console\Style\RectorConsoleOutputStyle $rectorConsoleOutputStyle)
{
$this->symfonyStyle = $symfonyStyle;
$this->rectorConsoleOutputStyle = $rectorConsoleOutputStyle;
}
public function progressStart(int $fileCount) : void
{
$this->rectorConsoleOutputStyle->createProgressBar($fileCount);
}
public function progressAdvance(int $step = 1) : void
{
$this->rectorConsoleOutputStyle->progressAdvance($step);
}
public function error(string $message) : void
{
$this->symfonyStyle->error($message);
$this->rectorConsoleOutputStyle->error($message);
}
public function warning(string $message) : void
{
$this->symfonyStyle->warning($message);
$this->rectorConsoleOutputStyle->warning($message);
}
public function success(string $message) : void
{
$this->symfonyStyle->success($message);
$this->rectorConsoleOutputStyle->success($message);
}
public function note(string $message) : void
{
$this->symfonyStyle->note($message);
$this->rectorConsoleOutputStyle->note($message);
}
public function title(string $message) : void
{
$this->symfonyStyle->title($message);
$this->rectorConsoleOutputStyle->title($message);
}
public function writeln(string $message) : void
{
$this->symfonyStyle->writeln($message);
$this->rectorConsoleOutputStyle->writeln($message);
}
public function newline(int $count = 1) : void
public function newLine(int $count = 1) : void
{
$this->symfonyStyle->newLine($count);
$this->rectorConsoleOutputStyle->newLine($count);
}
/**
* @param string[] $elements
*/
public function listing(array $elements) : void
{
$this->symfonyStyle->listing($elements);
$this->rectorConsoleOutputStyle->listing($elements);
}
public function isVerbose() : bool
{
return $this->rectorConsoleOutputStyle->isVerbose();
}
public function isDebug() : bool
{
return $this->rectorConsoleOutputStyle->isDebug();
}
public function setVerbosity(int $level) : void
{
$this->rectorConsoleOutputStyle->setVerbosity($level);
}
}

View File

@ -4,10 +4,15 @@ declare (strict_types=1);
namespace Rector\Core\Console\Style;
use RectorPrefix20220211\OndraM\CiDetector\CiDetector;
use RectorPrefix20220211\Symfony\Component\Console\Exception\RuntimeException;
use RectorPrefix20220211\Symfony\Component\Console\Helper\ProgressBar;
use RectorPrefix20220211\Symfony\Component\Console\Style\SymfonyStyle;
final class RectorConsoleOutputStyle extends \RectorPrefix20220211\Symfony\Component\Console\Style\SymfonyStyle
{
/**
* @var mixed|ProgressBar
*/
public $progressBar;
/**
* @var bool|null
*/
@ -25,14 +30,22 @@ final class RectorConsoleOutputStyle extends \RectorPrefix20220211\Symfony\Compo
$progressBar->minSecondsBetweenRedraws(15);
$progressBar->maxSecondsBetweenRedraws(30);
} elseif (\DIRECTORY_SEPARATOR === '\\') {
// windows
$progressBar->minSecondsBetweenRedraws(0.5);
$progressBar->maxSecondsBetweenRedraws(2);
} else {
// *nix
$progressBar->minSecondsBetweenRedraws(0.1);
$progressBar->maxSecondsBetweenRedraws(0.5);
}
$this->progressBar = $progressBar;
return $progressBar;
}
public function progressAdvance(int $step = 1) : void
{
$progressBar = $this->getProgressBar();
$progressBar->advance($step);
}
private function isCiDetected() : bool
{
if ($this->isCiDetected === null) {
@ -41,4 +54,11 @@ final class RectorConsoleOutputStyle extends \RectorPrefix20220211\Symfony\Compo
}
return $this->isCiDetected;
}
private function getProgressBar() : \RectorPrefix20220211\Symfony\Component\Console\Helper\ProgressBar
{
if (!isset($this->progressBar)) {
throw new \RectorPrefix20220211\Symfony\Component\Console\Exception\RuntimeException('The ProgressBar is not started.');
}
return $this->progressBar;
}
}

View File

@ -11,9 +11,14 @@ interface OutputStyleInterface
public function note(string $message) : void;
public function title(string $message) : void;
public function writeln(string $message) : void;
public function newline(int $count = 1) : void;
public function newLine(int $count = 1) : void;
/**
* @param string[] $elements
*/
public function listing(array $elements) : void;
public function isVerbose() : bool;
public function isDebug() : bool;
public function setVerbosity(int $level) : void;
public function progressStart(int $fileCount) : void;
public function progressAdvance(int $step = 1) : void;
}

View File

@ -21,6 +21,7 @@ use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
use Rector\ChangesReporting\ValueObject\RectorWithLineChange;
use Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector;
use Rector\Core\Configuration\CurrentNodeProvider;
use Rector\Core\Contract\Console\OutputStyleInterface;
use Rector\Core\Contract\Rector\PhpRectorInterface;
use Rector\Core\Exception\ShouldNotHappenException;
use Rector\Core\Exclusion\ExclusionManager;
@ -45,7 +46,6 @@ use Rector\NodeTypeResolver\NodeTypeResolver;
use Rector\PostRector\Collector\NodesToAddCollector;
use Rector\PostRector\Collector\NodesToRemoveCollector;
use Rector\StaticTypeMapper\StaticTypeMapper;
use RectorPrefix20220211\Symfony\Component\Console\Style\SymfonyStyle;
use RectorPrefix20220211\Symfony\Contracts\Service\Attribute\Required;
use RectorPrefix20220211\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser;
use RectorPrefix20220211\Symplify\PackageBuilder\Parameter\ParameterProvider;
@ -128,9 +128,9 @@ abstract class AbstractRector extends \PhpParser\NodeVisitorAbstract implements
*/
private $simpleCallableNodeTraverser;
/**
* @var \Symfony\Component\Console\Style\SymfonyStyle
* @var \Rector\Core\Contract\Console\OutputStyleInterface
*/
private $symfonyStyle;
private $rectorOutputStyle;
/**
* @var \Rector\Core\Exclusion\ExclusionManager
*/
@ -178,7 +178,7 @@ abstract class AbstractRector extends \PhpParser\NodeVisitorAbstract implements
/**
* @required
*/
public function autowire(\Rector\PostRector\Collector\NodesToRemoveCollector $nodesToRemoveCollector, \Rector\PostRector\Collector\NodesToAddCollector $nodesToAddCollector, \Rector\NodeRemoval\NodeRemover $nodeRemover, \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector $removedAndAddedFilesCollector, \Rector\Core\PhpParser\Printer\BetterStandardPrinter $betterStandardPrinter, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \RectorPrefix20220211\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\Core\PhpParser\Node\NodeFactory $nodeFactory, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \RectorPrefix20220211\Symfony\Component\Console\Style\SymfonyStyle $symfonyStyle, \Rector\Core\Php\PhpVersionProvider $phpVersionProvider, \Rector\Core\Exclusion\ExclusionManager $exclusionManager, \Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \RectorPrefix20220211\Symplify\PackageBuilder\Parameter\ParameterProvider $parameterProvider, \Rector\Core\Logging\CurrentRectorProvider $currentRectorProvider, \Rector\Core\Configuration\CurrentNodeProvider $currentNodeProvider, \RectorPrefix20220211\Symplify\Skipper\Skipper\Skipper $skipper, \Rector\Core\PhpParser\Node\Value\ValueResolver $valueResolver, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator, \Rector\Core\Provider\CurrentFileProvider $currentFileProvider, \Rector\Core\NodeAnalyzer\ChangedNodeAnalyzer $changedNodeAnalyzer, \Rector\Core\Validation\InfiniteLoopValidator $infiniteLoopValidator, \Rector\Core\ProcessAnalyzer\RectifiedAnalyzer $rectifiedAnalyzer, \Rector\Core\NodeDecorator\CreatedByRuleDecorator $createdByRuleDecorator) : void
public function autowire(\Rector\PostRector\Collector\NodesToRemoveCollector $nodesToRemoveCollector, \Rector\PostRector\Collector\NodesToAddCollector $nodesToAddCollector, \Rector\NodeRemoval\NodeRemover $nodeRemover, \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector $removedAndAddedFilesCollector, \Rector\Core\PhpParser\Printer\BetterStandardPrinter $betterStandardPrinter, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \RectorPrefix20220211\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\Core\PhpParser\Node\NodeFactory $nodeFactory, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\Core\Contract\Console\OutputStyleInterface $rectorOutputStyle, \Rector\Core\Php\PhpVersionProvider $phpVersionProvider, \Rector\Core\Exclusion\ExclusionManager $exclusionManager, \Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \RectorPrefix20220211\Symplify\PackageBuilder\Parameter\ParameterProvider $parameterProvider, \Rector\Core\Logging\CurrentRectorProvider $currentRectorProvider, \Rector\Core\Configuration\CurrentNodeProvider $currentNodeProvider, \RectorPrefix20220211\Symplify\Skipper\Skipper\Skipper $skipper, \Rector\Core\PhpParser\Node\Value\ValueResolver $valueResolver, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator, \Rector\Core\Provider\CurrentFileProvider $currentFileProvider, \Rector\Core\NodeAnalyzer\ChangedNodeAnalyzer $changedNodeAnalyzer, \Rector\Core\Validation\InfiniteLoopValidator $infiniteLoopValidator, \Rector\Core\ProcessAnalyzer\RectifiedAnalyzer $rectifiedAnalyzer, \Rector\Core\NodeDecorator\CreatedByRuleDecorator $createdByRuleDecorator) : void
{
$this->nodesToRemoveCollector = $nodesToRemoveCollector;
$this->nodesToAddCollector = $nodesToAddCollector;
@ -190,7 +190,7 @@ abstract class AbstractRector extends \PhpParser\NodeVisitorAbstract implements
$this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser;
$this->nodeFactory = $nodeFactory;
$this->phpDocInfoFactory = $phpDocInfoFactory;
$this->symfonyStyle = $symfonyStyle;
$this->rectorOutputStyle = $rectorOutputStyle;
$this->phpVersionProvider = $phpVersionProvider;
$this->exclusionManager = $exclusionManager;
$this->staticTypeMapper = $staticTypeMapper;
@ -447,7 +447,7 @@ abstract class AbstractRector extends \PhpParser\NodeVisitorAbstract implements
}
private function printDebugApplying() : void
{
if (!$this->symfonyStyle->isDebug()) {
if (!$this->rectorOutputStyle->isDebug()) {
return;
}
if ($this->previousAppliedClass === static::class) {
@ -455,7 +455,7 @@ abstract class AbstractRector extends \PhpParser\NodeVisitorAbstract implements
}
// prevent spamming with the same class over and over
// indented on purpose to improve log nesting under [refactoring]
$this->symfonyStyle->writeln(' [applying] ' . static::class);
$this->rectorOutputStyle->writeln(' [applying] ' . static::class);
$this->previousAppliedClass = static::class;
}
/**

View File

@ -3,11 +3,11 @@
declare (strict_types=1);
namespace Rector\Core\Reporting;
use Rector\Core\Contract\Console\OutputStyleInterface;
use Rector\Core\Contract\Rector\RectorInterface;
use Rector\PostRector\Contract\Rector\ComplementaryRectorInterface;
use Rector\PostRector\Contract\Rector\PostRectorInterface;
use RectorPrefix20220211\Symfony\Component\Console\Command\Command;
use RectorPrefix20220211\Symfony\Component\Console\Style\SymfonyStyle;
final class MissingRectorRulesReporter
{
/**
@ -17,16 +17,16 @@ final class MissingRectorRulesReporter
private $rectors;
/**
* @readonly
* @var \Symfony\Component\Console\Style\SymfonyStyle
* @var \Rector\Core\Contract\Console\OutputStyleInterface
*/
private $symfonyStyle;
private $rectorOutputStyle;
/**
* @param RectorInterface[] $rectors
*/
public function __construct(array $rectors, \RectorPrefix20220211\Symfony\Component\Console\Style\SymfonyStyle $symfonyStyle)
public function __construct(array $rectors, \Rector\Core\Contract\Console\OutputStyleInterface $rectorOutputStyle)
{
$this->rectors = $rectors;
$this->symfonyStyle = $symfonyStyle;
$this->rectorOutputStyle = $rectorOutputStyle;
}
public function reportIfMissing() : ?int
{
@ -44,16 +44,16 @@ final class MissingRectorRulesReporter
}
public function report() : void
{
$this->symfonyStyle->warning('We could not find any Rector rules to run. You have 2 options to add them:');
$this->symfonyStyle->title('1. Add single rule to "rector.php"');
$this->symfonyStyle->writeln(' $services = $containerConfigurator->services();');
$this->symfonyStyle->writeln(' $services->set(...);');
$this->symfonyStyle->newLine(1);
$this->symfonyStyle->title('2. Add set of rules to "rector.php"');
$this->symfonyStyle->writeln(' $containerConfigurator->import(SetList::...);');
$this->symfonyStyle->newLine(1);
$this->symfonyStyle->title('Missing "rector.php" in your project? Let Rector create it for you');
$this->symfonyStyle->writeln(' vendor/bin/rector init');
$this->symfonyStyle->newLine();
$this->rectorOutputStyle->warning('We could not find any Rector rules to run. You have 2 options to add them:');
$this->rectorOutputStyle->title('1. Add single rule to "rector.php"');
$this->rectorOutputStyle->writeln(' $services = $containerConfigurator->services();');
$this->rectorOutputStyle->writeln(' $services->set(...);');
$this->rectorOutputStyle->newLine(1);
$this->rectorOutputStyle->title('2. Add set of rules to "rector.php"');
$this->rectorOutputStyle->writeln(' $containerConfigurator->import(SetList::...);');
$this->rectorOutputStyle->newLine(1);
$this->rectorOutputStyle->title('Missing "rector.php" in your project? Let Rector create it for you');
$this->rectorOutputStyle->writeln(' vendor/bin/rector init');
$this->rectorOutputStyle->newLine();
}
}

View File

@ -3,9 +3,9 @@
declare (strict_types=1);
namespace Rector\Core\Validation;
use Rector\Core\Contract\Console\OutputStyleInterface;
use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
use Rector\Core\Validation\Collector\EmptyConfigurableRectorCollector;
use RectorPrefix20220211\Symfony\Component\Console\Style\SymfonyStyle;
final class EmptyConfigurableRectorChecker
{
/**
@ -15,13 +15,13 @@ final class EmptyConfigurableRectorChecker
private $emptyConfigurableRectorCollector;
/**
* @readonly
* @var \Symfony\Component\Console\Style\SymfonyStyle
* @var \Rector\Core\Contract\Console\OutputStyleInterface
*/
private $symfonyStyle;
public function __construct(\Rector\Core\Validation\Collector\EmptyConfigurableRectorCollector $emptyConfigurableRectorCollector, \RectorPrefix20220211\Symfony\Component\Console\Style\SymfonyStyle $symfonyStyle)
private $rectorOutputStyle;
public function __construct(\Rector\Core\Validation\Collector\EmptyConfigurableRectorCollector $emptyConfigurableRectorCollector, \Rector\Core\Contract\Console\OutputStyleInterface $rectorOutputStyle)
{
$this->emptyConfigurableRectorCollector = $emptyConfigurableRectorCollector;
$this->symfonyStyle = $symfonyStyle;
$this->rectorOutputStyle = $rectorOutputStyle;
}
public function check() : void
{
@ -31,10 +31,10 @@ final class EmptyConfigurableRectorChecker
}
$this->reportWarningMessage($emptyConfigurableRectorClasses);
$solutionMessage = \sprintf('Do you want to run them?%sConfigure them in `rector.php` with "...->configure(...);"', \PHP_EOL);
$this->symfonyStyle->note($solutionMessage);
if (!$this->symfonyStyle->isVerbose()) {
$this->rectorOutputStyle->note($solutionMessage);
if (!$this->rectorOutputStyle->isVerbose()) {
// ensure there is new line after progress bar and report : "[OK] Rector is done!" with add a space
$this->symfonyStyle->write(' ');
$this->rectorOutputStyle->writeln(' ');
}
}
/**
@ -43,9 +43,9 @@ final class EmptyConfigurableRectorChecker
private function reportWarningMessage(array $emptyConfigurableRectorClasses) : void
{
$warningMessage = \sprintf('Your project contains %d configurable rector rules that are skipped as need to be configured to run.', \count($emptyConfigurableRectorClasses));
$this->symfonyStyle->warning($warningMessage);
$this->rectorOutputStyle->warning($warningMessage);
foreach ($emptyConfigurableRectorClasses as $emptyConfigurableRectorClass) {
$this->symfonyStyle->writeln(' * ' . $emptyConfigurableRectorClass);
$this->rectorOutputStyle->writeln(' * ' . $emptyConfigurableRectorClass);
}
// to take time to absorb it
\sleep(3);

2
vendor/autoload.php vendored
View File

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInitc963080436bba2aacd9637472af1637d::getLoader();
return ComposerAutoloaderInit5276aae4be0394ca6762535405f46b21::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitc963080436bba2aacd9637472af1637d
class ComposerAutoloaderInit5276aae4be0394ca6762535405f46b21
{
private static $loader;
@ -22,15 +22,15 @@ class ComposerAutoloaderInitc963080436bba2aacd9637472af1637d
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitc963080436bba2aacd9637472af1637d', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit5276aae4be0394ca6762535405f46b21', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInitc963080436bba2aacd9637472af1637d', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit5276aae4be0394ca6762535405f46b21', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitc963080436bba2aacd9637472af1637d::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit5276aae4be0394ca6762535405f46b21::getInitializer($loader));
} else {
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
@ -42,12 +42,12 @@ class ComposerAutoloaderInitc963080436bba2aacd9637472af1637d
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInitc963080436bba2aacd9637472af1637d::$files;
$includeFiles = Composer\Autoload\ComposerStaticInit5276aae4be0394ca6762535405f46b21::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequirec963080436bba2aacd9637472af1637d($fileIdentifier, $file);
composerRequire5276aae4be0394ca6762535405f46b21($fileIdentifier, $file);
}
return $loader;
@ -59,7 +59,7 @@ class ComposerAutoloaderInitc963080436bba2aacd9637472af1637d
* @param string $file
* @return void
*/
function composerRequirec963080436bba2aacd9637472af1637d($fileIdentifier, $file)
function composerRequire5276aae4be0394ca6762535405f46b21($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 ComposerStaticInitc963080436bba2aacd9637472af1637d
class ComposerStaticInit5276aae4be0394ca6762535405f46b21
{
public static $files = array (
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
@ -3894,9 +3894,9 @@ class ComposerStaticInitc963080436bba2aacd9637472af1637d
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitc963080436bba2aacd9637472af1637d::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitc963080436bba2aacd9637472af1637d::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitc963080436bba2aacd9637472af1637d::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit5276aae4be0394ca6762535405f46b21::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit5276aae4be0394ca6762535405f46b21::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit5276aae4be0394ca6762535405f46b21::$classMap;
}, null, ClassLoader::class);
}

View File

@ -1808,26 +1808,26 @@
},
{
"name": "react\/promise",
"version": "v2.8.0",
"version_normalized": "2.8.0.0",
"version": "v2.9.0",
"version_normalized": "2.9.0.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/reactphp\/promise.git",
"reference": "f3cff96a19736714524ca0dd1d4130de73dbbbc4"
"reference": "234f8fd1023c9158e2314fa9d7d0e6a83db42910"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/reactphp\/promise\/zipball\/f3cff96a19736714524ca0dd1d4130de73dbbbc4",
"reference": "f3cff96a19736714524ca0dd1d4130de73dbbbc4",
"url": "https:\/\/api.github.com\/repos\/reactphp\/promise\/zipball\/234f8fd1023c9158e2314fa9d7d0e6a83db42910",
"reference": "234f8fd1023c9158e2314fa9d7d0e6a83db42910",
"shasum": ""
},
"require": {
"php": ">=5.4.0"
},
"require-dev": {
"phpunit\/phpunit": "^7.0 || ^6.5 || ^5.7 || ^4.8.36"
"phpunit\/phpunit": "^9.3 || ^5.7 || ^4.8.36"
},
"time": "2020-05-12T15:16:56+00:00",
"time": "2022-02-11T10:27:51+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@ -1845,7 +1845,23 @@
"authors": [
{
"name": "Jan Sorgalla",
"email": "jsorgalla@gmail.com"
"email": "jsorgalla@gmail.com",
"homepage": "https:\/\/sorgalla.com\/"
},
{
"name": "Christian L\u00fcck",
"email": "christian@clue.engineering",
"homepage": "https:\/\/clue.engineering\/"
},
{
"name": "Cees-Jan Kiewiet",
"email": "reactphp@ceesjankiewiet.nl",
"homepage": "https:\/\/wyrihaximus.net\/"
},
{
"name": "Chris Boden",
"email": "cboden@gmail.com",
"homepage": "https:\/\/cboden.dev\/"
}
],
"description": "A lightweight implementation of CommonJS Promises\/A for PHP",
@ -1855,8 +1871,18 @@
],
"support": {
"issues": "https:\/\/github.com\/reactphp\/promise\/issues",
"source": "https:\/\/github.com\/reactphp\/promise\/tree\/v2.8.0"
"source": "https:\/\/github.com\/reactphp\/promise\/tree\/v2.9.0"
},
"funding": [
{
"url": "https:\/\/github.com\/WyriHaximus",
"type": "github"
},
{
"url": "https:\/\/github.com\/clue",
"type": "github"
}
],
"install-path": "..\/react\/promise"
},
{

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,30 @@
CHANGELOG for 2.x
=================
* 2.9.0 (2022-02-11)
* Feature: Support union types and address deprecation of `ReflectionType::getClass()` (PHP 8+).
(#198 by @cdosoftei and @SimonFrings)
```php
$promise->otherwise(function (OverflowException|UnderflowException $e) {
echo 'Error: ' . $e->getMessage() . PHP_EOL;
});
```
* Feature: Support intersection types (PHP 8.1+).
(#195 by @bzikarsky)
```php
$promise->otherwise(function (OverflowException&CacheException $e) {
echo 'Error: ' . $e->getMessage() . PHP_EOL;
});
```
* Improve test suite, use GitHub actions for continuous integration (CI),
update to PHPUnit 9, and add full core team to the license.
(#174, #183, #186, and #201 by @SimonFrings and #211 by @clue)
* 2.8.0 (2020-05-12)
* Mark `FulfilledPromise`, `RejectedPromise` and `LazyPromise` as deprecated for Promise v2 (and remove for Promise v3).

View File

@ -1,4 +1,6 @@
Copyright (c) 2012-2016 Jan Sorgalla
The MIT License (MIT)
Copyright (c) 2012 Jan Sorgalla, Christian Lück, Cees-Jan Kiewiet, Chris Boden
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation

View File

@ -4,8 +4,7 @@ Promise
A lightweight implementation of
[CommonJS Promises/A](http://wiki.commonjs.org/wiki/Promises/A) for PHP.
[![Build Status](https://travis-ci.org/reactphp/promise.svg?branch=master)](http://travis-ci.org/reactphp/promise)
[![Coverage Status](https://coveralls.io/repos/github/reactphp/promise/badge.svg?branch=master)](https://coveralls.io/github/reactphp/promise?branch=master)
[![CI status](https://github.com/reactphp/promise/workflows/CI/badge.svg?branch=2.x)](https://github.com/reactphp/promise/actions)
Table of Contents
-----------------
@ -850,15 +849,14 @@ This project follows [SemVer](https://semver.org/).
This will install the latest supported version:
```bash
$ composer require react/promise:^2.8
$ composer require react/promise:^2.9
```
See also the [CHANGELOG](CHANGELOG.md) for details about version upgrades.
This project aims to run on any platform and thus does not require any PHP
extensions and supports running on legacy PHP 5.4 through current PHP 7+ and HHVM.
It's *highly recommended to use PHP 7+* for this project due to its vast
performance improvements.
extensions and supports running on legacy PHP 5.4 through current PHP 8+ and HHVM.
It's *highly recommended to use the latest supported PHP version* for this project.
Credits
-------

View File

@ -5,14 +5,30 @@
"authors": [
{
"name": "Jan Sorgalla",
"homepage": "https:\/\/sorgalla.com\/",
"email": "jsorgalla@gmail.com"
},
{
"name": "Christian L\u00fcck",
"homepage": "https:\/\/clue.engineering\/",
"email": "christian@clue.engineering"
},
{
"name": "Cees-Jan Kiewiet",
"homepage": "https:\/\/wyrihaximus.net\/",
"email": "reactphp@ceesjankiewiet.nl"
},
{
"name": "Chris Boden",
"homepage": "https:\/\/cboden.dev\/",
"email": "cboden@gmail.com"
}
],
"require": {
"php": ">=5.4.0"
},
"require-dev": {
"phpunit\/phpunit": "^7.0 || ^6.5 || ^5.7 || ^4.8.36"
"phpunit\/phpunit": "^9.3 || ^5.7 || ^4.8.36"
},
"autoload": {
"psr-4": {

View File

@ -275,8 +275,54 @@ function _checkTypehint(callable $callback, $object)
return \true;
}
$expectedException = $parameters[0];
if (!$expectedException->getClass()) {
// PHP before v8 used an easy API:
if (\PHP_VERSION_ID < 70100 || \defined('HHVM_VERSION')) {
if (!$expectedException->getClass()) {
return \true;
}
return $expectedException->getClass()->isInstance($object);
}
// Extract the type of the argument and handle different possibilities
$type = $expectedException->getType();
$isTypeUnion = \true;
$types = [];
switch (\true) {
case $type === null:
break;
case $type instanceof \ReflectionNamedType:
$types = [$type];
break;
case $type instanceof \RectorPrefix20220211\ReflectionIntersectionType:
$isTypeUnion = \false;
case $type instanceof \ReflectionUnionType:
$types = $type->getTypes();
break;
default:
throw new \LogicException('Unexpected return value of ReflectionParameter::getType');
}
// If there is no type restriction, it matches
if (empty($types)) {
return \true;
}
return $expectedException->getClass()->isInstance($object);
foreach ($types as $type) {
if (!$type instanceof \ReflectionNamedType) {
throw new \LogicException('This implementation does not support groups of intersection or union types');
}
// A named-type can be either a class-name or a built-in type like string, int, array, etc.
$matches = $type->isBuiltin() && \gettype($object) === $type->getName() || (new \ReflectionClass($type->getName()))->isInstance($object);
// If we look for a single match (union), we can return early on match
// If we look for a full match (intersection), we can return early on mismatch
if ($matches) {
if ($isTypeUnion) {
return \true;
}
} else {
if (!$isTypeUnion) {
return \false;
}
}
}
// If we look for a single match (union) and did not return early, we matched no type and are false
// If we look for a full match (intersection) and did not return early, we matched all types and are true
return $isTypeUnion ? \false : \true;
}

View File

@ -9,8 +9,8 @@ $loader = require_once __DIR__.'/autoload.php';
if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) {
spl_autoload_call('RectorPrefix20220211\AutoloadIncluder');
}
if (!class_exists('ComposerAutoloaderInitc963080436bba2aacd9637472af1637d', false) && !interface_exists('ComposerAutoloaderInitc963080436bba2aacd9637472af1637d', false) && !trait_exists('ComposerAutoloaderInitc963080436bba2aacd9637472af1637d', false)) {
spl_autoload_call('RectorPrefix20220211\ComposerAutoloaderInitc963080436bba2aacd9637472af1637d');
if (!class_exists('ComposerAutoloaderInit5276aae4be0394ca6762535405f46b21', false) && !interface_exists('ComposerAutoloaderInit5276aae4be0394ca6762535405f46b21', false) && !trait_exists('ComposerAutoloaderInit5276aae4be0394ca6762535405f46b21', false)) {
spl_autoload_call('RectorPrefix20220211\ComposerAutoloaderInit5276aae4be0394ca6762535405f46b21');
}
if (!class_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !interface_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !trait_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false)) {
spl_autoload_call('RectorPrefix20220211\Helmich\TypoScriptParser\Parser\AST\Statement');
@ -71,9 +71,9 @@ if (!function_exists('print_node')) {
return \RectorPrefix20220211\print_node(...func_get_args());
}
}
if (!function_exists('composerRequirec963080436bba2aacd9637472af1637d')) {
function composerRequirec963080436bba2aacd9637472af1637d() {
return \RectorPrefix20220211\composerRequirec963080436bba2aacd9637472af1637d(...func_get_args());
if (!function_exists('composerRequire5276aae4be0394ca6762535405f46b21')) {
function composerRequire5276aae4be0394ca6762535405f46b21() {
return \RectorPrefix20220211\composerRequire5276aae4be0394ca6762535405f46b21(...func_get_args());
}
}
if (!function_exists('scanPath')) {