This RFC allows to omit parentheses around the new expression when constructor arguments' parentheses are present.
$highlighter = (new Highlighter())->withGutter(); $highlighter = new Highlighter()->withGutter();
It also works with accessing properties, constants, etc.
new MyClass()::CONSTANT; new MyClass()::$staticProperty; new MyClass()::staticMethod(); new MyClass()->property; new MyClass()->method(); new MyClass()();
The code will be easier to read
If we remove parentheses for this case, why having them for the if statement and so on?
I think it's necessary for the parentheses to be kept because you have to prioritize the object instanciation to use a method it exposes.
It could led to typos because of the space between New and the Class instantiated, the "old" approach is more readable too
first of all it looks wrong
its a method on an object, which itself could be chainable; wrapping it in brackets makes it it object
not logical to remove them.
lgtm
I think this feels a lot cleaner. Not sure what the internal implications of this are but I like it.
Much cleaner
Makes it just cleaner
Ship it!
me parece una buena adición al lenguaje
It is a good quality of live improvement, I can't think of a possible downside
I think I would be fine if this had been in PHP all along, but for all existing developers this proposal really messes up my feeling for reading code. PHP always considers a space between words/symbols as a separator between two things. If you want to combine the result of that, you need to always use parentheses, so why create an exception here?
Less code is better code, this is implicit language priority no need to express it
This RFC proposes a way to have multi-line short closures — closures that don't need explicit use
statements, but can still have multiple lines and a return statement.
The "pipe operator" |>
allows you to chain multiple function calls in a more convenient way.