diff --git a/build/target-repository/docs/rector_rules_overview.md b/build/target-repository/docs/rector_rules_overview.md index 05fd70387d4..ccf92b2d912 100644 --- a/build/target-repository/docs/rector_rules_overview.md +++ b/build/target-repository/docs/rector_rules_overview.md @@ -1,4 +1,4 @@ -# 372 Rules Overview +# 371 Rules Overview
@@ -56,7 +56,7 @@ - [Strict](#strict) (5) -- [Transform](#transform) (23) +- [Transform](#transform) (22) - [TypeDeclaration](#typedeclaration) (40) @@ -950,7 +950,7 @@ Change unsafe new `static()` to new `self()` - class: [`Rector\CodeQuality\Rector\New_\NewStaticToNewSelfRector`](../rules/CodeQuality/Rector/New_/NewStaticToNewSelfRector.php) ```diff - class SomeClass + final class SomeClass { public function build() { @@ -7201,46 +7201,6 @@ return static function (RectorConfig $rectorConfig): void {
-### NewArgToMethodCallRector - -Change new with specific argument to method call - -:wrench: **configure it!** - -- class: [`Rector\Transform\Rector\New_\NewArgToMethodCallRector`](../rules/Transform/Rector/New_/NewArgToMethodCallRector.php) - -```php -ruleWithConfiguration(NewArgToMethodCallRector::class, [ - new NewArgToMethodCall('Dotenv', true, 'usePutenv'), - ]); -}; -``` - -↓ - -```diff - class SomeClass - { - public function run() - { -- $dotenv = new Dotenv(true); -+ $dotenv = new Dotenv(); -+ $dotenv->usePutenv(); - } - } -``` - -
- ### NewToStaticCallRector Change new Object to static call diff --git a/rules-tests/Transform/Rector/New_/NewArgToMethodCallRector/Fixture/some_class.php.inc b/rules-tests/Transform/Rector/New_/NewArgToMethodCallRector/Fixture/some_class.php.inc deleted file mode 100644 index cbbd5dc97b8..00000000000 --- a/rules-tests/Transform/Rector/New_/NewArgToMethodCallRector/Fixture/some_class.php.inc +++ /dev/null @@ -1,31 +0,0 @@ - ------ -usePutenv(); - } -} - -?> diff --git a/rules-tests/Transform/Rector/New_/NewArgToMethodCallRector/NewArgToMethodCallRectorTest.php b/rules-tests/Transform/Rector/New_/NewArgToMethodCallRector/NewArgToMethodCallRectorTest.php deleted file mode 100644 index 0bdbe7ecc2f..00000000000 --- a/rules-tests/Transform/Rector/New_/NewArgToMethodCallRector/NewArgToMethodCallRectorTest.php +++ /dev/null @@ -1,28 +0,0 @@ -doTestFile($filePath); - } - - public static function provideData(): Iterator - { - return self::yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - public function provideConfigFilePath(): string - { - return __DIR__ . '/config/configured_rule.php'; - } -} diff --git a/rules-tests/Transform/Rector/New_/NewArgToMethodCallRector/Source/SomeDotenv.php b/rules-tests/Transform/Rector/New_/NewArgToMethodCallRector/Source/SomeDotenv.php deleted file mode 100644 index da93c4acbb2..00000000000 --- a/rules-tests/Transform/Rector/New_/NewArgToMethodCallRector/Source/SomeDotenv.php +++ /dev/null @@ -1,13 +0,0 @@ -ruleWithConfiguration( - NewArgToMethodCallRector::class, - [new NewArgToMethodCall(SomeDotenv::class, true, 'usePutenv')] - ); -}; diff --git a/rules/Transform/Rector/New_/NewArgToMethodCallRector.php b/rules/Transform/Rector/New_/NewArgToMethodCallRector.php deleted file mode 100644 index d0d9630164f..00000000000 --- a/rules/Transform/Rector/New_/NewArgToMethodCallRector.php +++ /dev/null @@ -1,112 +0,0 @@ -usePutenv(); - } -} -CODE_SAMPLE - , - [new NewArgToMethodCall('Dotenv', true, 'usePutenv')] - ), - ]); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [New_::class]; - } - - /** - * @param New_ $node - */ - public function refactor(Node $node): ?Node - { - if ($node->isFirstClassCallable()) { - return null; - } - - foreach ($this->newArgsToMethodCalls as $newArgToMethodCall) { - if (! $this->isObjectType($node->class, $newArgToMethodCall->getObjectType())) { - continue; - } - - if (! isset($node->getArgs()[0])) { - return null; - } - - if (! $node->args[0] instanceof Arg) { - return null; - } - - $firstArgValue = $node->args[0]->value; - if (! $this->valueResolver->isValue($firstArgValue, $newArgToMethodCall->getValue())) { - continue; - } - - unset($node->args[0]); - - return new MethodCall($node, $newArgToMethodCall->getMethodCall()); - } - - return null; - } - - /** - * @param mixed[] $configuration - */ - public function configure(array $configuration): void - { - Assert::allIsAOf($configuration, NewArgToMethodCall::class); - - $this->newArgsToMethodCalls = $configuration; - } -} diff --git a/rules/Transform/ValueObject/NewArgToMethodCall.php b/rules/Transform/ValueObject/NewArgToMethodCall.php deleted file mode 100644 index 888531bdacf..00000000000 --- a/rules/Transform/ValueObject/NewArgToMethodCall.php +++ /dev/null @@ -1,38 +0,0 @@ -type); - } - - /** - * @return mixed - */ - public function getValue() - { - return $this->value; - } - - public function getMethodCall(): string - { - return $this->methodCall; - } -}