Skip to content

Commit

Permalink
Remove deprecated ParamTypeDeclarationRector, that treated docs as st…
Browse files Browse the repository at this point in the history
…rict types to keep type declaration set reliable (#3111)
  • Loading branch information
TomasVotruba committed Nov 27, 2022
1 parent 0d8c296 commit 83b13f5
Show file tree
Hide file tree
Showing 60 changed files with 53 additions and 1,412 deletions.
23 changes: 3 additions & 20 deletions build/target-repository/docs/rector_rules_overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -9152,30 +9152,13 @@ Change `@param` types to type declarations if not a BC-break
- class: [`Rector\TypeDeclaration\Rector\FunctionLike\ParamTypeDeclarationRector`](../rules/TypeDeclaration/Rector/FunctionLike/ParamTypeDeclarationRector.php)

```diff
abstract class VendorParentClass
{
/**
* @param int $number
*/
public function keep($number)
{
}
}

final class ChildClass extends VendorParentClass
final class SomeClass
{
/**
* @param int $number
*/
public function keep($number)
{
}

- /**
- * @param int $number
- */
- public function change($number)
+ public function change(int $number)
- public function run($number)
+ public function run(int $number)
{
}
}
Expand Down
2 changes: 0 additions & 2 deletions config/set/type-declaration.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedPropertyRector;
use Rector\TypeDeclaration\Rector\Closure\AddClosureReturnTypeRector;
use Rector\TypeDeclaration\Rector\FunctionLike\AddParamTypeSplFixedArrayRector;
use Rector\TypeDeclaration\Rector\FunctionLike\ParamTypeDeclarationRector;
use Rector\TypeDeclaration\Rector\FunctionLike\ReturnTypeDeclarationRector;
use Rector\TypeDeclaration\Rector\Param\ParamTypeFromStrictTypedPropertyRector;
use Rector\TypeDeclaration\Rector\Property\PropertyTypeDeclarationRector;
Expand All @@ -36,7 +35,6 @@

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->rules([
ParamTypeDeclarationRector::class,
ReturnTypeDeclarationRector::class,
PropertyTypeDeclarationRector::class,
AddClosureReturnTypeRector::class,
Expand Down
5 changes: 3 additions & 2 deletions easy-ci.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
use Rector\StaticTypeMapper\Contract\PhpParser\PhpParserNodeMapperInterface;
use Rector\Testing\PHPUnit\AbstractTestCase;
use Rector\TypeDeclaration\Contract\PHPStan\TypeWithClassTypeSpecifierInterface;
use Rector\TypeDeclaration\Contract\TypeInferer\ParamTypeInfererInterface;
use Rector\TypeDeclaration\Contract\TypeInferer\ReturnTypeInfererInterface;
use Rector\TypeDeclaration\NodeAnalyzer\ControllerRenderMethodAnalyzer;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symplify\EasyCI\Config\EasyCIConfig;
Expand All @@ -59,7 +59,8 @@
Application::class,
RectorInterface::class,
TypeToCallReflectionResolverInterface::class,
ParamTypeInfererInterface::class,
// used in another Rector package
ControllerRenderMethodAnalyzer::class,
ReturnTypeInfererInterface::class,
FileProcessorInterface::class,
ClassNameImportSkipVoterInterface::class,
Expand Down
32 changes: 0 additions & 32 deletions packages/VendorLocker/ParentClassMethodTypeOverrideGuard.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,16 @@
use PHPStan\Type\MixedType;
use PHPStan\Type\Type;
use Rector\Core\FileSystem\FilePathHelper;
use Rector\Core\PhpParser\AstResolver;
use Rector\Core\Reflection\ReflectionResolver;
use Rector\Core\ValueObject\MethodName;
use Rector\NodeNameResolver\NodeNameResolver;
use Rector\NodeTypeResolver\TypeComparator\TypeComparator;
use Rector\StaticTypeMapper\StaticTypeMapper;
use Rector\TypeDeclaration\TypeInferer\ParamTypeInferer;

final class ParentClassMethodTypeOverrideGuard
{
public function __construct(
private readonly NodeNameResolver $nodeNameResolver,
private readonly AstResolver $astResolver,
private readonly ParamTypeInferer $paramTypeInferer,
private readonly ReflectionResolver $reflectionResolver,
private readonly TypeComparator $typeComparator,
private readonly StaticTypeMapper $staticTypeMapper,
Expand Down Expand Up @@ -93,34 +89,6 @@ public function hasParentClassMethod(ClassMethod $classMethod): bool
return $this->getParentClassMethod($classMethod) instanceof MethodReflection;
}

public function hasParentClassMethodDifferentType(ClassMethod $classMethod, int $position, Type $currentType): bool
{
if ($classMethod->isPrivate()) {
return false;
}

$methodReflection = $this->getParentClassMethod($classMethod);
if (! $methodReflection instanceof MethodReflection) {
return false;
}

$classMethod = $this->astResolver->resolveClassMethodFromMethodReflection($methodReflection);
if (! $classMethod instanceof ClassMethod) {
return false;
}

if ($classMethod->isPrivate()) {
return false;
}

if (! isset($classMethod->params[$position])) {
return false;
}

$inferedType = $this->paramTypeInferer->inferParam($classMethod->params[$position]);
return $inferedType::class !== $currentType::class;
}

public function getParentClassMethod(ClassMethod $classMethod): ?MethodReflection
{
$classReflection = $this->reflectionResolver->resolveClassReflection($classMethod);
Expand Down
41 changes: 0 additions & 41 deletions packages/VendorLocker/VendorLockResolver.php

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 83b13f5

Please sign in to comment.