Skip to content

Commit

Permalink
[deprecated] Remove deprecated properties from AbstractRector (#5243)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Nov 11, 2023
1 parent 4ed71bc commit 42b697f
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 41 deletions.
2 changes: 1 addition & 1 deletion packages/PostRector/Rector/ClassRenamingPostRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
use Rector\Core\Configuration\RenamedClassesDataCollector;
use Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\Renaming\NodeManipulator\ClassRenamer;
use Rector\Renaming\Collector\RenamedNameCollector;
use Rector\Renaming\NodeManipulator\ClassRenamer;

final class ClassRenamingPostRector extends AbstractPostRector
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types=1);

use Rector\CodingStyle\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector;
use Rector\Config\RectorConfig;
use Rector\Core\ValueObject\PhpVersion;
use Rector\CodingStyle\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->phpVersion(PhpVersion::PHP_74);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types=1);

use Rector\CodingStyle\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector;
use Rector\Config\RectorConfig;
use Rector\Core\ValueObject\PhpVersion;
use Rector\CodingStyle\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->phpVersion(PhpVersion::PHP_81);
Expand Down
5 changes: 3 additions & 2 deletions rules/CodingStyle/Application/UseImportsRemover.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@

final class UseImportsRemover
{
public function __construct(private readonly RenamedNameCollector $renamedNameCollector)
{
public function __construct(
private readonly RenamedNameCollector $renamedNameCollector
) {
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

namespace Rector\Php74\Rector\Property;

use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\Property;
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\ValueObject\PhpVersionFeature;
use Rector\TypeDeclaration\AlreadyAssignDetector\ConstructorAssignDetector;
Expand All @@ -22,7 +22,8 @@
final class RestoreDefaultNullToNullableTypePropertyRector extends AbstractRector implements MinPhpVersionInterface
{
public function __construct(
private readonly ConstructorAssignDetector $constructorAssignDetector, private readonly PhpDocInfoFactory $phpDocInfoFactory
private readonly ConstructorAssignDetector $constructorAssignDetector,
private readonly PhpDocInfoFactory $phpDocInfoFactory
) {
}

Expand Down Expand Up @@ -120,7 +121,8 @@ private function shouldSkip(Property $property, Class_ $class): bool
return $this->constructorAssignDetector->isPropertyAssigned($class, $propertyName);
}

private function isReadonly(Property $property): bool {
private function isReadonly(Property $property): bool
{
// native readonly
if ($property->isReadonly()) {
return true;
Expand Down
10 changes: 0 additions & 10 deletions src/DependencyInjection/LazyContainerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@
use Rector\Core\Contract\Rector\RectorInterface;
use Rector\Core\NodeDecorator\CreatedByRuleDecorator;
use Rector\Core\PhpParser\Comparing\NodeComparator;
use Rector\Core\PhpParser\Node\BetterNodeFinder;
use Rector\Core\PhpParser\Node\NodeFactory;
use Rector\Core\PhpParser\Node\Value\ValueResolver;
use Rector\Core\PhpParser\NodeTraverser\RectorNodeTraverser;
use Rector\Core\Provider\CurrentFileProvider;
use Rector\Core\Rector\AbstractRector;
Expand Down Expand Up @@ -531,15 +529,7 @@ static function (AbstractRector $rector, Container $container): void {
$container->get(NodeTypeResolver::class),
$container->get(SimpleCallableNodeTraverser::class),
$container->get(NodeFactory::class),
// @deprecated, use injected service in your Rector rules
$container->get(PhpDocInfoFactory::class),
// @deprecated, use injected service in your Rector rules
$container->get(StaticTypeMapper::class),
$container->get(Skipper::class),
// @deprecated, use injected service in your Rector rules
$container->get(ValueResolver::class),
// @deprecated, use injected service in your Rector rules
$container->get(BetterNodeFinder::class),
$container->get(NodeComparator::class),
$container->get(CurrentFileProvider::class),
$container->get(CreatedByRuleDecorator::class),
Expand Down
24 changes: 1 addition & 23 deletions src/Rector/AbstractRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,21 @@
use PHPStan\Analyser\MutatingScope;
use PHPStan\Type\ObjectType;
use PHPStan\Type\Type;
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
use Rector\ChangesReporting\ValueObject\RectorWithLineChange;
use Rector\Core\Application\ChangedNodeScopeRefresher;
use Rector\Core\Contract\Rector\RectorInterface;
use Rector\Core\Exception\ShouldNotHappenException;
use Rector\Core\NodeDecorator\CreatedByRuleDecorator;
use Rector\Core\PhpParser\Comparing\NodeComparator;
use Rector\Core\PhpParser\Node\BetterNodeFinder;
use Rector\Core\PhpParser\Node\NodeFactory;
use Rector\Core\PhpParser\Node\Value\ValueResolver;
use Rector\Core\Provider\CurrentFileProvider;
use Rector\Core\ValueObject\Application\File;
use Rector\NodeNameResolver\NodeNameResolver;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\NodeTypeResolver\NodeTypeResolver;
use Rector\PhpDocParser\NodeTraverser\SimpleCallableNodeTraverser;
use Rector\Skipper\Skipper\Skipper;
use Rector\StaticTypeMapper\StaticTypeMapper;

/**
* @property-read PhpDocInfoFactory $phpDocInfoFactory; @deprecated The parent AbstractRector dependency is deprecated and will be removed. Use dependency injection in your own rule instead.
*
* @property-read ValueResolver $valueResolver; @deprecated The parent AbstractRector dependency is deprecated and will be removed. Use dependency injection in your own rule instead.
*
* @property-read BetterNodeFinder $betterNodeFinder; @deprecated The parent AbstractRector dependency is deprecated and will be removed. Use dependency injection in your own rule instead.
*
* @property-read StaticTypeMapper $staticTypeMapper; @deprecated The parent AbstractRector dependency is deprecated and will be removed. Use dependency injection in your own rule instead.
*/

abstract class AbstractRector extends NodeVisitorAbstract implements RectorInterface
{
/**
Expand Down Expand Up @@ -118,11 +105,7 @@ public function autowire(
NodeTypeResolver $nodeTypeResolver,
SimpleCallableNodeTraverser $simpleCallableNodeTraverser,
NodeFactory $nodeFactory,
PhpDocInfoFactory $phpDocInfoFactory,
StaticTypeMapper $staticTypeMapper,
Skipper $skipper,
ValueResolver $valueResolver,
BetterNodeFinder $betterNodeFinder,
NodeComparator $nodeComparator,
CurrentFileProvider $currentFileProvider,
CreatedByRuleDecorator $createdByRuleDecorator,
Expand All @@ -137,11 +120,6 @@ public function autowire(
$this->currentFileProvider = $currentFileProvider;
$this->createdByRuleDecorator = $createdByRuleDecorator;
$this->changedNodeScopeRefresher = $changedNodeScopeRefresher;

$this->deprecatedDependencies['phpDocInfoFactory'] = $phpDocInfoFactory;
$this->deprecatedDependencies['valueResolver'] = $valueResolver;
$this->deprecatedDependencies['betterNodeFinder'] = $betterNodeFinder;
$this->deprecatedDependencies['staticTypeMapper'] = $staticTypeMapper;
}

/**
Expand Down

0 comments on commit 42b697f

Please sign in to comment.