From 120a7594fb53c4a1f21959c299d00a75c460e5d7 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sat, 27 Jan 2024 12:22:01 +0000 Subject: [PATCH] Updated Rector to commit b2d76bd6eff80326b8f89a061f44b06cf90ba49a https://github.com/rectorphp/rector-src/commit/b2d76bd6eff80326b8f89a061f44b06cf90ba49a Improve config builder + add withAttributesSets() method (#5509) --- src/Application/VersionResolver.php | 4 +- src/Configuration/RectorConfigBuilder.php | 73 +++++++++++-------- .../utils/rector/src/Rector/__Name__.php | 2 +- 3 files changed, 46 insertions(+), 33 deletions(-) diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 91c0ad7a304..3be9f6fa8d3 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -19,12 +19,12 @@ final class VersionResolver * @api * @var string */ - public const PACKAGE_VERSION = '1fe8f3a7694b7fad2e6fee66b575fe2e05738824'; + public const PACKAGE_VERSION = 'b2d76bd6eff80326b8f89a061f44b06cf90ba49a'; /** * @api * @var string */ - public const RELEASE_DATE = '2024-01-27 12:01:46'; + public const RELEASE_DATE = '2024-01-27 13:19:51'; /** * @var int */ diff --git a/src/Configuration/RectorConfigBuilder.php b/src/Configuration/RectorConfigBuilder.php index 67f46b8a446..e81870416a0 100644 --- a/src/Configuration/RectorConfigBuilder.php +++ b/src/Configuration/RectorConfigBuilder.php @@ -6,7 +6,13 @@ namespace Rector\Configuration; use Rector\Caching\Contract\ValueObject\Storage\CacheStorageInterface; use Rector\Config\RectorConfig; use Rector\Contract\Rector\RectorInterface; +use Rector\Doctrine\Set\DoctrineSetList; +use Rector\PHPUnit\Set\PHPUnitSetList; use Rector\Set\ValueObject\SetList; +use Rector\Symfony\Set\FOSRestSetList; +use Rector\Symfony\Set\JMSSetList; +use Rector\Symfony\Set\SensiolabsSetList; +use Rector\Symfony\Set\SymfonySetList; use Rector\ValueObject\PhpVersion; use RectorPrefix202401\Symfony\Component\Finder\Finder; /** @@ -107,10 +113,6 @@ final class RectorConfigBuilder * @var int */ private $indentSize = 4; - /** - * @var string|null - */ - private $phpstanConfig; /** * @var string[] */ @@ -162,9 +164,6 @@ final class RectorConfigBuilder if ($this->indentChar !== ' ' || $this->indentSize !== 4) { $rectorConfig->indent($this->indentChar, $this->indentSize); } - if ($this->phpstanConfig !== null) { - $rectorConfig->phpstanConfig($this->phpstanConfig); - } if ($this->phpstanConfigs !== []) { $rectorConfig->phpstanConfigs($this->phpstanConfigs); } @@ -213,6 +212,37 @@ final class RectorConfigBuilder $this->sets = \array_merge($this->sets, $sets); return $this; } + /** + * Upgrade your annotations to attributes + */ + public function withAttributesSets(bool $symfony = \false, bool $doctrine = \false, bool $mongoDb = \false, bool $gedmo = \false, bool $phpunit = \false, bool $fosRest = \false, bool $jms = \false, bool $sensiolabs = \false) : self + { + if ($symfony) { + $this->sets[] = SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES; + } + if ($doctrine) { + $this->sets[] = DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES; + } + if ($mongoDb) { + $this->sets[] = DoctrineSetList::MONGODB__ANNOTATIONS_TO_ATTRIBUTES; + } + if ($gedmo) { + $this->sets[] = DoctrineSetList::GEDMO_ANNOTATIONS_TO_ATTRIBUTES; + } + if ($phpunit) { + $this->sets[] = PHPUnitSetList::ANNOTATIONS_TO_ATTRIBUTES; + } + if ($fosRest) { + $this->sets[] = FOSRestSetList::ANNOTATIONS_TO_ATTRIBUTES; + } + if ($jms) { + $this->sets[] = JMSSetList::ANNOTATIONS_TO_ATTRIBUTES; + } + if ($sensiolabs) { + $this->sets[] = SensiolabsSetList::ANNOTATIONS_TO_ATTRIBUTES; + } + return $this; + } public function withPreparedSets(bool $deadCode = \false, bool $codeQuality = \false, bool $codingStyle = \false, bool $typeDeclarations = \false, bool $privatization = \false, bool $naming = \false, bool $instanceOf = \false, bool $earlyReturn = \false, bool $strictBooleans = \false) : self { if ($deadCode) { @@ -260,18 +290,14 @@ final class RectorConfigBuilder $this->fileExtensions = $fileExtensions; return $this; } - public function withCacheDirectory(string $cacheDirectory, ?string $containerCacheDirectory = null) : self + /** + * @param class-string|null $cacheClass + */ + public function withCache(?string $cacheDirectory = null, ?string $cacheClass = null, ?string $containerCacheDirectory = null) : self { $this->cacheDirectory = $cacheDirectory; - $this->containerCacheDirectory = $containerCacheDirectory; - return $this; - } - /** - * @param class-string $cacheClass - */ - public function withClassCache(string $cacheClass) : self - { $this->cacheClass = $cacheClass; + $this->containerCacheDirectory = $containerCacheDirectory; return $this; } /** @@ -302,19 +328,11 @@ final class RectorConfigBuilder $this->parallel = \false; return $this; } - public function withImportNames(bool $importNames = \true, bool $importDocBlockNames = \true) : self + public function withImportNames(bool $importNames = \true, bool $importDocBlockNames = \true, bool $importShortClasses = \true, bool $removeUnusedImports = \false) : self { $this->importNames = $importNames; $this->importDocBlockNames = $importDocBlockNames; - return $this; - } - public function withImporShortClasses(bool $importShortClasses = \true) : self - { $this->importShortClasses = $importShortClasses; - return $this; - } - public function withRemoveUnusedImports(bool $removeUnusedImports = \false) : self - { $this->removeUnusedImports = $removeUnusedImports; return $this; } @@ -350,11 +368,6 @@ final class RectorConfigBuilder $this->bootstrapFiles = $bootstrapFiles; return $this; } - public function withPHPStanConfig(string $phpstanConfig) : self - { - $this->phpstanConfig = $phpstanConfig; - return $this; - } /** * @param string[] $phpstanConfigs */ diff --git a/templates/custom-rule/utils/rector/src/Rector/__Name__.php b/templates/custom-rule/utils/rector/src/Rector/__Name__.php index fd7c21e7c81..f3b9e64e45e 100644 --- a/templates/custom-rule/utils/rector/src/Rector/__Name__.php +++ b/templates/custom-rule/utils/rector/src/Rector/__Name__.php @@ -10,7 +10,7 @@ use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** - * @see \rector\tests\Rector\__Name__\__Name__Test + * @see \Utils\Rector\Tests\Rector\__Name__\__Name__Test */ final class __Name__ extends AbstractRector {