Updated Rector to commit b2d76bd6eff80326b8f89a061f44b06cf90ba49a

b2d76bd6ef Improve config builder + add withAttributesSets() method (#5509)
This commit is contained in:
Tomas Votruba 2024-01-27 12:22:01 +00:00
parent b6bd629be8
commit 120a7594fb
3 changed files with 46 additions and 33 deletions

View File

@ -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
*/

View File

@ -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<CacheStorageInterface>|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<CacheStorageInterface> $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
*/

View File

@ -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
{