Skip to content

Commit 359c74c

Browse files
ohmyfelixf3l1x
authored andcommitted
Fix phpstan value typing in HomePresenter form validation
1 parent ee864f3 commit 359c74c

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

app/UI/Home/HomePresenter.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use App\UI\BasePresenter;
66
use Nette\Application\UI\Form;
7-
use Nette\Utils\ArrayHash;
87
use Nette\Utils\DateTime;
98
use Nette\Utils\Html;
109
use Nette\Utils\Strings;
@@ -53,11 +52,11 @@ protected function createComponentUserForm(): Form
5352

5453
$form->onValidate[] = function (Form $form): void {
5554
$values = $form->getUntrustedValues();
56-
assert($values instanceof ArrayHash);
55+
$email = is_object($values) ? ($values->email ?? null) : ($values['email'] ?? null);
5756

5857
// Validate e-mail duplicities (against DB?)
59-
if (str_ends_with($values->email, '@nette.org')) {
60-
$form->addError(sprintf('E-mail "%s" is already picked', $values->email));
58+
if (is_string($email) && str_ends_with($email, '@nette.org')) {
59+
$form->addError(sprintf('E-mail "%s" is already picked', $email));
6160
}
6261
};
6362

0 commit comments

Comments
 (0)