DowngradeNewMethodCallWithoutParenthesesRector
Add parentheses around new on method call, property fetch, static access, array access or invocation
-new Request()->withMethod('GET')->withUri('/hello-world');
-$message = new Regex('some-pattern')->message;
-$value = new ArrayObject($items)['key'];
+(new Request())->withMethod('GET')->withUri('/hello-world');
+$message = (new Regex('some-pattern'))->message;
+$value = (new ArrayObject($items))['key'];
Configure your rector.php:
<?php
use Rector\Config\RectorConfig;
use Rector\DowngradePhp84\Rector\MethodCall\DowngradeNewMethodCallWithoutParenthesesRector;
return RectorConfig::configure()
->withRules([
DowngradeNewMethodCallWithoutParenthesesRector::class,
]);