phpstan level 3, fixed deprecations, code cleanup (#811)

This commit is contained in:
Kevin Papst
2019-05-28 12:24:21 +02:00
committed by GitHub
parent d9dca96a32
commit 393abe9e62
69 changed files with 381 additions and 189 deletions

View File

@@ -125,7 +125,7 @@ class ConvertTimezoneCommand extends Command
if ('y' !== $answer) {
$io->text('Aborting.');
return;
return 1;
}
$utc = new \DateTimeZone('UTC');
@@ -145,5 +145,7 @@ class ConvertTimezoneCommand extends Command
$io->writeln('. (' . $i . '/' . $amount . ')');
$io->writeln('');
return 0;
}
}

View File

@@ -10,7 +10,6 @@
namespace App\Command;
use App\Entity\User;
use Doctrine\Bundle\DoctrineBundle\Registry;
use Symfony\Bridge\Doctrine\RegistryInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\QuestionHelper;
@@ -19,7 +18,6 @@ use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\Question;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoder;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
use Symfony\Component\Validator\Validator\ValidatorInterface;
@@ -29,11 +27,11 @@ use Symfony\Component\Validator\Validator\ValidatorInterface;
class CreateUserCommand extends Command
{
/**
* @var UserPasswordEncoder
* @var UserPasswordEncoderInterface
*/
protected $encoder;
/**
* @var Registry
* @var RegistryInterface
*/
protected $doctrine;
/**
@@ -124,7 +122,7 @@ class CreateUserCommand extends Command
);
}
return;
return 1;
}
try {
@@ -132,10 +130,14 @@ class CreateUserCommand extends Command
$entityManager->persist($user);
$entityManager->flush();
$io->success('Success! Created user: ' . $user->getUsername());
return 0;
} catch (\Exception $ex) {
$io->error('Failed to create user: ' . $user->getUsername());
$io->error('Reason: ' . $ex->getMessage());
}
return 2;
}
/**

View File

@@ -29,7 +29,6 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoder;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
use Symfony\Component\Validator\Validator\ValidatorInterface;
@@ -48,7 +47,7 @@ class KimaiImporterCommand extends Command
/**
* Create the user default passwords
* @var UserPasswordEncoder
* @var UserPasswordEncoderInterface
*/
protected $encoder;
/**
@@ -389,7 +388,7 @@ class KimaiImporterCommand extends Command
/**
* Thanks to "xelozz -at- gmail.com", see http://php.net/manual/en/function.memory-get-usage.php#96280
* @param $size
* @param int $size
* @return string
*/
protected function bytesHumanReadable($size)
@@ -402,7 +401,7 @@ class KimaiImporterCommand extends Command
}
/**
* @param $table
* @param string $table
* @param array $where
* @return array
*/
@@ -429,7 +428,7 @@ class KimaiImporterCommand extends Command
/**
* @param SymfonyStyle $io
* @param $object
* @param object $object
* @return bool
*/
protected function validateImport(SymfonyStyle $io, $object)

View File

@@ -10,6 +10,7 @@
namespace App\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
@@ -129,6 +130,7 @@ EOT
return true;
}
/** @var QuestionHelper $questionHelper */
$questionHelper = $this->getHelperSet()->get('question');
$question = new ConfirmationQuestion('<question>' . $question . '</question>', $default);

View File

@@ -47,27 +47,29 @@ class VersionCommand extends Command
if ($input->getOption('semver')) {
$io->writeln(Constants::VERSION . '-' . Constants::STATUS);
return;
return 0;
}
if ($input->getOption('short')) {
$io->writeln(Constants::VERSION);
return;
return 0;
}
if ($input->getOption('name')) {
$io->writeln(Constants::NAME);
return;
return 0;
}
if ($input->getOption('candidate')) {
$io->writeln(Constants::STATUS);
return;
return 0;
}
$io->writeln('Kimai 2 - ' . Constants::VERSION . ' ' . Constants::STATUS . ' (' . Constants::NAME . ') by Kevin Papst and contributors.');
return 0;
}
}