-
-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blog #611
Blog #611
Conversation
PR Summary
|
Thank you! |
$user = $this->signupForm->signup(); | ||
} catch (Throwable $t) { | ||
$io->error($t->getMessage() . ' ' . $t->getFile() . ' ' . $t->getLine()); | ||
|
||
return $t->getCode() ?: ExitCode::UNSPECIFIED_ERROR; | ||
} | ||
|
||
if ($user === false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Psalm Level 1: Testing
ERROR: TypeDoesNotContainType - src/User/Console/CreateCommand.php:78:13 - Type App\User\User for $user is never falsy (see https://psalm.dev/056)
if ($user === false) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recommended: if (!$user instanceof User) {
@@ -12,14 +12,19 @@ | |||
use Symfony\Component\Console\Output\OutputInterface; | |||
use Symfony\Component\Console\Style\SymfonyStyle; | |||
use Throwable; | |||
use Yiisoft\FormModel\FormHydrator; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Psalm Level 1 Testing Recommendation: Add the following to support recommendation below:
use App\User\User;
$errors = $this->signupForm->getFormErrors()->getFirstErrors(); | ||
array_walk($errors, fn ($error, $attribute) => $io->error("$attribute: $error")); | ||
|
||
$errors = $this->signupForm->getValidationResult()?->getErrorMessagesIndexedByAttribute(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Psalm Level 1 Testing:
ERROR: TypeDoesNotContainNull - src/User/Console/CreateCommand.php:62:23 - Yiisoft\Validator\Result does not contain null (see https://psalm.dev/090)
$errors = $this->signupForm->getValidationResult()?->getErrorMessagesIndexedByAttribute();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recommended: Remove the question mark in getValidationResult?
fixed errors and updated the code a little