On Fri, Jun 7, 2024, at 7:20 PM, Pierre wrote:

> I sincerely do not want to see a new operator for replacing the "new" 
> operator, because then we would have two different syntaxes which would 
> be semantically equivalent.
>
> Creating a new object, in most API design, is not something you do very 
> often, especially when working in a framework that does it for you 
> (dependency injection, etc...).

This is not entirely true.  Creating a new service object, yes, you rarely 
never do that yourself.  Creating a new data object (value object, struct 
object, DTO, and a dozen other terms) is something that should happen more than 
most PHP developers currently do, because most of us have primitive obsession.  
(Or array obsession.)  

Consider attributes: Any time you want to have an object as the value for one 
of the arguments to an attribute, you need a "new."  Any time you create a 
value object for a more strongly typed parameter than the horrid $options 
array, you'll be using "new."

So I'm sympathetic to making that syntax easier, and would be OK with it if a 
workable syntax was found.  But so far in this thread, a workable syntax has 
not been found.

I agree it's not the greatest usability concern in PHP right now, though.

--Larry Garfield

Reply via email to