rector-laravel icon indicating copy to clipboard operation
rector-laravel copied to clipboard

Facades are rewritten to Service via StaticCallOnNonStaticToInstanceCallRector

Open Jaspur opened this issue 1 year ago • 1 comments

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

Jaspur avatar Feb 26 '24 09:02 Jaspur

@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?

GeniJaho avatar Feb 29 '24 21:02 GeniJaho