for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace App\Console\Commands\Traits;
trait AskForPassword
{
private function askForPassword(): string
do {
$password = $this->secret('Your desired password');
secret()
If this is a false-positive, you can also ignore this issue in your code via the ignore-call annotation
ignore-call
/** @scrutinizer ignore-call */
if (!$password) {
$this->error('Passwords cannot be empty. You know that.');
error()
$this->/** @scrutinizer ignore-call */
error('Passwords cannot be empty. You know that.');
continue;
}
$confirmedPassword = $this->secret('Again, just to be sure');
} while (!$this->comparePasswords($password, $confirmedPassword ?? null));
return $password;
private function comparePasswords(?string $password, ?string $confirmedPassword): bool
if (!$password || !$confirmedPassword) {
return false;
if (strcmp($password, $confirmedPassword) !== 0) {
$this->error('The passwords do not match. Try again maybe?');
return true;