Skip to content

[deprecation] Deprecate FuncCallToMethodCallRector - #8343

Merged
TomasVotruba merged 1 commit into
mainfrom
deprecate-func-call-to-method-call-rector
Aug 10, 2026
Merged

[deprecation] Deprecate FuncCallToMethodCallRector#8343
TomasVotruba merged 1 commit into
mainfrom
deprecate-func-call-to-method-call-rector

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Deprecates FuncCallToMethodCallRector.

The rule turns a function call into a local method call, but that only works when a matching service is already available in the class, when the method signature lines up and when the function has no side effects. In practice these conditions almost never hold together, so the rule breaks code more often than it helps.

 class SomeClass
 {
+    public function __construct(private \Namespaced\SomeRenderer $someRenderer)
+    {
+    }
+
     public function run()
     {
-        view('...');
+        $this->someRenderer->render('...');
     }
 }

The rule is not part of any set. It has to be configured by hand, and no core, Laravel or Drupal ruleset uses it. A project-specific custom rule is a safer way to do this change.

Notes:

  • Rector\Transform\ValueObject\FuncCallToMethodCall stays in place, so existing configs do not fatal.
  • NodeFactory::createMethodCall() gets an @api tag, as the last core caller is gone but rector-symfony, rector-doctrine and rector-phpunit still use it.

@TomasVotruba
TomasVotruba merged commit 7c1071c into main Aug 10, 2026
52 checks passed
@TomasVotruba
TomasVotruba deleted the deprecate-func-call-to-method-call-rector branch August 10, 2026 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant