I describe the Login method in the user model. The result of an email search query is an object of class User. Accordingly, if the password hashes match, I would like to record all the properties of the found object in the current object, and return it as the result of the method. Something like $this = $result; return $this; $this = $result; return $this;
public function login($email, $password) { $sql = 'SELECT * FROM user WHERE email = :email'; $db = new Db(); $result = $db->query($sql, self::class, [':email' => $email])[0]; if (password_verify($password, $result->getPassword())) { //Как здесь записать в текущий объект все свойства объекта $result? return $this; } else { $error = 'Неправильная пара логин\пароль'; return $error; } }