mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-05 02:40:50 +00:00
cs fixes
This commit is contained in:
parent
3142225473
commit
140475ff86
|
@ -43,12 +43,10 @@ parameters:
|
|||
skip:
|
||||
Symplify\CodingStandard\Fixer\Php\ClassStringToClassConstantFixer:
|
||||
# classes might not exist
|
||||
- */src/Rector/Contrib/Nette/*Rector.php
|
||||
- src/Rector/Contrib/Symfony/StringFormTypeToClassRector.php
|
||||
- src/Rector/Contrib/Symfony/FormIsValidRector.php
|
||||
- */src/Rector/Contrib/*/*Rector.php
|
||||
Symplify\CodingStandard\Sniffs\Debug\CommentedOutCodeSniff:
|
||||
# examples of code to be found
|
||||
- src/Rector/Contrib/Symfony/GetterToPropertyRector.php
|
||||
- src/Rector/Contrib/SymfonyExtra/CommandToConstructorInjectionRector.php
|
||||
SlevomatCodingStandard\Sniffs\Classes\UnusedPrivateElementsSniff:
|
||||
# will be used soon
|
||||
- packages/NodeTypeResolver/src/TypeContext.php
|
||||
|
|
|
@ -49,9 +49,13 @@ final class VarDumperTestTraitMethodArgsRector extends AbstractRector
|
|||
|
||||
public function isCandidate(Node $node): bool
|
||||
{
|
||||
if (! $this->methodCallAnalyzer->isStaticMethodCallTypeAndMethods($node,self::TRAIT_NAME, ['assertDumpEquals', 'assertDumpMatchesFormat'])) {
|
||||
if (! $this->methodCallAnalyzer->isStaticMethodCallTypeAndMethods(
|
||||
$node,
|
||||
self::TRAIT_NAME,
|
||||
['assertDumpEquals', 'assertDumpMatchesFormat']
|
||||
)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** @var StaticCall $node */
|
||||
if (count($node->args) <= 2) {
|
||||
|
|
|
@ -4,10 +4,9 @@ namespace Rector\Rector\Contrib\SymfonyExtra;
|
|||
|
||||
use Nette\Utils\Strings;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\ClassConstFetch;
|
||||
use PhpParser\Node\Expr\ConstFetch;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Expr\PropertyFetch;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
|
@ -17,7 +16,6 @@ use Rector\Builder\Naming\NameResolver;
|
|||
use Rector\Deprecation\SetNames;
|
||||
use Rector\Rector\AbstractRector;
|
||||
use Rector\Tests\Rector\Contrib\SymfonyExtra\GetterToPropertyRector\Source\LocalKernel;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
|
||||
/**
|
||||
* Ref: https://github.com/symfony/symfony/blob/master/UPGRADE-4.0.md#console
|
||||
|
@ -103,35 +101,24 @@ final class CommandToConstructorInjectionRector extends AbstractRector
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
public function isCandidate(Node $node): bool
|
||||
{
|
||||
if (! Strings::endsWith($this->getClassName(), 'Command')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// $this->getContainer()->get('some_service');
|
||||
if (! $node instanceof MethodCall) {
|
||||
// finds **$this->getContainer()->get**('some_service');
|
||||
if (! $node instanceof MethodCall || ! $node->var instanceof MethodCall) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (! $node->var instanceof MethodCall) {
|
||||
// finds **$this**->getContainer()->**get**('some_service');
|
||||
if ((string) $node->var->var->name !== 'this' || (string) $node->name !== 'get') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((string) $node->var->var->name !== 'this') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((string) $node->name !== 'get') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (! isset($node->args[0])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (! $node->args[0]->value instanceof String_) {
|
||||
// finds $this->getContainer()->get**('some_service')**;
|
||||
if (count($node->args) !== 1 || ! $node->args[0]->value instanceof String_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -170,7 +157,7 @@ final class CommandToConstructorInjectionRector extends AbstractRector
|
|||
private function createPropertyFetch(string $propertyName): PropertyFetch
|
||||
{
|
||||
return new PropertyFetch(
|
||||
new Node\Expr\Variable('this', [
|
||||
new Variable('this', [
|
||||
'name' => $propertyName,
|
||||
]),
|
||||
$propertyName
|
||||
|
|
|
@ -74,21 +74,17 @@ final class GetterToPropertyRector extends AbstractRector
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Node $node
|
||||
* Possibly simlify to just "$this->get('some_service')"
|
||||
*/
|
||||
public function isCandidate(Node $node): bool
|
||||
{
|
||||
// $var = $this->get('some_service');
|
||||
// $var = $this->get('some_service')->getData();
|
||||
// finds $var = $this->get('some_service');
|
||||
// finds $var = $this->get('some_service')->getData();
|
||||
if ($node instanceof Assign && ($node->expr instanceof MethodCall || $node->var instanceof MethodCall)) {
|
||||
if ($this->isContainerGetCall($node->expr)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// ['var => $this->get('some_service')->getData()]
|
||||
// finds ['var => $this->get('some_service')->getData()]
|
||||
if ($node instanceof MethodCall && $node->var instanceof MethodCall) {
|
||||
if ($this->isContainerGetCall($node->var)) {
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue
Block a user