code cleanup for phpstan level 4 (#1522)
This commit is contained in:
@@ -293,7 +293,7 @@ final class TeamController extends BaseApiController
|
||||
throw new NotFoundException('Team not found');
|
||||
}
|
||||
|
||||
/** @var User $user */
|
||||
/** @var User|null $user */
|
||||
$user = $repository->find($userId);
|
||||
|
||||
if (null === $user) {
|
||||
@@ -356,7 +356,7 @@ final class TeamController extends BaseApiController
|
||||
throw new NotFoundException('Team not found');
|
||||
}
|
||||
|
||||
/** @var User $user */
|
||||
/** @var User|null $user */
|
||||
$user = $repository->find($userId);
|
||||
|
||||
if (null === $user) {
|
||||
@@ -419,7 +419,7 @@ final class TeamController extends BaseApiController
|
||||
throw new NotFoundException('Team not found');
|
||||
}
|
||||
|
||||
/** @var Customer $customer */
|
||||
/** @var Customer|null $customer */
|
||||
$customer = $repository->find($customerId);
|
||||
|
||||
if (null === $customer) {
|
||||
@@ -482,7 +482,7 @@ final class TeamController extends BaseApiController
|
||||
throw new NotFoundException('Team not found');
|
||||
}
|
||||
|
||||
/** @var Customer $customer */
|
||||
/** @var Customer|null $customer */
|
||||
$customer = $repository->find($customerId);
|
||||
|
||||
if (null === $customer) {
|
||||
@@ -541,7 +541,7 @@ final class TeamController extends BaseApiController
|
||||
throw new NotFoundException('Team not found');
|
||||
}
|
||||
|
||||
/** @var Project $project */
|
||||
/** @var Project|null $project */
|
||||
$project = $repository->find($projectId);
|
||||
|
||||
if (null === $project) {
|
||||
@@ -604,7 +604,7 @@ final class TeamController extends BaseApiController
|
||||
throw new NotFoundException('Team not found');
|
||||
}
|
||||
|
||||
/** @var Project $project */
|
||||
/** @var Project|null $project */
|
||||
$project = $repository->find($projectId);
|
||||
|
||||
if (null === $project) {
|
||||
|
||||
@@ -103,13 +103,7 @@ class CreateReleaseCommand extends Command
|
||||
$io->success('Prepare new packages for Kimai ' . $version . ' in ' . $tmpDir);
|
||||
|
||||
$gitCmd = sprintf(self::CLONE_CMD, $version);
|
||||
$zip = 'kimai-release-' . $version;
|
||||
|
||||
if ($version === Constants::VERSION && Constants::STATUS !== 'stable') {
|
||||
$zip .= '_' . Constants::STATUS;
|
||||
}
|
||||
|
||||
$zip .= '.zip';
|
||||
$zip = 'kimai-release-' . $version . '.zip';
|
||||
|
||||
$prefix = 'APP_ENV=prod DATABASE_URL=sqlite:///%kernel.project_dir%/var/data/kimai.sqlite';
|
||||
|
||||
|
||||
@@ -26,11 +26,6 @@ class ExportServiceCompilerPass implements CompilerPassInterface
|
||||
*/
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
// always first check if the primary service is defined
|
||||
if (!$container->has(ServiceExport::class)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$definition = $container->findDefinition(ServiceExport::class);
|
||||
|
||||
$taggedRenderer = $container->findTaggedServiceIds(Kernel::TAG_EXPORT_RENDERER);
|
||||
|
||||
@@ -26,11 +26,6 @@ class InvoiceServiceCompilerPass implements CompilerPassInterface
|
||||
*/
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
// always first check if the primary service is defined
|
||||
if (!$container->has(ServiceInvoice::class)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$definition = $container->findDefinition(ServiceInvoice::class);
|
||||
|
||||
$taggedRenderer = $container->findTaggedServiceIds(Kernel::TAG_INVOICE_RENDERER);
|
||||
|
||||
@@ -26,11 +26,6 @@ class WidgetCompilerPass implements CompilerPassInterface
|
||||
*/
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
// always first check if the primary service is defined
|
||||
if (!$container->has(WidgetRepository::class)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$definition = $container->findDefinition(WidgetRepository::class);
|
||||
|
||||
$taggedRenderer = $container->findTaggedServiceIds(Kernel::TAG_WIDGET);
|
||||
|
||||
@@ -42,10 +42,6 @@ class TimezoneSubscriber implements EventSubscriberInterface
|
||||
|
||||
$user = $this->storage->getToken()->getUser();
|
||||
|
||||
if (null === $user) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($user instanceof User) {
|
||||
date_default_timezone_set($user->getTimezone());
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ class UserPreferenceSubscriber implements EventSubscriberInterface
|
||||
return $this->formConfig->getUserDefaultTheme();
|
||||
}
|
||||
|
||||
private function getDefaultCurrency(): ?string
|
||||
private function getDefaultCurrency(): string
|
||||
{
|
||||
return $this->formConfig->getUserDefaultCurrency();
|
||||
}
|
||||
|
||||
@@ -123,10 +123,6 @@ trait FormTrait
|
||||
$event->getForm()->add('activity', ActivityType::class, [
|
||||
'placeholder' => '',
|
||||
'query_builder' => function (ActivityRepository $repo) use ($data, $activity) {
|
||||
if (!empty($activity) && is_string($activity)) {
|
||||
$activity = $repo->find($activity);
|
||||
}
|
||||
|
||||
return $repo->getQueryBuilderForFormType(new ActivityFormTypeQuery($activity, $data['project']));
|
||||
},
|
||||
]);
|
||||
|
||||
@@ -27,7 +27,7 @@ interface InvoiceFormatter
|
||||
public function getFormattedTime(\DateTime $date);
|
||||
|
||||
/**
|
||||
* @param int $amount
|
||||
* @param int|float $amount
|
||||
* @param string|null $currency
|
||||
* @return mixed
|
||||
*/
|
||||
|
||||
@@ -63,11 +63,14 @@ class LdapUserHydrator
|
||||
|
||||
$this->hydrateUserWithAttributesMap($user, $ldapEntry, $attributeMap);
|
||||
|
||||
if (is_array($user->getEmail())) {
|
||||
$user->setEmail($user->getEmail()[0]);
|
||||
/** @var string|array|null $email */
|
||||
$email = $user->getEmail();
|
||||
|
||||
if (is_array($email)) {
|
||||
$user->setEmail($email[0]);
|
||||
}
|
||||
|
||||
if (null === $user->getEmail()) {
|
||||
if (null === $email) {
|
||||
$user->setEmail($user->getUsername());
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ class TimesheetQuery extends ActivityQuery
|
||||
/**
|
||||
* Limit the data exclusively to the user (eg. users own timesheets).
|
||||
*
|
||||
* @return User|null
|
||||
* @return User|int|null
|
||||
*/
|
||||
public function getUser()
|
||||
{
|
||||
|
||||
@@ -17,7 +17,6 @@ use Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProvid
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
||||
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
|
||||
use Symfony\Component\Security\Core\User\ChainUserProvider;
|
||||
use Symfony\Component\Security\Core\User\UserProviderInterface;
|
||||
|
||||
final class SamlProvider implements AuthenticationProviderInterface
|
||||
@@ -51,9 +50,6 @@ final class SamlProvider implements AuthenticationProviderInterface
|
||||
{
|
||||
$user = null;
|
||||
|
||||
/** @var ChainUserProvider $p */
|
||||
$p = $this->userProvider;
|
||||
|
||||
try {
|
||||
$user = $this->userProvider->loadUserByUsername($token->getUsername());
|
||||
} catch (UsernameNotFoundException $e) {
|
||||
@@ -73,14 +69,10 @@ final class SamlProvider implements AuthenticationProviderInterface
|
||||
);
|
||||
}
|
||||
|
||||
if ($user) {
|
||||
$authenticatedToken = $this->tokenFactory->createToken($user, $token->getAttributes(), $user->getRoles());
|
||||
$authenticatedToken->setAuthenticated(true);
|
||||
$authenticatedToken = $this->tokenFactory->createToken($user, $token->getAttributes(), $user->getRoles());
|
||||
$authenticatedToken->setAuthenticated(true);
|
||||
|
||||
return $authenticatedToken;
|
||||
}
|
||||
|
||||
throw new AuthenticationException('The authentication failed.');
|
||||
return $authenticatedToken;
|
||||
}
|
||||
|
||||
public function supports(TokenInterface $token)
|
||||
|
||||
@@ -36,7 +36,7 @@ final class DoctrineUserProvider implements UserProviderInterface
|
||||
$user = null;
|
||||
|
||||
try {
|
||||
/** @var User $user */
|
||||
/** @var User|null $user */
|
||||
$user = $this->repository->loadUserByUsername($username);
|
||||
} catch (\Exception $ex) {
|
||||
}
|
||||
@@ -57,7 +57,7 @@ final class DoctrineUserProvider implements UserProviderInterface
|
||||
throw new UnsupportedUserException(sprintf('Expected an instance of %s, but got "%s".', User::class, get_class($user)));
|
||||
}
|
||||
|
||||
/** @var User $reloadedUser */
|
||||
/** @var User|null $reloadedUser */
|
||||
$reloadedUser = $this->repository->getUserById($user->getId());
|
||||
|
||||
if (null === $reloadedUser) {
|
||||
|
||||
Reference in New Issue
Block a user