Re: Suggest new operator like with in c#
| From: | Ben Ramsey | Date: | Wed, 04 Feb 2026 18:52:54 +0000 |
| Subject: | Re: Suggest new operator like with in c# | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-130015@lists.php.net to get a copy of this message | ||
On 2/4/26 10:03, Larry Garfield wrote:
On Wed, Feb 4, 2026, at 9:50 AM, Ivan Borzenkov wrote:I imagine this is desirable when one moves away from defining setters and uses property hooks instead. Cheers, BenHello As i read in https://wiki.php.net/rfc/howto write here “concept”. For fill dto and other same objects need assign to many fields of on object, before properties was be use return $this in setters and code loos like this $itemThese days, such objects usually have promoted properties in their constructor, and we have named arguments, which allows this already: readonly class Item { public function __construct(->setType(Item::TYPE_CLOUT) ->setProduct($product) ->setPrice($price)and it was single operator, but it not work with simple property or get-set function need write $item->type = Item::TYPE_CLOUT; $item->product = $product; $item->price = $price; suggest add operator like with in c# which do action and back context back and use for example :> same assign will be look like this $item:>type = Item::TYPE_CLOUT :>product = $product :>price = $price;public int $type, public Product $product, public float $price,) {} } $item = new Item( type: Item::TYPE_CLOUT, product: $product, price: $price ); In what way is that insufficient? True it only works on the constructor, but commonly such objects are only assigned to in the constructor.