driftingly / rector-laravel

Rector upgrades rules for Laravel
http://getrector.org
MIT License
469 stars 48 forks source link

Facades are rewritten to Service via StaticCallOnNonStaticToInstanceCallRector #187

Open Jaspur opened 4 months ago

Jaspur commented 4 months ago

Hi,

How can I prevent that Facades are being rewritten to Service classes?

-        $subtotal = Webshop::calculateTotals($order->cart, $order->country, coupon: $coupon);
+        $subtotal = (new Webshop())->calculateTotals($order->cart, $order->country, coupon: $coupon);

Want to keep the Facade-way, because Facade isn't static.

Adding one of those to withSkip() didn't help: ThisCallOnStaticMethodToStaticCallRector::class & StaticCallOnNonStaticToInstanceCallRector

GeniJaho commented 4 months ago

@Jaspur skipping StaticCallOnNonStaticToInstanceCallRector should work, unless there is some other rule that is making the change. When you run Rector (also with --dry-run), you can see which rule made the change, and you can skip it. If that doesn't work, can you share the rules you're using and skipping in your RectorConfig, please?