Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Mar 19, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants