Объект-заместитель контролирует доступ к другому объекту: ленивая инициализация, кеширование, проверка прав, логирование.
class LazyRepositoryProxy implements UserRepositoryInterface {
private ?UserRepository $real = null;
public function find(int $id): User {
$this->real ??= new UserRepository($this->connection);
return $this->real->find($id);
}
}Виды: Virtual (ленивая загрузка), Protection (access control), Remote, Cache proxy.