1
0
mirror of https://github.com/rectorphp/rector.git synced 2025-04-24 09:25:42 +02:00
This commit is contained in:
TomasVotruba 2020-12-19 23:37:11 +01:00
parent 720b2c34eb
commit b7c6e2b7c0
16 changed files with 50 additions and 39 deletions
config/set
packages
phpstan-static-type-mapper/src/TypeMapper
vendor-locker/src/NodeVendorLocker
rector-ci.php
rules
coding-style/src/Rector
downgrade-php73/src/Rector/List_
generic/src/Rector/Property
magic-disclosure/src/Rector/Assign
php-spec-to-phpunit/src/Rector/MethodCall
symfony3/src/Rector/ClassMethod
symfony4/src/Rector
symfony5/src/Rector/New_
type-declaration/src/TypeInferer/ReturnTypeInferer
src/Bootstrap

@ -55,16 +55,56 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services->set(RenameMethodRector::class)
->call('configure', [[
RenameMethodRector::METHOD_CALL_RENAMES => ValueObjectInliner::inline([
new MethodCallRename('Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken', 'setProviderKey', 'setFirewallName'),
new MethodCallRename('Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken', 'getProviderKey', 'getFirewallName'),
new MethodCallRename('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken', 'setProviderKey', 'setFirewallName'),
new MethodCallRename('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken', 'getProviderKey', 'getFirewallName'),
new MethodCallRename('Symfony\Component\Security\Core\Authentication\Token\SwitchUserToken', 'setProviderKey', 'setFirewallName'),
new MethodCallRename('Symfony\Component\Security\Core\Authentication\Token\SwitchUserToken', 'getProviderKey', 'getFirewallName'),
new MethodCallRename('Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken', 'setProviderKey', 'setFirewallName'),
new MethodCallRename('Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken', 'getProviderKey', 'getFirewallName'),
new MethodCallRename('Symfony\Component\Security\Http\Authentication\DefaultAuthenticationSuccessHandler', 'setProviderKey', 'setFirewallName'),
new MethodCallRename('Symfony\Component\Security\Http\Authentication\DefaultAuthenticationSuccessHandler', 'getProviderKey', 'getFirewallName'),
new MethodCallRename(
'Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken',
'setProviderKey',
'setFirewallName'
),
new MethodCallRename(
'Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken',
'getProviderKey',
'getFirewallName'
),
new MethodCallRename(
'Symfony\Component\Security\Core\Authentication\Token\RememberMeToken',
'setProviderKey',
'setFirewallName'
),
new MethodCallRename(
'Symfony\Component\Security\Core\Authentication\Token\RememberMeToken',
'getProviderKey',
'getFirewallName'
),
new MethodCallRename(
'Symfony\Component\Security\Core\Authentication\Token\SwitchUserToken',
'setProviderKey',
'setFirewallName'
),
new MethodCallRename(
'Symfony\Component\Security\Core\Authentication\Token\SwitchUserToken',
'getProviderKey',
'getFirewallName'
),
new MethodCallRename(
'Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken',
'setProviderKey',
'setFirewallName'
),
new MethodCallRename(
'Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken',
'getProviderKey',
'getFirewallName'
),
new MethodCallRename(
'Symfony\Component\Security\Http\Authentication\DefaultAuthenticationSuccessHandler',
'setProviderKey',
'setFirewallName'
),
new MethodCallRename(
'Symfony\Component\Security\Http\Authentication\DefaultAuthenticationSuccessHandler',
'getProviderKey',
'getFirewallName'
),
]),
]]);
};

@ -97,7 +97,6 @@ final class UnionTypeMapper implements TypeMapperInterface
*/
public function mapToPhpParserNode(Type $type, ?string $kind = null): ?Node
{
// match array types
$arrayNode = $this->matchArrayTypes($type);
if ($arrayNode !== null) {
return $arrayNode;

@ -57,8 +57,6 @@ final class ClassMethodParamVendorLockResolver extends AbstractNodeVendorLockRes
return $parentClassMethod->params[$paramPosition]->type === null;
}
}
// if not, look for it's parent parent
if (method_exists($parentClassName, $methodName)) {
// parent class method in external scope → it's not ok
// if not, look for it's parent parent

@ -85,7 +85,6 @@ return static function (ContainerConfigurator $containerConfigurator): void {
__DIR__ . '/packages/doctrine-annotation-generated/src',
// template files
__DIR__ . '/packages/rector-generator/templates',
// public api
__DIR__ . '/packages/rector-generator/src/ValueObject/RectorRecipe.php',
]);

@ -280,8 +280,6 @@ CODE_SAMPLE
}
$nextExpressionNode = $nextExpression->expr;
// $value .= '...';
if ($nextExpressionNode instanceof ConcatAssign) {
// is assign to same variable?
if (! $this->areNodesEqual($expr, $nextExpressionNode->var)) {

@ -176,8 +176,6 @@ CODE_SAMPLE
if (! $node instanceof BooleanAnd) {
return null;
}
// $this->value !== null
if (! $this->isLocalPropertyOfNamesNotIdenticalToNull($node->left, $propertyNames)) {
return null;
}

@ -199,8 +199,6 @@ CODE_SAMPLE
if ($listItem === null) {
continue;
}
// If it's a variable by value, not by reference, then skip
if ($listItem->value instanceof Variable && ! $listItem->byRef) {
continue;
}

@ -241,7 +241,6 @@ CODE_SAMPLE
$serviceName = $jmsInjectTagValueNode->getServiceName();
if ($serviceName) {
// 1. service class
if (class_exists($serviceName)) {
return new ObjectType($serviceName);
}

@ -167,8 +167,6 @@ CODE_SAMPLE
if (! $this->propertyFetchManipulator->isMagicOnType($propertyFetch, $objectType)) {
return true;
}
// $this->value = $value
return $this->propertyFetchManipulator->isPropertyToSelf($propertyFetch);
}

@ -174,8 +174,6 @@ final class PhpSpecPromisesToPHPUnitAssertRector extends AbstractPhpSpecToPHPUni
if ($this->shouldSkip($node)) {
return null;
}
// $this->clone() → clone $this->testedObject
if ($this->isName($node->name, 'clone')) {
return new Clone_($this->testedObjectPropertyFetch);
}
@ -260,7 +258,6 @@ final class PhpSpecPromisesToPHPUnitAssertRector extends AbstractPhpSpecToPHPUni
}
if ($this->isName($methodCall->name, 'beConstructedThrough')) {
// static method
$methodName = $this->getValue($methodCall->args[0]->value);
$staticCall = $this->createStaticCall($this->testedClass, $methodName);

@ -164,8 +164,6 @@ CODE_SAMPLE
if ($containsGetRequestMethod) {
return true;
}
// "$this->get('request')"
/** @var MethodCall[] $getMethodCalls */
$getMethodCalls = $this->betterNodeFinder->find($node, function (Node $node): bool {
return $this->isLocalMethodCallNamed($node, 'get');
@ -202,7 +200,6 @@ CODE_SAMPLE
private function containsGetRequestMethod(Node $node): bool
{
// "$this->getRequest()"
return (bool) $this->betterNodeFinder->find($node, function (Node $node): bool {
return $this->isLocalMethodCallNamed($node, 'getRequest');
});

@ -125,8 +125,6 @@ CODE_SAMPLE
if ($args !== null) {
return $this->createLocalMethodCall('assertSelectorTextContains', $args);
}
// 3. assertResponseRedirects
return $this->processAssertResponseRedirects($node);
}

@ -77,8 +77,6 @@ CODE_SAMPLE
if (! $rootNameNode instanceof String_) {
return null;
}
// switch arguments
[$node->args, $rootMethodCallNode->args] = [$rootMethodCallNode->args, $node->args];
$rootMethodCallNode->name = new Identifier('getRootNode');

@ -5,7 +5,6 @@ declare(strict_types=1);
namespace Rector\Symfony5\Rector\New_;
use PhpParser\Node;
use PhpParser\Node\Arg;
use PhpParser\Node\Expr\New_;
use PhpParser\Node\Name;
use PhpParser\Node\Name\FullyQualified;

@ -141,7 +141,6 @@ final class ReturnedNodesReturnTypeInferer extends AbstractTypeInferer implement
private function isAbstractMethod(ClassLike $classLike, FunctionLike $functionLike): bool
{
// abstract class method
if ($functionLike instanceof ClassMethod && $functionLike->isAbstract()) {
return true;
}
@ -149,8 +148,6 @@ final class ReturnedNodesReturnTypeInferer extends AbstractTypeInferer implement
if (! $classLike instanceof Class_) {
return false;
}
// abstract class
return $classLike->isAbstract();
}
}

@ -57,8 +57,6 @@ final class RectorConfigsResolver
$argvInput = new ArgvInput();
$this->guardDeprecatedSetOption($argvInput);
// And from --config or default one
$inputOrFallbackConfigFileInfo = $this->configResolver->resolveFromInputWithFallback(
$argvInput,
['rector.php']