0

I see some people use braces "()" when creating a new instance of a class using new. Some do not.

Is there any difference?

localheinz
  • 9,179
  • 2
  • 33
  • 44
  • 2
    No difference if they are empty. Reason is they can be omitted if so. They are only required if you want to hand over arguments, then you do need them for syntactical reasons. – arkascha Jul 01 '17 at 07:24
  • You can enforce using `new` with braces using https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/2.3/src/Fixer/Operator/NewWithBracesFixer.php. – localheinz Jul 01 '17 at 08:37

0 Answers0