mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-01 17:00:51 +00:00
[Utils] Add OnlyOneClassMethodRule (#4814)
* [Utils] Add OnlyOneClassMethodRule * [ci-review] Rector Rectify Co-authored-by: rector-bot <tomas@getrector.org>
This commit is contained in:
parent
e945b5705f
commit
ca353017e2
|
@ -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",
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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_);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user