setName("Just a name"); $user->setName("Some new name"); $userObserver = new UserObserver(); $user->attach($userObserver); $user->setName("Another new name"); $user->setName("Once again new name"); $user->setName("Possibly other new name"); /** @noinspection ForgottenDebugOutputInspection */ dump( getenv('APP_ENV'), ["Another new name", "Once again new name", "Possibly other new name"], $userObserver->getNamesLog(), ["Another new name", "Once again new name", "Possibly other new name"] === $userObserver->getNamesLog() );