mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-05 15:43:29 +02:00
Update User.php
php8.1 test error handle
This commit is contained in:
@ -22,23 +22,23 @@ class User implements SplSubject
|
|||||||
$this->observers = new SplObjectStorage();
|
$this->observers = new SplObjectStorage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function attach(SplObserver $observer)
|
public function attach(SplObserver $observer): void
|
||||||
{
|
{
|
||||||
$this->observers->attach($observer);
|
$this->observers->attach($observer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function detach(SplObserver $observer)
|
public function detach(SplObserver $observer): void
|
||||||
{
|
{
|
||||||
$this->observers->detach($observer);
|
$this->observers->detach($observer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function changeEmail(string $email)
|
public function changeEmail(string $email): void
|
||||||
{
|
{
|
||||||
$this->email = $email;
|
$this->email = $email;
|
||||||
$this->notify();
|
$this->notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function notify()
|
public function notify(): void
|
||||||
{
|
{
|
||||||
/** @var SplObserver $observer */
|
/** @var SplObserver $observer */
|
||||||
foreach ($this->observers as $observer) {
|
foreach ($this->observers as $observer) {
|
||||||
|
Reference in New Issue
Block a user