mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-19 14:27:14 +01:00
[Naming] Skip return without type and with args
This commit is contained in:
parent
fc347413f3
commit
133683dc3d
@ -21,7 +21,8 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
|
||||
$parameters->set(Option::SETS, [
|
||||
'coding-style', 'code-quality', 'dead-code', 'nette-utils-code-quality', 'solid', 'privatization', 'naming',
|
||||
// @todo use constants here, so we don't have to google the strings that can be used here
|
||||
'coding-style', 'code-quality', 'dead-code', 'nette-utils-code-quality', 'solid', 'privatization', 'naming', 'decomplex',
|
||||
]);
|
||||
|
||||
$parameters->set(Option::PATHS, [
|
||||
|
@ -3,7 +3,7 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Decomplex\Rector\MethodCall\UseMessageVariableForSprintfInSymfonyStyleRector;
|
||||
use Rector\Naming\Rector\Assign\RenameVariableToMatchGetMethodNameRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
@ -11,7 +11,7 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
|
||||
$services = $containerConfigurator->services();
|
||||
|
||||
$services->set(UseMessageVariableForSprintfInSymfonyStyleRector::class);
|
||||
$services->set(RenameVariableToMatchGetMethodNameRector::class);
|
||||
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
|
||||
|
@ -181,8 +181,13 @@ final class ExpectedNameResolver
|
||||
return $expectedName;
|
||||
}
|
||||
|
||||
// call with args can return different value, so skip there if not sure about the type
|
||||
if (count($call->args) > 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// @see https://regex101.com/r/hnU5pm/2/
|
||||
$matches = Strings::match($name, '#^get(([A-Z]).+)#');
|
||||
$matches = Strings::match($name, '#^get([A-Z].+)#');
|
||||
if ($matches === null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -105,6 +105,7 @@ PHP
|
||||
}
|
||||
|
||||
$newName = $this->expectedNameResolver->resolveForGetCallExpr($node->expr);
|
||||
|
||||
if ($newName === null || $this->isName($node, $newName)) {
|
||||
return null;
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\Naming\Tests\Rector\Assign\RenameVariableToMatchGetMethodNameRector\Fixture;
|
||||
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
|
||||
class SkipAttributeUseCase
|
||||
{
|
||||
public function readMethodAnnotation(ClassMethod $classMethod)
|
||||
{
|
||||
/** @var string $className */
|
||||
$className = $classMethod->getAttribute(AttributeKey::CLASS_NAME);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user