[Utils] Add OnlyOneClassMethodRule (#4814)

* [Utils] Add OnlyOneClassMethodRule

* [ci-review] Rector Rectify

Co-authored-by: rector-bot <tomas@getrector.org>
This commit is contained in:
Tomas Votruba 2020-12-07 01:48:01 +01:00 committed by GitHub
parent e945b5705f
commit ca353017e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 23 additions and 22 deletions

View File

@ -18,7 +18,7 @@
"jean85/pretty-package-versions": "^1.5.1",
"nette/robot-loader": "^3.2",
"nette/utils": "^3.1",
"nikic/php-parser": "4.10.3",
"nikic/php-parser": "^4.10.3",
"phpstan/phpdoc-parser": "^0.4.9",
"phpstan/phpstan": "^0.12.52",
"phpstan/phpstan-phpunit": "^0.12.16",

View File

@ -3,8 +3,8 @@
declare(strict_types=1);
use Rector\Downgrade\Rector\LNumber\ChangePhpVersionInPlatformCheckRector;
use Rector\DowngradePhp73\Rector\FuncCall\SetCookieOptionsArrayToArgumentsRector;
use Rector\DowngradePhp73\Rector\FuncCall\DowngradeTrailingCommasInFunctionCallsRector;
use Rector\DowngradePhp73\Rector\FuncCall\SetCookieOptionsArrayToArgumentsRector;
use Rector\DowngradePhp73\Rector\List_\DowngradeListReferenceAssignmentRector;
use Rector\DowngradePhp73\Rector\String_\DowngradeFlexibleHeredocSyntaxRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

View File

@ -4,8 +4,8 @@ declare(strict_types=1);
use Rector\Downgrade\Rector\LNumber\ChangePhpVersionInPlatformCheckRector;
use Rector\DowngradePhp80\Rector\Catch_\DowngradeNonCapturingCatchesRector;
use Rector\DowngradePhp80\Rector\ClassConstFetch\DowngradeClassOnObjectToGetClassRector;
use Rector\DowngradePhp80\Rector\Class_\DowngradePropertyPromotionToConstructorPropertyAssignRector;
use Rector\DowngradePhp80\Rector\ClassConstFetch\DowngradeClassOnObjectToGetClassRector;
use Rector\DowngradePhp80\Rector\Expression\DowngradeMatchToSwitchRector;
use Rector\DowngradePhp80\Rector\FunctionLike\DowngradeParamMixedTypeDeclarationRector;
use Rector\DowngradePhp80\Rector\FunctionLike\DowngradeReturnMixedTypeDeclarationRector;

View File

@ -10,9 +10,9 @@ use PhpParser\Node\Expr\Array_;
use PhpParser\Node\Expr\ArrayItem;
use PhpParser\Node\Expr\ConstFetch;
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Scalar\String_;
use PhpParser\Node\Scalar\LNumber;
use PhpParser\Node\Name;
use PhpParser\Node\Scalar\LNumber;
use PhpParser\Node\Scalar\String_;
use Rector\Core\Exception\ShouldNotHappenException;
use Rector\Core\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
@ -35,10 +35,14 @@ final class SetCookieOptionsArrayToArgumentsRector extends AbstractRector
'httponly' => 6,
];
/** @var int */
/**
* @var int
*/
private $highestIndex = 1;
/** @var Arg[] */
/**
* @var Arg[]
*/
private $newArguments = [];
public function getRuleDefinition(): RuleDefinition
@ -91,12 +95,7 @@ CODE_SAMPLE
if ($argsCount <= 2) {
return true;
}
if (! ($funcCall->args[2]->value instanceof Array_)) {
return true;
}
return false;
return ! ($funcCall->args[2]->value instanceof Array_);
}
/**

View File

@ -5,9 +5,7 @@ declare(strict_types=1);
namespace Rector\DowngradePhp73\Tests\Rector\FuncCall\SetCookieOptionsArrayToArgumentsRector;
use Iterator;
use Rector\Core\ValueObject\PhpVersionFeature;
use Rector\DowngradePhp73\Rector\FuncCall\SetCookieOptionsArrayToArgumentsRector;
use Rector\DowngradePhp73\Rector\List_\DowngradeListReferenceAssignmentRector;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
use Symplify\SmartFileSystem\SmartFileInfo;

View File

@ -5,7 +5,6 @@ declare(strict_types=1);
namespace Rector\PSR4\Tests\Rector\FileWithoutNamespace\NormalizeNamespaceByPSR4ComposerAutoloadRector;
use Iterator;
use Rector\PSR4\Rector\FileWithoutNamespace\NormalizeNamespaceByPSR4ComposerAutoloadRector;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
use Symplify\SmartFileSystem\SmartFileInfo;
@ -28,9 +27,4 @@ final class NormalizeNamespaceByPSR4ComposerAutoloadRectorTest extends AbstractR
{
return new SmartFileInfo(__DIR__ . '/config/normalize_namespace_without_namespace_config.php');
}
protected function getRectorClass(): string
{
return NormalizeNamespaceByPSR4ComposerAutoloadRector::class;
}
}

View File

@ -1,4 +1,14 @@
services:
-
class: Symplify\PHPStanRules\Rules\OnlyOneClassMethodRule
tags: [phpstan.rules.rule]
arguments:
onlyOneMethodsByType:
Rector\Testing\PHPUnit\AbstractRectorTestCase:
- getRectorClass
- provideConfigFileInfo
- getRectorsWithConfiguration
-
class: Symplify\PHPStanRules\Rules\ForbiddenMethodCallOnTypeRule
tags: [phpstan.rules.rule]
@ -6,7 +16,7 @@ services:
forbiddenMethodNamesByTypes:
PhpParser\Node:
- 'getComments'
- getDocComment
- 'getDocComment'
-
class: Rector\PHPStanExtensions\Rule\RequireRectorCategoryByGetNodeTypesRule