add docblock on downgrade by default (#4799)

* add docblock on downgrade by default

* update docs

* drop no docblock test
This commit is contained in:
Tomas Votruba 2020-12-05 23:33:27 +01:00 committed by GitHub
parent 18fdd3313a
commit dc61d2fecf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
36 changed files with 233 additions and 705 deletions

View File

@ -2428,7 +2428,7 @@ return new TryCatch($tryStmts, [$catch]);
```php
try {
echo 'one';
} catch (\CatchedType) {
} catch (CatchedType) {
echo 'two';
}
```

View File

@ -1,4 +1,4 @@
# 633 Rules Overview
# 639 Rules Overview
<br>
@ -12,7 +12,7 @@
- [Carbon](#carbon) (2)
- [CodeQuality](#codequality) (61)
- [CodeQuality](#codequality) (62)
- [CodingStyle](#codingstyle) (33)
@ -34,11 +34,11 @@
- [DowngradePhp72](#downgradephp72) (2)
- [DowngradePhp73](#downgradephp73) (2)
- [DowngradePhp73](#downgradephp73) (3)
- [DowngradePhp74](#downgradephp74) (9)
- [DowngradePhp80](#downgradephp80) (8)
- [DowngradePhp80](#downgradephp80) (10)
- [FileSystemRector](#filesystemrector) (1)
@ -108,7 +108,7 @@
- [Php74](#php74) (15)
- [Php80](#php80) (13)
- [Php80](#php80) (15)
- [PhpDeglobalize](#phpdeglobalize) (1)
@ -307,12 +307,8 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services->set(MoveValueObjectsToValueObjectDirectoryRector::class)
->call('configure', [[
MoveValueObjectsToValueObjectDirectoryRector::TYPES => [
'ValueObjectInterfaceClassName',
],
MoveValueObjectsToValueObjectDirectoryRector::SUFFIXES => [
'Search',
],
MoveValueObjectsToValueObjectDirectoryRector::TYPES => ['ValueObjectInterfaceClassName'],
MoveValueObjectsToValueObjectDirectoryRector::SUFFIXES => ['Search'],
MoveValueObjectsToValueObjectDirectoryRector::ENABLE_VALUE_OBJECT_GUESSING => true,
]]);
};
@ -918,6 +914,27 @@ Change multiple null compares to ?? queue
<br>
### DateTimeToDateTimeInterfaceRector
Changes DateTime type-hint to DateTimeInterface
- class: `Rector\CodeQuality\Rector\ClassMethod\DateTimeToDateTimeInterfaceRector`
```diff
class SomeClass {
- public function methodWithDateTime(\DateTime $dateTime)
+ /**
+ * @param \DateTime|\DateTimeImmutable $dateTime
+ */
+ public function methodWithDateTime(\DateTimeInterface $dateTime)
{
return true;
}
}
```
<br>
### ExplicitBoolCompareRector
Make if conditions more explicit
@ -2296,7 +2313,7 @@ return static function (ContainerConfigurator $containerConfigurator): void {
### SplitDoubleAssignRector
Split multiple inline assigns to `each` own lines default value, to prevent undefined array issues
Split multiple inline assigns to each own lines default value, to prevent undefined array issues
- class: `Rector\CodingStyle\Rector\Assign\SplitDoubleAssignRector`
@ -4883,26 +4900,8 @@ Downgrade class constant visibility
Remove the iterable pseudo type params, add `@param` tags instead
:wrench: **configure it!**
- class: `Rector\DowngradePhp71\Rector\FunctionLike\DowngradeIterablePseudoTypeParamDeclarationRector`
```php
use Rector\DowngradePhp71\Rector\FunctionLike\DowngradeIterablePseudoTypeParamDeclarationRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(DowngradeIterablePseudoTypeParamDeclarationRector::class)
->call('configure', [[
DowngradeIterablePseudoTypeParamDeclarationRector::ADD_DOC_BLOCK => true,
]]);
};
```
```diff
<?php
@ -4925,26 +4924,8 @@ return static function (ContainerConfigurator $containerConfigurator): void {
Remove returning iterable pseud type, add a `@return` tag instead
:wrench: **configure it!**
- class: `Rector\DowngradePhp71\Rector\FunctionLike\DowngradeIterablePseudoTypeReturnDeclarationRector`
```php
use Rector\DowngradePhp71\Rector\FunctionLike\DowngradeIterablePseudoTypeReturnDeclarationRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(DowngradeIterablePseudoTypeReturnDeclarationRector::class)
->call('configure', [[
DowngradeIterablePseudoTypeReturnDeclarationRector::ADD_DOC_BLOCK => true,
]]);
};
```
```diff
<?php
@ -4967,26 +4948,8 @@ return static function (ContainerConfigurator $containerConfigurator): void {
Remove the nullable type params, add `@param` tags instead
:wrench: **configure it!**
- class: `Rector\DowngradePhp71\Rector\FunctionLike\DowngradeNullableTypeParamDeclarationRector`
```php
use Rector\DowngradePhp71\Rector\FunctionLike\DowngradeNullableTypeParamDeclarationRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(DowngradeNullableTypeParamDeclarationRector::class)
->call('configure', [[
DowngradeNullableTypeParamDeclarationRector::ADD_DOC_BLOCK => true,
]]);
};
```
```diff
<?php
@ -5009,26 +4972,8 @@ return static function (ContainerConfigurator $containerConfigurator): void {
Remove returning nullable types, add a `@return` tag instead
:wrench: **configure it!**
- class: `Rector\DowngradePhp71\Rector\FunctionLike\DowngradeNullableTypeReturnDeclarationRector`
```php
use Rector\DowngradePhp71\Rector\FunctionLike\DowngradeNullableTypeReturnDeclarationRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(DowngradeNullableTypeReturnDeclarationRector::class)
->call('configure', [[
DowngradeNullableTypeReturnDeclarationRector::ADD_DOC_BLOCK => true,
]]);
};
```
```diff
<?php
@ -5074,26 +5019,8 @@ Downgrade single one | separated to multi catch exception
Remove the 'void' function type, add a `@return` tag instead
:wrench: **configure it!**
- class: `Rector\DowngradePhp71\Rector\FunctionLike\DowngradeVoidTypeReturnDeclarationRector`
```php
use Rector\DowngradePhp71\Rector\FunctionLike\DowngradeVoidTypeReturnDeclarationRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(DowngradeVoidTypeReturnDeclarationRector::class)
->call('configure', [[
DowngradeVoidTypeReturnDeclarationRector::ADD_DOC_BLOCK => true,
]]);
};
```
```diff
<?php
@ -5118,26 +5045,8 @@ return static function (ContainerConfigurator $containerConfigurator): void {
Remove the 'object' param type, add a `@param` tag instead
:wrench: **configure it!**
- class: `Rector\DowngradePhp72\Rector\FunctionLike\DowngradeParamObjectTypeDeclarationRector`
```php
use Rector\DowngradePhp72\Rector\FunctionLike\DowngradeParamObjectTypeDeclarationRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(DowngradeParamObjectTypeDeclarationRector::class)
->call('configure', [[
DowngradeParamObjectTypeDeclarationRector::ADD_DOC_BLOCK => true,
]]);
};
```
```diff
<?php
@ -5159,26 +5068,8 @@ return static function (ContainerConfigurator $containerConfigurator): void {
Remove the 'object' function type, add a `@return` tag instead
:wrench: **configure it!**
- class: `Rector\DowngradePhp72\Rector\FunctionLike\DowngradeReturnObjectTypeDeclarationRector`
```php
use Rector\DowngradePhp72\Rector\FunctionLike\DowngradeReturnObjectTypeDeclarationRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(DowngradeReturnObjectTypeDeclarationRector::class)
->call('configure', [[
DowngradeReturnObjectTypeDeclarationRector::ADD_DOC_BLOCK => true,
]]);
};
```
```diff
<?php
@ -5250,6 +5141,28 @@ Convert the list reference assignment to its equivalent PHP 7.2 code
<br>
### DowngradeTrailingCommasInFunctionCallsRector
Remove trailing commas in function calls
- class: `Rector\DowngradePhp73\Rector\FuncCall\DowngradeTrailingCommasInFunctionCallsRector`
```diff
class SomeClass
{
public function __construct(string $value)
{
$compacted = compact(
'posts',
- 'units',
+ 'units'
);
}
}
```
<br>
## DowngradePhp74
### ArrowFunctionToAnonymousFunctionRector
@ -5326,26 +5239,8 @@ Replace array spread with `array_merge` function
Remove contravariant argument type declarations
:wrench: **configure it!**
- class: `Rector\DowngradePhp74\Rector\ClassMethod\DowngradeContravariantArgumentTypeRector`
```php
use Rector\DowngradePhp74\Rector\ClassMethod\DowngradeContravariantArgumentTypeRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(DowngradeContravariantArgumentTypeRector::class)
->call('configure', [[
DowngradeContravariantArgumentTypeRector::ADD_DOC_BLOCK => true,
]]);
};
```
```diff
class ParentType {}
class ChildType extends ParentType {}
@ -5467,26 +5362,8 @@ Convert 2nd param to `strip_tags` from array to string
Changes property type definition from type definitions to `@var` annotations.
:wrench: **configure it!**
- class: `Rector\DowngradePhp74\Rector\Property\DowngradeTypedPropertyRector`
```php
use Rector\DowngradePhp74\Rector\Property\DowngradeTypedPropertyRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(DowngradeTypedPropertyRector::class)
->call('configure', [[
DowngradeTypedPropertyRector::ADD_DOC_BLOCK => true,
]]);
};
```
```diff
class SomeClass
{
@ -5521,30 +5398,69 @@ Change `$object::class` to get_class($object)
<br>
### DowngradeMatchToSwitchRector
Downgrade `match()` to `switch()`
- class: `Rector\DowngradePhp80\Rector\Expression\DowngradeMatchToSwitchRector`
```diff
class SomeClass
{
public function run()
{
- $message = match ($statusCode) {
- 200, 300 => null,
- 400 => 'not found',
- default => 'unknown status code',
- };
+ switch ($statusCode) {
+ case 200:
+ case 300:
+ $message = null;
+ break;
+ case 400:
+ $message = 'not found';
+ break;
+ default:
+ $message = 'unknown status code';
+ break;
+ }
}
}
```
<br>
### DowngradeNonCapturingCatchesRector
Downgrade catch () without variable to one
- class: `Rector\DowngradePhp80\Rector\Catch_\DowngradeNonCapturingCatchesRector`
```diff
class SomeClass
{
public function run()
{
try {
// code
- } catch (\Exception) {
+ } catch (\Exception $exception) {
// error
}
}
}
```
<br>
### DowngradeParamMixedTypeDeclarationRector
Remove the 'mixed' param type, add a `@param` tag instead
:wrench: **configure it!**
- class: `Rector\DowngradePhp80\Rector\FunctionLike\DowngradeParamMixedTypeDeclarationRector`
```php
use Rector\DowngradePhp80\Rector\FunctionLike\DowngradeParamMixedTypeDeclarationRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(DowngradeParamMixedTypeDeclarationRector::class)
->call('configure', [[
DowngradeParamMixedTypeDeclarationRector::ADD_DOC_BLOCK => true,
]]);
};
```
```diff
<?php
@ -5587,26 +5503,8 @@ Change constructor property promotion to property asssign
Remove the 'mixed' function type, add a `@return` tag instead
:wrench: **configure it!**
- class: `Rector\DowngradePhp80\Rector\FunctionLike\DowngradeReturnMixedTypeDeclarationRector`
```php
use Rector\DowngradePhp80\Rector\FunctionLike\DowngradeReturnMixedTypeDeclarationRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(DowngradeReturnMixedTypeDeclarationRector::class)
->call('configure', [[
DowngradeReturnMixedTypeDeclarationRector::ADD_DOC_BLOCK => true,
]]);
};
```
```diff
<?php
@ -5632,26 +5530,8 @@ return static function (ContainerConfigurator $containerConfigurator): void {
Remove the 'static' function type, add a `@return` tag instead
:wrench: **configure it!**
- class: `Rector\DowngradePhp80\Rector\FunctionLike\DowngradeReturnStaticTypeDeclarationRector`
```php
use Rector\DowngradePhp80\Rector\FunctionLike\DowngradeReturnStaticTypeDeclarationRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(DowngradeReturnStaticTypeDeclarationRector::class)
->call('configure', [[
DowngradeReturnStaticTypeDeclarationRector::ADD_DOC_BLOCK => true,
]]);
};
```
```diff
<?php
@ -5674,26 +5554,8 @@ return static function (ContainerConfigurator $containerConfigurator): void {
Remove the union type params, add `@param` tags instead
:wrench: **configure it!**
- class: `Rector\DowngradePhp80\Rector\FunctionLike\DowngradeUnionTypeParamDeclarationRector`
```php
use Rector\DowngradePhp80\Rector\FunctionLike\DowngradeUnionTypeParamDeclarationRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(DowngradeUnionTypeParamDeclarationRector::class)
->call('configure', [[
DowngradeUnionTypeParamDeclarationRector::ADD_DOC_BLOCK => true,
]]);
};
```
```diff
<?php
@ -5716,26 +5578,8 @@ return static function (ContainerConfigurator $containerConfigurator): void {
Remove returning union types, add a `@return` tag instead
:wrench: **configure it!**
- class: `Rector\DowngradePhp80\Rector\FunctionLike\DowngradeUnionTypeReturnDeclarationRector`
```php
use Rector\DowngradePhp80\Rector\FunctionLike\DowngradeUnionTypeReturnDeclarationRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(DowngradeUnionTypeReturnDeclarationRector::class)
->call('configure', [[
DowngradeUnionTypeReturnDeclarationRector::ADD_DOC_BLOCK => true,
]]);
};
```
```diff
<?php
@ -5761,26 +5605,8 @@ return static function (ContainerConfigurator $containerConfigurator): void {
Removes union type property type definition, adding `@var` annotations instead.
:wrench: **configure it!**
- class: `Rector\DowngradePhp80\Rector\Property\DowngradeUnionTypeTypedPropertyRector`
```php
use Rector\DowngradePhp80\Rector\Property\DowngradeUnionTypeTypedPropertyRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(DowngradeUnionTypeTypedPropertyRector::class)
->call('configure', [[
DowngradeUnionTypeTypedPropertyRector::ADD_DOC_BLOCK => true,
]]);
};
```
```diff
class SomeClass
{
@ -6430,7 +6256,10 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services->set(InjectAnnotationClassRector::class)
->call('configure', [[
InjectAnnotationClassRector::ANNOTATION_CLASSES => ['DI\Annotation\Inject', 'JMS\DiExtraBundle\Annotation\Inject'],
InjectAnnotationClassRector::ANNOTATION_CLASSES => [
'DI\Annotation\Inject',
'JMS\DiExtraBundle\Annotation\Inject',
],
]]);
};
```
@ -7441,10 +7270,7 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services->set(AddTopIncludeRector::class)
->call('configure', [[
AddTopIncludeRector::AUTOLOAD_FILE_PATH => '/../autoloader.php',
AddTopIncludeRector::PATTERNS => [
'pat*/*/?ame.php',
'somepath/?ame.php',
],
AddTopIncludeRector::PATTERNS => ['pat*/*/?ame.php', 'somepath/?ame.php'],
]]);
};
```
@ -12492,6 +12318,24 @@ Change simple property init and assign to constructor promotion
<br>
### FinalPrivateToPrivateVisibilityRector
Changes method visibility from final private to only private
- class: `Rector\Php80\Rector\ClassMethod\FinalPrivateToPrivateVisibilityRector`
```diff
class SomeClass
{
- final private function getter() {
+ private function getter() {
return $this;
}
}
```
<br>
### GetDebugTypeRector
Change ternary type resolve to `get_debug_type()`
@ -12556,6 +12400,24 @@ Remove unused variable in `catch()`
<br>
### SetStateToStaticRector
Adds static visibility to `__set_state()` methods
- class: `Rector\Php80\Rector\ClassMethod\SetStateToStaticRector`
```diff
class SomeClass
{
- public function __set_state($properties) {
+ public static function __set_state($properties) {
}
}
```
<br>
### StrContainsRector
Replace `strpos()` !== false and `strstr()` with `str_contains()`
@ -13392,7 +13254,7 @@ return static function (ContainerConfigurator $containerConfigurator): void {
### PassFactoryToUniqueObjectRector
Convert new `X/Static::call()` to factories in entities, pass them via constructor to `each` other
Convert new `X/Static::call()` to factories in entities, pass them via constructor to each other
:wrench: **configure it!**
@ -15193,7 +15055,10 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services->set(GetToConstructorInjectionRector::class)
->call('configure', [[
GetToConstructorInjectionRector::GET_METHOD_AWARE_TYPES => ['SymfonyControllerClassName', 'GetTraitClassName'],
GetToConstructorInjectionRector::GET_METHOD_AWARE_TYPES => [
'SymfonyControllerClassName',
'GetTraitClassName',
],
]]);
};
```

View File

@ -14,11 +14,12 @@ use PHPStan\Type\IterableType;
use PHPStan\Type\ObjectType;
use PHPStan\Type\UnionType;
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
use Rector\Core\Rector\AbstractRector;
use Rector\DowngradePhp71\Contract\Rector\DowngradeParamDeclarationRectorInterface;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Traversable;
abstract class AbstractDowngradeParamDeclarationRector extends AbstractDowngradeRector implements DowngradeParamDeclarationRectorInterface
abstract class AbstractDowngradeParamDeclarationRector extends AbstractRector implements DowngradeParamDeclarationRectorInterface
{
/**
* @return string[]
@ -53,26 +54,32 @@ abstract class AbstractDowngradeParamDeclarationRector extends AbstractDowngrade
return;
}
if ($this->addDocBlock) {
$node = $functionLike;
/** @var PhpDocInfo|null $phpDocInfo */
$phpDocInfo = $node->getAttribute(AttributeKey::PHP_DOC_INFO);
if ($phpDocInfo === null) {
$phpDocInfo = $this->phpDocInfoFactory->createEmpty($node);
}
if ($param->type !== null) {
$type = $this->staticTypeMapper->mapPhpParserNodePHPStanType($param->type);
if ($type instanceof IterableType) {
$type = new UnionType([$type, new IntersectionType([new ObjectType(Traversable::class)])]);
}
$paramName = $this->getName($param->var) ?? '';
$phpDocInfo->changeParamType($type, $param, $paramName);
}
}
$this->decorateWithDocBlock($functionLike, $param);
$param->type = null;
}
/**
* @param ClassMethod|Function_ $functionLike
*/
private function decorateWithDocBlock(FunctionLike $functionLike, Param $param): void
{
$node = $functionLike;
/** @var PhpDocInfo|null $phpDocInfo */
$phpDocInfo = $node->getAttribute(AttributeKey::PHP_DOC_INFO);
if ($phpDocInfo === null) {
$phpDocInfo = $this->phpDocInfoFactory->createEmpty($node);
}
if ($param->type !== null) {
$type = $this->staticTypeMapper->mapPhpParserNodePHPStanType($param->type);
if ($type instanceof IterableType) {
$type = new UnionType([$type, new IntersectionType([new ObjectType(Traversable::class)])]);
}
$paramName = $this->getName($param->var) ?? '';
$phpDocInfo->changeParamType($type, $param, $paramName);
}
}
}

View File

@ -1,9 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\DowngradePhp71\Rector\FunctionLike;
abstract class AbstractDowngradeRector extends AbstractMaybeAddDocBlockRector
{
}

View File

@ -13,11 +13,12 @@ use PHPStan\Type\IterableType;
use PHPStan\Type\ObjectType;
use PHPStan\Type\UnionType;
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
use Rector\Core\Rector\AbstractRector;
use Rector\DowngradePhp71\Contract\Rector\DowngradeReturnDeclarationRectorInterface;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Traversable;
abstract class AbstractDowngradeReturnDeclarationRector extends AbstractDowngradeRector implements DowngradeReturnDeclarationRectorInterface
abstract class AbstractDowngradeReturnDeclarationRector extends AbstractRector implements DowngradeReturnDeclarationRectorInterface
{
/**
* @return string[]
@ -36,9 +37,7 @@ abstract class AbstractDowngradeReturnDeclarationRector extends AbstractDowngrad
return null;
}
if ($this->addDocBlock) {
$this->addDocBlockReturn($node);
}
$this->addDocBlockReturn($node);
$node->returnType = null;

View File

@ -1,26 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\DowngradePhp71\Rector\FunctionLike;
use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
use Rector\Core\Rector\AbstractRector;
abstract class AbstractMaybeAddDocBlockRector extends AbstractRector implements ConfigurableRectorInterface
{
/**
* @var string
*/
public const ADD_DOC_BLOCK = '$addDocBlock';
/**
* @var bool
*/
protected $addDocBlock = true;
public function configure(array $configuration): void
{
$this->addDocBlock = $configuration[self::ADD_DOC_BLOCK] ?? true;
}
}

View File

@ -7,7 +7,7 @@ namespace Rector\DowngradePhp71\Rector\FunctionLike;
use PhpParser\Node\FunctionLike;
use PhpParser\Node\Identifier;
use PhpParser\Node\Param;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
@ -20,7 +20,7 @@ final class DowngradeIterablePseudoTypeParamDeclarationRector extends AbstractDo
return new RuleDefinition(
'Remove the iterable pseudo type params, add @param tags instead',
[
new ConfiguredCodeSample(
new CodeSample(
<<<'CODE_SAMPLE'
<?php
@ -47,10 +47,6 @@ class SomeClass
}
}
CODE_SAMPLE
,
[
self::ADD_DOC_BLOCK => true,
]
),
]
);

View File

@ -7,7 +7,7 @@ namespace Rector\DowngradePhp71\Rector\FunctionLike;
use PhpParser\Node\FunctionLike;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Function_;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
@ -20,7 +20,7 @@ final class DowngradeIterablePseudoTypeReturnDeclarationRector extends AbstractD
return new RuleDefinition(
'Remove returning iterable pseud type, add a @return tag instead',
[
new ConfiguredCodeSample(
new CodeSample(
<<<'CODE_SAMPLE'
<?php
@ -47,10 +47,6 @@ class SomeClass
}
}
CODE_SAMPLE
,
[
self::ADD_DOC_BLOCK => true,
]
),
]
);

View File

@ -7,7 +7,7 @@ namespace Rector\DowngradePhp71\Rector\FunctionLike;
use PhpParser\Node\FunctionLike;
use PhpParser\Node\NullableType;
use PhpParser\Node\Param;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
@ -20,7 +20,7 @@ final class DowngradeNullableTypeParamDeclarationRector extends AbstractDowngrad
return new RuleDefinition(
'Remove the nullable type params, add @param tags instead',
[
new ConfiguredCodeSample(
new CodeSample(
<<<'CODE_SAMPLE'
<?php
@ -47,10 +47,6 @@ class SomeClass
}
}
CODE_SAMPLE
,
[
self::ADD_DOC_BLOCK => true,
]
),
]
);

View File

@ -8,7 +8,7 @@ use PhpParser\Node\FunctionLike;
use PhpParser\Node\NullableType;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Function_;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
@ -21,7 +21,7 @@ final class DowngradeNullableTypeReturnDeclarationRector extends AbstractDowngra
return new RuleDefinition(
'Remove returning nullable types, add a @return tag instead',
[
new ConfiguredCodeSample(
new CodeSample(
<<<'CODE_SAMPLE'
<?php
@ -54,10 +54,6 @@ class SomeClass
}
}
CODE_SAMPLE
,
[
self::ADD_DOC_BLOCK => true,
]
),
]
);

View File

@ -5,7 +5,7 @@ declare(strict_types=1);
namespace Rector\DowngradePhp71\Rector\FunctionLike;
use Rector\DowngradePhp72\Rector\FunctionLike\AbstractDowngradeReturnTypeDeclarationRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
@ -18,7 +18,7 @@ final class DowngradeVoidTypeReturnDeclarationRector extends AbstractDowngradeRe
return new RuleDefinition(
$this->getRectorDefinitionDescription(),
[
new ConfiguredCodeSample(
new CodeSample(
<<<'CODE_SAMPLE'
<?php
@ -45,10 +45,6 @@ class SomeClass
}
}
CODE_SAMPLE
,
[
self::ADD_DOC_BLOCK => true,
]
),
]
);

View File

@ -25,18 +25,6 @@ final class DowngradeVoidTypeReturnDeclarationRectorTest extends AbstractRectorT
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
}
/**
* @return array<string, mixed[]>
*/
protected function getRectorsWithConfiguration(): array
{
return [
DowngradeVoidTypeReturnDeclarationRector::class => [
DowngradeVoidTypeReturnDeclarationRector::ADD_DOC_BLOCK => true,
],
];
}
protected function getRectorClass(): string
{
return DowngradeVoidTypeReturnDeclarationRector::class;

View File

@ -4,7 +4,7 @@ declare(strict_types=1);
namespace Rector\DowngradePhp72\Rector\FunctionLike;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
@ -17,7 +17,7 @@ final class DowngradeParamObjectTypeDeclarationRector extends AbstractDowngradeP
return new RuleDefinition(
$this->getRectorDefinitionDescription(),
[
new ConfiguredCodeSample(
new CodeSample(
<<<'CODE_SAMPLE'
<?php
@ -42,10 +42,6 @@ class SomeClass
}
}
CODE_SAMPLE
,
[
self::ADD_DOC_BLOCK => true,
]
),
]
);

View File

@ -4,7 +4,7 @@ declare(strict_types=1);
namespace Rector\DowngradePhp72\Rector\FunctionLike;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
@ -17,7 +17,7 @@ final class DowngradeReturnObjectTypeDeclarationRector extends AbstractDowngrade
return new RuleDefinition(
$this->getRectorDefinitionDescription(),
[
new ConfiguredCodeSample(
new CodeSample(
<<<'CODE_SAMPLE'
<?php
@ -44,10 +44,6 @@ class SomeClass
}
}
CODE_SAMPLE
,
[
self::ADD_DOC_BLOCK => true,
]
),
]
);

View File

@ -26,18 +26,6 @@ final class DowngradeParamObjectTypeDeclarationRectorTest extends AbstractRector
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
}
/**
* @return array<string, mixed[]>
*/
protected function getRectorsWithConfiguration(): array
{
return [
DowngradeParamObjectTypeDeclarationRector::class => [
DowngradeParamObjectTypeDeclarationRector::ADD_DOC_BLOCK => true,
],
];
}
protected function getRectorClass(): string
{
return DowngradeParamObjectTypeDeclarationRector::class;

View File

@ -26,18 +26,6 @@ final class DowngradeReturnObjectTypeDeclarationRectorTest extends AbstractRecto
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
}
/**
* @return array<string, mixed[]>
*/
protected function getRectorsWithConfiguration(): array
{
return [
DowngradeReturnObjectTypeDeclarationRector::class => [
DowngradeReturnObjectTypeDeclarationRector::ADD_DOC_BLOCK => true,
],
];
}
protected function getRectorClass(): string
{
return DowngradeReturnObjectTypeDeclarationRector::class;

View File

@ -16,7 +16,7 @@ use Rector\NodeTypeResolver\Node\AttributeKey;
use ReflectionMethod;
use ReflectionNamedType;
use ReflectionParameter;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
@ -29,7 +29,7 @@ final class DowngradeContravariantArgumentTypeRector extends AbstractDowngradePa
public function getRuleDefinition(): RuleDefinition
{
return new RuleDefinition('Remove contravariant argument type declarations', [
new ConfiguredCodeSample(
new CodeSample(
<<<'CODE_SAMPLE'
class ParentType {}
class ChildType extends ParentType {}
@ -66,10 +66,6 @@ class B extends A
{ /* … */ }
}
CODE_SAMPLE
,
[
self::ADD_DOC_BLOCK => true,
]
),
]);
}

View File

@ -7,11 +7,11 @@ namespace Rector\DowngradePhp74\Rector\Property;
use PhpParser\Node;
use PhpParser\Node\Stmt\Property;
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
use Rector\DowngradePhp71\Rector\FunctionLike\AbstractDowngradeRector;
use Rector\Core\Rector\AbstractRector;
use Rector\DowngradePhp74\Contract\Rector\DowngradeTypedPropertyRectorInterface;
use Rector\NodeTypeResolver\Node\AttributeKey;
abstract class AbstractDowngradeTypedPropertyRector extends AbstractDowngradeRector implements DowngradeTypedPropertyRectorInterface
abstract class AbstractDowngradeTypedPropertyRector extends AbstractRector implements DowngradeTypedPropertyRectorInterface
{
/**
* @return string[]
@ -34,20 +34,24 @@ abstract class AbstractDowngradeTypedPropertyRector extends AbstractDowngradeRec
return null;
}
if ($this->addDocBlock) {
/** @var PhpDocInfo|null $phpDocInfo */
$phpDocInfo = $node->getAttribute(AttributeKey::PHP_DOC_INFO);
if ($phpDocInfo === null) {
$phpDocInfo = $this->phpDocInfoFactory->createEmpty($node);
}
$this->decorateWithDocBlock($node);
if ($phpDocInfo->getVarTagValueNode() === null) {
$newType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($node->type);
$phpDocInfo->changeVarType($newType);
}
}
$node->type = null;
return $node;
}
private function decorateWithDocBlock(Node $node): void
{
/** @var PhpDocInfo|null $phpDocInfo */
$phpDocInfo = $node->getAttribute(AttributeKey::PHP_DOC_INFO);
if ($phpDocInfo === null) {
$phpDocInfo = $this->phpDocInfoFactory->createEmpty($node);
}
if ($phpDocInfo->getVarTagValueNode() === null) {
$newType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($node->type);
$phpDocInfo->changeVarType($newType);
}
}
}

View File

@ -5,7 +5,7 @@ declare(strict_types=1);
namespace Rector\DowngradePhp74\Rector\Property;
use PhpParser\Node\Stmt\Property;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
@ -16,7 +16,7 @@ final class DowngradeTypedPropertyRector extends AbstractDowngradeTypedPropertyR
public function getRuleDefinition(): RuleDefinition
{
return new RuleDefinition('Changes property type definition from type definitions to `@var` annotations.', [
new ConfiguredCodeSample(
new CodeSample(
<<<'CODE_SAMPLE'
class SomeClass
{
@ -33,10 +33,6 @@ class SomeClass
private $property;
}
CODE_SAMPLE
,
[
self::ADD_DOC_BLOCK => true,
]
),
]);
}

View File

@ -26,18 +26,6 @@ final class DowngradeTypedPropertyRectorTest extends AbstractRectorTestCase
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
}
/**
* @return array<string, mixed[]>
*/
protected function getRectorsWithConfiguration(): array
{
return [
DowngradeTypedPropertyRector::class => [
DowngradeTypedPropertyRector::ADD_DOC_BLOCK => true,
],
];
}
protected function getRectorClass(): string
{
return DowngradeTypedPropertyRector::class;

View File

@ -1,25 +0,0 @@
<?php
namespace Rector\DowngradePhp74\Tests\Rector\Property\DowngradeTypedPropertyRector\FixtureNoDocBlock;
use Rector\DowngradePhp74\Tests\Rector\Property\DowngradeTypedPropertyRector\SourceNoDocBlock\AnotherClass;
class ClassNameNullableTypeClass
{
private ?AnotherClass $property;
}
?>
-----
<?php
namespace Rector\DowngradePhp74\Tests\Rector\Property\DowngradeTypedPropertyRector\FixtureNoDocBlock;
use Rector\DowngradePhp74\Tests\Rector\Property\DowngradeTypedPropertyRector\SourceNoDocBlock\AnotherClass;
class ClassNameNullableTypeClass
{
private $property;
}
?>

View File

@ -1,19 +0,0 @@
<?php
namespace Rector\DowngradePhp74\Tests\Rector\Property\DowngradeTypedPropertyRector\FixtureNoDocBlock;
class ClassNameClass {
private \Rector\DowngradePhp74\Tests\Rector\Property\DowngradeTypedPropertyRector\SourceNoDocBlock\AnotherClass $property;
}
?>
-----
<?php
namespace Rector\DowngradePhp74\Tests\Rector\Property\DowngradeTypedPropertyRector\FixtureNoDocBlock;
class ClassNameClass {
private $property;
}
?>

View File

@ -1,25 +0,0 @@
<?php
namespace Rector\DowngradePhp74\Tests\Rector\Property\DowngradeTypedPropertyRector\FixtureNoDocBlock;
class DocBlockExists {
/**
* This property is the best one
*/
private ?string $property;
}
?>
-----
<?php
namespace Rector\DowngradePhp74\Tests\Rector\Property\DowngradeTypedPropertyRector\FixtureNoDocBlock;
class DocBlockExists {
/**
* This property is the best one
*/
private $property;
}
?>

View File

@ -1,21 +0,0 @@
<?php
namespace Rector\DowngradePhp74\Tests\Rector\Property\DowngradeTypedPropertyRector\FixtureNoDocBlock;
class SomeClass
{
private string $property;
}
?>
-----
<?php
namespace Rector\DowngradePhp74\Tests\Rector\Property\DowngradeTypedPropertyRector\FixtureNoDocBlock;
class SomeClass
{
private $property;
}
?>

View File

@ -1,19 +0,0 @@
<?php
namespace Rector\DowngradePhp74\Tests\Rector\Property\DowngradeTypedPropertyRector\FixtureNoDocBlock;
class NullableTypeClass {
private ?string $property;
}
?>
-----
<?php
namespace Rector\DowngradePhp74\Tests\Rector\Property\DowngradeTypedPropertyRector\FixtureNoDocBlock;
class NullableTypeClass {
private $property;
}
?>

View File

@ -1,50 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\DowngradePhp74\Tests\Rector\Property\DowngradeTypedPropertyRector;
use Iterator;
use Rector\Core\ValueObject\PhpVersionFeature;
use Rector\DowngradePhp74\Rector\Property\DowngradeTypedPropertyRector;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
use Symplify\SmartFileSystem\SmartFileInfo;
final class NoDocBlockTest extends AbstractRectorTestCase
{
/**
* @requires PHP 7.4
* @dataProvider provideData()
*/
public function test(SmartFileInfo $fileInfo): void
{
$this->doTestFileInfo($fileInfo);
}
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/FixtureNoDocBlock');
}
/**
* @return array<string, mixed[]>
*/
protected function getRectorsWithConfiguration(): array
{
return [
DowngradeTypedPropertyRector::class => [
DowngradeTypedPropertyRector::ADD_DOC_BLOCK => false,
],
];
}
protected function getRectorClass(): string
{
return DowngradeTypedPropertyRector::class;
}
protected function getPhpVersion(): int
{
return PhpVersionFeature::TYPED_PROPERTIES - 1;
}
}

View File

@ -1,9 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\DowngradePhp74\Tests\Rector\Property\DowngradeTypedPropertyRector\SourceNoDocBlock;
final class AnotherClass
{
}

View File

@ -5,7 +5,7 @@ declare(strict_types=1);
namespace Rector\DowngradePhp80\Rector\FunctionLike;
use Rector\DowngradePhp72\Rector\FunctionLike\AbstractDowngradeParamTypeDeclarationRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
@ -18,7 +18,7 @@ final class DowngradeParamMixedTypeDeclarationRector extends AbstractDowngradePa
return new RuleDefinition(
$this->getRectorDefinitionDescription(),
[
new ConfiguredCodeSample(
new CodeSample(
<<<'CODE_SAMPLE'
<?php
@ -43,10 +43,6 @@ class SomeClass
}
}
CODE_SAMPLE
,
[
self::ADD_DOC_BLOCK => true,
]
),
]
);

View File

@ -5,7 +5,7 @@ declare(strict_types=1);
namespace Rector\DowngradePhp80\Rector\FunctionLike;
use Rector\DowngradePhp72\Rector\FunctionLike\AbstractDowngradeReturnTypeDeclarationRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
@ -18,7 +18,7 @@ final class DowngradeReturnMixedTypeDeclarationRector extends AbstractDowngradeR
return new RuleDefinition(
$this->getRectorDefinitionDescription(),
[
new ConfiguredCodeSample(
new CodeSample(
<<<'CODE_SAMPLE'
<?php
@ -51,10 +51,6 @@ class SomeClass
}
}
CODE_SAMPLE
,
[
self::ADD_DOC_BLOCK => true,
]
),
]
);

View File

@ -5,7 +5,7 @@ declare(strict_types=1);
namespace Rector\DowngradePhp80\Rector\FunctionLike;
use Rector\DowngradePhp72\Rector\FunctionLike\AbstractDowngradeReturnTypeDeclarationRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
@ -18,7 +18,7 @@ final class DowngradeReturnStaticTypeDeclarationRector extends AbstractDowngrade
return new RuleDefinition(
$this->getRectorDefinitionDescription(),
[
new ConfiguredCodeSample(
new CodeSample(
<<<'CODE_SAMPLE'
<?php
@ -45,10 +45,6 @@ class SomeClass
}
}
CODE_SAMPLE
,
[
self::ADD_DOC_BLOCK => true,
]
),
]
);

View File

@ -8,7 +8,7 @@ use PhpParser\Node\FunctionLike;
use PhpParser\Node\Param;
use PhpParser\Node\UnionType;
use Rector\DowngradePhp71\Rector\FunctionLike\AbstractDowngradeParamDeclarationRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
@ -21,7 +21,7 @@ final class DowngradeUnionTypeParamDeclarationRector extends AbstractDowngradePa
return new RuleDefinition(
'Remove the union type params, add @param tags instead',
[
new ConfiguredCodeSample(
new CodeSample(
<<<'CODE_SAMPLE'
<?php
@ -48,10 +48,6 @@ class SomeClass
}
}
CODE_SAMPLE
,
[
self::ADD_DOC_BLOCK => true,
]
),
]
);

View File

@ -9,7 +9,7 @@ use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Function_;
use PhpParser\Node\UnionType;
use Rector\DowngradePhp71\Rector\FunctionLike\AbstractDowngradeReturnDeclarationRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
@ -22,7 +22,7 @@ final class DowngradeUnionTypeReturnDeclarationRector extends AbstractDowngradeR
return new RuleDefinition(
'Remove returning union types, add a @return tag instead',
[
new ConfiguredCodeSample(
new CodeSample(
<<<'CODE_SAMPLE'
<?php
@ -55,10 +55,6 @@ class SomeClass
}
}
CODE_SAMPLE
,
[
self::ADD_DOC_BLOCK => true,
]
),
]
);

View File

@ -7,7 +7,7 @@ namespace Rector\DowngradePhp80\Rector\Property;
use PhpParser\Node\Stmt\Property;
use PhpParser\Node\UnionType;
use Rector\DowngradePhp74\Rector\Property\AbstractDowngradeTypedPropertyRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
@ -18,7 +18,7 @@ final class DowngradeUnionTypeTypedPropertyRector extends AbstractDowngradeTyped
public function getRuleDefinition(): RuleDefinition
{
return new RuleDefinition('Removes union type property type definition, adding `@var` annotations instead.', [
new ConfiguredCodeSample(
new CodeSample(
<<<'CODE_SAMPLE'
class SomeClass
{
@ -35,10 +35,6 @@ class SomeClass
private $property;
}
CODE_SAMPLE
,
[
self::ADD_DOC_BLOCK => true,
]
),
]);
}

View File

@ -26,18 +26,6 @@ final class DowngradeParamMixedTypeDeclarationRectorTest extends AbstractRectorT
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
}
/**
* @return array<string, mixed[]>
*/
protected function getRectorsWithConfiguration(): array
{
return [
DowngradeParamMixedTypeDeclarationRector::class => [
DowngradeParamMixedTypeDeclarationRector::ADD_DOC_BLOCK => true,
],
];
}
protected function getRectorClass(): string
{
return DowngradeParamMixedTypeDeclarationRector::class;

View File

@ -26,18 +26,6 @@ final class DowngradeReturnMixedTypeDeclarationRectorTest extends AbstractRector
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
}
/**
* @return array<string, mixed[]>
*/
protected function getRectorsWithConfiguration(): array
{
return [
DowngradeReturnMixedTypeDeclarationRector::class => [
DowngradeReturnMixedTypeDeclarationRector::ADD_DOC_BLOCK => true,
],
];
}
protected function getRectorClass(): string
{
return DowngradeReturnMixedTypeDeclarationRector::class;

View File

@ -13,7 +13,7 @@ use Symplify\SmartFileSystem\SmartFileInfo;
final class DowngradeReturnStaticTypeDeclarationRectorTest extends AbstractRectorTestCase
{
/**
* @requires PHP = 8.1
* @requires PHP >= 8.0
* @dataProvider provideData()
*/
public function test(SmartFileInfo $fileInfo): void
@ -26,18 +26,6 @@ final class DowngradeReturnStaticTypeDeclarationRectorTest extends AbstractRecto
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
}
/**
* @return array<string, mixed[]>
*/
protected function getRectorsWithConfiguration(): array
{
return [
DowngradeReturnStaticTypeDeclarationRector::class => [
DowngradeReturnStaticTypeDeclarationRector::ADD_DOC_BLOCK => true,
],
];
}
protected function getRectorClass(): string
{
return DowngradeReturnStaticTypeDeclarationRector::class;