# Suggest new operator like with in c#

- Thread: https://externals.io/message/130010
- Original archive: https://news-web.php.net/php.internals/130010
- Started by Ivan Borzenkov on 2026-02-04T15:50:55+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #130010 — Ivan Borzenkov — 2026-02-04T15:50:55+00:00

URL: https://externals.io/message/130010#130010

Hello

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

$item
     ->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
;

---

## #130011 — Larry Garfield — 2026-02-04T16:03:01+00:00

URL: https://externals.io/message/130010#130011 · In reply to: #130010

> Hello
>
> 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
>
> $item
>      ->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
> ;

These 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(
    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.

--Larry Garfield

---

## #130015 — Ben Ramsey — 2026-02-04T18:52:54+00:00

URL: https://externals.io/message/130010#130015 · In reply to: #130011

> 
> > […]
> 
> These 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(
>      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.


I imagine this is desirable when one moves away from defining setters 
and uses property hooks instead.

Cheers,
Ben
