
Rule new_with_parentheses
ΒΆ
All instances created with new
keyword must (not) be followed by
parentheses.
ConfigurationΒΆ
anonymous_class
ΒΆ
Whether anonymous classes should be followed by parentheses.
Allowed types: bool
Default value: true
named_class
ΒΆ
Whether named classes should be followed by parentheses.
Allowed types: bool
Default value: true
ExamplesΒΆ
Example #1ΒΆ
Default configuration.
--- Original
+++ New
<?php
-$x = new X;
-$y = new class {};
+$x = new X();
+$y = new class() {};
Example #2ΒΆ
With configuration: ['anonymous_class' => false]
.
--- Original
+++ New
<?php
-$y = new class() {};
+$y = new class {};
Example #3ΒΆ
With configuration: ['named_class' => false]
.
--- Original
+++ New
<?php
-$x = new X();
+$x = new X;
Rule setsΒΆ
The rule is part of the following rule sets: