apply more cs rules for php-cs

This commit is contained in:
2023-10-17 13:27:03 +02:00
parent 0b0cbed9db
commit bc2041cbdd
1485 changed files with 8169 additions and 9620 deletions

View File

@@ -14,10 +14,7 @@ namespace Chill\MainBundle\Command;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Notification\Mailer;
use Chill\MainBundle\Security\PasswordRecover\RecoverPasswordHelper;
use DateTime;
use Doctrine\ORM\EntityManagerInterface;
use Exception;
use InvalidArgumentException;
use League\Csv\Reader;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Command\Command;
@@ -27,11 +24,6 @@ use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use function array_key_exists;
use function array_merge;
use function in_array;
use function trim;
/**
* Class ChillUserSendRenewPasswordCodeCommand.
*/
@@ -115,19 +107,20 @@ class ChillUserSendRenewPasswordCodeCommand extends Command
$this->sendRecoverCode($user);
}
return 0;
}
/**
* @throws Exception
*
* @return Reader
*
* @throws \Exception
*/
protected function getReader()
{
try {
$reader = Reader::createFromPath($this->input->getArgument('csvfile'));
} catch (Exception $e) {
} catch (\Exception $e) {
$this->logger->error('The csv file could not be read', [
'path' => $this->input->getArgument('csvfile'),
]);
@@ -140,11 +133,10 @@ class ChillUserSendRenewPasswordCodeCommand extends Command
$headers = $reader->getHeader();
if (
false === in_array('username', $headers, true)
&& false === in_array('email', $headers, true)
false === \in_array('username', $headers, true)
&& false === \in_array('email', $headers, true)
) {
throw new InvalidArgumentException('The csv file does not have an '
. 'username or email header');
throw new \InvalidArgumentException('The csv file does not have an username or email header');
}
return $reader;
@@ -156,16 +148,16 @@ class ChillUserSendRenewPasswordCodeCommand extends Command
$userRepository = $this->em->getRepository(User::class);
try {
if (array_key_exists('email', $row)) {
return $userRepository->findOneByUsernameOrEmail(trim((string) $row['email']));
if (\array_key_exists('email', $row)) {
return $userRepository->findOneByUsernameOrEmail(\trim((string) $row['email']));
}
} catch (\Doctrine\ORM\NoResultException) {
// continue, we will try username
}
try {
if (array_key_exists('username', $row)) {
return $userRepository->findOneByUsernameOrEmail(trim((string) $row['username']));
if (\array_key_exists('username', $row)) {
return $userRepository->findOneByUsernameOrEmail(\trim((string) $row['username']));
}
} catch (\Doctrine\ORM\NoResultException) {
return null;
@@ -174,7 +166,7 @@ class ChillUserSendRenewPasswordCodeCommand extends Command
protected function onUserNotFound($row, $offset)
{
$this->logger->alert('User not found', array_merge([
$this->logger->alert('User not found', \array_merge([
'offset' => $offset,
], $row));
}
@@ -191,7 +183,7 @@ class ChillUserSendRenewPasswordCodeCommand extends Command
}
$template = $this->input->getOption('template');
$expiration = DateTime::createFromFormat(
$expiration = \DateTime::createFromFormat(
'U',
$this->input->getOption('expiration')
);