$this as function argument

Hello,

Is it ok to pass $this as a argument to a function

(bad) example:

class Order{

 public function __construct($orderid, $user){
  $this->OrderId = $orderid;
  $this->User = $user;
 }
  public OrderId;
  public Product;
  public User;
}

class User{
 public ID;

 public function GetOrders(){
  /*Some funky code to get Orders from database by userID.*/
 $orders[] = new Order($row['orderId'], $this);
}

}

I know this works, im just making sure i am doing it correct

^^

Thanks

Passing $this is absolutely fine.

What I don’t like is this:

class Order{
 public function __construct($orderid, $user){

That will complicate things if, for example, you want to grab an order by an ID regardless of user.

Passing $this as an argument is fine.