Skip to content

Fix method name in StaticCallToMethodCallRector, in case of method is static#6789

Merged
samsonasik merged 1 commit intorectorphp:mainfrom
parth391:main
Mar 19, 2025
Merged

Fix method name in StaticCallToMethodCallRector, in case of method is static#6789
samsonasik merged 1 commit intorectorphp:mainfrom
parth391:main

Conversation

@parth391
Copy link
Contributor

This PR fixes method name in StaticCallToMethodCallRector, while method is static and wildcard is used. At the moment method name is been replaced by the *.

Config

$rectorConfig
    ->ruleWithConfiguration(StaticCallToMethodCallRector::class, [
        new StaticCallToMethodCall(
            'Illuminate\Support\Facades\App',
            '*',
            'Illuminate\Foundation\Application',
            '*'
        ),
    ]);

Before

use Illuminate\Support\Facades\App;

class ModelSeeder
{
    public static function seed() {
        App::get(ClassName::class)
            ->handle();
    }
}

After

use Illuminate\Support\Facades\App;

class ModelSeeder
{
    public static function seed() {
        (new \Illuminate\Foundation\Application())->*(SomeClass::class)
             ->handle();
    }
}

Expected

use Illuminate\Support\Facades\App;

class ModelSeeder
{
    public static function seed() {
        (new \Illuminate\Foundation\Application())->get(SomeClass::class)
             ->handle();
    }
}

@samsonasik samsonasik merged commit d80e482 into rectorphp:main Mar 19, 2025
44 checks passed
@samsonasik
Copy link
Member

Thank you @parth391

@github-actions
Copy link
Contributor

github-actions bot commented Dec 7, 2025

This pull request has been automatically locked because it has been closed for 150 days. Please open a new PR if you want to continue the work.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 7, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants