From 1b35356f818177ffb8ec12a843fa20aabe9ab488 Mon Sep 17 00:00:00 2001 From: Kevin Papst Date: Tue, 2 Nov 2021 13:33:21 +0100 Subject: [PATCH] activate bleeding edge phpstan rules (#2898) --- composer.lock | 12 ++++---- phpstan.neon | 1 + src/API/ActivityController.php | 4 +-- src/API/Model/I18nConfig.php | 8 ++++++ src/API/Model/TimesheetConfig.php | 6 ++++ src/API/ProjectController.php | 4 +-- src/API/TimesheetController.php | 17 ++--------- src/Activity/ActivityStatisticService.php | 5 +--- src/Command/InstallCommand.php | 7 +---- src/Command/KimaiImporterCommand.php | 22 --------------- src/Command/UpdateCommand.php | 7 +---- .../Reporting/ReportByUserController.php | 5 +--- .../Reporting/ReportUsersListController.php | 5 +--- src/Controller/TeamController.php | 28 ++++++++----------- src/Customer/CustomerStatisticService.php | 5 +--- src/Doctrine/AbstractMigration.php | 16 ----------- src/Entity/Configuration.php | 1 + src/Entity/Invoice.php | 1 + src/Entity/Role.php | 1 + src/Entity/RolePermission.php | 1 + src/Entity/Tag.php | 1 + src/Entity/TeamMember.php | 1 + src/Entity/User.php | 4 +-- .../Extension/SelectWithApiDataExtension.php | 6 +--- src/Form/QuickEntryForm.php | 3 ++ src/Form/TimesheetEditForm.php | 8 +----- src/Invoice/ServiceInvoice.php | 4 --- src/Ldap/LdapAuthenticationProvider.php | 1 + src/Repository/ConfigurationRepository.php | 27 +++++++++--------- src/Widget/Type/UserTeamProjects.php | 2 +- tests/Command/InstallCommandTest.php | 1 - tests/Command/UpdateCommandTest.php | 1 - 32 files changed, 73 insertions(+), 142 deletions(-) diff --git a/composer.lock b/composer.lock index bb1f9f9b..ac355928 100644 --- a/composer.lock +++ b/composer.lock @@ -6149,16 +6149,16 @@ }, { "name": "symfony/flex", - "version": "v1.17.1", + "version": "v1.17.2", "source": { "type": "git", "url": "https://github.com/symfony/flex.git", - "reference": "782ef2269622b8349c4bc3dc795fc79d39e8a5b2" + "reference": "0170279814f86648c62aede39b100a343ea29962" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/flex/zipball/782ef2269622b8349c4bc3dc795fc79d39e8a5b2", - "reference": "782ef2269622b8349c4bc3dc795fc79d39e8a5b2", + "url": "https://api.github.com/repos/symfony/flex/zipball/0170279814f86648c62aede39b100a343ea29962", + "reference": "0170279814f86648c62aede39b100a343ea29962", "shasum": "" }, "require": { @@ -6197,7 +6197,7 @@ "description": "Composer plugin for Symfony", "support": { "issues": "https://github.com/symfony/flex/issues", - "source": "https://github.com/symfony/flex/tree/v1.17.1" + "source": "https://github.com/symfony/flex/tree/v1.17.2" }, "funding": [ { @@ -6213,7 +6213,7 @@ "type": "tidelift" } ], - "time": "2021-10-14T06:14:48+00:00" + "time": "2021-10-21T08:39:19+00:00" }, { "name": "symfony/form", diff --git a/phpstan.neon b/phpstan.neon index b91b9525..effa03fc 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,6 +2,7 @@ includes: - vendor/phpstan/phpstan-symfony/extension.neon - vendor/phpstan/phpstan-doctrine/extension.neon - vendor/phpstan/phpstan-symfony/rules.neon + - vendor/phpstan/phpstan/conf/bleedingEdge.neon parameters: tmpDir: %rootDir%/../../../var/cache/phpstan diff --git a/src/API/ActivityController.php b/src/API/ActivityController.php index b99d7b70..25b3ffd4 100644 --- a/src/API/ActivityController.php +++ b/src/API/ActivityController.php @@ -123,9 +123,7 @@ class ActivityController extends BaseApiController if (!\is_array($projects)) { $projects = explode(',', $projects); } - if (!empty($projects)) { - $query->setProjects($projects); - } + $query->setProjects($projects); } if (!empty($project = $paramFetcher->get('project'))) { diff --git a/src/API/Model/I18nConfig.php b/src/API/Model/I18nConfig.php index 2ccefaf0..9688eece 100644 --- a/src/API/Model/I18nConfig.php +++ b/src/API/Model/I18nConfig.php @@ -26,6 +26,7 @@ final class I18nConfig * @Serializer\Expose() * @Serializer\Groups({"Default"}) * @Serializer\Type(name="string") + * @phpstan-ignore-next-line */ private $formDateTime = ''; /** @@ -36,6 +37,7 @@ final class I18nConfig * @Serializer\Expose() * @Serializer\Groups({"Default"}) * @Serializer\Type(name="string") + * @phpstan-ignore-next-line */ private $formDate = ''; /** @@ -46,6 +48,7 @@ final class I18nConfig * @Serializer\Expose() * @Serializer\Groups({"Default"}) * @Serializer\Type(name="string") + * @phpstan-ignore-next-line */ private $dateTime = ''; /** @@ -56,6 +59,7 @@ final class I18nConfig * @Serializer\Expose() * @Serializer\Groups({"Default"}) * @Serializer\Type(name="string") + * @phpstan-ignore-next-line */ private $date = ''; /** @@ -66,6 +70,7 @@ final class I18nConfig * @Serializer\Expose() * @Serializer\Groups({"Default"}) * @Serializer\Type(name="string") + * @phpstan-ignore-next-line */ private $time = ''; /** @@ -76,6 +81,7 @@ final class I18nConfig * @Serializer\Expose() * @Serializer\Groups({"Default"}) * @Serializer\Type(name="string") + * @phpstan-ignore-next-line */ private $duration = ''; /** @@ -86,6 +92,7 @@ final class I18nConfig * @Serializer\Expose() * @Serializer\Groups({"Default"}) * @Serializer\Type(name="boolean") + * @phpstan-ignore-next-line */ private $is24hours = true; /** @@ -96,6 +103,7 @@ final class I18nConfig * @Serializer\Expose() * @Serializer\Groups({"Default"}) * @Serializer\Type(name="DateTime") + * @phpstan-ignore-next-line */ private $now; diff --git a/src/API/Model/TimesheetConfig.php b/src/API/Model/TimesheetConfig.php index 0587642d..e5ad8274 100644 --- a/src/API/Model/TimesheetConfig.php +++ b/src/API/Model/TimesheetConfig.php @@ -26,6 +26,7 @@ final class TimesheetConfig * @Serializer\Expose() * @Serializer\Groups({"Default"}) * @Serializer\Type(name="string") + * @phpstan-ignore-next-line */ private $trackingMode = 'default'; /** @@ -36,6 +37,7 @@ final class TimesheetConfig * @Serializer\Expose() * @Serializer\Groups({"Default"}) * @Serializer\Type(name="string") + * @phpstan-ignore-next-line */ private $defaultBeginTime = 'now'; /** @@ -46,6 +48,7 @@ final class TimesheetConfig * @Serializer\Expose() * @Serializer\Groups({"Default"}) * @Serializer\Type(name="integer") + * @phpstan-ignore-next-line */ private $activeEntriesHardLimit = 1; /** @@ -56,6 +59,7 @@ final class TimesheetConfig * @Serializer\Expose() * @Serializer\Groups({"Default"}) * @Serializer\Type(name="integer") + * @phpstan-ignore-next-line */ private $activeEntriesSoftLimit = 1; /** @@ -66,6 +70,7 @@ final class TimesheetConfig * @Serializer\Expose() * @Serializer\Groups({"Default"}) * @Serializer\Type(name="boolean") + * @phpstan-ignore-next-line */ private $isAllowFutureTimes = true; /** @@ -76,6 +81,7 @@ final class TimesheetConfig * @Serializer\Expose() * @Serializer\Groups({"Default"}) * @Serializer\Type(name="boolean") + * @phpstan-ignore-next-line */ private $isAllowOverlapping = true; diff --git a/src/API/ProjectController.php b/src/API/ProjectController.php index ef114f8e..64b1acb6 100644 --- a/src/API/ProjectController.php +++ b/src/API/ProjectController.php @@ -123,9 +123,7 @@ class ProjectController extends BaseApiController if (!\is_array($customers)) { $customers = explode(',', $customers); } - if (!empty($customers)) { - $query->setCustomers($customers); - } + $query->setCustomers($customers); } if (!empty($customer = $paramFetcher->get('customer'))) { diff --git a/src/API/TimesheetController.php b/src/API/TimesheetController.php index bffd388d..7ca7ddea 100644 --- a/src/API/TimesheetController.php +++ b/src/API/TimesheetController.php @@ -23,7 +23,6 @@ use App\Repository\TagRepository; use App\Repository\TimesheetRepository; use App\Timesheet\TimesheetService; use App\Timesheet\TrackingMode\TrackingModeInterface; -use App\Timesheet\TrackingModeService; use App\Utils\SearchTerm; use Doctrine\Common\Collections\ArrayCollection; use FOS\RestBundle\Controller\Annotations as Rest; @@ -67,10 +66,6 @@ class TimesheetController extends BaseApiController * @var TagRepository */ private $tagRepository; - /** - * @var TrackingModeService - */ - private $trackingModeService; /** * @var EventDispatcherInterface */ @@ -152,9 +147,7 @@ class TimesheetController extends BaseApiController if (!\is_array($customers)) { $customers = explode(',', $customers); } - if (!empty($customers)) { - $query->setCustomers($customers); - } + $query->setCustomers($customers); } if (!empty($customer = $paramFetcher->get('customer'))) { @@ -165,9 +158,7 @@ class TimesheetController extends BaseApiController if (!\is_array($projects)) { $projects = explode(',', $projects); } - if (!empty($projects)) { - $query->setProjects($projects); - } + $query->setProjects($projects); } if (!empty($project = $paramFetcher->get('project'))) { @@ -178,9 +169,7 @@ class TimesheetController extends BaseApiController if (!\is_array($activities)) { $activities = explode(',', $activities); } - if (!empty($activities)) { - $query->setActivities($activities); - } + $query->setActivities($activities); } if (!empty($activity = $paramFetcher->get('activity'))) { diff --git a/src/Activity/ActivityStatisticService.php b/src/Activity/ActivityStatisticService.php index 4f8a0855..0378e451 100644 --- a/src/Activity/ActivityStatisticService.php +++ b/src/Activity/ActivityStatisticService.php @@ -14,7 +14,6 @@ use App\Event\ActivityBudgetStatisticEvent; use App\Event\ActivityStatisticEvent; use App\Model\ActivityBudgetStatisticModel; use App\Model\ActivityStatistic; -use App\Repository\ActivityRepository; use App\Repository\TimesheetRepository; use App\Timesheet\DateTimeFactory; use DateTime; @@ -27,13 +26,11 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface; */ class ActivityStatisticService { - private $activityRepository; private $timesheetRepository; private $dispatcher; - public function __construct(ActivityRepository $activityRepository, TimesheetRepository $timesheetRepository, EventDispatcherInterface $dispatcher) + public function __construct(TimesheetRepository $timesheetRepository, EventDispatcherInterface $dispatcher) { - $this->activityRepository = $activityRepository; $this->timesheetRepository = $timesheetRepository; $this->dispatcher = $dispatcher; } diff --git a/src/Command/InstallCommand.php b/src/Command/InstallCommand.php index b1adfa48..627a4512 100644 --- a/src/Command/InstallCommand.php +++ b/src/Command/InstallCommand.php @@ -35,19 +35,14 @@ final class InstallCommand extends Command public const ERROR_DATABASE = 8; public const ERROR_MIGRATIONS = 32; - /** - * @var string - */ - private $rootDir; /** * @var Connection */ private $connection; - public function __construct(string $projectDirectory, Connection $connection) + public function __construct(Connection $connection) { parent::__construct(); - $this->rootDir = $projectDirectory; $this->connection = $connection; } diff --git a/src/Command/KimaiImporterCommand.php b/src/Command/KimaiImporterCommand.php index 6ee6b106..c87551fc 100755 --- a/src/Command/KimaiImporterCommand.php +++ b/src/Command/KimaiImporterCommand.php @@ -117,12 +117,6 @@ final class KimaiImporterCommand extends Command * @var Customer[] */ private $customers = []; - /** - * Instance specific mappings of customer IDs to cache IDs - * - * @var string[] - */ - private $customerIds = []; /** * Old Project ID => new Project() * Global across all instances. @@ -130,12 +124,6 @@ final class KimaiImporterCommand extends Command * @var Project[] */ private $projects = []; - /** - * Instance specific mappings of project IDs to cache IDs - * - * @var string[] - */ - private $projectIds = []; /** * id => [projectId => Activity] * @var array @@ -151,13 +139,6 @@ final class KimaiImporterCommand extends Command * @var array */ private $oldActivities = []; - /** - * If true, unknown Activities will be created globally. - * Default behavior: create project specific activities - * - * @var bool - */ - private $unknownAsGlobal = false; private $options = []; @@ -316,8 +297,6 @@ final class KimaiImporterCommand extends Command $this->teamIds = []; $this->userIds = []; - $this->customerIds = []; - $this->projectIds = []; $this->oldActivities = []; if (!$options['merge-customer']) { @@ -986,7 +965,6 @@ final class KimaiImporterCommand extends Command private function setCustomerCache(array $oldCustomer, Customer $customer): void { - //$this->customerIds[$this->dbPrefix . $oldCustomer['customerID']] = $oldCustomer['customerID']; $this->customers[$oldCustomer['customerID']] = $customer; } diff --git a/src/Command/UpdateCommand.php b/src/Command/UpdateCommand.php index 3e7fef3f..9cf2239e 100644 --- a/src/Command/UpdateCommand.php +++ b/src/Command/UpdateCommand.php @@ -29,19 +29,14 @@ final class UpdateCommand extends Command public const ERROR_DATABASE = 8; public const ERROR_MIGRATIONS = 32; - /** - * @var string - */ - private $rootDir; /** * @var Connection */ private $connection; - public function __construct(string $projectDirectory, Connection $connection) + public function __construct(Connection $connection) { parent::__construct(); - $this->rootDir = $projectDirectory; $this->connection = $connection; } diff --git a/src/Controller/Reporting/ReportByUserController.php b/src/Controller/Reporting/ReportByUserController.php index 0094f82d..01c08824 100644 --- a/src/Controller/Reporting/ReportByUserController.php +++ b/src/Controller/Reporting/ReportByUserController.php @@ -19,7 +19,6 @@ use App\Reporting\WeekByUser; use App\Reporting\WeekByUserForm; use App\Repository\ActivityRepository; use App\Repository\ProjectRepository; -use App\Repository\TimesheetRepository; use App\Timesheet\TimesheetStatisticService; use DateTime; use Exception; @@ -35,14 +34,12 @@ use Symfony\Component\Security\Core\Exception\AccessDeniedException; */ final class ReportByUserController extends AbstractController { - private $timesheetRepository; private $statisticService; private $projectRepository; private $activityRepository; - public function __construct(TimesheetRepository $timesheetRepository, TimesheetStatisticService $statisticService, ProjectRepository $projectRepository, ActivityRepository $activityRepository) + public function __construct(TimesheetStatisticService $statisticService, ProjectRepository $projectRepository, ActivityRepository $activityRepository) { - $this->timesheetRepository = $timesheetRepository; $this->statisticService = $statisticService; $this->projectRepository = $projectRepository; $this->activityRepository = $activityRepository; diff --git a/src/Controller/Reporting/ReportUsersListController.php b/src/Controller/Reporting/ReportUsersListController.php index 739c1b06..8c561860 100644 --- a/src/Controller/Reporting/ReportUsersListController.php +++ b/src/Controller/Reporting/ReportUsersListController.php @@ -20,7 +20,6 @@ use App\Reporting\WeeklyUserListForm; use App\Reporting\YearlyUserList; use App\Reporting\YearlyUserListForm; use App\Repository\Query\UserQuery; -use App\Repository\TimesheetRepository; use App\Repository\UserRepository; use App\Timesheet\TimesheetStatisticService; use Exception; @@ -35,12 +34,10 @@ use Symfony\Component\Routing\Annotation\Route; */ final class ReportUsersListController extends AbstractController { - private $timesheetRepository; private $userRepository; - public function __construct(TimesheetRepository $timesheetRepository, UserRepository $userRepository) + public function __construct(UserRepository $userRepository) { - $this->timesheetRepository = $timesheetRepository; $this->userRepository = $userRepository; } diff --git a/src/Controller/TeamController.php b/src/Controller/TeamController.php index a78f5b9e..98681c65 100644 --- a/src/Controller/TeamController.php +++ b/src/Controller/TeamController.php @@ -176,15 +176,13 @@ final class TeamController extends AbstractController $customerForm->handleRequest($request); if ($customerForm->isSubmitted() && $customerForm->isValid()) { - if ($customerForm->isValid()) { - try { - $this->repository->saveTeam($team); - $this->flashSuccess('action.update.success'); + try { + $this->repository->saveTeam($team); + $this->flashSuccess('action.update.success'); - return $this->redirectToRoute('admin_team_edit', ['id' => $team->getId()]); - } catch (\Exception $ex) { - $this->flashUpdateException($ex); - } + return $this->redirectToRoute('admin_team_edit', ['id' => $team->getId()]); + } catch (\Exception $ex) { + $this->flashUpdateException($ex); } } @@ -194,15 +192,13 @@ final class TeamController extends AbstractController $projectForm->handleRequest($request); if ($projectForm->isSubmitted() && $projectForm->isValid()) { - if ($projectForm->isValid()) { - try { - $this->repository->saveTeam($team); - $this->flashSuccess('action.update.success'); + try { + $this->repository->saveTeam($team); + $this->flashSuccess('action.update.success'); - return $this->redirectToRoute('admin_team_edit', ['id' => $team->getId()]); - } catch (\Exception $ex) { - $this->flashUpdateException($ex); - } + return $this->redirectToRoute('admin_team_edit', ['id' => $team->getId()]); + } catch (\Exception $ex) { + $this->flashUpdateException($ex); } } } diff --git a/src/Customer/CustomerStatisticService.php b/src/Customer/CustomerStatisticService.php index 324b983c..2cef85ec 100644 --- a/src/Customer/CustomerStatisticService.php +++ b/src/Customer/CustomerStatisticService.php @@ -14,7 +14,6 @@ use App\Entity\Project; use App\Event\CustomerStatisticEvent; use App\Model\CustomerBudgetStatisticModel; use App\Model\CustomerStatistic; -use App\Repository\CustomerRepository; use App\Repository\TimesheetRepository; use App\Timesheet\DateTimeFactory; use DateTime; @@ -28,13 +27,11 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface; */ class CustomerStatisticService { - private $repository; private $timesheetRepository; private $dispatcher; - public function __construct(CustomerRepository $customerRepository, TimesheetRepository $timesheetRepository, EventDispatcherInterface $dispatcher) + public function __construct(TimesheetRepository $timesheetRepository, EventDispatcherInterface $dispatcher) { - $this->repository = $customerRepository; $this->timesheetRepository = $timesheetRepository; $this->dispatcher = $dispatcher; } diff --git a/src/Doctrine/AbstractMigration.php b/src/Doctrine/AbstractMigration.php index 4120747a..5cc965ab 100644 --- a/src/Doctrine/AbstractMigration.php +++ b/src/Doctrine/AbstractMigration.php @@ -49,22 +49,6 @@ abstract class AbstractMigration extends BaseAbstractMigration return true; } - /** - * @deprecated since 1.14 - will be removed with 2.0 - */ - protected function deactivateForeignKeysOnSqlite() - { - @trigger_error('deactivateForeignKeysOnSqlite() is deprecated and will be removed with 2.0', E_USER_DEPRECATED); - } - - /** - * @deprecated since 1.14 - will be removed with 2.0 - */ - private function activateForeignKeysOnSqlite() - { - @trigger_error('activateForeignKeysOnSqlite() is deprecated and will be removed with 2.0', E_USER_DEPRECATED); - } - /** * @param Schema $schema * @throws Exception diff --git a/src/Entity/Configuration.php b/src/Entity/Configuration.php index 77f40b30..634be521 100644 --- a/src/Entity/Configuration.php +++ b/src/Entity/Configuration.php @@ -30,6 +30,7 @@ class Configuration * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(name="id", type="integer") + * @phpstan-ignore-next-line */ private $id; diff --git a/src/Entity/Invoice.php b/src/Entity/Invoice.php index 3cd3cad7..6b9cfedc 100644 --- a/src/Entity/Invoice.php +++ b/src/Entity/Invoice.php @@ -47,6 +47,7 @@ class Invoice * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="IDENTITY") + * @phpstan-ignore-next-line */ private $id; diff --git a/src/Entity/Role.php b/src/Entity/Role.php index 73a88198..c6f45aa6 100644 --- a/src/Entity/Role.php +++ b/src/Entity/Role.php @@ -30,6 +30,7 @@ class Role * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="IDENTITY") + * @phpstan-ignore-next-line */ private $id; /** diff --git a/src/Entity/RolePermission.php b/src/Entity/RolePermission.php index 800e8bbf..6a1e49f6 100644 --- a/src/Entity/RolePermission.php +++ b/src/Entity/RolePermission.php @@ -30,6 +30,7 @@ class RolePermission * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="IDENTITY") + * @phpstan-ignore-next-line */ private $id; /** diff --git a/src/Entity/Tag.php b/src/Entity/Tag.php index c7a6ddb4..b5bd765b 100644 --- a/src/Entity/Tag.php +++ b/src/Entity/Tag.php @@ -39,6 +39,7 @@ class Tag * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="IDENTITY") + * @phpstan-ignore-next-line */ private $id; /** diff --git a/src/Entity/TeamMember.php b/src/Entity/TeamMember.php index 67c3d742..8e101bda 100644 --- a/src/Entity/TeamMember.php +++ b/src/Entity/TeamMember.php @@ -32,6 +32,7 @@ class TeamMember * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="IDENTITY") + * @phpstan-ignore-next-line */ private $id; /** diff --git a/src/Entity/User.php b/src/Entity/User.php index 719873b9..6e0d8873 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -415,9 +415,9 @@ class User implements UserInterface, EquatableInterface, \Serializable public function getPreference(string $name): ?UserPreference { - // this code will be triggered, if a currently logged-in user will be deleted and the refreshed from the session + // this code will be triggered, if a currently logged-in user will be deleted and then refreshed from the session // via one of the UserProvider - e.g. see LdapUserProvider::refreshUser() which calls $user->getPreferenceValue() - if (empty($this->preferences)) { + if ($this->preferences === null) { return null; } diff --git a/src/Form/Extension/SelectWithApiDataExtension.php b/src/Form/Extension/SelectWithApiDataExtension.php index 03001771..53fe8a61 100644 --- a/src/Form/Extension/SelectWithApiDataExtension.php +++ b/src/Form/Extension/SelectWithApiDataExtension.php @@ -76,11 +76,7 @@ class SelectWithApiDataExtension extends AbstractTypeExtension $formPrefix = implode('_', array_reverse($formPrefixes)); - $formField = $formPrefix; - if (!empty($formField)) { - $formField .= '_'; - } - $formField .= $apiData['select']; + $formField = $formPrefix . '_' . $apiData['select']; $view->vars['attr'] = array_merge($view->vars['attr'], [ 'data-form-prefix' => $formPrefix, diff --git a/src/Form/QuickEntryForm.php b/src/Form/QuickEntryForm.php index ff3cd30a..f36dff78 100644 --- a/src/Form/QuickEntryForm.php +++ b/src/Form/QuickEntryForm.php @@ -50,6 +50,9 @@ class QuickEntryForm extends AbstractType foreach ($value->getRows() as $row) { $project = $row->getProject(); $activity = $row->getActivity(); + if ($project === null || $activity === null) { + continue; + } foreach ($row->getTimesheets() as $timesheet) { $timesheet->setProject($project); $timesheet->setActivity($activity); diff --git a/src/Form/TimesheetEditForm.php b/src/Form/TimesheetEditForm.php index 30f04a9f..02a8cc17 100644 --- a/src/Form/TimesheetEditForm.php +++ b/src/Form/TimesheetEditForm.php @@ -21,7 +21,6 @@ use App\Form\Type\TagsType; use App\Form\Type\UserType; use App\Form\Type\YesNoType; use App\Repository\CustomerRepository; -use App\Repository\ProjectRepository; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormEvent; @@ -39,15 +38,10 @@ class TimesheetEditForm extends AbstractType * @var CustomerRepository */ private $customers; - /** - * @var ProjectRepository - */ - private $projects; - public function __construct(CustomerRepository $customer, ProjectRepository $project) + public function __construct(CustomerRepository $customer) { $this->customers = $customer; - $this->projects = $project; } /** diff --git a/src/Invoice/ServiceInvoice.php b/src/Invoice/ServiceInvoice.php index 4b8f38db..d0f42d5b 100644 --- a/src/Invoice/ServiceInvoice.php +++ b/src/Invoice/ServiceInvoice.php @@ -566,10 +566,6 @@ final class ServiceInvoice }); foreach ($customerEntries as $id => $settings) { - if (empty($settings['entries'])) { - continue; - } - $customerQuery = clone $query; $customerQuery->setCustomers([$settings['customer']]); $model = $this->createModelWithoutEntries($customerQuery); diff --git a/src/Ldap/LdapAuthenticationProvider.php b/src/Ldap/LdapAuthenticationProvider.php index fdd31a98..4f250148 100644 --- a/src/Ldap/LdapAuthenticationProvider.php +++ b/src/Ldap/LdapAuthenticationProvider.php @@ -64,6 +64,7 @@ class LdapAuthenticationProvider extends UserAuthenticationProvider // do not update the user here from LDAP, as we don't know if the user can be authenticated } catch (UsernameNotFoundException $notFound) { throw $notFound; + /* @phpstan-ignore-next-line */ } catch (\Exception $repositoryProblem) { $e = new AuthenticationServiceException($repositoryProblem->getMessage(), (int) $repositoryProblem->getCode(), $repositoryProblem); $e->setToken($token); diff --git a/src/Repository/ConfigurationRepository.php b/src/Repository/ConfigurationRepository.php index 60f4cc4b..de249746 100644 --- a/src/Repository/ConfigurationRepository.php +++ b/src/Repository/ConfigurationRepository.php @@ -13,10 +13,11 @@ use App\Configuration\ConfigLoaderInterface; use App\Entity\Configuration; use App\Form\Model\SystemConfiguration; use Doctrine\ORM\EntityRepository; -use Doctrine\ORM\ORMException; +use Doctrine\ORM\Exception\ORMException; /** * @extends \Doctrine\ORM\EntityRepository + * @final */ class ConfigurationRepository extends EntityRepository implements ConfigLoaderInterface { @@ -26,14 +27,14 @@ class ConfigurationRepository extends EntityRepository implements ConfigLoaderIn public function clearCache() { - static::$cacheByPrefix = []; - static::$cacheAll = []; - static::$initialized = false; + self::$cacheByPrefix = []; + self::$cacheAll = []; + self::$initialized = false; } private function prefillCache() { - if (static::$initialized === true) { + if (self::$initialized === true) { return; } @@ -41,13 +42,13 @@ class ConfigurationRepository extends EntityRepository implements ConfigLoaderIn $configs = $this->findAll(); foreach ($configs as $config) { $key = substr($config->getName(), 0, strpos($config->getName(), '.')); - if (!\array_key_exists($key, static::$cacheByPrefix)) { - static::$cacheByPrefix[$key] = []; + if (!\array_key_exists($key, self::$cacheByPrefix)) { + self::$cacheByPrefix[$key] = []; } - static::$cacheByPrefix[$key][] = $config; - static::$cacheAll[] = $config; + self::$cacheByPrefix[$key][] = $config; + self::$cacheAll[] = $config; } - static::$initialized = true; + self::$initialized = true; } public function saveConfiguration(Configuration $configuration) @@ -67,14 +68,14 @@ class ConfigurationRepository extends EntityRepository implements ConfigLoaderIn $this->prefillCache(); if (null === $prefix) { - return static::$cacheAll; + return self::$cacheAll; } - if (!\array_key_exists($prefix, static::$cacheByPrefix)) { + if (!\array_key_exists($prefix, self::$cacheByPrefix)) { return []; } - return static::$cacheByPrefix[$prefix]; + return self::$cacheByPrefix[$prefix]; } public function saveSystemConfiguration(SystemConfiguration $model) diff --git a/src/Widget/Type/UserTeamProjects.php b/src/Widget/Type/UserTeamProjects.php index ca5456ea..510b3cb4 100644 --- a/src/Widget/Type/UserTeamProjects.php +++ b/src/Widget/Type/UserTeamProjects.php @@ -59,7 +59,7 @@ class UserTeamProjects extends SimpleWidget implements AuthorizedWidget, UserWid foreach ($user->getTeams() as $team) { /** @var Project $project */ foreach ($team->getProjects() as $project) { - if (!isset($projects[$project->getId()])) { + if (!isset($teamProjects[$project->getId()])) { $teamProjects[$project->getId()] = $project; } } diff --git a/tests/Command/InstallCommandTest.php b/tests/Command/InstallCommandTest.php index 3b4f821d..65ae0fd7 100644 --- a/tests/Command/InstallCommandTest.php +++ b/tests/Command/InstallCommandTest.php @@ -31,7 +31,6 @@ class InstallCommandTest extends KernelTestCase $container = self::$kernel->getContainer(); $this->application->add(new InstallCommand( - $container->getParameter('kernel.project_dir'), $container->get('doctrine')->getConnection() )); } diff --git a/tests/Command/UpdateCommandTest.php b/tests/Command/UpdateCommandTest.php index 0a65e013..c76aa358 100644 --- a/tests/Command/UpdateCommandTest.php +++ b/tests/Command/UpdateCommandTest.php @@ -34,7 +34,6 @@ class UpdateCommandTest extends KernelTestCase $container = self::$kernel->getContainer(); $this->application->add(new UpdateCommand( - $container->getParameter('kernel.project_dir'), $container->get('doctrine')->getConnection() ));