From 0f3fa8fdbeb08fdb61f48dcd5e87c77d9f50bd9e Mon Sep 17 00:00:00 2001 From: Kevin Papst Date: Sun, 19 Apr 2020 14:37:14 +0200 Subject: [PATCH] Code improvements (#1649) * use global namespace for faster lookups * phpstan level 5 --- .php_cs.dist | 12 +++ composer.json | 2 +- src/API/ActivityController.php | 2 +- src/API/ProjectController.php | 4 +- src/API/TimesheetController.php | 18 ++--- src/Command/CreateUserCommand.php | 2 +- src/Command/ImportCustomerCommand.php | 10 +-- src/Command/ImportTimesheetCommand.php | 26 +++---- src/Command/InvoiceCreateCommand.php | 2 +- src/Command/KimaiImporterCommand.php | 40 +++++----- .../StringAccessibleConfigTrait.php | 16 ++-- src/Controller/DoctorController.php | 6 +- src/Controller/PermissionController.php | 2 +- .../TimesheetAbstractController.php | 4 +- src/DataFixtures/TagFixtures.php | 2 +- src/DataFixtures/TeamFixtures.php | 8 +- src/DataFixtures/UserFixtures.php | 4 +- src/DependencyInjection/AppExtension.php | 8 +- .../Compiler/DoctrineCompilerPass.php | 2 +- .../Compiler/ExportServiceCompilerPass.php | 2 +- .../Compiler/TwigContextCompilerPass.php | 2 +- src/DependencyInjection/Configuration.php | 4 +- src/Doctrine/AbstractMigration.php | 2 +- src/Entity/ActivityMeta.php | 2 +- src/Entity/CustomerMeta.php | 2 +- src/Entity/ProjectMeta.php | 2 +- src/Entity/TimesheetMeta.php | 2 +- src/Event/PermissionsEvent.php | 10 +-- src/EventSubscriber/DashboardSubscriber.php | 18 +++-- src/EventSubscriber/MenuBuilderSubscriber.php | 3 +- .../RedirectToLocaleSubscriber.php | 2 +- .../Base/AbstractSpreadsheetRenderer.php | 28 +++---- src/Export/Base/XlsxRenderer.php | 1 + .../Extension/SelectWithApiDataExtension.php | 2 +- src/Form/FormTrait.php | 2 +- src/Form/RoleType.php | 2 +- src/Form/Toolbar/AbstractToolbarForm.php | 6 +- src/Form/Type/CustomerType.php | 2 +- src/Form/Type/DateRangeType.php | 2 +- src/Form/Type/InvoiceRendererType.php | 2 +- src/Form/Type/LanguageType.php | 2 +- src/Form/Type/ProjectType.php | 2 +- .../Calculator/ShortInvoiceCalculator.php | 4 +- .../ConfigurableNumberGenerator.php | 9 ++- .../Renderer/AbstractSpreadsheetRenderer.php | 2 +- src/Invoice/Renderer/AdvancedValueBinder.php | 2 +- src/Invoice/Renderer/DocxRenderer.php | 4 +- src/Invoice/ServiceInvoice.php | 12 +-- src/Ldap/LdapDriver.php | 2 +- src/Ldap/LdapManager.php | 4 +- src/Ldap/LdapUserHydrator.php | 10 +-- src/Ldap/LdapUserProvider.php | 4 +- src/Migrations/Version20180715160326.php | 2 +- src/Plugin/PluginManager.php | 2 +- src/Repository/ActivityRepository.php | 2 +- src/Repository/ConfigurationRepository.php | 6 +- src/Repository/InvoiceDocumentRepository.php | 2 +- src/Repository/InvoiceRepository.php | 8 +- src/Repository/Loader/UserIdLoader.php | 2 +- src/Repository/ProjectRepository.php | 2 +- .../Query/ActivityFormTypeQuery.php | 4 +- src/Repository/Query/ActivityQuery.php | 2 +- src/Repository/Query/BaseFormTypeQuery.php | 6 +- src/Repository/Query/BaseQuery.php | 4 +- .../Query/CustomerFormTypeQuery.php | 2 +- src/Repository/Query/ProjectFormTypeQuery.php | 4 +- src/Repository/Query/ProjectQuery.php | 2 +- src/Repository/Query/TimesheetQuery.php | 6 +- src/Repository/Query/VisibilityTrait.php | 2 +- .../TimesheetInvoiceItemRepository.php | 2 +- src/Repository/TimesheetRepository.php | 4 +- src/Repository/UserRepository.php | 2 +- src/Saml/Provider/SamlProvider.php | 6 ++ src/Saml/User/SamlUserFactory.php | 6 +- src/Security/DoctrineUserProvider.php | 2 +- src/Security/RolePermissionManager.php | 10 +-- src/Security/RoleService.php | 2 +- src/Timesheet/Calculator/RateCalculator.php | 2 +- src/Timesheet/RoundingService.php | 10 +-- src/Twig/DatatableExtensions.php | 6 +- src/Twig/Extensions.php | 6 +- src/Twig/MarkdownExtension.php | 2 +- src/Twig/PaginationExtension.php | 2 +- src/Twig/WidgetExtension.php | 4 +- src/Utils/AvatarService.php | 4 +- src/Utils/Duration.php | 6 +- src/Utils/MPdfConverter.php | 6 +- src/Utils/MenuItemModel.php | 2 +- src/Utils/ParsedownExtension.php | 2 +- src/Utils/SearchTerm.php | 4 +- .../Constraints/ProjectValidator.php | 2 +- src/Validator/Constraints/RoleValidator.php | 4 +- .../TimesheetMultiUpdateValidator.php | 2 +- .../Constraints/TimesheetValidator.php | 2 +- src/Voter/ActivityVoter.php | 2 +- src/Voter/CustomerVoter.php | 4 +- src/Voter/ProjectVoter.php | 4 +- src/Voter/TeamVoter.php | 2 +- src/Voter/TimesheetVoter.php | 2 +- src/Voter/UserVoter.php | 2 +- src/Widget/Type/AbstractWidgetType.php | 2 +- src/Widget/Type/DailyWorkingTimeChart.php | 2 +- src/Widget/Type/PaginatedWorkingTimeChart.php | 2 +- src/Widget/WidgetService.php | 2 +- tests/API/ActivityControllerTest.php | 10 +-- tests/API/ConfigurationControllerTest.php | 4 +- tests/API/CustomerControllerTest.php | 8 +- tests/API/ProjectControllerTest.php | 10 +-- tests/API/RateControllerTestTrait.php | 17 ++++- tests/API/TagControllerTest.php | 10 +-- tests/API/TeamControllerTest.php | 4 +- tests/API/TimesheetControllerTest.php | 74 +++++++++---------- tests/API/UserControllerTest.php | 6 +- tests/Command/InvoiceCreateCommandTest.php | 10 +-- .../CalendarConfigurationTest.php | 2 +- tests/Controller/AboutControllerTest.php | 4 +- tests/Controller/ActivityControllerTest.php | 26 +++---- tests/Controller/ControllerBaseTest.php | 10 +-- tests/Controller/CustomerControllerTest.php | 24 +++--- tests/Controller/DoctorControllerTest.php | 2 +- tests/Controller/ExportControllerTest.php | 28 +++---- tests/Controller/HomepageControllerTest.php | 2 +- tests/Controller/InvoiceControllerTest.php | 30 ++++---- tests/Controller/LayoutControllerTest.php | 4 +- tests/Controller/PermissionControllerTest.php | 6 +- tests/Controller/ProfileControllerTest.php | 32 ++++---- tests/Controller/ProjectControllerTest.php | 34 ++++----- .../SystemConfigurationControllerTest.php | 12 +-- tests/Controller/TagControllerTest.php | 2 +- tests/Controller/TeamControllerTest.php | 20 ++--- tests/Controller/TimesheetControllerTest.php | 30 ++++---- .../TimesheetTeamControllerTest.php | 38 +++++----- tests/Controller/UserControllerTest.php | 8 +- tests/DataFixtures/ActivityFixtures.php | 2 +- tests/DataFixtures/CustomerFixtures.php | 2 +- tests/DataFixtures/ProjectFixtures.php | 2 +- tests/DataFixtures/TagFixtures.php | 2 +- tests/DataFixtures/TeamFixtures.php | 6 +- tests/DataFixtures/TimesheetFixtures.php | 8 +- .../SqliteSessionInitSubscriberTest.php | 2 +- tests/Doctrine/TimesheetSubscriberTest.php | 2 +- tests/Entity/EntityValidationTestTrait.php | 8 +- tests/Entity/UserTest.php | 8 +- .../DashboardSubscriberTest.php | 10 +-- tests/Export/Renderer/CsvRendererTest.php | 4 +- tests/Export/ServiceExportTest.php | 4 +- tests/Export/Timesheet/CsvRendererTest.php | 4 +- .../Calculator/AbstractCalculatorTest.php | 4 +- .../ActivityInvoiceCalculatorTest.php | 2 +- .../Calculator/DateInvoiceCalculatorTest.php | 2 +- .../ProjectInvoiceCalculatorTest.php | 2 +- .../Calculator/ShortInvoiceCalculatorTest.php | 6 +- .../Calculator/UserInvoiceCalculatorTest.php | 2 +- .../InvoiceItemDefaultHydratorTest.php | 2 +- .../ConfigurableNumberGeneratorTest.php | 3 + tests/Invoice/Renderer/DebugRendererTest.php | 6 +- tests/Invoice/Renderer/TextRendererTest.php | 2 +- tests/Invoice/Renderer/XmlRendererTest.php | 2 +- tests/Invoice/ServiceInvoiceTest.php | 6 +- tests/KernelTestTrait.php | 19 +---- tests/Model/Statistic/YearTest.php | 4 +- tests/Plugin/PluginManagerTest.php | 2 +- .../InvoiceDocumentRepositoryTest.php | 4 +- .../Query/BaseFormTypeQueryTest.php | 4 +- tests/Repository/Query/BaseQueryTest.php | 4 +- tests/Repository/TagRepositoryTest.php | 10 +-- tests/Repository/TimesheetRepositoryTest.php | 18 ++--- tests/Saml/Logout/SamlLogoutHandlerTest.php | 2 +- .../SamlAuthenticationSuccessHandlerTest.php | 2 +- tests/Twig/AvatarExtensionTest.php | 2 +- tests/Twig/ConfigExtensionTest.php | 2 +- tests/Twig/DatatableExtensionsTest.php | 2 +- tests/Twig/DateExtensionsTest.php | 4 +- tests/Twig/EncoreExtensionTest.php | 2 +- tests/Twig/ExtensionsTest.php | 4 +- tests/Twig/IconExtensionTest.php | 2 +- tests/Twig/PaginationExtensionTest.php | 2 +- tests/Twig/TitleExtensionTest.php | 2 +- tests/Twig/WidgetExtensionTest.php | 2 +- .../DateTimeFormatValidatorTest.php | 2 +- .../Constraints/DurationValidatorTest.php | 2 +- .../Constraints/RoleValidatorTest.php | 2 +- .../Renderer/SimpleWidgetRendererTest.php | 2 +- 183 files changed, 604 insertions(+), 574 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index 4e352a0d..9fa9529f 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -141,6 +141,18 @@ return PhpCsFixer\Config::create() 'method', 'property', ]], + 'native_function_invocation' => [ + 'include' => [ + '@compiler_optimized' + ], + 'scope' => 'namespaced' + ], + 'native_function_type_declaration_casing' => true, + 'no_alias_functions' => [ + 'sets' => [ + '@internal' + ] + ], ]) ->setFinder( PhpCsFixer\Finder::create() diff --git a/composer.json b/composer.json index 4884ca11..30ccd777 100644 --- a/composer.json +++ b/composer.json @@ -167,7 +167,7 @@ "kimai:tests-unit": "vendor/bin/phpunit --exclude-group integration tests/", "kimai:tests-integration": "vendor/bin/phpunit --group integration tests/", "kimai:phpstan": [ - "vendor/bin/phpstan analyse src -c phpstan.neon --level=4", + "vendor/bin/phpstan analyse src -c phpstan.neon --level=5", "vendor/bin/phpstan analyse tests -c tests/phpstan.neon --level=4" ], "kimai:codestyle": "vendor/bin/php-cs-fixer fix --dry-run --verbose --show-progress=none", diff --git a/src/API/ActivityController.php b/src/API/ActivityController.php index 7d16b9e3..1f311471 100644 --- a/src/API/ActivityController.php +++ b/src/API/ActivityController.php @@ -110,7 +110,7 @@ class ActivityController extends BaseApiController } if (!empty($projects = $paramFetcher->get('projects'))) { - if (!is_array($projects)) { + if (!\is_array($projects)) { $projects = explode(',', $projects); } if (!empty($projects)) { diff --git a/src/API/ProjectController.php b/src/API/ProjectController.php index 13a6dafd..46b6d5c8 100644 --- a/src/API/ProjectController.php +++ b/src/API/ProjectController.php @@ -116,7 +116,7 @@ class ProjectController extends BaseApiController } if (!empty($customers = $paramFetcher->get('customers'))) { - if (!is_array($customers)) { + if (!\is_array($customers)) { $customers = explode(',', $customers); } if (!empty($customers)) { @@ -134,7 +134,7 @@ class ProjectController extends BaseApiController $ignoreDates = false; if (null !== $paramFetcher->get('ignoreDates')) { - $ignoreDates = intval($paramFetcher->get('ignoreDates')) === 1; + $ignoreDates = \intval($paramFetcher->get('ignoreDates')) === 1; } if (!$ignoreDates) { diff --git a/src/API/TimesheetController.php b/src/API/TimesheetController.php index f89af7c0..278a86ac 100644 --- a/src/API/TimesheetController.php +++ b/src/API/TimesheetController.php @@ -164,7 +164,7 @@ class TimesheetController extends BaseApiController } if (!empty($customers = $paramFetcher->get('customers'))) { - if (!is_array($customers)) { + if (!\is_array($customers)) { $customers = explode(',', $customers); } if (!empty($customers)) { @@ -177,7 +177,7 @@ class TimesheetController extends BaseApiController } if (!empty($projects = $paramFetcher->get('projects'))) { - if (!is_array($projects)) { + if (!\is_array($projects)) { $projects = explode(',', $projects); } if (!empty($projects)) { @@ -190,7 +190,7 @@ class TimesheetController extends BaseApiController } if (!empty($activities = $paramFetcher->get('activities'))) { - if (!is_array($activities)) { + if (!\is_array($activities)) { $activities = explode(',', $activities); } if (!empty($activities)) { @@ -212,7 +212,7 @@ class TimesheetController extends BaseApiController if (null !== ($tags = $paramFetcher->get('tags'))) { $ids = $this->tagRepository->findIdsByTagNameList($tags); - if ($ids !== null && sizeof($ids) > 0) { + if ($ids !== null && \count($ids) > 0) { $query->setTags(new ArrayCollection($ids)); } } @@ -650,22 +650,22 @@ class TimesheetController extends BaseApiController $this->roundingService->roundBegin($copyTimesheet); if (null !== ($copy = $paramFetcher->get('copy'))) { - if (in_array($copy, ['rates', 'all'])) { + if (\in_array($copy, ['rates', 'all'])) { $copyTimesheet->setHourlyRate($timesheet->getHourlyRate()); $copyTimesheet->setFixedRate($timesheet->getFixedRate()); } - if (in_array($copy, ['description', 'all'])) { + if (\in_array($copy, ['description', 'all'])) { $copyTimesheet->setDescription($timesheet->getDescription()); } - if (in_array($copy, ['tags', 'all'])) { + if (\in_array($copy, ['tags', 'all'])) { foreach ($timesheet->getTags() as $tag) { $copyTimesheet->addTag($tag); } } - if (in_array($copy, ['meta', 'all'])) { + if (\in_array($copy, ['meta', 'all'])) { foreach ($timesheet->getMetaFields() as $metaField) { $metaNew = clone $metaField; $copyTimesheet->setMetaField($metaNew); @@ -675,7 +675,7 @@ class TimesheetController extends BaseApiController $errors = $validator->validate($copyTimesheet); - if (count($errors) > 0) { + if (\count($errors) > 0) { throw new BadRequestHttpException($errors[0]->getPropertyPath() . ' = ' . $errors[0]->getMessage()); } diff --git a/src/Command/CreateUserCommand.php b/src/Command/CreateUserCommand.php index 6beb291c..4dcdc53d 100644 --- a/src/Command/CreateUserCommand.php +++ b/src/Command/CreateUserCommand.php @@ -102,7 +102,7 @@ final class CreateUserCommand extends Command $value = $error->getInvalidValue(); $io->error( $error->getPropertyPath() - . ' (' . (is_array($value) ? implode(',', $value) : $value) . ')' + . ' (' . (\is_array($value) ? implode(',', $value) : $value) . ')' . "\n " . $error->getMessage() ); diff --git a/src/Command/ImportCustomerCommand.php b/src/Command/ImportCustomerCommand.php index 349af4a0..8fd3a554 100644 --- a/src/Command/ImportCustomerCommand.php +++ b/src/Command/ImportCustomerCommand.php @@ -266,12 +266,12 @@ class ImportCustomerCommand extends Command private function getCustomer(string $customerName): Customer { - if (!array_key_exists($customerName, $this->customerCache)) { + if (!\array_key_exists($customerName, $this->customerCache)) { $tmpCustomer = $this->customers->findBy(['name' => $customerName]); - if (count($tmpCustomer) > 1) { + if (\count($tmpCustomer) > 1) { throw new \Exception(sprintf('Found multiple customers with the name: %s', $customerName)); - } elseif (count($tmpCustomer) === 1) { + } elseif (\count($tmpCustomer) === 1) { $tmpCustomer = $tmpCustomer[0]; } @@ -280,7 +280,7 @@ class ImportCustomerCommand extends Command } } - if (array_key_exists($customerName, $this->customerCache)) { + if (\array_key_exists($customerName, $this->customerCache)) { return $this->customerCache[$customerName]; } @@ -328,7 +328,7 @@ class ImportCustomerCommand extends Command $fields = []; foreach (self::$requiredHeader as $headerName) { - if (!in_array($headerName, $header)) { + if (!\in_array($headerName, $header)) { $fields[] = $headerName; } } diff --git a/src/Command/ImportTimesheetCommand.php b/src/Command/ImportTimesheetCommand.php index 6f5ed4c3..e81e4f58 100644 --- a/src/Command/ImportTimesheetCommand.php +++ b/src/Command/ImportTimesheetCommand.php @@ -202,7 +202,7 @@ class ImportTimesheetCommand extends Command $activityType = $input->getOption('activity'); $allowedActivityTypes = ['project', 'global']; - if (!in_array($activityType, $allowedActivityTypes)) { + if (!\in_array($activityType, $allowedActivityTypes)) { $io->error(sprintf('Invalid activity type "%s" given, allowed values are: %s', $activityType, implode(', ', $allowedActivityTypes))); return 4; @@ -274,7 +274,7 @@ class ImportTimesheetCommand extends Command $duration = 0; if (!empty($record['Duration'])) { - if (is_int($record['Duration'])) { + if (\is_int($record['Duration'])) { $duration = $record['Duration']; } else { $duration = $durationParser->parseDurationString($record['Duration']); @@ -342,7 +342,7 @@ class ImportTimesheetCommand extends Command private function getUser($user): User { - if (!array_key_exists($user, $this->userCache)) { + if (!\array_key_exists($user, $this->userCache)) { $tmpUser = $this->users->findOneBy(['username' => $user]); if (null === $tmpUser) { $tmpUser = $this->users->findOneBy(['email' => $user]); @@ -362,9 +362,9 @@ class ImportTimesheetCommand extends Command $tmpActivities = $this->activities->findBy(['project' => $project, 'name' => $activity]); - if (count($tmpActivities) === 0) { + if (\count($tmpActivities) === 0) { $tmpActivity = $this->activities->findOneBy(['project' => null, 'name' => $activity]); - } elseif (count($tmpActivities) === 1) { + } elseif (\count($tmpActivities) === 1) { $tmpActivity = $tmpActivities[0]; } @@ -390,7 +390,7 @@ class ImportTimesheetCommand extends Command /** @var Project[] $tmpProjects */ $tmpProjects = $this->projects->findBy(['name' => $project]); - if (count($tmpProjects) > 1) { + if (\count($tmpProjects) > 1) { /** @var Project $prj */ foreach ($tmpProjects as $prj) { if ($prj->getCustomer()->getName() !== $tmpCustomer->getName()) { @@ -399,7 +399,7 @@ class ImportTimesheetCommand extends Command $tmpProject = $prj; break; } - } elseif (count($tmpProjects) === 1) { + } elseif (\count($tmpProjects) === 1) { $tmpProject = $tmpProjects[0]; } @@ -423,11 +423,11 @@ class ImportTimesheetCommand extends Command private function getCustomer($customer, $fallback): Customer { if (!empty($customer)) { - if (!array_key_exists($customer, $this->customerCache)) { + if (!\array_key_exists($customer, $this->customerCache)) { $tmpCustomer = $this->customers->findBy(['name' => $customer]); - if (count($tmpCustomer) > 1) { + if (\count($tmpCustomer) > 1) { throw new \Exception(sprintf('Found multiple customers with the name: %s', $customer)); - } elseif (count($tmpCustomer) === 1) { + } elseif (\count($tmpCustomer) === 1) { $tmpCustomer = $tmpCustomer[0]; } @@ -436,7 +436,7 @@ class ImportTimesheetCommand extends Command } } - if (array_key_exists($customer, $this->customerCache)) { + if (\array_key_exists($customer, $this->customerCache)) { return $this->customerCache[$customer]; } } @@ -445,7 +445,7 @@ class ImportTimesheetCommand extends Command $tmpFallback = null; if (!empty($fallback)) { - if (is_int($customer)) { + if (\is_int($customer)) { $tmpFallback = $this->customers->find($fallback); } else { /** @var Customer|null $tmpFallback */ @@ -455,7 +455,7 @@ class ImportTimesheetCommand extends Command if (null === $tmpFallback) { $newName = self::DEFAULT_CUSTOMER; - if (!empty($fallback) && is_string($fallback)) { + if (!empty($fallback) && \is_string($fallback)) { $newName = $fallback; } $tmpFallback = new Customer(); diff --git a/src/Command/InvoiceCreateCommand.php b/src/Command/InvoiceCreateCommand.php index ba1c29be..e0af29b0 100644 --- a/src/Command/InvoiceCreateCommand.php +++ b/src/Command/InvoiceCreateCommand.php @@ -346,7 +346,7 @@ class InvoiceCreateCommand extends Command $columns = ['ID', 'Customer', 'Total', 'Filename']; $table = new Table($output); - $table->setHeaderTitle(sprintf('Created %s invoice(s)', count($invoices))); + $table->setHeaderTitle(sprintf('Created %s invoice(s)', \count($invoices))); $table->setHeaders($columns); foreach ($invoices as $invoice) { diff --git a/src/Command/KimaiImporterCommand.php b/src/Command/KimaiImporterCommand.php index 57b395ce..3bbabfe9 100755 --- a/src/Command/KimaiImporterCommand.php +++ b/src/Command/KimaiImporterCommand.php @@ -166,21 +166,21 @@ final class KimaiImporterCommand extends Command $this->dbPrefix = $input->getArgument('prefix'); $password = $input->getArgument('password'); - if (trim(strlen($password)) < 6) { - $io->error('Password length is not sufficient, at least 6 character are required'); + if (null === $password || \strlen($password = trim($password)) < 8) { + $io->error('Password length is not sufficient, at least 8 character are required'); return 1; } $country = $input->getArgument('country'); - if (2 != trim(strlen($country))) { + if (null === $country || 2 != \strlen($country = trim($country))) { $io->error('Country code needs to be exactly 2 character'); return 1; } $currency = $input->getArgument('currency'); - if (3 != trim(strlen($currency))) { + if (null === $currency || 3 != \strlen($currency = trim($currency))) { $io->error('Currency code needs to be exactly 3 character'); return 1; @@ -300,7 +300,7 @@ final class KimaiImporterCommand extends Command $validationMessages[] = sprintf('User "%s" with ID %s has no email', $oldUser['name'], $oldUser['userID']); continue; } - if (in_array($oldUser['mail'], $usedEmails)) { + if (\in_array($oldUser['mail'], $usedEmails)) { $validationMessages[] = sprintf('Email "%s" for user "%s" with ID %s is already used', $oldUser['mail'], $oldUser['name'], $oldUser['userID']); } $usedEmails[] = $oldUser['mail']; @@ -312,7 +312,7 @@ final class KimaiImporterCommand extends Command } foreach ($projects as $oldProject) { - if (!in_array($oldProject['customerID'], $customerIds)) { + if (!\in_array($oldProject['customerID'], $customerIds)) { $validationMessages[] = sprintf('Project "%s" with ID %s has unknown customer with ID %s', $oldProject['name'], $oldProject['projectID'], $oldProject['customerID']); } } @@ -465,12 +465,10 @@ final class KimaiImporterCommand extends Command protected function deactivateLifecycleCallbacks(Connection $connection) { $allListener = $connection->getEventManager()->getListeners(); - foreach ($allListener as $name => $listener) { - if (in_array($name, ['prePersist', 'preUpdate'])) { - foreach ($listener as $service => $class) { - if (TimesheetSubscriber::class === $class) { - $connection->getEventManager()->removeEventListener(['prePersist', 'preUpdate'], $class); - } + foreach ($allListener as $event => $listeners) { + foreach ($listeners as $hash => $object) { + if ($object instanceof TimesheetSubscriber) { + $connection->getEventManager()->removeEventListener([$event], $object); } } } @@ -602,7 +600,7 @@ final class KimaiImporterCommand extends Command foreach ($preferences as $pref) { $key = $pref['option']; - if (!array_key_exists($key, $prefsToImport)) { + if (!\array_key_exists($key, $prefsToImport)) { continue; } @@ -951,7 +949,7 @@ final class KimaiImporterCommand extends Command * @param array $oldActivity * @param array $fixedRates * @param array $rates - * @param int $oldProjectId + * @param int|null $oldProjectId * @return Activity * @throws Exception */ @@ -961,7 +959,7 @@ final class KimaiImporterCommand extends Command array $oldActivity, array $fixedRates, array $rates, - $oldProjectId + $oldProjectId = null ) { $oldActivityId = $oldActivity['activityID']; @@ -1119,7 +1117,7 @@ final class KimaiImporterCommand extends Command $activityCounter = 0; $userCounter = 0; $entityManager = $this->getDoctrine()->getManager(); - $total = count($records); + $total = \count($records); $io->writeln('Importing timesheets, please wait'); @@ -1256,7 +1254,7 @@ final class KimaiImporterCommand extends Command ->setDuration($duration) ->setActivity($activity) ->setProject($project) - ->setExported(intval($oldRecord['cleared']) !== 0) + ->setExported(\intval($oldRecord['cleared']) !== 0) ->setTimezone($timezone) ; @@ -1299,7 +1297,7 @@ final class KimaiImporterCommand extends Command if ($activityCounter > 0) { $io->success('Created new activities during timesheet import: ' . $activityCounter); } - if (count($errors['projectActivityMismatch']) > 0) { + if (\count($errors['projectActivityMismatch']) > 0) { $io->error('Found invalid mapped project - activity combinations in these old timesheet recors: ' . implode(',', $errors['projectActivityMismatch'])); } if ($failed > 0) { @@ -1446,9 +1444,9 @@ final class KimaiImporterCommand extends Command sprintf( 'Created team: %s with %s users, %s projects and %s customers.', $team->getName(), - count($team->getUsers()), - count($team->getProjects()), - count($team->getCustomers()) + \count($team->getUsers()), + \count($team->getProjects()), + \count($team->getCustomers()) ) ); } diff --git a/src/Configuration/StringAccessibleConfigTrait.php b/src/Configuration/StringAccessibleConfigTrait.php index c2f32163..ad94e2f2 100644 --- a/src/Configuration/StringAccessibleConfigTrait.php +++ b/src/Configuration/StringAccessibleConfigTrait.php @@ -53,18 +53,18 @@ trait StringAccessibleConfigTrait $temp = explode('.', $configuration->getName()); $array = &$this->settings; if ($temp[0] === $this->getPrefix()) { - $temp = array_slice($temp, 1); + $temp = \array_slice($temp, 1); } foreach ($temp as $key2) { - if (!array_key_exists($key2, $array)) { + if (!\array_key_exists($key2, $array)) { // unknown values will silently be skipped continue 2; } - if (is_array($array[$key2])) { + if (\is_array($array[$key2])) { $array = &$array[$key2]; - } elseif (is_bool($array[$key2])) { + } elseif (\is_bool($array[$key2])) { $array[$key2] = (bool) $configuration->getValue(); - } elseif (is_int($array[$key2])) { + } elseif (\is_int($array[$key2])) { $array[$key2] = (int) $configuration->getValue(); } else { $array[$key2] = $configuration->getValue(); @@ -88,7 +88,7 @@ trait StringAccessibleConfigTrait { $this->prepare(); $prefix = $this->getPrefix() . '.'; - $length = strlen($prefix); + $length = \strlen($prefix); if (substr($key, 0, $length) === $prefix) { $key = substr($key, $length); @@ -107,11 +107,11 @@ trait StringAccessibleConfigTrait $keys = explode('.', $key); $search = array_shift($keys); - if (!array_key_exists($search, $config)) { + if (!\array_key_exists($search, $config)) { throw new \InvalidArgumentException('Unknown config: ' . $key); } - if (is_array($config[$search]) && !empty($keys)) { + if (\is_array($config[$search]) && !empty($keys)) { return $this->get(implode('.', $keys), $config[$search]); } diff --git a/src/Controller/DoctorController.php b/src/Controller/DoctorController.php index 67aaa01e..f7269bd9 100644 --- a/src/Controller/DoctorController.php +++ b/src/Controller/DoctorController.php @@ -110,14 +110,14 @@ class DoctorController extends AbstractController foreach (self::REQUIRED_EXTENSIONS as $extName) { $results[$extName] = false; - if (extension_loaded($extName)) { + if (\extension_loaded($extName)) { $results[$extName] = true; } } $results['Freetype Support'] = true; // @see AvatarService::hasDependencies() - if (!function_exists('imagettfbbox')) { + if (!\function_exists('imagettfbbox')) { $results['Freetype Support'] = false; } @@ -135,7 +135,7 @@ class DoctorController extends AbstractController private function getLogFilename(): string { // why is this check here ??? - if (!in_array(getenv('APP_ENV'), ['test', 'dev', 'prod'])) { + if (!\in_array(getenv('APP_ENV'), ['test', 'dev', 'prod'])) { throw new \RuntimeException('Unsupported log environment'); } diff --git a/src/Controller/PermissionController.php b/src/Controller/PermissionController.php index 35931ac5..e0ff56f0 100644 --- a/src/Controller/PermissionController.php +++ b/src/Controller/PermissionController.php @@ -72,7 +72,7 @@ final class PermissionController extends AbstractController // automatically import all hard coded (default) roles into the database table foreach ($this->roleService->getAvailableNames() as $roleName) { $roleName = strtoupper($roleName); - if (!in_array($roleName, $existing)) { + if (!\in_array($roleName, $existing)) { $role = new Role(); $role->setName($roleName); $this->roleRepository->saveRole($role); diff --git a/src/Controller/TimesheetAbstractController.php b/src/Controller/TimesheetAbstractController.php index 6a8bffac..ec66d1f1 100644 --- a/src/Controller/TimesheetAbstractController.php +++ b/src/Controller/TimesheetAbstractController.php @@ -172,7 +172,7 @@ abstract class TimesheetAbstractController extends AbstractController protected function getTags(TagRepository $tagRepository, $tagNames) { $tags = []; - if (!is_array($tagNames)) { + if (!\is_array($tagNames)) { $tagNames = explode(',', $tagNames); } foreach ($tagNames as $tagName) { @@ -296,7 +296,7 @@ abstract class TimesheetAbstractController extends AbstractController $dto->setEntities($timesheets); - if (count($dto->getEntities()) === 0) { + if (\count($dto->getEntities()) === 0) { return $this->redirectToRoute($this->getTimesheetRoute()); } diff --git a/src/DataFixtures/TagFixtures.php b/src/DataFixtures/TagFixtures.php index fca79cf2..ad281ab6 100644 --- a/src/DataFixtures/TagFixtures.php +++ b/src/DataFixtures/TagFixtures.php @@ -61,7 +61,7 @@ class TagFixtures extends Fixture $tagName = $faker->text(rand(5, 10)); } - if (in_array($tagName, $existing)) { + if (\in_array($tagName, $existing)) { continue; } diff --git a/src/DataFixtures/TeamFixtures.php b/src/DataFixtures/TeamFixtures.php index 8585d6b8..05bbe7c5 100644 --- a/src/DataFixtures/TeamFixtures.php +++ b/src/DataFixtures/TeamFixtures.php @@ -88,13 +88,13 @@ class TeamFixtures extends Fixture implements DependentFixtureInterface $faker = Factory::create(); for ($i = 1; $i <= self::AMOUNT_TEAMS; $i++) { - $maxUsers = count($allUsers) - 1; + $maxUsers = \count($allUsers) - 1; if (self::MAX_USERS_PER_TEAM < $maxUsers) { $maxUsers = self::MAX_USERS_PER_TEAM; } $userCount = mt_rand(0, $maxUsers); - $maxProjects = count($allProjects) - 1; + $maxProjects = \count($allProjects) - 1; if (self::MAX_PROJECTS_PER_TEAM < $maxProjects) { $maxProjects = self::MAX_PROJECTS_PER_TEAM; } @@ -108,7 +108,7 @@ class TeamFixtures extends Fixture implements DependentFixtureInterface if ($userCount > 0) { $userKeys = array_rand($allUsers, $userCount); - if (!is_array($userKeys)) { + if (!\is_array($userKeys)) { $userKeys = [$userKeys]; } foreach ($userKeys as $userKey) { @@ -118,7 +118,7 @@ class TeamFixtures extends Fixture implements DependentFixtureInterface if ($projectCount > 0) { $projectKeys = array_rand($allProjects, $projectCount); - if (!is_array($projectKeys)) { + if (!\is_array($projectKeys)) { $projectKeys = [$projectKeys]; } foreach ($projectKeys as $projectKey) { diff --git a/src/DataFixtures/UserFixtures.php b/src/DataFixtures/UserFixtures.php index 938a09e2..cdc92e78 100644 --- a/src/DataFixtures/UserFixtures.php +++ b/src/DataFixtures/UserFixtures.php @@ -140,11 +140,11 @@ class UserFixtures extends Fixture $username = $faker->userName; $email = $faker->email; - if (in_array($username, $existingName)) { + if (\in_array($username, $existingName)) { continue; } - if (in_array($email, $existingEmail)) { + if (\in_array($email, $existingEmail)) { continue; } diff --git a/src/DependencyInjection/AppExtension.php b/src/DependencyInjection/AppExtension.php index 19002f45..3ebfeae5 100644 --- a/src/DependencyInjection/AppExtension.php +++ b/src/DependencyInjection/AppExtension.php @@ -90,11 +90,11 @@ class AppExtension extends Extension // this should happen always at the end, so bundles do not mess with the base configuration if ($container->hasParameter('kimai.bundles.config')) { $bundleConfig = $container->getParameter('kimai.bundles.config'); - if (!is_array($bundleConfig)) { + if (!\is_array($bundleConfig)) { trigger_error('Invalid bundle configuration found, skipping all bundle configuration'); } foreach ($bundleConfig as $key => $value) { - if (array_key_exists($key, $config)) { + if (\array_key_exists($key, $config)) { trigger_error(sprintf('Invalid bundle configuration "%s" found, skipping', $key)); continue; } @@ -110,7 +110,7 @@ class AppExtension extends Extension // make sure all allowed locales are registered foreach ($locales as $locale) { - if (!array_key_exists($locale, $config)) { + if (!\array_key_exists($locale, $config)) { $config[$locale] = $config[Constants::DEFAULT_LOCALE]; } } @@ -190,7 +190,7 @@ class AppExtension extends Extension return false; } - return !in_array('!' . $permission, $deleteFromArray); + return !\in_array('!' . $permission, $deleteFromArray); }); } diff --git a/src/DependencyInjection/Compiler/DoctrineCompilerPass.php b/src/DependencyInjection/Compiler/DoctrineCompilerPass.php index 7677243c..30d7f5d8 100644 --- a/src/DependencyInjection/Compiler/DoctrineCompilerPass.php +++ b/src/DependencyInjection/Compiler/DoctrineCompilerPass.php @@ -50,7 +50,7 @@ class DoctrineCompilerPass implements CompilerPassInterface ); } - if (!in_array($engine, $this->allowedEngines)) { + if (!\in_array($engine, $this->allowedEngines)) { throw new \Exception( 'Unsupported database engine: ' . $engine . '. Kimai only supports one of: ' . implode(', ', $this->allowedEngines) diff --git a/src/DependencyInjection/Compiler/ExportServiceCompilerPass.php b/src/DependencyInjection/Compiler/ExportServiceCompilerPass.php index 44a4f271..dfef97df 100644 --- a/src/DependencyInjection/Compiler/ExportServiceCompilerPass.php +++ b/src/DependencyInjection/Compiler/ExportServiceCompilerPass.php @@ -42,7 +42,7 @@ class ExportServiceCompilerPass implements CompilerPassInterface $definition->addMethodCall('addTimesheetExporter', [new Reference($id)]); } - $path = dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR; + $path = \dirname(\dirname(\dirname(__DIR__))) . DIRECTORY_SEPARATOR; foreach ($container->getParameter('kimai.export.documents') as $exportPath) { if (!is_dir($path . $exportPath)) { continue; diff --git a/src/DependencyInjection/Compiler/TwigContextCompilerPass.php b/src/DependencyInjection/Compiler/TwigContextCompilerPass.php index 98622ac2..5ef91c4c 100644 --- a/src/DependencyInjection/Compiler/TwigContextCompilerPass.php +++ b/src/DependencyInjection/Compiler/TwigContextCompilerPass.php @@ -34,7 +34,7 @@ class TwigContextCompilerPass implements CompilerPassInterface $definition = $container->getDefinition('twig.loader.native_filesystem'); - $path = dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR; + $path = \dirname(\dirname(\dirname(__DIR__))) . DIRECTORY_SEPARATOR; foreach ($container->getParameter('kimai.invoice.documents') as $invoicePath) { if (!is_dir($path . $invoicePath)) { continue; diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 71c74cce..c3136360 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -690,7 +690,7 @@ class Configuration implements ConfigurationInterface ->end() ->validate() ->ifTrue(static function ($v) { - return null !== $v['connection']['host'] && !extension_loaded('ldap'); + return null !== $v['connection']['host'] && !\extension_loaded('ldap'); }) ->thenInvalid('LDAP is activated, but the LDAP PHP extension is not loaded.') ->end() @@ -833,7 +833,7 @@ class Configuration implements ConfigurationInterface ->variableNode('requestedAuthnContext') ->validate() ->ifTrue(function ($v) { - return !is_bool($v) && !is_array($v); + return !\is_bool($v) && !\is_array($v); }) ->thenInvalid('Must be an array or a bool.') ->end() diff --git a/src/Doctrine/AbstractMigration.php b/src/Doctrine/AbstractMigration.php index 5f5e58ae..6a9452b1 100644 --- a/src/Doctrine/AbstractMigration.php +++ b/src/Doctrine/AbstractMigration.php @@ -124,7 +124,7 @@ abstract class AbstractMigration extends BaseAbstractMigration implements Contai protected function abortIfPlatformNotSupported() { $platform = $this->getPlatform(); - if (!in_array($platform, ['sqlite', 'mysql'])) { + if (!\in_array($platform, ['sqlite', 'mysql'])) { $this->abortIf(true, 'Unsupported database platform: ' . $platform); } } diff --git a/src/Entity/ActivityMeta.php b/src/Entity/ActivityMeta.php index ece56003..c52d541b 100644 --- a/src/Entity/ActivityMeta.php +++ b/src/Entity/ActivityMeta.php @@ -39,7 +39,7 @@ class ActivityMeta implements MetaTableTypeInterface { if (!($entity instanceof Activity)) { throw new \InvalidArgumentException( - sprintf('Expected instanceof Activity, received "%s"', get_class($entity)) + sprintf('Expected instanceof Activity, received "%s"', \get_class($entity)) ); } $this->activity = $entity; diff --git a/src/Entity/CustomerMeta.php b/src/Entity/CustomerMeta.php index acf818c8..96e3f2b1 100644 --- a/src/Entity/CustomerMeta.php +++ b/src/Entity/CustomerMeta.php @@ -39,7 +39,7 @@ class CustomerMeta implements MetaTableTypeInterface { if (!($entity instanceof Customer)) { throw new \InvalidArgumentException( - sprintf('Expected instanceof Customer, received "%s"', get_class($entity)) + sprintf('Expected instanceof Customer, received "%s"', \get_class($entity)) ); } $this->customer = $entity; diff --git a/src/Entity/ProjectMeta.php b/src/Entity/ProjectMeta.php index 375061d4..a1806c55 100644 --- a/src/Entity/ProjectMeta.php +++ b/src/Entity/ProjectMeta.php @@ -39,7 +39,7 @@ class ProjectMeta implements MetaTableTypeInterface { if (!($entity instanceof Project)) { throw new \InvalidArgumentException( - sprintf('Expected instanceof Project, received "%s"', get_class($entity)) + sprintf('Expected instanceof Project, received "%s"', \get_class($entity)) ); } $this->project = $entity; diff --git a/src/Entity/TimesheetMeta.php b/src/Entity/TimesheetMeta.php index cbcc9427..bd0e84ac 100644 --- a/src/Entity/TimesheetMeta.php +++ b/src/Entity/TimesheetMeta.php @@ -39,7 +39,7 @@ class TimesheetMeta implements MetaTableTypeInterface { if (!($entity instanceof Timesheet)) { throw new \InvalidArgumentException( - sprintf('Expected instanceof Timesheet, received "%s"', get_class($entity)) + sprintf('Expected instanceof Timesheet, received "%s"', \get_class($entity)) ); } $this->timesheet = $entity; diff --git a/src/Event/PermissionsEvent.php b/src/Event/PermissionsEvent.php index 63d31335..83e1b497 100644 --- a/src/Event/PermissionsEvent.php +++ b/src/Event/PermissionsEvent.php @@ -35,8 +35,8 @@ final class PermissionsEvent extends Event public function removePermission(string $section, string $permission): PermissionsEvent { - if (array_key_exists($section, $this->sections)) { - if (array_key_exists($permission, $this->sections[$section])) { + if (\array_key_exists($section, $this->sections)) { + if (\array_key_exists($permission, $this->sections[$section])) { unset($this->sections[$section][$permission]); } } @@ -46,12 +46,12 @@ final class PermissionsEvent extends Event public function hasSection(string $section): bool { - return array_key_exists($section, $this->sections); + return \array_key_exists($section, $this->sections); } public function removeSection(string $section): PermissionsEvent { - if (array_key_exists($section, $this->sections)) { + if (\array_key_exists($section, $this->sections)) { unset($this->sections[$section]); } @@ -60,7 +60,7 @@ final class PermissionsEvent extends Event public function getSection(string $section): ?array { - if (array_key_exists($section, $this->sections)) { + if (\array_key_exists($section, $this->sections)) { return $this->sections[$section]; } diff --git a/src/EventSubscriber/DashboardSubscriber.php b/src/EventSubscriber/DashboardSubscriber.php index ab026d2e..f20f6691 100644 --- a/src/EventSubscriber/DashboardSubscriber.php +++ b/src/EventSubscriber/DashboardSubscriber.php @@ -92,11 +92,13 @@ class DashboardSubscriber implements EventSubscriberInterface $section->setOrder(100); if ($this->security->isGranted('view_user')) { + $query = new UserQuery(); + $query->setCurrentUser($user); $section->addWidget( (new More()) ->setId('userTotal') ->setTitle('stats.userTotal') - ->setData($this->user->countUsersForQuery((new UserQuery())->setCurrentUser($user))) + ->setData($this->user->countUsersForQuery($query)) ->setOptions([ 'route' => 'admin_user', 'icon' => 'user', @@ -106,11 +108,13 @@ class DashboardSubscriber implements EventSubscriberInterface } if ($this->security->isGranted('view_customer')) { + $query = new CustomerQuery(); + $query->setCurrentUser($user); $section->addWidget( (new More()) ->setId('customerTotal') ->setTitle('stats.customerTotal') - ->setData($this->customer->countCustomersForQuery((new CustomerQuery())->setCurrentUser($user))) + ->setData($this->customer->countCustomersForQuery($query)) ->setOptions([ 'route' => 'admin_customer', 'icon' => 'customer', @@ -120,11 +124,13 @@ class DashboardSubscriber implements EventSubscriberInterface } if ($this->security->isGranted('view_project')) { + $query = new ProjectQuery(); + $query->setCurrentUser($user); $section->addWidget( (new More()) ->setId('projectTotal') ->setTitle('stats.projectTotal') - ->setData($this->project->countProjectsForQuery((new ProjectQuery())->setCurrentUser($user))) + ->setData($this->project->countProjectsForQuery($query)) ->setOptions([ 'route' => 'admin_project', 'icon' => 'project', @@ -134,11 +140,13 @@ class DashboardSubscriber implements EventSubscriberInterface } if ($this->security->isGranted('view_activity')) { + $query = new ActivityQuery(); + $query->setCurrentUser($user); $section->addWidget( (new More()) ->setId('activityTotal') ->setTitle('stats.activityTotal') - ->setData($this->activity->countActivitiesForQuery((new ActivityQuery())->setCurrentUser($user))) + ->setData($this->activity->countActivitiesForQuery($query)) ->setOptions([ 'route' => 'admin_activity', 'icon' => 'activity', @@ -147,7 +155,7 @@ class DashboardSubscriber implements EventSubscriberInterface ); } - if (count($section->getWidgets()) > 0) { + if (\count($section->getWidgets()) > 0) { $event->addSection($section); } } diff --git a/src/EventSubscriber/MenuBuilderSubscriber.php b/src/EventSubscriber/MenuBuilderSubscriber.php index 380243f0..487a8024 100644 --- a/src/EventSubscriber/MenuBuilderSubscriber.php +++ b/src/EventSubscriber/MenuBuilderSubscriber.php @@ -12,6 +12,7 @@ namespace App\EventSubscriber; use App\Event\ConfigureMainMenuEvent; use App\Utils\MenuItemModel as KimaiMenuItemModel; use KevinPapst\AdminLTEBundle\Event\SidebarMenuEvent; +use KevinPapst\AdminLTEBundle\Model\MenuItemInterface; use KevinPapst\AdminLTEBundle\Model\MenuItemModel; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; @@ -95,7 +96,7 @@ class MenuBuilderSubscriber implements EventSubscriberInterface /** * @param string $route - * @param MenuItemModel[] $items + * @param MenuItemInterface[] $items */ protected function activateByRoute($route, $items) { diff --git a/src/EventSubscriber/RedirectToLocaleSubscriber.php b/src/EventSubscriber/RedirectToLocaleSubscriber.php index 45a20652..9c81f7cd 100644 --- a/src/EventSubscriber/RedirectToLocaleSubscriber.php +++ b/src/EventSubscriber/RedirectToLocaleSubscriber.php @@ -59,7 +59,7 @@ class RedirectToLocaleSubscriber implements EventSubscriberInterface } $this->defaultLocale = $defaultLocale ?: $this->locales[0]; - if (!in_array($this->defaultLocale, $this->locales)) { + if (!\in_array($this->defaultLocale, $this->locales)) { throw new \UnexpectedValueException( sprintf('The default locale ("%s") must be one of "%s".', $this->defaultLocale, $locales) ); diff --git a/src/Export/Base/AbstractSpreadsheetRenderer.php b/src/Export/Base/AbstractSpreadsheetRenderer.php index 16f57c8d..d7a4b209 100644 --- a/src/Export/Base/AbstractSpreadsheetRenderer.php +++ b/src/Export/Base/AbstractSpreadsheetRenderer.php @@ -282,8 +282,8 @@ abstract class AbstractSpreadsheetRenderer } if (isset($columns['description']) && !isset($columns['description']['render'])) { - $maxWidth = array_key_exists('maxWidth', $columns['description']) ? intval($columns['description']['maxWidth']) : null; - $wrapText = array_key_exists('wrapText', $columns['description']) ? (bool) $columns['description']['wrapText'] : false; + $maxWidth = \array_key_exists('maxWidth', $columns['description']) ? \intval($columns['description']['maxWidth']) : null; + $wrapText = \array_key_exists('wrapText', $columns['description']) ? (bool) $columns['description']['wrapText'] : false; // This column has a column-only formatter to set the maximum width of a column. // It needs to be executed once, so we use this as a flag on when to skip it. @@ -352,7 +352,7 @@ abstract class AbstractSpreadsheetRenderer $sheet->setCellValueByColumnAndRow($column++, $row, $this->translator->trans($metaField->getLabel())); } - return count($timesheetMetaFields); + return \count($timesheetMetaFields); }, 'render' => function (Worksheet $sheet, int $row, int $column, ExportItemInterface $entity) use ($timesheetMetaFields) { foreach ($timesheetMetaFields as $metaField) { @@ -364,7 +364,7 @@ abstract class AbstractSpreadsheetRenderer $sheet->setCellValueByColumnAndRow($column++, $row, $metaFieldValue); } - return count($timesheetMetaFields); + return \count($timesheetMetaFields); } ]; } @@ -380,7 +380,7 @@ abstract class AbstractSpreadsheetRenderer $sheet->setCellValueByColumnAndRow($column++, $row, $this->translator->trans($metaField->getLabel())); } - return count($customerMetaFields); + return \count($customerMetaFields); }, 'render' => function (Worksheet $sheet, int $row, int $column, ExportItemInterface $entity) use ($customerMetaFields) { foreach ($customerMetaFields as $metaField) { @@ -394,7 +394,7 @@ abstract class AbstractSpreadsheetRenderer $sheet->setCellValueByColumnAndRow($column++, $row, $metaFieldValue); } - return count($customerMetaFields); + return \count($customerMetaFields); } ]; } @@ -407,7 +407,7 @@ abstract class AbstractSpreadsheetRenderer $sheet->setCellValueByColumnAndRow($column++, $row, $this->translator->trans($metaField->getLabel())); } - return count($projectMetaFields); + return \count($projectMetaFields); }, 'render' => function (Worksheet $sheet, int $row, int $column, ExportItemInterface $entity) use ($projectMetaFields) { foreach ($projectMetaFields as $metaField) { @@ -421,7 +421,7 @@ abstract class AbstractSpreadsheetRenderer $sheet->setCellValueByColumnAndRow($column++, $row, $metaFieldValue); } - return count($projectMetaFields); + return \count($projectMetaFields); } ]; } @@ -434,7 +434,7 @@ abstract class AbstractSpreadsheetRenderer $sheet->setCellValueByColumnAndRow($column++, $row, $this->translator->trans($metaField->getLabel())); } - return count($activityMetaFields); + return \count($activityMetaFields); }, 'render' => function (Worksheet $sheet, int $row, int $column, ExportItemInterface $entity) use ($activityMetaFields) { foreach ($activityMetaFields as $metaField) { @@ -448,7 +448,7 @@ abstract class AbstractSpreadsheetRenderer $sheet->setCellValueByColumnAndRow($column++, $row, $metaFieldValue); } - return count($activityMetaFields); + return \count($activityMetaFields); } ]; } @@ -463,7 +463,7 @@ abstract class AbstractSpreadsheetRenderer $sheet->setCellValueByColumnAndRow($column++, $row, $this->translator->trans($metaField->getLabel())); } - return count($userPreferences); + return \count($userPreferences); }, 'render' => function (Worksheet $sheet, int $row, int $column, ExportItemInterface $entity) use ($userPreferences) { foreach ($userPreferences as $preference) { @@ -477,7 +477,7 @@ abstract class AbstractSpreadsheetRenderer $sheet->setCellValueByColumnAndRow($column++, $row, $metaFieldValue); } - return count($userPreferences); + return \count($userPreferences); } ]; } @@ -485,7 +485,7 @@ abstract class AbstractSpreadsheetRenderer if (!$showRates) { $removes = ['rate', 'fixedRate', 'hourlyRate', 'rate_internal']; foreach ($removes as $removeMe) { - if (array_key_exists($removeMe, $columns)) { + if (\array_key_exists($removeMe, $columns)) { unset($columns[$removeMe]); } } @@ -543,7 +543,7 @@ abstract class AbstractSpreadsheetRenderer $internalRateColumn = $entryHeaderColumn; } - if (!array_key_exists('render', $settings) || !is_callable($settings['render'])) { + if (!\array_key_exists('render', $settings) || !\is_callable($settings['render'])) { throw new \RuntimeException(sprintf('Missing renderer for export column %s', $label)); } diff --git a/src/Export/Base/XlsxRenderer.php b/src/Export/Base/XlsxRenderer.php index 068e1834..789b519d 100644 --- a/src/Export/Base/XlsxRenderer.php +++ b/src/Export/Base/XlsxRenderer.php @@ -51,6 +51,7 @@ class XlsxRenderer extends AbstractSpreadsheetRenderer // Freeze first row and date & time columns for easier navigation $sheet->freezePane('D2'); + /** @var string $column */ foreach (range('A', $highestColumn) as $column) { // We default to a reasonable auto-width decided by the client, // sadly ->getDefaultColumnDimension() is not supported so it needs diff --git a/src/Form/Extension/SelectWithApiDataExtension.php b/src/Form/Extension/SelectWithApiDataExtension.php index 0dcc3b85..3985f6dc 100644 --- a/src/Form/Extension/SelectWithApiDataExtension.php +++ b/src/Form/Extension/SelectWithApiDataExtension.php @@ -52,7 +52,7 @@ class SelectWithApiDataExtension extends AbstractTypeExtension $apiData = $options['api_data']; - if (!is_array($apiData)) { + if (!\is_array($apiData)) { throw new \InvalidArgumentException('Option "api_data" must be an array for form "' . $form->getName() . '"'); } diff --git a/src/Form/FormTrait.php b/src/Form/FormTrait.php index 21f4b4af..d3d5f785 100644 --- a/src/Form/FormTrait.php +++ b/src/Form/FormTrait.php @@ -78,7 +78,7 @@ trait FormTrait 'group_by' => null, 'query_builder' => function (ProjectRepository $repo) use ($builder, $project, $customer, $isNew) { // is there a better wa to prevent starting a record with a hidden project ? - if ($isNew && !empty($project) && (is_int($project) || is_string($project))) { + if ($isNew && !empty($project) && (\is_int($project) || \is_string($project))) { /** @var Project $project */ $project = $repo->find($project); if (null !== $project) { diff --git a/src/Form/RoleType.php b/src/Form/RoleType.php index 92ad7c8d..1d4fea99 100644 --- a/src/Form/RoleType.php +++ b/src/Form/RoleType.php @@ -44,7 +44,7 @@ class RoleType extends AbstractType $builder->get('name')->addViewTransformer( new CallbackTransformer( function ($roleName) { - if (is_string($roleName)) { + if (\is_string($roleName)) { $roleName = str_replace(' ', '_', $roleName); $roleName = str_replace('-', '_', $roleName); $roleName = strtoupper($roleName); diff --git a/src/Form/Toolbar/AbstractToolbarForm.php b/src/Form/Toolbar/AbstractToolbarForm.php index 1cb4f240..5905a103 100644 --- a/src/Form/Toolbar/AbstractToolbarForm.php +++ b/src/Form/Toolbar/AbstractToolbarForm.php @@ -188,7 +188,7 @@ abstract class AbstractToolbarForm extends AbstractType $name = $multiCustomer ? 'customers' : 'customer'; if (isset($data[$name]) && !empty($data[$name])) { - if (is_array($data[$name])) { + if (\is_array($data[$name])) { $query->setCustomers($data[$name]); } else { $query->addCustomer($data[$name]); @@ -197,7 +197,7 @@ abstract class AbstractToolbarForm extends AbstractType $name = $multiProject ? 'projects' : 'project'; if (isset($data[$name]) && !empty($data[$name])) { - if (is_array($data[$name])) { + if (\is_array($data[$name])) { $query->setProjects($data[$name]); } else { $query->addProject($data[$name]); @@ -249,7 +249,7 @@ abstract class AbstractToolbarForm extends AbstractType if (isset($data[$name]) && !empty($data[$name])) { // we need to pre-fetch the activities to see if they are global, see ActivityFormTypeQuery::isGlobalsOnly() $activities = $data[$name]; - if (!is_array($activities)) { + if (!\is_array($activities)) { $activities = [$activities]; } foreach ($activities as $activity) { diff --git a/src/Form/Type/CustomerType.php b/src/Form/Type/CustomerType.php index 4f84d0e2..a5bd017b 100644 --- a/src/Form/Type/CustomerType.php +++ b/src/Form/Type/CustomerType.php @@ -59,7 +59,7 @@ class CustomerType extends AbstractType $resolver->setDefault('api_data', function (Options $options) { if (false !== $options['project_enabled']) { - $name = is_string($options['project_enabled']) ? $options['project_enabled'] : 'customer'; + $name = \is_string($options['project_enabled']) ? $options['project_enabled'] : 'customer'; $routeParams = [$name => '%' . $name . '%', 'visible' => $options['project_visibility']]; $emptyRouteParams = ['visible' => $options['project_visibility']]; diff --git a/src/Form/Type/DateRangeType.php b/src/Form/Type/DateRangeType.php index 64e225df..cc7656a1 100644 --- a/src/Form/Type/DateRangeType.php +++ b/src/Form/Type/DateRangeType.php @@ -167,7 +167,7 @@ class DateRangeType extends AbstractType $values = explode($separator, $dates); - if (count($values) !== 2) { + if (\count($values) !== 2) { throw new TransformationFailedException('Invalid date range given'); } diff --git a/src/Form/Type/InvoiceRendererType.php b/src/Form/Type/InvoiceRendererType.php index 4ea044c5..40aa4895 100644 --- a/src/Form/Type/InvoiceRendererType.php +++ b/src/Form/Type/InvoiceRendererType.php @@ -73,7 +73,7 @@ class InvoiceRendererType extends AbstractType $parts = explode('.', $renderer); - if (count($parts) > 2) { + if (\count($parts) > 2) { array_pop($parts); } diff --git a/src/Form/Type/LanguageType.php b/src/Form/Type/LanguageType.php index 1225dc5b..fc8f1ac2 100644 --- a/src/Form/Type/LanguageType.php +++ b/src/Form/Type/LanguageType.php @@ -29,7 +29,7 @@ class LanguageType extends AbstractType */ public function __construct($locales) { - if (!is_array($locales)) { + if (!\is_array($locales)) { $locales = explode('|', $locales); } diff --git a/src/Form/Type/ProjectType.php b/src/Form/Type/ProjectType.php index e9e57f17..245d056f 100644 --- a/src/Form/Type/ProjectType.php +++ b/src/Form/Type/ProjectType.php @@ -85,7 +85,7 @@ class ProjectType extends AbstractType $resolver->setDefault('api_data', function (Options $options) { if (false !== $options['activity_enabled']) { - $name = is_string($options['activity_enabled']) ? $options['activity_enabled'] : 'project'; + $name = \is_string($options['activity_enabled']) ? $options['activity_enabled'] : 'project'; return [ 'select' => $options['activity_select'], diff --git a/src/Invoice/Calculator/ShortInvoiceCalculator.php b/src/Invoice/Calculator/ShortInvoiceCalculator.php index 61989f07..adf5e88e 100644 --- a/src/Invoice/Calculator/ShortInvoiceCalculator.php +++ b/src/Invoice/Calculator/ShortInvoiceCalculator.php @@ -36,13 +36,13 @@ class ShortInvoiceCalculator extends AbstractMergedCalculator implements Calcula if (null !== $entry->getFixedRate()) { $key = 'fixed_' . (string) $entry->getFixedRate(); } - if (!in_array($key, $keys)) { + if (!\in_array($key, $keys)) { $keys[] = $key; } $this->mergeInvoiceItems($invoiceItem, $entry); } - if (count($keys) > 1) { + if (\count($keys) > 1) { $invoiceItem->setAmount(1); $invoiceItem->setFixedRate($invoiceItem->getRate()); $invoiceItem->setHourlyRate($invoiceItem->getRate()); diff --git a/src/Invoice/NumberGenerator/ConfigurableNumberGenerator.php b/src/Invoice/NumberGenerator/ConfigurableNumberGenerator.php index d44dfdf0..caf00712 100644 --- a/src/Invoice/NumberGenerator/ConfigurableNumberGenerator.php +++ b/src/Invoice/NumberGenerator/ConfigurableNumberGenerator.php @@ -67,9 +67,12 @@ final class ConfigurableNumberGenerator implements NumberGeneratorInterface // number format if (substr_count($tmp, ',') !== 0) { - $formatter = explode(',', $tmp); - $tmp = $formatter[0]; - $formatter = $formatter[1]; + $parts = explode(',', $tmp); + $tmp = $parts[0]; + $formatter = \intval($parts[1]); + if ((string) $formatter !== $parts[1]) { + $formatter = null; + } } switch ($tmp) { diff --git a/src/Invoice/Renderer/AbstractSpreadsheetRenderer.php b/src/Invoice/Renderer/AbstractSpreadsheetRenderer.php index cb0f3f8e..c3df3068 100644 --- a/src/Invoice/Renderer/AbstractSpreadsheetRenderer.php +++ b/src/Invoice/Renderer/AbstractSpreadsheetRenderer.php @@ -45,7 +45,7 @@ abstract class AbstractSpreadsheetRenderer extends AbstractRenderer $worksheet = $spreadsheet->getActiveSheet(); $entries = $model->getCalculator()->getEntries(); $sheetReplacer = $model->toArray(); - $invoiceItemCount = count($entries); + $invoiceItemCount = \count($entries); if ($invoiceItemCount > 1) { $this->addTemplateRows($worksheet, $invoiceItemCount); } diff --git a/src/Invoice/Renderer/AdvancedValueBinder.php b/src/Invoice/Renderer/AdvancedValueBinder.php index 634cff4a..651515a0 100644 --- a/src/Invoice/Renderer/AdvancedValueBinder.php +++ b/src/Invoice/Renderer/AdvancedValueBinder.php @@ -30,7 +30,7 @@ class AdvancedValueBinder extends DefaultValueBinder implements IValueBinder */ public function bindValue(Cell $cell, $value = null) { - if (is_string($value)) { + if (\is_string($value)) { $value = StringHelper::sanitizeUTF8($value); } diff --git a/src/Invoice/Renderer/DocxRenderer.php b/src/Invoice/Renderer/DocxRenderer.php index c88ad540..92d7fa14 100644 --- a/src/Invoice/Renderer/DocxRenderer.php +++ b/src/Invoice/Renderer/DocxRenderer.php @@ -41,10 +41,10 @@ final class DocxRenderer extends AbstractRenderer implements RendererInterface } try { - $template->cloneRow('entry.description', count($model->getCalculator()->getEntries())); + $template->cloneRow('entry.description', \count($model->getCalculator()->getEntries())); } catch (OfficeException $ex) { try { - $template->cloneRow('entry.row', count($model->getCalculator()->getEntries())); + $template->cloneRow('entry.row', \count($model->getCalculator()->getEntries())); } catch (OfficeException $ex) { @trigger_error( sprintf('Invoice document (%s) did not contain a clone row, was that on purpose?', $document->getFilename()) diff --git a/src/Invoice/ServiceInvoice.php b/src/Invoice/ServiceInvoice.php index 5cbd021c..fb954a7a 100644 --- a/src/Invoice/ServiceInvoice.php +++ b/src/Invoice/ServiceInvoice.php @@ -206,7 +206,7 @@ final class ServiceInvoice continue; } $filename = explode('filename=', $part); - if (count($filename) > 1) { + if (\count($filename) > 1) { $filename = $filename[1]; } } @@ -233,7 +233,7 @@ final class ServiceInvoice public function changeInvoiceStatus(Invoice $invoice, string $status) { - if (!in_array($status, [Invoice::STATUS_NEW, Invoice::STATUS_PENDING, Invoice::STATUS_PAID])) { + if (!\in_array($status, [Invoice::STATUS_NEW, Invoice::STATUS_PENDING, Invoice::STATUS_PAID])) { throw new \InvalidArgumentException('Unknown invoice status'); } @@ -256,7 +256,7 @@ final class ServiceInvoice /** * @param InvoiceQuery $query - * @return InvoiceItemInterface[] + * @return array */ private function findInvoiceItemsWithRepository(InvoiceQuery $query): array { @@ -278,7 +278,7 @@ final class ServiceInvoice $items = []; foreach ($repositories as $repository) { - $items[get_class($repository)] = $repository->getInvoiceItemsForQuery($query); + $items[\get_class($repository)] = $repository->getInvoiceItemsForQuery($query); } return $items; @@ -301,7 +301,7 @@ final class ServiceInvoice } /** - * @param InvoiceItemInterface[] $entries + * @param array $entries */ private function markEntriesAsExported(iterable $entries) { @@ -309,7 +309,7 @@ final class ServiceInvoice foreach ($entries as $repo => $items) { foreach ($repositories as $repository) { - if (get_class($repository) === $repo) { + if (\get_class($repository) === $repo) { $repository->setExported($items); } } diff --git a/src/Ldap/LdapDriver.php b/src/Ldap/LdapDriver.php index 3275f641..1b2813d0 100644 --- a/src/Ldap/LdapDriver.php +++ b/src/Ldap/LdapDriver.php @@ -95,7 +95,7 @@ class LdapDriver $entries = $driver->searchEntries($filter, $baseDn, Ldap::SEARCH_SCOPE_SUB, $attributes); // searchEntries don't return 'count' key as specified by php native function ldap_get_entries() - $entries['count'] = count($entries); + $entries['count'] = \count($entries); } catch (LdapException $exception) { $this->ldapExceptionHandler($exception); diff --git a/src/Ldap/LdapManager.php b/src/Ldap/LdapManager.php index 5679352a..cbcb98cb 100644 --- a/src/Ldap/LdapManager.php +++ b/src/Ldap/LdapManager.php @@ -141,7 +141,7 @@ class LdapManager } $roleValue = $entries[0][$param]; - if (is_array($roleValue)) { + if (\is_array($roleValue)) { $roleValue = $roleValue[0]; } $roles = $this->getRoles($roleValue, $roleParameter); @@ -157,7 +157,7 @@ class LdapManager return $this->driver->search( $roleParameter['baseDn'], - sprintf('(&%s(%s=%s))', $filter, $roleParameter['userDnAttribute'], ldap_escape($dn, null, LDAP_ESCAPE_FILTER)), + sprintf('(&%s(%s=%s))', $filter, $roleParameter['userDnAttribute'], ldap_escape($dn, '', LDAP_ESCAPE_FILTER)), [$roleParameter['nameAttribute']] ); } diff --git a/src/Ldap/LdapUserHydrator.php b/src/Ldap/LdapUserHydrator.php index 1c5e1b85..4ca692b8 100644 --- a/src/Ldap/LdapUserHydrator.php +++ b/src/Ldap/LdapUserHydrator.php @@ -66,7 +66,7 @@ class LdapUserHydrator /** @var string|array|null $email */ $email = $user->getEmail(); - if (is_array($email)) { + if (\is_array($email)) { $user->setEmail($email[0]); } @@ -107,7 +107,7 @@ class LdapUserHydrator $roleName = sprintf('ROLE_%s', self::slugify($roleName)); } - if (!in_array($roleName, $allowedRoles)) { + if (!\in_array($roleName, $allowedRoles)) { continue; } @@ -130,17 +130,17 @@ class LdapUserHydrator { /** @var array $attr */ foreach ($attributeMap as $attr) { - if (!array_key_exists($attr['ldap_attr'], $ldapUserAttributes)) { + if (!\array_key_exists($attr['ldap_attr'], $ldapUserAttributes)) { continue; } $ldapValue = $ldapUserAttributes[$attr['ldap_attr']]; - if (array_key_exists('count', $ldapValue)) { + if (\array_key_exists('count', $ldapValue)) { unset($ldapValue['count']); } - if (1 === count($ldapValue)) { + if (1 === \count($ldapValue)) { $value = array_shift($ldapValue); } else { $value = $ldapValue; diff --git a/src/Ldap/LdapUserProvider.php b/src/Ldap/LdapUserProvider.php index f8fbb87a..c823eb3f 100644 --- a/src/Ldap/LdapUserProvider.php +++ b/src/Ldap/LdapUserProvider.php @@ -69,8 +69,8 @@ class LdapUserProvider implements UserProviderInterface public function refreshUser(UserInterface $user) { - if (!($user instanceof User) || !$this->supportsClass(get_class($user))) { - throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_class($user))); + if (!($user instanceof User) || !$this->supportsClass(\get_class($user))) { + throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user))); } if (!$user->isLdapUser() && null === $user->getPreferenceValue('ldap.dn')) { diff --git a/src/Migrations/Version20180715160326.php b/src/Migrations/Version20180715160326.php index 0507e930..bdb6fcfe 100644 --- a/src/Migrations/Version20180715160326.php +++ b/src/Migrations/Version20180715160326.php @@ -42,7 +42,7 @@ final class Version20180715160326 extends AbstractMigration // delete all existing indexes $indexesOld = $schema->getTable($users)->getIndexes(); foreach ($indexesOld as $index) { - if (in_array('name', $index->getColumns()) || in_array('mail', $index->getColumns())) { + if (\in_array('name', $index->getColumns()) || \in_array('mail', $index->getColumns())) { $this->indexesOld[] = $index; $this->addSqlDropIndex($index->getName(), $users); } diff --git a/src/Plugin/PluginManager.php b/src/Plugin/PluginManager.php index 2719521b..db3ce184 100644 --- a/src/Plugin/PluginManager.php +++ b/src/Plugin/PluginManager.php @@ -101,7 +101,7 @@ class PluginManager $homepage = $json['homepage'] ?? Constants::HOMEPAGE . '/store/'; - if (array_key_exists('name', $json['extra']['kimai'])) { + if (\array_key_exists('name', $json['extra']['kimai'])) { $plugin->setName($json['extra']['kimai']['name']); } diff --git a/src/Repository/ActivityRepository.php b/src/Repository/ActivityRepository.php index 0efb2519..50f7a4c0 100644 --- a/src/Repository/ActivityRepository.php +++ b/src/Repository/ActivityRepository.php @@ -275,7 +275,7 @@ class ActivityRepository extends EntityRepository $where = $qb->expr()->andX(); - if (in_array($query->getVisibility(), [ActivityQuery::SHOW_VISIBLE, ActivityQuery::SHOW_HIDDEN])) { + if (\in_array($query->getVisibility(), [ActivityQuery::SHOW_VISIBLE, ActivityQuery::SHOW_HIDDEN])) { if (!$query->isGlobalsOnly()) { $where->add( $qb->expr()->orX( diff --git a/src/Repository/ConfigurationRepository.php b/src/Repository/ConfigurationRepository.php index f7131719..78a8b971 100644 --- a/src/Repository/ConfigurationRepository.php +++ b/src/Repository/ConfigurationRepository.php @@ -36,7 +36,7 @@ class ConfigurationRepository extends EntityRepository implements ConfigLoaderIn static::$cacheByPrefix = []; foreach ($configs as $config) { $key = substr($config->getName(), 0, strpos($config->getName(), '.')); - if (!array_key_exists($key, static::$cacheByPrefix)) { + if (!\array_key_exists($key, static::$cacheByPrefix)) { static::$cacheByPrefix[$key] = []; } static::$cacheByPrefix[$key][] = $config; @@ -56,7 +56,7 @@ class ConfigurationRepository extends EntityRepository implements ConfigLoaderIn return static::$cacheAll; } - if (!array_key_exists($prefix, static::$cacheByPrefix)) { + if (!\array_key_exists($prefix, static::$cacheByPrefix)) { return []; } @@ -84,7 +84,7 @@ class ConfigurationRepository extends EntityRepository implements ConfigLoaderIn } // allow to use entity types - if (is_object($value) && method_exists($value, 'getId')) { + if (\is_object($value) && method_exists($value, 'getId')) { $value = $value->getId(); } diff --git a/src/Repository/InvoiceDocumentRepository.php b/src/Repository/InvoiceDocumentRepository.php index 77883e7b..f72fdd41 100644 --- a/src/Repository/InvoiceDocumentRepository.php +++ b/src/Repository/InvoiceDocumentRepository.php @@ -47,7 +47,7 @@ final class InvoiceDocumentRepository */ public function findAll() { - $base = dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR; + $base = \dirname(\dirname(__DIR__)) . DIRECTORY_SEPARATOR; $documents = []; diff --git a/src/Repository/InvoiceRepository.php b/src/Repository/InvoiceRepository.php index 7e72ec6e..17200981 100644 --- a/src/Repository/InvoiceRepository.php +++ b/src/Repository/InvoiceRepository.php @@ -58,16 +58,16 @@ class InvoiceRepository extends EntityRepository public function getCounterForMonth(\DateTime $date): int { - $start = (clone $date)->setDate($date->format('Y'), $date->format('n'), 1)->setTime(0, 0, 0); - $end = (clone $date)->setDate($date->format('Y'), $date->format('n'), $date->format('t'))->setTime(23, 59, 59); + $start = (clone $date)->setDate((int) $date->format('Y'), (int) $date->format('n'), 1)->setTime(0, 0, 0); + $end = (clone $date)->setDate((int) $date->format('Y'), (int) $date->format('n'), (int) $date->format('t'))->setTime(23, 59, 59); return $this->getCounterFor($start, $end); } public function getCounterForYear(\DateTime $date): int { - $start = (clone $date)->setDate($date->format('Y'), 1, 1)->setTime(0, 0, 0); - $end = (clone $date)->setDate($date->format('Y'), 12, 31)->setTime(23, 59, 59); + $start = (clone $date)->setDate((int) $date->format('Y'), 1, 1)->setTime(0, 0, 0); + $end = (clone $date)->setDate((int) $date->format('Y'), 12, 31)->setTime(23, 59, 59); return $this->getCounterFor($start, $end); } diff --git a/src/Repository/Loader/UserIdLoader.php b/src/Repository/Loader/UserIdLoader.php index d5789634..e0d1bbdf 100644 --- a/src/Repository/Loader/UserIdLoader.php +++ b/src/Repository/Loader/UserIdLoader.php @@ -63,7 +63,7 @@ final class UserIdLoader implements LoaderInterface } } - if (count($teamIds) > 0) { + if (\count($teamIds) > 0) { $qb = $em->createQueryBuilder(); $qb->select('PARTIAL t.{id}', 'teamlead') ->from(Team::class, 't') diff --git a/src/Repository/ProjectRepository.php b/src/Repository/ProjectRepository.php index 0fb8c3c5..b4aeacd2 100644 --- a/src/Repository/ProjectRepository.php +++ b/src/Repository/ProjectRepository.php @@ -271,7 +271,7 @@ class ProjectRepository extends EntityRepository $qb->addOrderBy($orderBy, $query->getOrder()); - if (in_array($query->getVisibility(), [ProjectQuery::SHOW_VISIBLE, ProjectQuery::SHOW_HIDDEN])) { + if (\in_array($query->getVisibility(), [ProjectQuery::SHOW_VISIBLE, ProjectQuery::SHOW_HIDDEN])) { $qb ->andWhere($qb->expr()->eq('p.visible', ':visible')) ->andWhere($qb->expr()->eq('c.visible', ':customer_visible')) diff --git a/src/Repository/Query/ActivityFormTypeQuery.php b/src/Repository/Query/ActivityFormTypeQuery.php index df8b222c..8f0dd3ab 100644 --- a/src/Repository/Query/ActivityFormTypeQuery.php +++ b/src/Repository/Query/ActivityFormTypeQuery.php @@ -26,14 +26,14 @@ final class ActivityFormTypeQuery extends BaseFormTypeQuery public function __construct($activity = null, $project = null) { if (null !== $activity) { - if (!is_array($activity)) { + if (!\is_array($activity)) { $activity = [$activity]; } $this->setActivities($activity); } if (null !== $project) { - if (!is_array($project)) { + if (!\is_array($project)) { $project = [$project]; } $this->setProjects($project); diff --git a/src/Repository/Query/ActivityQuery.php b/src/Repository/Query/ActivityQuery.php index 16aeaa6f..9b28e70b 100644 --- a/src/Repository/Query/ActivityQuery.php +++ b/src/Repository/Query/ActivityQuery.php @@ -76,7 +76,7 @@ class ActivityQuery extends ProjectQuery */ public function getProject() { - if (count($this->projects) > 0) { + if (\count($this->projects) > 0) { return $this->projects[0]; } diff --git a/src/Repository/Query/BaseFormTypeQuery.php b/src/Repository/Query/BaseFormTypeQuery.php index f03b7653..b15c7bb1 100644 --- a/src/Repository/Query/BaseFormTypeQuery.php +++ b/src/Repository/Query/BaseFormTypeQuery.php @@ -44,7 +44,7 @@ abstract class BaseFormTypeQuery */ public function getActivity() { - if (count($this->activities) > 0) { + if (\count($this->activities) > 0) { return $this->activities[0]; } @@ -107,7 +107,7 @@ abstract class BaseFormTypeQuery */ public function getProject() { - if (count($this->projects) > 0) { + if (\count($this->projects) > 0) { return $this->projects[0]; } @@ -173,7 +173,7 @@ abstract class BaseFormTypeQuery */ public function getCustomer() { - if (count($this->customers) > 0) { + if (\count($this->customers) > 0) { return $this->customers[0]; } diff --git a/src/Repository/Query/BaseQuery.php b/src/Repository/Query/BaseQuery.php index 2ed53cc2..73876485 100644 --- a/src/Repository/Query/BaseQuery.php +++ b/src/Repository/Query/BaseQuery.php @@ -193,7 +193,7 @@ class BaseQuery */ public function setOrder($order) { - if (in_array($order, [self::ORDER_ASC, self::ORDER_DESC])) { + if (\in_array($order, [self::ORDER_ASC, self::ORDER_DESC])) { $this->order = $order; } @@ -264,7 +264,7 @@ class BaseQuery { foreach ($errors as $error) { $key = $error->getOrigin()->getName(); - if (array_key_exists($key, $this->defaults)) { + if (\array_key_exists($key, $this->defaults)) { $this->set($key, $this->defaults[$key]); } } diff --git a/src/Repository/Query/CustomerFormTypeQuery.php b/src/Repository/Query/CustomerFormTypeQuery.php index 1e6ab69b..2375f796 100644 --- a/src/Repository/Query/CustomerFormTypeQuery.php +++ b/src/Repository/Query/CustomerFormTypeQuery.php @@ -27,7 +27,7 @@ final class CustomerFormTypeQuery extends BaseFormTypeQuery public function __construct($customer = null) { if (null !== $customer) { - if (!is_array($customer)) { + if (!\is_array($customer)) { $customer = [$customer]; } $this->setCustomers($customer); diff --git a/src/Repository/Query/ProjectFormTypeQuery.php b/src/Repository/Query/ProjectFormTypeQuery.php index bc69603c..f53d005f 100644 --- a/src/Repository/Query/ProjectFormTypeQuery.php +++ b/src/Repository/Query/ProjectFormTypeQuery.php @@ -30,14 +30,14 @@ final class ProjectFormTypeQuery extends BaseFormTypeQuery public function __construct($project = null, $customer = null) { if (null !== $project) { - if (!is_array($project)) { + if (!\is_array($project)) { $project = [$project]; } $this->setProjects($project); } if (null !== $customer) { - if (!is_array($customer)) { + if (!\is_array($customer)) { $customer = [$customer]; } $this->setCustomers($customer); diff --git a/src/Repository/Query/ProjectQuery.php b/src/Repository/Query/ProjectQuery.php index a6cac45d..f2e7593d 100644 --- a/src/Repository/Query/ProjectQuery.php +++ b/src/Repository/Query/ProjectQuery.php @@ -46,7 +46,7 @@ class ProjectQuery extends BaseQuery implements VisibilityInterface */ public function getCustomer() { - if (count($this->customers) > 0) { + if (\count($this->customers) > 0) { return $this->customers[0]; } diff --git a/src/Repository/Query/TimesheetQuery.php b/src/Repository/Query/TimesheetQuery.php index ac6ab7b6..0d664d6e 100644 --- a/src/Repository/Query/TimesheetQuery.php +++ b/src/Repository/Query/TimesheetQuery.php @@ -119,7 +119,7 @@ class TimesheetQuery extends ActivityQuery */ public function getActivity() { - if (count($this->activities) > 0) { + if (\count($this->activities) > 0) { return $this->activities[0]; } @@ -189,7 +189,7 @@ class TimesheetQuery extends ActivityQuery public function setState($state) { $state = (int) $state; - if (in_array($state, [self::STATE_ALL, self::STATE_RUNNING, self::STATE_STOPPED], true)) { + if (\in_array($state, [self::STATE_ALL, self::STATE_RUNNING, self::STATE_STOPPED], true)) { $this->state = $state; } @@ -211,7 +211,7 @@ class TimesheetQuery extends ActivityQuery public function setExported($exported) { $exported = (int) $exported; - if (in_array($exported, [self::STATE_ALL, self::STATE_EXPORTED, self::STATE_NOT_EXPORTED], true)) { + if (\in_array($exported, [self::STATE_ALL, self::STATE_EXPORTED, self::STATE_NOT_EXPORTED], true)) { $this->exported = $exported; } diff --git a/src/Repository/Query/VisibilityTrait.php b/src/Repository/Query/VisibilityTrait.php index 715e6282..6215c3e4 100644 --- a/src/Repository/Query/VisibilityTrait.php +++ b/src/Repository/Query/VisibilityTrait.php @@ -24,7 +24,7 @@ trait VisibilityTrait public function setVisibility($visibility) { $visibility = (int) $visibility; - if (in_array($visibility, VisibilityInterface::ALLOWED_VISIBILITY_STATES, true)) { + if (\in_array($visibility, VisibilityInterface::ALLOWED_VISIBILITY_STATES, true)) { $this->visibility = $visibility; } diff --git a/src/Repository/TimesheetInvoiceItemRepository.php b/src/Repository/TimesheetInvoiceItemRepository.php index c437424d..c14af756 100644 --- a/src/Repository/TimesheetInvoiceItemRepository.php +++ b/src/Repository/TimesheetInvoiceItemRepository.php @@ -36,7 +36,7 @@ final class TimesheetInvoiceItemRepository implements InvoiceItemRepositoryInter } /** - * @param InvoiceItemInterface[] $invoiceItems + * @param Timesheet[] $invoiceItems */ public function setExported(array $invoiceItems) { diff --git a/src/Repository/TimesheetRepository.php b/src/Repository/TimesheetRepository.php index 33dc22de..2b50a12b 100644 --- a/src/Repository/TimesheetRepository.php +++ b/src/Repository/TimesheetRepository.php @@ -185,7 +185,7 @@ class TimesheetRepository extends EntityRepository { switch ($type) { case self::STATS_QUERY_ACTIVE: - return count($this->getActiveEntries($user)); + return \count($this->getActiveEntries($user)); case self::STATS_QUERY_MONTHLY: return $this->getMonthlyStats($user, $begin, $end); @@ -524,7 +524,7 @@ class TimesheetRepository extends EntityRepository // -> all entries, including the new one must not exceed the $limit $limit = $hardLimit - 1; - if (count($activeEntries) > $limit) { + if (\count($activeEntries) > $limit) { $i = 1; foreach ($activeEntries as $activeEntry) { if ($i > $limit) { diff --git a/src/Repository/UserRepository.php b/src/Repository/UserRepository.php index 65b9d650..fdeeeef8 100644 --- a/src/Repository/UserRepository.php +++ b/src/Repository/UserRepository.php @@ -71,7 +71,7 @@ class UserRepository extends EntityRepository implements UserLoaderInterface */ public function findOneBy(array $criteria, array $orderBy = null) { - if (count($criteria) == 1 && isset($criteria['username'])) { + if (\count($criteria) == 1 && isset($criteria['username'])) { return $this->loadUserByUsername($criteria['username']); } diff --git a/src/Saml/Provider/SamlProvider.php b/src/Saml/Provider/SamlProvider.php index 50355556..92747f43 100644 --- a/src/Saml/Provider/SamlProvider.php +++ b/src/Saml/Provider/SamlProvider.php @@ -9,6 +9,7 @@ namespace App\Saml\Provider; +use App\Entity\User; use App\Repository\UserRepository; use App\Saml\SamlTokenFactory; use App\Saml\User\SamlUserFactory; @@ -46,11 +47,16 @@ final class SamlProvider implements AuthenticationProviderInterface $this->userFactory = $userFactory; } + /** + * @param SamlTokenInterface $token + * @return SamlTokenInterface + */ public function authenticate(TokenInterface $token) { $user = null; try { + /** @var User $user */ $user = $this->userProvider->loadUserByUsername($token->getUsername()); } catch (UsernameNotFoundException $e) { } diff --git a/src/Saml/User/SamlUserFactory.php b/src/Saml/User/SamlUserFactory.php index 4ab1c354..12d9ebbd 100644 --- a/src/Saml/User/SamlUserFactory.php +++ b/src/Saml/User/SamlUserFactory.php @@ -35,6 +35,10 @@ final class SamlUserFactory implements SamlUserFactoryInterface $this->groupMapping = $attributes['roles']['mapping']; } + /** + * @param SamlTokenInterface $token + * @return User + */ public function createUser(SamlTokenInterface $token) { $user = new User(); @@ -60,7 +64,7 @@ final class SamlUserFactory implements SamlUserFactoryInterface $roles = []; $samlGroups = $token->getAttribute($this->groupAttribute); foreach ($samlGroups as $groupName) { - if (array_key_exists($groupName, $groupMap)) { + if (\array_key_exists($groupName, $groupMap)) { $roles[] = $groupMap[$groupName]; } } diff --git a/src/Security/DoctrineUserProvider.php b/src/Security/DoctrineUserProvider.php index 63a187d8..a4a26ec3 100644 --- a/src/Security/DoctrineUserProvider.php +++ b/src/Security/DoctrineUserProvider.php @@ -54,7 +54,7 @@ final class DoctrineUserProvider implements UserProviderInterface public function refreshUser(SecurityUserInterface $user) { if (!$user instanceof User) { - throw new UnsupportedUserException(sprintf('Expected an instance of %s, but got "%s".', User::class, get_class($user))); + throw new UnsupportedUserException(sprintf('Expected an instance of %s, but got "%s".', User::class, \get_class($user))); } /** @var User|null $reloadedUser */ diff --git a/src/Security/RolePermissionManager.php b/src/Security/RolePermissionManager.php index a4cbd7e7..72b73a82 100644 --- a/src/Security/RolePermissionManager.php +++ b/src/Security/RolePermissionManager.php @@ -39,18 +39,18 @@ final class RolePermissionManager $isAllowed = $item['allowed']; // see permissions.html.twig for this special case - if ($role === User::ROLE_SUPER_ADMIN && in_array($perm, ['role_permissions', 'view_user'])) { + if ($role === User::ROLE_SUPER_ADMIN && \in_array($perm, ['role_permissions', 'view_user'])) { continue; } if (!$isAllowed) { - if (array_key_exists($role, $this->permissions)) { + if (\array_key_exists($role, $this->permissions)) { if (($key = array_search($perm, $this->permissions[$role])) !== false) { unset($this->permissions[$role][$key]); } } } else { - if (!array_key_exists($role, $this->permissions)) { + if (!\array_key_exists($role, $this->permissions)) { $this->permissions[$role] = []; } $this->permissions[$role][] = $perm; @@ -66,7 +66,7 @@ final class RolePermissionManager */ public function isRegisteredPermission(string $permission): bool { - return in_array($permission, $this->knownPermissions); + return \in_array($permission, $this->knownPermissions); } public function hasPermission(string $role, string $permission): bool @@ -77,7 +77,7 @@ final class RolePermissionManager return false; } - return in_array($permission, $this->permissions[$role]); + return \in_array($permission, $this->permissions[$role]); } /** diff --git a/src/Security/RoleService.php b/src/Security/RoleService.php index 2995ce57..37ae899a 100644 --- a/src/Security/RoleService.php +++ b/src/Security/RoleService.php @@ -39,7 +39,7 @@ final class RoleService $roles = []; foreach ($this->roles as $key => $value) { $roles[] = $key; - if (is_array($value)) { + if (\is_array($value)) { foreach ($value as $name) { $roles[] = $name; } diff --git a/src/Timesheet/Calculator/RateCalculator.php b/src/Timesheet/Calculator/RateCalculator.php index e7a5aa3b..fb64754c 100644 --- a/src/Timesheet/Calculator/RateCalculator.php +++ b/src/Timesheet/Calculator/RateCalculator.php @@ -144,7 +144,7 @@ class RateCalculator implements CalculatorInterface foreach ($this->rates as $rateFactor) { $weekday = $record->getEnd()->format('l'); $days = array_map('strtolower', $rateFactor['days']); - if (in_array(strtolower($weekday), $days)) { + if (\in_array(strtolower($weekday), $days)) { $factor += $rateFactor['factor']; } } diff --git a/src/Timesheet/RoundingService.php b/src/Timesheet/RoundingService.php index 078ba749..d658342c 100644 --- a/src/Timesheet/RoundingService.php +++ b/src/Timesheet/RoundingService.php @@ -48,7 +48,7 @@ final class RoundingService { if (empty($this->rulesCache)) { $this->rulesCache = $this->rules; - if (empty($this->rulesCache) || array_key_exists('default', $this->rulesCache)) { + if (empty($this->rulesCache) || \array_key_exists('default', $this->rulesCache)) { $this->rulesCache['default']['days'] = $this->configuration->getDefaultRoundingDays(); $this->rulesCache['default']['begin'] = $this->configuration->getDefaultRoundingBegin(); $this->rulesCache['default']['end'] = $this->configuration->getDefaultRoundingEnd(); @@ -73,7 +73,7 @@ final class RoundingService foreach ($this->getRoundingRules() as $rounding) { $weekday = $record->getBegin()->format('l'); - if (in_array(strtolower($weekday), $rounding['days'])) { + if (\in_array(strtolower($weekday), $rounding['days'])) { $rounder = $this->getRoundingMode($rounding['mode']); $rounder->roundBegin($record, $rounding['begin']); } @@ -85,7 +85,7 @@ final class RoundingService foreach ($this->getRoundingRules() as $rounding) { $weekday = $record->getEnd()->format('l'); - if (in_array(strtolower($weekday), $rounding['days'])) { + if (\in_array(strtolower($weekday), $rounding['days'])) { $rounder = $this->getRoundingMode($rounding['mode']); $rounder->roundEnd($record, $rounding['end']); } @@ -97,7 +97,7 @@ final class RoundingService foreach ($this->getRoundingRules() as $rounding) { $weekday = $record->getEnd()->format('l'); - if (in_array(strtolower($weekday), $rounding['days'])) { + if (\in_array(strtolower($weekday), $rounding['days'])) { $rounder = $this->getRoundingMode($rounding['mode']); $rounder->roundDuration($record, $rounding['duration']); } @@ -113,7 +113,7 @@ final class RoundingService foreach ($this->getRoundingRules() as $rounding) { $weekday = $record->getEnd()->format('l'); - if (in_array(strtolower($weekday), $rounding['days'])) { + if (\in_array(strtolower($weekday), $rounding['days'])) { $rounder = $this->getRoundingMode($rounding['mode']); $rounder->roundBegin($record, $rounding['begin']); $rounder->roundEnd($record, $rounding['end']); diff --git a/src/Twig/DatatableExtensions.php b/src/Twig/DatatableExtensions.php index 2a2a29e8..4ad8077c 100644 --- a/src/Twig/DatatableExtensions.php +++ b/src/Twig/DatatableExtensions.php @@ -86,7 +86,7 @@ class DatatableExtensions extends AbstractExtension } $values = $this->cookies[$cookie]; - if (empty($values) || !is_array($values)) { + if (empty($values) || !\is_array($values)) { return $this->checkInColumDefinition($columns, $column); } @@ -103,9 +103,9 @@ class DatatableExtensions extends AbstractExtension private function checkInColumDefinition(array $columns, string $column) { - if (array_key_exists($column, $columns)) { + if (\array_key_exists($column, $columns)) { $tmp = $columns[$column]; - if (is_array($tmp)) { + if (\is_array($tmp)) { $tmp = $tmp['class']; } foreach (explode(' ', $tmp) as $class) { diff --git a/src/Twig/Extensions.php b/src/Twig/Extensions.php index 080e9f7c..46bf2028 100644 --- a/src/Twig/Extensions.php +++ b/src/Twig/Extensions.php @@ -92,11 +92,11 @@ class Extensions extends AbstractExtension */ public function getClassName($object) { - if (!is_object($object)) { + if (!\is_object($object)) { return null; } - return get_class($object); + return \get_class($object); } public function multilineIndent(?string $string, string $indent): string @@ -106,7 +106,7 @@ class Extensions extends AbstractExtension } $parts = explode("\r\n", $string); - if (count($parts) === 1) { + if (\count($parts) === 1) { $parts = explode("\n", $string); } diff --git a/src/Twig/MarkdownExtension.php b/src/Twig/MarkdownExtension.php index 7100b8f8..05e3790f 100644 --- a/src/Twig/MarkdownExtension.php +++ b/src/Twig/MarkdownExtension.php @@ -62,7 +62,7 @@ final class MarkdownExtension extends AbstractExtension return ''; } - if (!$fullLength && strlen($content) > 101) { + if (!$fullLength && \strlen($content) > 101) { $content = trim(substr($content, 0, 100)) . ' …'; } diff --git a/src/Twig/PaginationExtension.php b/src/Twig/PaginationExtension.php index ad909b10..879cd0dd 100644 --- a/src/Twig/PaginationExtension.php +++ b/src/Twig/PaginationExtension.php @@ -53,7 +53,7 @@ class PaginationExtension extends AbstractExtension { @trigger_error('Twig function pagerfanta() is deprecated and will be removed with 2.0, use pagination() instead', E_USER_DEPRECATED); - if (is_array($viewName)) { + if (\is_array($viewName)) { $options = $viewName; } diff --git a/src/Twig/WidgetExtension.php b/src/Twig/WidgetExtension.php index b6425948..c6d3b3dd 100644 --- a/src/Twig/WidgetExtension.php +++ b/src/Twig/WidgetExtension.php @@ -46,11 +46,11 @@ class WidgetExtension extends AbstractExtension */ public function renderWidget($widget, array $options = []) { - if (!($widget instanceof WidgetInterface) && !is_string($widget)) { + if (!($widget instanceof WidgetInterface) && !\is_string($widget)) { throw new InvalidArgumentException('Widget must either implement WidgetInterface or be a string'); } - if (is_string($widget)) { + if (\is_string($widget)) { if (!$this->service->hasWidget($widget)) { throw new InvalidArgumentException(sprintf('Unknown widget "%s" requested', $widget)); } diff --git a/src/Utils/AvatarService.php b/src/Utils/AvatarService.php index e54e8bbf..78a5b27e 100644 --- a/src/Utils/AvatarService.php +++ b/src/Utils/AvatarService.php @@ -129,7 +129,7 @@ class AvatarService $filePath = $this->getImagePath($profile); if ($regenerate || !file_exists($filePath)) { - if (!is_writable(dirname($filePath))) { + if (!is_writable(\dirname($filePath))) { return false; } $avatar = new Avatar(self::AVATAR_CONFIG); @@ -154,6 +154,6 @@ class AvatarService public function hasDependencies(): bool { - return extension_loaded('gd') && function_exists('imagettfbbox'); + return \extension_loaded('gd') && \function_exists('imagettfbbox'); } } diff --git a/src/Utils/Duration.php b/src/Utils/Duration.php index 3aa7bebb..f031dc53 100644 --- a/src/Utils/Duration.php +++ b/src/Utils/Duration.php @@ -122,14 +122,14 @@ class Duration protected function parseColonFormat(string $duration): int { $parts = explode(':', $duration); - if (count($parts) < 2 || count($parts) > 3) { + if (\count($parts) < 2 || \count($parts) > 3) { throw new \InvalidArgumentException( sprintf('Invalid colon format given in "%s"', $duration) ); } foreach ($parts as $part) { - if (strlen($part) === 0) { + if (\strlen($part) === 0) { throw new \InvalidArgumentException( sprintf('Colon format cannot parse "%s"', $duration) ); @@ -143,7 +143,7 @@ class Duration $seconds = 0; - if (3 == count($parts)) { + if (3 == \count($parts)) { $seconds += (int) array_pop($parts); } diff --git a/src/Utils/MPdfConverter.php b/src/Utils/MPdfConverter.php index e0c9bc8e..91e22bde 100644 --- a/src/Utils/MPdfConverter.php +++ b/src/Utils/MPdfConverter.php @@ -37,15 +37,15 @@ class MPdfConverter implements HtmlToPdfConverter // some OS do not follow the PHP default settings if ((int) ini_get('pcre.backtrack_limit') < 1000000) { - @ini_set('pcre.backtrack_limit', 1000000); + @ini_set('pcre.backtrack_limit', '1000000'); } // reduce the size of content parts that are passed to MPDF, to prevent // https://mpdf.github.io/troubleshooting/known-issues.html#blank-pages-or-some-sections-missing $parts = explode('', $html); - for ($i = 0; $i < count($parts); $i++) { + for ($i = 0; $i < \count($parts); $i++) { $mpdf->WriteHTML($parts[$i]); - if ($i < count($parts) - 1) { + if ($i < \count($parts) - 1) { $mpdf->WriteHTML(''); } } diff --git a/src/Utils/MenuItemModel.php b/src/Utils/MenuItemModel.php index 192f3cb2..681fa22d 100644 --- a/src/Utils/MenuItemModel.php +++ b/src/Utils/MenuItemModel.php @@ -31,6 +31,6 @@ class MenuItemModel extends BaseMenuItemModel public function isChildRoute(string $route): bool { - return in_array($route, $this->childRoutes); + return \in_array($route, $this->childRoutes); } } diff --git a/src/Utils/ParsedownExtension.php b/src/Utils/ParsedownExtension.php index 6ecc8d5a..0c54b78f 100644 --- a/src/Utils/ParsedownExtension.php +++ b/src/Utils/ParsedownExtension.php @@ -52,7 +52,7 @@ class ParsedownExtension extends \Parsedown $url = $matches[0][0]; $Inline = [ - 'extent' => strlen($matches[0][0]), + 'extent' => \strlen($matches[0][0]), 'position' => $matches[0][1], 'element' => [ 'name' => 'a', diff --git a/src/Utils/SearchTerm.php b/src/Utils/SearchTerm.php index 5ff5adcf..63f7c4f1 100644 --- a/src/Utils/SearchTerm.php +++ b/src/Utils/SearchTerm.php @@ -38,7 +38,7 @@ final class SearchTerm foreach ($terms as $term) { $tmp = explode(':', $term); - if (count($tmp) === 2) { + if (\count($tmp) === 2) { $fields[$tmp[0]] = $tmp[1]; } else { $finalTerm[] = $term; @@ -51,7 +51,7 @@ final class SearchTerm public function hasSearchField(string $name): bool { - return array_key_exists($name, $this->fields); + return \array_key_exists($name, $this->fields); } public function getSearchField(string $name): ?string diff --git a/src/Validator/Constraints/ProjectValidator.php b/src/Validator/Constraints/ProjectValidator.php index 23b873e1..418106ee 100644 --- a/src/Validator/Constraints/ProjectValidator.php +++ b/src/Validator/Constraints/ProjectValidator.php @@ -28,7 +28,7 @@ class ProjectValidator extends ConstraintValidator throw new UnexpectedTypeException($constraint, __NAMESPACE__ . '\Project'); } - if (!is_object($value) || !($value instanceof Project)) { + if (!\is_object($value) || !($value instanceof Project)) { return; } diff --git a/src/Validator/Constraints/RoleValidator.php b/src/Validator/Constraints/RoleValidator.php index c1a45383..1a8c5cb6 100644 --- a/src/Validator/Constraints/RoleValidator.php +++ b/src/Validator/Constraints/RoleValidator.php @@ -37,7 +37,7 @@ class RoleValidator extends ConstraintValidator $roles = $value; - if (!is_array($roles)) { + if (!\is_array($roles)) { $roles = [$roles]; } @@ -45,7 +45,7 @@ class RoleValidator extends ConstraintValidator $allowedRoles = array_map('strtoupper', $this->service->getAvailableNames()); foreach ($roles as $role) { - if (!is_string($role) || !in_array($role, $allowedRoles)) { + if (!\is_string($role) || !\in_array($role, $allowedRoles)) { $this->context->buildViolation($constraint->message) ->setParameter('{{ value }}', $this->formatValue($role)) ->setCode(Role::ROLE_ERROR) diff --git a/src/Validator/Constraints/TimesheetMultiUpdateValidator.php b/src/Validator/Constraints/TimesheetMultiUpdateValidator.php index f21a1a0f..a0c77890 100644 --- a/src/Validator/Constraints/TimesheetMultiUpdateValidator.php +++ b/src/Validator/Constraints/TimesheetMultiUpdateValidator.php @@ -28,7 +28,7 @@ final class TimesheetMultiUpdateValidator extends ConstraintValidator throw new UnexpectedTypeException($constraint, __NAMESPACE__ . '\TimesheetMultiUpdate'); } - if (!is_object($value) || !($value instanceof TimesheetMultiUpdateDTO)) { + if (!\is_object($value) || !($value instanceof TimesheetMultiUpdateDTO)) { return; } diff --git a/src/Validator/Constraints/TimesheetValidator.php b/src/Validator/Constraints/TimesheetValidator.php index d5c811c2..b30af822 100644 --- a/src/Validator/Constraints/TimesheetValidator.php +++ b/src/Validator/Constraints/TimesheetValidator.php @@ -55,7 +55,7 @@ class TimesheetValidator extends ConstraintValidator throw new UnexpectedTypeException($constraint, __NAMESPACE__ . '\Timesheet'); } - if (!is_object($value) || !($value instanceof TimesheetEntity)) { + if (!\is_object($value) || !($value instanceof TimesheetEntity)) { return; } diff --git a/src/Voter/ActivityVoter.php b/src/Voter/ActivityVoter.php index 267eac31..9d9b363e 100644 --- a/src/Voter/ActivityVoter.php +++ b/src/Voter/ActivityVoter.php @@ -45,7 +45,7 @@ class ActivityVoter extends AbstractVoter return false; } - if (!in_array($attribute, self::ALLOWED_ATTRIBUTES)) { + if (!\in_array($attribute, self::ALLOWED_ATTRIBUTES)) { return false; } diff --git a/src/Voter/CustomerVoter.php b/src/Voter/CustomerVoter.php index 2e707027..948f3d8b 100644 --- a/src/Voter/CustomerVoter.php +++ b/src/Voter/CustomerVoter.php @@ -45,7 +45,7 @@ class CustomerVoter extends AbstractVoter return false; } - if (!in_array($attribute, self::ALLOWED_ATTRIBUTES)) { + if (!\in_array($attribute, self::ALLOWED_ATTRIBUTES)) { return false; } @@ -71,7 +71,7 @@ class CustomerVoter extends AbstractVoter } // those cannot be assigned to teams - if (in_array($attribute, ['create', 'delete'])) { + if (\in_array($attribute, ['create', 'delete'])) { return false; } diff --git a/src/Voter/ProjectVoter.php b/src/Voter/ProjectVoter.php index b3fc676d..0eb4db53 100644 --- a/src/Voter/ProjectVoter.php +++ b/src/Voter/ProjectVoter.php @@ -44,7 +44,7 @@ class ProjectVoter extends AbstractVoter return false; } - if (!in_array($attribute, self::ALLOWED_ATTRIBUTES)) { + if (!\in_array($attribute, self::ALLOWED_ATTRIBUTES)) { return false; } @@ -70,7 +70,7 @@ class ProjectVoter extends AbstractVoter } // those cannot be assigned to teams - if (in_array($attribute, ['create', 'delete'])) { + if (\in_array($attribute, ['create', 'delete'])) { return false; } diff --git a/src/Voter/TeamVoter.php b/src/Voter/TeamVoter.php index e0c12c2c..7d21c735 100644 --- a/src/Voter/TeamVoter.php +++ b/src/Voter/TeamVoter.php @@ -35,7 +35,7 @@ class TeamVoter extends AbstractVoter return false; } - if (!in_array($attribute, self::ALLOWED_ATTRIBUTES)) { + if (!\in_array($attribute, self::ALLOWED_ATTRIBUTES)) { return false; } diff --git a/src/Voter/TimesheetVoter.php b/src/Voter/TimesheetVoter.php index 4cf503bd..8ea790a0 100644 --- a/src/Voter/TimesheetVoter.php +++ b/src/Voter/TimesheetVoter.php @@ -55,7 +55,7 @@ class TimesheetVoter extends AbstractVoter return false; } - if (!in_array($attribute, self::ALLOWED_ATTRIBUTES)) { + if (!\in_array($attribute, self::ALLOWED_ATTRIBUTES)) { return false; } diff --git a/src/Voter/UserVoter.php b/src/Voter/UserVoter.php index 596d24dc..218fb051 100644 --- a/src/Voter/UserVoter.php +++ b/src/Voter/UserVoter.php @@ -40,7 +40,7 @@ class UserVoter extends AbstractVoter return false; } - if (!in_array($attribute, self::ALLOWED_ATTRIBUTES)) { + if (!\in_array($attribute, self::ALLOWED_ATTRIBUTES)) { return false; } diff --git a/src/Widget/Type/AbstractWidgetType.php b/src/Widget/Type/AbstractWidgetType.php index 2b8fdc14..07970b3f 100644 --- a/src/Widget/Type/AbstractWidgetType.php +++ b/src/Widget/Type/AbstractWidgetType.php @@ -95,7 +95,7 @@ abstract class AbstractWidgetType implements WidgetInterface */ public function getOption(string $name, $default = null) { - if (array_key_exists($name, $this->options)) { + if (\array_key_exists($name, $this->options)) { return $this->options[$name]; } diff --git a/src/Widget/Type/DailyWorkingTimeChart.php b/src/Widget/Type/DailyWorkingTimeChart.php index f90ed3bf..8efb8414 100644 --- a/src/Widget/Type/DailyWorkingTimeChart.php +++ b/src/Widget/Type/DailyWorkingTimeChart.php @@ -47,7 +47,7 @@ class DailyWorkingTimeChart extends SimpleWidget { $options = parent::getOptions($options); - if (!in_array($options['type'], ['bar', 'line'])) { + if (!\in_array($options['type'], ['bar', 'line'])) { $options['type'] = self::DEFAULT_CHART; } diff --git a/src/Widget/Type/PaginatedWorkingTimeChart.php b/src/Widget/Type/PaginatedWorkingTimeChart.php index 1d536026..3ee5c658 100644 --- a/src/Widget/Type/PaginatedWorkingTimeChart.php +++ b/src/Widget/Type/PaginatedWorkingTimeChart.php @@ -44,7 +44,7 @@ final class PaginatedWorkingTimeChart extends SimpleWidget { $options = parent::getOptions($options); - if (!in_array($options['type'], ['bar', 'line'])) { + if (!\in_array($options['type'], ['bar', 'line'])) { $options['type'] = 'bar'; } diff --git a/src/Widget/WidgetService.php b/src/Widget/WidgetService.php index 4d999f13..7477b8a4 100644 --- a/src/Widget/WidgetService.php +++ b/src/Widget/WidgetService.php @@ -68,7 +68,7 @@ class WidgetService } } - throw new WidgetException(sprintf('No renderer available for widget "%s"', get_class($widget))); + throw new WidgetException(sprintf('No renderer available for widget "%s"', \get_class($widget))); } /** diff --git a/tests/API/ActivityControllerTest.php b/tests/API/ActivityControllerTest.php index 661d616f..88565c2d 100644 --- a/tests/API/ActivityControllerTest.php +++ b/tests/API/ActivityControllerTest.php @@ -28,7 +28,7 @@ class ActivityControllerTest extends APIControllerBaseTest { use RateControllerTestTrait; - protected function getRateUrl(string $id = '1', ?string $rateId = null): string + protected function getRateUrl($id = '1', $rateId = null): string { if (null !== $rateId) { return sprintf('/api/activities/%s/rates/%s', $id, $rateId); @@ -37,7 +37,7 @@ class ActivityControllerTest extends APIControllerBaseTest return sprintf('/api/activities/%s/rates', $id); } - protected function importTestRates(string $id): array + protected function importTestRates($id): array { /** @var ActivityRateRepository $rateRepository */ $rateRepository = $this->getEntityManager()->getRepository(ActivityRate::class); @@ -123,8 +123,8 @@ class ActivityControllerTest extends APIControllerBaseTest $this->assertIsArray($result); $this->assertNotEmpty($result); - $this->assertEquals(count($expected), count($result)); - for ($i = 0; $i < count($result); $i++) { + $this->assertEquals(\count($expected), \count($result)); + for ($i = 0; $i < \count($result); $i++) { $activity = $result[$i]; $hasProject = $expected[$i][0]; $this->assertStructure($activity, false); @@ -160,7 +160,7 @@ class ActivityControllerTest extends APIControllerBaseTest $this->assertIsArray($result); $this->assertNotEmpty($result); - $this->assertEquals(5, count($result)); + $this->assertEquals(5, \count($result)); $this->assertStructure($result[0], false); $this->assertEquals(1, $result[4]['project']); $this->assertEquals(2, $result[3]['project']); diff --git a/tests/API/ConfigurationControllerTest.php b/tests/API/ConfigurationControllerTest.php index 9c5bf613..55a05171 100644 --- a/tests/API/ConfigurationControllerTest.php +++ b/tests/API/ConfigurationControllerTest.php @@ -29,7 +29,7 @@ class ConfigurationControllerTest extends APIControllerBaseTest $this->assertIsArray($result); $this->assertNotEmpty($result); - $this->assertEquals(7, count($result)); + $this->assertEquals(7, \count($result)); $this->assertI18nStructure($result); } @@ -56,7 +56,7 @@ class ConfigurationControllerTest extends APIControllerBaseTest $this->assertIsArray($result); $this->assertNotEmpty($result); - $this->assertEquals(5, count($result)); + $this->assertEquals(5, \count($result)); $this->assertTimesheetStructure($result); } diff --git a/tests/API/CustomerControllerTest.php b/tests/API/CustomerControllerTest.php index d97f9c51..c52bfd05 100644 --- a/tests/API/CustomerControllerTest.php +++ b/tests/API/CustomerControllerTest.php @@ -25,7 +25,7 @@ class CustomerControllerTest extends APIControllerBaseTest { use RateControllerTestTrait; - protected function getRateUrl(string $id = '1', ?string $rateId = null): string + protected function getRateUrl($id = '1', $rateId = null): string { if (null !== $rateId) { return sprintf('/api/customers/%s/rates/%s', $id, $rateId); @@ -34,7 +34,7 @@ class CustomerControllerTest extends APIControllerBaseTest return sprintf('/api/customers/%s/rates', $id); } - protected function importTestRates(string $id): array + protected function importTestRates($id): array { /** @var CustomerRateRepository $rateRepository */ $rateRepository = $this->getEntityManager()->getRepository(CustomerRate::class); @@ -83,7 +83,7 @@ class CustomerControllerTest extends APIControllerBaseTest $this->assertIsArray($result); $this->assertNotEmpty($result); - $this->assertEquals(1, count($result)); + $this->assertEquals(1, \count($result)); $this->assertStructure($result[0], false); } @@ -96,7 +96,7 @@ class CustomerControllerTest extends APIControllerBaseTest $this->assertIsArray($result); $this->assertNotEmpty($result); - $this->assertEquals(1, count($result)); + $this->assertEquals(1, \count($result)); $this->assertStructure($result[0], false); } diff --git a/tests/API/ProjectControllerTest.php b/tests/API/ProjectControllerTest.php index f3473fc7..b7d76601 100644 --- a/tests/API/ProjectControllerTest.php +++ b/tests/API/ProjectControllerTest.php @@ -28,7 +28,7 @@ class ProjectControllerTest extends APIControllerBaseTest { use RateControllerTestTrait; - protected function getRateUrl(string $id = '1', ?string $rateId = null): string + protected function getRateUrl($id = '1', $rateId = null): string { if (null !== $rateId) { return sprintf('/api/projects/%s/rates/%s', $id, $rateId); @@ -37,7 +37,7 @@ class ProjectControllerTest extends APIControllerBaseTest return sprintf('/api/projects/%s/rates', $id); } - protected function importTestRates(string $id): array + protected function importTestRates($id): array { /** @var ProjectRateRepository $rateRepository */ $rateRepository = $this->getEntityManager()->getRepository(ProjectRate::class); @@ -85,7 +85,7 @@ class ProjectControllerTest extends APIControllerBaseTest $this->assertIsArray($result); $this->assertNotEmpty($result); - $this->assertEquals(1, count($result)); + $this->assertEquals(1, \count($result)); $this->assertStructure($result[0], false); } @@ -133,9 +133,9 @@ class ProjectControllerTest extends APIControllerBaseTest $result = json_decode($client->getResponse()->getContent(), true); $this->assertIsArray($result); - $this->assertEquals(count($expected), count($result), 'Found wrong amount of projects'); + $this->assertEquals(\count($expected), \count($result), 'Found wrong amount of projects'); - for ($i = 0; $i < count($expected); $i++) { + for ($i = 0; $i < \count($expected); $i++) { $project = $result[$i]; $compare = $expected[$i]; $this->assertStructure($project, false); diff --git a/tests/API/RateControllerTestTrait.php b/tests/API/RateControllerTestTrait.php index 1efab167..ba509464 100644 --- a/tests/API/RateControllerTestTrait.php +++ b/tests/API/RateControllerTestTrait.php @@ -17,9 +17,18 @@ use Symfony\Component\HttpFoundation\Response; */ trait RateControllerTestTrait { - abstract protected function getRateUrl(string $id = '1', ?string $rateId = null): string; + /** + * @param string|int $id + * @param string|int|null $rateId + * @return string + */ + abstract protected function getRateUrl($id = '1', $rateId = null): string; - abstract protected function importTestRates(string $id): array; + /** + * @param string|int $id + * @return array + */ + abstract protected function importTestRates($id): array; public function testAddRateMissingEntityAction() { @@ -129,7 +138,7 @@ trait RateControllerTestTrait $result = json_decode($client->getResponse()->getContent(), true); $this->assertIsArray($result); $this->assertNotEmpty($result); - $this->assertEquals(count($expectedRates), count($result)); + $this->assertEquals(\count($expectedRates), \count($result)); foreach ($result as $rate) { $this->assertRateStructure($rate, ($rate['user'] === null ? null : $rate['user']['id'])); @@ -161,7 +170,7 @@ trait RateControllerTestTrait $result = json_decode($client->getResponse()->getContent(), true); $this->assertIsArray($result); - $this->assertEquals(count($expectedRates) - 1, count($result)); + $this->assertEquals(\count($expectedRates) - 1, \count($result)); } public function testDeleteRateEntityNotFound() diff --git a/tests/API/TagControllerTest.php b/tests/API/TagControllerTest.php index cfa3fdc6..53375503 100644 --- a/tests/API/TagControllerTest.php +++ b/tests/API/TagControllerTest.php @@ -26,7 +26,7 @@ class TagControllerTest extends APIControllerBaseTest $fixture = new TagFixtures(); $fixture->setTagArray($tagList); - $this->importFixture($client, $fixture); + $this->importFixture($fixture); } public function testIsSecure() @@ -43,7 +43,7 @@ class TagControllerTest extends APIControllerBaseTest $this->assertIsArray($result); $this->assertNotEmpty($result); - $this->assertEquals(10, count($result)); + $this->assertEquals(10, \count($result)); $this->assertEquals('Test', $result[9]); } @@ -57,7 +57,7 @@ class TagControllerTest extends APIControllerBaseTest $this->assertIsArray($result); $this->assertEmpty($result); - $this->assertEquals(0, count($result)); + $this->assertEquals(0, \count($result)); } public function testPostAction() @@ -101,7 +101,7 @@ class TagControllerTest extends APIControllerBaseTest $this->assertIsArray($result); $this->assertNotEmpty($result); - $this->assertEquals(3, count($result)); + $this->assertEquals(3, \count($result)); $this->assertEquals('Administration', $result[0]); $this->assertEquals('Bug Fixing', $result[1]); @@ -121,7 +121,7 @@ class TagControllerTest extends APIControllerBaseTest $this->assertAccessIsGranted($client, '/api/tags'); $result = json_decode($client->getResponse()->getContent(), true); - $this->assertEquals(9, count($result)); + $this->assertEquals(9, \count($result)); } public function testDeleteActionWithUnknownTimesheet() diff --git a/tests/API/TeamControllerTest.php b/tests/API/TeamControllerTest.php index 0a8b35ba..7a7ed005 100644 --- a/tests/API/TeamControllerTest.php +++ b/tests/API/TeamControllerTest.php @@ -25,7 +25,7 @@ class TeamControllerTest extends APIControllerBaseTest { $fixture = new TeamFixtures(); $fixture->setAmount(1); - $this->importFixture($client, $fixture); + $this->importFixture($fixture); } public function testIsSecure() @@ -58,7 +58,7 @@ class TeamControllerTest extends APIControllerBaseTest $this->assertIsArray($result); $this->assertNotEmpty($result); - self::assertEquals(2, count($result)); + self::assertEquals(2, \count($result)); $this->assertStructure($result[0], false); } diff --git a/tests/API/TimesheetControllerTest.php b/tests/API/TimesheetControllerTest.php index e8186280..3578b508 100644 --- a/tests/API/TimesheetControllerTest.php +++ b/tests/API/TimesheetControllerTest.php @@ -32,18 +32,16 @@ class TimesheetControllerTest extends APIControllerBaseTest protected function importFixtureForUser(string $role) { - $em = $this->getEntityManager(); - $fixture = new TimesheetFixtures(); $fixture ->setFixedRate(true) ->setHourlyRate(true) ->setAmount(10) - ->setUser($this->getUserByRole($em, $role)) + ->setUser($this->getUserByRole($role)) ->setStartDate((new \DateTime('first day of this month'))->setTime(0, 0, 1)) ->setAllowEmptyDescriptions(false) ; - $this->importFixture($this, $fixture); + $this->importFixture($fixture); } public function testIsSecure() @@ -60,7 +58,7 @@ class TimesheetControllerTest extends APIControllerBaseTest $this->assertIsArray($result); $this->assertNotEmpty($result); - $this->assertEquals(10, count($result)); + $this->assertEquals(10, \count($result)); $this->assertDefaultStructure($result[0], false); } @@ -73,7 +71,7 @@ class TimesheetControllerTest extends APIControllerBaseTest $this->assertIsArray($result); $this->assertNotEmpty($result); - $this->assertEquals(10, count($result)); + $this->assertEquals(10, \count($result)); $this->assertDefaultStructure($result[0], false); $this->assertHasSubresources($result[0]); } @@ -89,10 +87,10 @@ class TimesheetControllerTest extends APIControllerBaseTest ->setFixedRate(true) ->setHourlyRate(true) ->setAmount(7) - ->setUser($this->getUserByRole($em, User::ROLE_ADMIN)) + ->setUser($this->getUserByRole(User::ROLE_ADMIN)) ->setStartDate(new \DateTime('-10 days')) ; - $this->importFixture($em, $fixture); + $this->importFixture($fixture); $query = ['user' => 2]; $this->assertAccessIsGranted($client, '/api/timesheets', 'GET', $query); @@ -100,7 +98,7 @@ class TimesheetControllerTest extends APIControllerBaseTest $this->assertIsArray($result); $this->assertNotEmpty($result); - $this->assertEquals(10, count($result)); + $this->assertEquals(10, \count($result)); $this->assertDefaultStructure($result[0], false); } @@ -115,10 +113,10 @@ class TimesheetControllerTest extends APIControllerBaseTest ->setFixedRate(true) ->setHourlyRate(true) ->setAmount(7) - ->setUser($this->getUserByRole($em, User::ROLE_ADMIN)) + ->setUser($this->getUserByRole(User::ROLE_ADMIN)) ->setStartDate(new \DateTime('-10 days')) ; - $this->importFixture($em, $fixture); + $this->importFixture($fixture); $query = ['user' => 'all']; $this->assertAccessIsGranted($client, '/api/timesheets', 'GET', $query); @@ -126,7 +124,7 @@ class TimesheetControllerTest extends APIControllerBaseTest $this->assertIsArray($result); $this->assertNotEmpty($result); - $this->assertEquals(17, count($result)); + $this->assertEquals(17, \count($result)); $this->assertDefaultStructure($result[0], false); } @@ -169,7 +167,7 @@ class TimesheetControllerTest extends APIControllerBaseTest $this->assertIsArray($result); $this->assertNotEmpty($result); - $this->assertEquals(5, count($result)); + $this->assertEquals(5, \count($result)); $this->assertDefaultStructure($result[0], false); } @@ -201,7 +199,7 @@ class TimesheetControllerTest extends APIControllerBaseTest $this->assertIsArray($result); $this->assertNotEmpty($result); - $this->assertEquals(5, count($result)); + $this->assertEquals(5, \count($result)); $this->assertDefaultStructure($result[0], false); } @@ -215,11 +213,11 @@ class TimesheetControllerTest extends APIControllerBaseTest $fixture ->setExported(true) ->setAmount(7) - ->setUser($this->getUserByRole($em, User::ROLE_USER)) + ->setUser($this->getUserByRole(User::ROLE_USER)) ->setStartDate(new \DateTime('first day of this month')) ->setAllowEmptyDescriptions(false) ; - $this->importFixture($em, $fixture); + $this->importFixture($fixture); $begin = new \DateTime('first day of this month'); $begin->setTime(0, 0, 0); @@ -239,7 +237,7 @@ class TimesheetControllerTest extends APIControllerBaseTest $this->assertIsArray($result); $this->assertNotEmpty($result); - $this->assertEquals(7, count($result)); + $this->assertEquals(7, \count($result)); $this->assertDefaultStructure($result[0], false); $query = [ @@ -255,7 +253,7 @@ class TimesheetControllerTest extends APIControllerBaseTest $this->assertIsArray($result); $this->assertNotEmpty($result); - $this->assertEquals(10, count($result)); + $this->assertEquals(10, \count($result)); $this->assertDefaultStructure($result[0], false); $query = [ @@ -269,7 +267,7 @@ class TimesheetControllerTest extends APIControllerBaseTest $this->assertIsArray($result); $this->assertNotEmpty($result); - $this->assertEquals(17, count($result)); + $this->assertEquals(17, \count($result)); $this->assertDefaultStructure($result[0], false); } @@ -424,11 +422,11 @@ class TimesheetControllerTest extends APIControllerBaseTest ->setFixedRate(true) ->setHourlyRate(true) ->setAmount(10) - ->setUser($this->getUserByRole($em, User::ROLE_TEAMLEAD)) + ->setUser($this->getUserByRole(User::ROLE_TEAMLEAD)) ->setStartDate(new \DateTime('-10 days')) ->setAllowEmptyDescriptions(false) ; - $this->importFixture($em, $fixture); + $this->importFixture($fixture); $data = [ 'activity' => 1, @@ -567,10 +565,10 @@ class TimesheetControllerTest extends APIControllerBaseTest ->setFixedRate(true) ->setHourlyRate(true) ->setAmount(10) - ->setUser($this->getUserByRole($em, User::ROLE_ADMIN)) + ->setUser($this->getUserByRole(User::ROLE_ADMIN)) ->setStartDate($start) ; - $this->importFixture($em, $fixture); + $this->importFixture($fixture); $query = [ 'user' => 'all', @@ -583,7 +581,7 @@ class TimesheetControllerTest extends APIControllerBaseTest $this->assertIsArray($result); $this->assertNotEmpty($result); - $this->assertEquals(1, count($result)); + $this->assertEquals(1, \count($result)); $this->assertDefaultStructure($result[0], false); $this->assertHasSubresources($result[0]); } @@ -600,17 +598,17 @@ class TimesheetControllerTest extends APIControllerBaseTest ->setFixedRate(true) ->setHourlyRate(true) ->setAmount(0) - ->setUser($this->getUserByRole($em, User::ROLE_USER)) + ->setUser($this->getUserByRole(User::ROLE_USER)) ->setStartDate($start) ->setAmountRunning(3) ; - $this->importFixture($em, $fixture); + $this->importFixture($fixture); $this->request($client, '/api/timesheets/active'); $this->assertTrue($client->getResponse()->isSuccessful()); $results = json_decode($client->getResponse()->getContent(), true); - $this->assertEquals(3, count($results)); + $this->assertEquals(3, \count($results)); foreach ($results as $timesheet) { $this->assertDefaultStructure($timesheet, false); } @@ -629,11 +627,11 @@ class TimesheetControllerTest extends APIControllerBaseTest ->setFixedRate(true) ->setHourlyRate(true) ->setAmount(0) - ->setUser($this->getUserByRole($em, User::ROLE_USER)) + ->setUser($this->getUserByRole(User::ROLE_USER)) ->setStartDate($start) ->setAmountRunning(1) ; - $this->importFixture($em, $fixture); + $this->importFixture($fixture); $this->request($client, '/api/timesheets/11/stop', 'PATCH'); $this->assertTrue($client->getResponse()->isSuccessful()); @@ -671,11 +669,11 @@ class TimesheetControllerTest extends APIControllerBaseTest ->setFixedRate(true) ->setHourlyRate(true) ->setAmount(2) - ->setUser($this->getUserByRole($em, User::ROLE_ADMIN)) + ->setUser($this->getUserByRole(User::ROLE_ADMIN)) ->setStartDate($start) ->setAmountRunning(3) ; - $this->importFixture($em, $fixture); + $this->importFixture($fixture); $this->request($client, '/api/timesheets/12/stop', 'PATCH'); $this->assertApiResponseAccessDenied($client->getResponse(), 'You are not allowed to stop this timesheet'); @@ -692,12 +690,12 @@ class TimesheetControllerTest extends APIControllerBaseTest ->setFixedRate(true) ->setHourlyRate(true) ->setAmount(10) - ->setUser($this->getUserByRole($em, User::ROLE_USER)) + ->setUser($this->getUserByRole(User::ROLE_USER)) ->setStartDate(new \DateTime('-10 days')) ->setAllowEmptyDescriptions(false) ->setUseTags(true) ->setTags(['Test', 'Administration']); - $this->importFixture($em, $fixture); + $this->importFixture($fixture); $query = ['tags' => 'Test']; $this->assertAccessIsGranted($client, '/api/timesheets', 'GET', $query); @@ -705,7 +703,7 @@ class TimesheetControllerTest extends APIControllerBaseTest $this->assertIsArray($result); $this->assertNotEmpty($result); - $this->assertEquals(5, count($result)); + $this->assertEquals(5, \count($result)); $this->assertDefaultStructure($result[0], false); $query = ['tags' => 'Test,Admin']; @@ -714,7 +712,7 @@ class TimesheetControllerTest extends APIControllerBaseTest $this->assertIsArray($result); $this->assertNotEmpty($result); - $this->assertEquals(10, count($result)); + $this->assertEquals(10, \count($result)); $this->assertDefaultStructure($result[0], false); $query = ['tags' => 'Nothing-2-see,here']; @@ -723,7 +721,7 @@ class TimesheetControllerTest extends APIControllerBaseTest $this->assertIsArray($result); $this->assertNotEmpty($result); - $this->assertEquals(20, count($result)); + $this->assertEquals(20, \count($result)); $this->assertDefaultStructure($result[0], false); } @@ -811,11 +809,11 @@ class TimesheetControllerTest extends APIControllerBaseTest ->setFixedRate(true) ->setHourlyRate(true) ->setAmount(2) - ->setUser($this->getUserByRole($em, User::ROLE_ADMIN)) + ->setUser($this->getUserByRole(User::ROLE_ADMIN)) ->setStartDate($start) ->setAmountRunning(3) ; - $this->importFixture($em, $fixture); + $this->importFixture($fixture); $this->request($client, '/api/timesheets/2/restart', 'PATCH'); $this->assertApiResponseAccessDenied($client->getResponse(), 'You are not allowed to re-start this timesheet'); diff --git a/tests/API/UserControllerTest.php b/tests/API/UserControllerTest.php index b8741b31..b45fd1e0 100644 --- a/tests/API/UserControllerTest.php +++ b/tests/API/UserControllerTest.php @@ -47,7 +47,7 @@ class UserControllerTest extends APIControllerBaseTest $this->assertIsArray($result); $this->assertNotEmpty($result); - $this->assertEquals(7, count($result)); + $this->assertEquals(7, \count($result)); foreach ($result as $user) { $this->assertStructure($user, false); } @@ -61,7 +61,7 @@ class UserControllerTest extends APIControllerBaseTest $this->assertIsArray($result); $this->assertNotEmpty($result); - $this->assertEquals(1, count($result)); + $this->assertEquals(1, \count($result)); foreach ($result as $user) { $this->assertStructure($user, false); } @@ -75,7 +75,7 @@ class UserControllerTest extends APIControllerBaseTest $this->assertIsArray($result); $this->assertNotEmpty($result); - $this->assertEquals(8, count($result)); + $this->assertEquals(8, \count($result)); foreach ($result as $user) { $this->assertStructure($user, false); } diff --git a/tests/Command/InvoiceCreateCommandTest.php b/tests/Command/InvoiceCreateCommandTest.php index 59a8d509..a3c61b7c 100644 --- a/tests/Command/InvoiceCreateCommandTest.php +++ b/tests/Command/InvoiceCreateCommandTest.php @@ -165,7 +165,7 @@ class InvoiceCreateCommandTest extends KernelTestCase public function testCreateInvoice() { $fixture = new InvoiceFixtures(); - $this->importFixture($this, $fixture); + $this->importFixture($fixture); $commandTester = $this->createInvoice(['--user' => UserFixtures::USERNAME_SUPER_ADMIN, '--set-exported' => null, '--customer' => 1, '--template' => 'Invoice', '--start' => '2020-01-01', '--end' => '2020-03-01']); @@ -189,22 +189,22 @@ class InvoiceCreateCommandTest extends KernelTestCase $meta->setValue('Invoice'); $customer->setMetaField($meta); }); - $this->importFixture($em, $fixture); + $this->importFixture($fixture); $fixture = new ProjectFixtures(); $fixture->setCustomers([$em->getRepository(Customer::class)->find(2)]); $fixture->setAmount(1); - $this->importFixture($em, $fixture); + $this->importFixture($fixture); $fixture = new TimesheetFixtures(); $fixture->setUser($this->getUserByName(UserFixtures::USERNAME_SUPER_ADMIN)); $fixture->setAmount(20); $fixture->setStartDate($start); $fixture->setProjects([$em->getRepository(Project::class)->find(2)]); - $this->importFixture($em, $fixture); + $this->importFixture($fixture); $fixture = new InvoiceFixtures(); - $this->importFixture($em, $fixture); + $this->importFixture($fixture); } public function testCreateInvoiceByCustomer() diff --git a/tests/Configuration/CalendarConfigurationTest.php b/tests/Configuration/CalendarConfigurationTest.php index 2363140f..0d793961 100644 --- a/tests/Configuration/CalendarConfigurationTest.php +++ b/tests/Configuration/CalendarConfigurationTest.php @@ -79,6 +79,6 @@ class CalendarConfigurationTest extends TestCase $this->assertEquals('wertwertwegsdfbdf243w567fg8ihuon', $sut->getGoogleApiKey()); $sources = $sut->getGoogleSources(); - $this->assertEquals(2, count($sources)); + $this->assertEquals(2, \count($sources)); } } diff --git a/tests/Controller/AboutControllerTest.php b/tests/Controller/AboutControllerTest.php index 0d9d89f5..d18bddb4 100644 --- a/tests/Controller/AboutControllerTest.php +++ b/tests/Controller/AboutControllerTest.php @@ -22,10 +22,10 @@ class AboutControllerTest extends ControllerBaseTest $this->assertAccessIsGranted($client, '/about'); $result = $client->getCrawler()->filter('ul.nav.nav-stacked li a'); - $this->assertEquals(4, count($result)); + $this->assertEquals(4, \count($result)); $result = $client->getCrawler()->filter('div.box-body pre'); - $this->assertEquals(1, count($result)); + $this->assertEquals(1, \count($result)); $this->assertStringContainsString('MIT License', $result->text(null, true)); } } diff --git a/tests/Controller/ActivityControllerTest.php b/tests/Controller/ActivityControllerTest.php index 04fbff05..5cae2c65 100644 --- a/tests/Controller/ActivityControllerTest.php +++ b/tests/Controller/ActivityControllerTest.php @@ -54,7 +54,7 @@ class ActivityControllerTest extends ControllerBaseTest $activity->setMetaField((new ActivityMeta())->setName('location')->setValue('homeoffice')); $activity->setMetaField((new ActivityMeta())->setName('feature')->setValue('timetracking')); }); - $this->importFixture($client, $fixture); + $this->importFixture($fixture); $this->assertAccessIsGranted($client, '/admin/activity/'); @@ -82,14 +82,14 @@ class ActivityControllerTest extends ControllerBaseTest $fixture = new TimesheetFixtures(); $fixture->setAmount(10); $fixture->setActivities($em->getRepository(Activity::class)->findAll()); - $fixture->setUser($this->getUserByRole($em, User::ROLE_ADMIN)); - $this->importFixture($client, $fixture); + $fixture->setUser($this->getUserByRole(User::ROLE_ADMIN)); + $this->importFixture($fixture); $project = $em->getRepository(Project::class)->find(1); $fixture = new ActivityFixtures(); $fixture->setAmount(6); // to trigger a second page $fixture->setProjects([$project]); - $this->importFixture($client, $fixture); + $this->importFixture($fixture); $this->assertAccessIsGranted($client, '/admin/activity/1/details'); self::assertHasProgressbar($client); @@ -165,7 +165,7 @@ class ActivityControllerTest extends ControllerBaseTest $fixture = new ProjectFixtures(); $fixture->setAmount(10); - $this->importFixture($client, $fixture); + $this->importFixture($fixture); $this->assertAccessIsGranted($client, '/admin/activity/create'); $form = $client->getCrawler()->filter('form[name=activity_edit_form]')->form(); @@ -262,12 +262,12 @@ class ActivityControllerTest extends ControllerBaseTest $em = $this->getEntityManager(); $fixture = new TimesheetFixtures(); - $fixture->setUser($this->getUserByRole($em, User::ROLE_USER)); + $fixture->setUser($this->getUserByRole(User::ROLE_USER)); $fixture->setAmount(10); - $this->importFixture($client, $fixture); + $this->importFixture($fixture); $timesheets = $em->getRepository(Timesheet::class)->findAll(); - $this->assertEquals(10, count($timesheets)); + $this->assertEquals(10, \count($timesheets)); /** @var Timesheet $entry */ foreach ($timesheets as $entry) { @@ -303,15 +303,15 @@ class ActivityControllerTest extends ControllerBaseTest $em = $this->getEntityManager(); $fixture = new TimesheetFixtures(); - $fixture->setUser($this->getUserByRole($em, User::ROLE_USER)); + $fixture->setUser($this->getUserByRole(User::ROLE_USER)); $fixture->setAmount(10); - $this->importFixture($client, $fixture); + $this->importFixture($fixture); $fixture = new ActivityFixtures(); $fixture->setAmount(1)->setIsGlobal(true)->setIsVisible(true); - $this->importFixture($client, $fixture); + $this->importFixture($fixture); $timesheets = $em->getRepository(Timesheet::class)->findAll(); - $this->assertEquals(10, count($timesheets)); + $this->assertEquals(10, \count($timesheets)); /** @var Timesheet $entry */ foreach ($timesheets as $entry) { @@ -335,7 +335,7 @@ class ActivityControllerTest extends ControllerBaseTest $this->assertHasFlashSuccess($client); $timesheets = $em->getRepository(Timesheet::class)->findAll(); - $this->assertEquals(10, count($timesheets)); + $this->assertEquals(10, \count($timesheets)); /** @var Timesheet $entry */ foreach ($timesheets as $entry) { diff --git a/tests/Controller/ControllerBaseTest.php b/tests/Controller/ControllerBaseTest.php index 3848af4b..4a2e0b01 100644 --- a/tests/Controller/ControllerBaseTest.php +++ b/tests/Controller/ControllerBaseTest.php @@ -214,7 +214,7 @@ abstract class ControllerBaseTest extends WebTestCase self::assertEquals($expectedUrl, $element->getAttribute('href')); } - self::assertEquals(count($buttons), $node->count(), 'Invalid amount of page actions'); + self::assertEquals(\count($buttons), $node->count(), 'Invalid amount of page actions'); } /** @@ -239,9 +239,9 @@ abstract class ControllerBaseTest extends WebTestCase $validationErrors = $submittedForm->filter('li.text-danger'); self::assertEquals( - count($fieldNames), - count($validationErrors), - sprintf('Expected %s validation errors, found %s', count($fieldNames), count($validationErrors)) + \count($fieldNames), + \count($validationErrors), + sprintf('Expected %s validation errors, found %s', \count($fieldNames), \count($validationErrors)) ); foreach ($fieldNames as $name) { @@ -251,7 +251,7 @@ abstract class ControllerBaseTest extends WebTestCase self::assertNotNull($list, 'Form field has no validation message: ' . $name); $validation = $list->filter('li.text-danger'); - if (count($validation) < 1) { + if (\count($validation) < 1) { // decorated form fields with icon have a different html structure, see kimai-theme.html.twig /** @var \DOMElement $listMsg */ $listMsg = $field->parents()->getNode(1); diff --git a/tests/Controller/CustomerControllerTest.php b/tests/Controller/CustomerControllerTest.php index ac78e80c..b598dc43 100644 --- a/tests/Controller/CustomerControllerTest.php +++ b/tests/Controller/CustomerControllerTest.php @@ -55,7 +55,7 @@ class CustomerControllerTest extends ControllerBaseTest $customer->setMetaField((new CustomerMeta())->setName('location')->setValue('homeoffice')); $customer->setMetaField((new CustomerMeta())->setName('feature')->setValue('timetracking')); }); - $this->importFixture($client, $fixture); + $this->importFixture($fixture); $this->assertAccessIsGranted($client, '/admin/customer/'); @@ -209,7 +209,7 @@ class CustomerControllerTest extends ControllerBaseTest $fixture = new ProjectFixtures(); $fixture->setAmount(9); // to trigger a second page (every third activity is hidden) $fixture->setCustomers([$customer]); - $this->importFixture($client, $fixture); + $this->importFixture($fixture); $this->assertAccessIsGranted($client, '/admin/customer/1/projects/1'); @@ -289,7 +289,7 @@ class CustomerControllerTest extends ControllerBaseTest $fixture = new TeamFixtures(); $fixture->setAmount(2); $fixture->setAddCustomer(false); - $this->importFixture($client, $fixture); + $this->importFixture($fixture); $this->assertAccessIsGranted($client, '/admin/customer/1/permissions'); $form = $client->getCrawler()->filter('form[name=customer_team_permission_form]')->form(); @@ -316,7 +316,7 @@ class CustomerControllerTest extends ControllerBaseTest $fixture = new CustomerFixtures(); $fixture->setAmount(1); - $this->importFixture($client, $fixture); + $this->importFixture($fixture); $this->request($client, '/admin/customer/2/edit'); $this->assertTrue($client->getResponse()->isSuccessful()); @@ -341,12 +341,12 @@ class CustomerControllerTest extends ControllerBaseTest $em = $this->getEntityManager(); $fixture = new TimesheetFixtures(); - $fixture->setUser($this->getUserByRole($em, User::ROLE_USER)); + $fixture->setUser($this->getUserByRole(User::ROLE_USER)); $fixture->setAmount(10); - $this->importFixture($client, $fixture); + $this->importFixture($fixture); $timesheets = $em->getRepository(Timesheet::class)->findAll(); - $this->assertEquals(10, count($timesheets)); + $this->assertEquals(10, \count($timesheets)); /** @var Timesheet $entry */ foreach ($timesheets as $entry) { @@ -380,15 +380,15 @@ class CustomerControllerTest extends ControllerBaseTest $em = $this->getEntityManager(); $fixture = new TimesheetFixtures(); - $fixture->setUser($this->getUserByRole($em, User::ROLE_USER)); + $fixture->setUser($this->getUserByRole(User::ROLE_USER)); $fixture->setAmount(10); - $this->importFixture($client, $fixture); + $this->importFixture($fixture); $fixture = new CustomerFixtures(); $fixture->setAmount(1)->setIsVisible(true); - $this->importFixture($client, $fixture); + $this->importFixture($fixture); $timesheets = $em->getRepository(Timesheet::class)->findAll(); - $this->assertEquals(10, count($timesheets)); + $this->assertEquals(10, \count($timesheets)); /** @var Timesheet $entry */ foreach ($timesheets as $entry) { @@ -412,7 +412,7 @@ class CustomerControllerTest extends ControllerBaseTest $this->assertHasFlashSuccess($client); $timesheets = $em->getRepository(Timesheet::class)->findAll(); - $this->assertEquals(10, count($timesheets)); + $this->assertEquals(10, \count($timesheets)); /** @var Timesheet $entry */ foreach ($timesheets as $entry) { diff --git a/tests/Controller/DoctorControllerTest.php b/tests/Controller/DoctorControllerTest.php index 1fa40970..aaa93f0f 100644 --- a/tests/Controller/DoctorControllerTest.php +++ b/tests/Controller/DoctorControllerTest.php @@ -32,6 +32,6 @@ class DoctorControllerTest extends ControllerBaseTest $this->assertAccessIsGranted($client, '/doctor'); $result = $client->getCrawler()->filter('.content .box-header'); - $this->assertEquals(7, count($result)); + $this->assertEquals(7, \count($result)); } } diff --git a/tests/Controller/ExportControllerTest.php b/tests/Controller/ExportControllerTest.php index b2adedca..ea66fa0f 100644 --- a/tests/Controller/ExportControllerTest.php +++ b/tests/Controller/ExportControllerTest.php @@ -45,8 +45,8 @@ class ExportControllerTest extends ControllerBaseTest $client = $this->getClientForAuthenticatedUser(User::ROLE_TEAMLEAD); $em = $this->getEntityManager(); - $teamlead = $this->getUserByRole($em, User::ROLE_TEAMLEAD); - $user = $this->getUserByRole($em, User::ROLE_USER); + $teamlead = $this->getUserByRole(User::ROLE_TEAMLEAD); + $user = $this->getUserByRole(User::ROLE_USER); /** @var Team $team */ $team = new Team(); $team->setName('fooo'); @@ -57,7 +57,7 @@ class ExportControllerTest extends ControllerBaseTest $em->persist($teamlead); $em->flush(); - $user = $this->getUserByRole($em, User::ROLE_USER); + $user = $this->getUserByRole(User::ROLE_USER); $begin = new \DateTime('first day of this month'); $fixture = new TimesheetFixtures(); @@ -70,9 +70,9 @@ class ExportControllerTest extends ControllerBaseTest $em->persist($team); }) ; - $this->importFixture($client, $fixture); + $this->importFixture($fixture); - $teamlead = $this->getUserByRole($em, User::ROLE_TEAMLEAD); + $teamlead = $this->getUserByRole(User::ROLE_TEAMLEAD); $fixture = new TimesheetFixtures(); $fixture @@ -80,7 +80,7 @@ class ExportControllerTest extends ControllerBaseTest ->setAmount(2) ->setStartDate($begin) ; - $this->importFixture($client, $fixture); + $this->importFixture($fixture); $em->flush(); $this->request($client, '/export/?preview='); @@ -94,7 +94,7 @@ class ExportControllerTest extends ControllerBaseTest // assert export type buttons are available $expected = ['csv', 'default.html.twig', 'default-budget.pdf.twig', 'default-internal.pdf.twig', 'default.pdf.twig', 'xlsx']; $node = $client->getCrawler()->filter('#export-buttons .startExportBtn'); - $this->assertEquals(count($expected), $node->count()); + $this->assertEquals(\count($expected), $node->count()); /** @var \DOMElement $button */ foreach ($node->getIterator() as $button) { $type = $button->getAttribute('data-type'); @@ -108,7 +108,7 @@ class ExportControllerTest extends ControllerBaseTest $em = $this->getEntityManager(); $begin = new \DateTime('first day of this month'); - $user = $this->getUserByRole($em, User::ROLE_USER); + $user = $this->getUserByRole(User::ROLE_USER); // these should be ignored, becuase teamlead and user do NOT share a team! $fixture = new TimesheetFixtures(); @@ -117,7 +117,7 @@ class ExportControllerTest extends ControllerBaseTest ->setAmount(20) ->setStartDate($begin) ; - $this->importFixture($client, $fixture); + $this->importFixture($fixture); $this->request($client, '/export/?preview='); $this->assertTrue($client->getResponse()->isSuccessful()); @@ -125,7 +125,7 @@ class ExportControllerTest extends ControllerBaseTest // make sure all existing records are displayed $this->assertHasNoEntriesWithFilter($client); - $teamlead = $this->getUserByRole($em, User::ROLE_TEAMLEAD); + $teamlead = $this->getUserByRole(User::ROLE_TEAMLEAD); $fixture = new TimesheetFixtures(); $fixture @@ -133,7 +133,7 @@ class ExportControllerTest extends ControllerBaseTest ->setAmount(2) ->setStartDate($begin) ; - $this->importFixture($client, $fixture); + $this->importFixture($fixture); $this->request($client, '/export/?preview='); $this->assertTrue($client->getResponse()->isSuccessful()); @@ -146,7 +146,7 @@ class ExportControllerTest extends ControllerBaseTest // assert export type buttons are available $expected = ['csv', 'default.html.twig', 'default-budget.pdf.twig', 'default-internal.pdf.twig', 'default.pdf.twig', 'xlsx']; $node = $client->getCrawler()->filter('#export-buttons .startExportBtn'); - $this->assertEquals(count($expected), $node->count()); + $this->assertEquals(\count($expected), $node->count()); /** @var \DOMElement $button */ foreach ($node->getIterator() as $button) { $type = $button->getAttribute('data-type'); @@ -196,11 +196,11 @@ class ExportControllerTest extends ControllerBaseTest $begin = new \DateTime('first day of this month'); $fixture = new TimesheetFixtures(); $fixture - ->setUser($this->getUserByRole($em, User::ROLE_USER)) + ->setUser($this->getUserByRole(User::ROLE_USER)) ->setAmount(20) ->setStartDate($begin) ; - $this->importFixture($client, $fixture); + $this->importFixture($fixture); $this->request($client, '/export/'); $this->assertTrue($client->getResponse()->isSuccessful()); diff --git a/tests/Controller/HomepageControllerTest.php b/tests/Controller/HomepageControllerTest.php index 25b823c4..5131e422 100644 --- a/tests/Controller/HomepageControllerTest.php +++ b/tests/Controller/HomepageControllerTest.php @@ -36,7 +36,7 @@ class HomepageControllerTest extends ControllerBaseTest $client = $this->getClientForAuthenticatedUser(User::ROLE_USER); $em = $this->getEntityManager(); - $user = $this->getUserByRole($em, User::ROLE_USER); + $user = $this->getUserByRole(User::ROLE_USER); $pref = (new UserPreference()) ->setName('login.initial_view') diff --git a/tests/Controller/InvoiceControllerTest.php b/tests/Controller/InvoiceControllerTest.php index 7dcba0c1..012f48d2 100644 --- a/tests/Controller/InvoiceControllerTest.php +++ b/tests/Controller/InvoiceControllerTest.php @@ -70,7 +70,7 @@ class InvoiceControllerTest extends ControllerBaseTest $client = $this->getClientForAuthenticatedUser(User::ROLE_TEAMLEAD); $fixture = new InvoiceFixtures(); - $this->importFixture($client, $fixture); + $this->importFixture($fixture); $this->request($client, '/invoice/?preview='); $this->assertTrue($client->getResponse()->isSuccessful()); @@ -83,7 +83,7 @@ class InvoiceControllerTest extends ControllerBaseTest $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN); $fixture = new InvoiceFixtures(); - $this->importFixture($client, $fixture); + $this->importFixture($fixture); $this->request($client, '/invoice/template'); @@ -120,7 +120,7 @@ class InvoiceControllerTest extends ControllerBaseTest $em = $this->getEntityManager(); $fixture = new InvoiceFixtures(); - $this->importFixture($client, $fixture); + $this->importFixture($fixture); /** @var InvoiceTemplate $template */ $template = $em->getRepository(InvoiceTemplate::class)->find(1); @@ -148,17 +148,17 @@ class InvoiceControllerTest extends ControllerBaseTest $em = $this->getEntityManager(); $fixture = new InvoiceFixtures(); - $this->importFixture($client, $fixture); + $this->importFixture($fixture); $begin = new \DateTime('first day of this month'); $end = new \DateTime('last day of this month'); $fixture = new TimesheetFixtures(); $fixture - ->setUser($this->getUserByRole($em, User::ROLE_TEAMLEAD)) + ->setUser($this->getUserByRole(User::ROLE_TEAMLEAD)) ->setAmount(20) ->setStartDate($begin) ; - $this->importFixture($client, $fixture); + $this->importFixture($fixture); $this->request($client, '/invoice/'); $this->assertTrue($client->getResponse()->isSuccessful()); @@ -214,17 +214,17 @@ class InvoiceControllerTest extends ControllerBaseTest $em = $this->getEntityManager(); $fixture = new InvoiceFixtures(); - $this->importFixture($client, $fixture); + $this->importFixture($fixture); $begin = new \DateTime('first day of this month'); $end = new \DateTime('last day of this month'); $fixture = new TimesheetFixtures(); $fixture - ->setUser($this->getUserByRole($em, User::ROLE_TEAMLEAD)) + ->setUser($this->getUserByRole(User::ROLE_TEAMLEAD)) ->setAmount(20) ->setStartDate($begin) ; - $this->importFixture($client, $fixture); + $this->importFixture($fixture); $this->request($client, '/invoice/'); $this->assertTrue($client->getResponse()->isSuccessful()); @@ -273,17 +273,17 @@ class InvoiceControllerTest extends ControllerBaseTest $em = $this->getEntityManager(); $fixture = new InvoiceFixtures(); - $this->importFixture($client, $fixture); + $this->importFixture($fixture); $begin = new \DateTime('first day of this month'); $end = new \DateTime('last day of this month'); $fixture = new TimesheetFixtures(); $fixture - ->setUser($this->getUserByRole($em, User::ROLE_ADMIN)) + ->setUser($this->getUserByRole(User::ROLE_ADMIN)) ->setAmount(20) ->setStartDate($begin) ; - $this->importFixture($client, $fixture); + $this->importFixture($fixture); $this->request($client, '/invoice/'); $this->assertTrue($client->getResponse()->isSuccessful()); @@ -357,7 +357,7 @@ class InvoiceControllerTest extends ControllerBaseTest $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN); $fixture = new InvoiceFixtures(); - $this->importFixture($client, $fixture); + $this->importFixture($fixture); $this->request($client, '/invoice/template/1/edit?page=1'); $form = $client->getCrawler()->filter('form[name=invoice_template_form]')->form(); @@ -384,7 +384,7 @@ class InvoiceControllerTest extends ControllerBaseTest $em = $this->getEntityManager(); $fixture = new InvoiceFixtures(); - $this->importFixture($client, $fixture); + $this->importFixture($fixture); $this->request($client, '/invoice/template/1/delete'); $this->assertIsRedirect($client, '/invoice/template'); @@ -402,7 +402,7 @@ class InvoiceControllerTest extends ControllerBaseTest $em = $this->getEntityManager(); $fixture = new InvoiceFixtures(); - $this->importFixture($client, $fixture); + $this->importFixture($fixture); $this->request($client, '/invoice/document_upload'); $this->assertTrue($client->getResponse()->isSuccessful()); diff --git a/tests/Controller/LayoutControllerTest.php b/tests/Controller/LayoutControllerTest.php index a12f8566..9f7b9e23 100644 --- a/tests/Controller/LayoutControllerTest.php +++ b/tests/Controller/LayoutControllerTest.php @@ -22,7 +22,7 @@ class LayoutControllerTest extends ControllerBaseTest $client = $this->getClientForAuthenticatedUser(User::ROLE_USER); $em = $this->getEntityManager(); - $user = $this->getUserByRole($em, User::ROLE_USER); + $user = $this->getUserByRole(User::ROLE_USER); $this->request($client, '/dashboard/'); $this->assertTrue($client->getResponse()->isSuccessful()); @@ -78,7 +78,7 @@ class LayoutControllerTest extends ControllerBaseTest $client = $this->getClientForAuthenticatedUser(User::ROLE_USER); $em = $this->getEntityManager(); - $user = $this->getUserByRole($em, User::ROLE_USER); + $user = $this->getUserByRole(User::ROLE_USER); $this->request($client, '/layou/active_entries'); $this->assertTrue($client->getResponse()->isSuccessful()); diff --git a/tests/Controller/PermissionControllerTest.php b/tests/Controller/PermissionControllerTest.php index f02ed4af..62333960 100644 --- a/tests/Controller/PermissionControllerTest.php +++ b/tests/Controller/PermissionControllerTest.php @@ -160,7 +160,7 @@ class PermissionControllerTest extends ControllerBaseTest $em = $this->getEntityManager(); $rolePermissions = $em->getRepository(RolePermission::class)->findAll(); - $this->assertEquals(0, count($rolePermissions)); + $this->assertEquals(0, \count($rolePermissions)); // create the permission $this->request($client, '/admin/permissions/roles/1/view_user/1'); @@ -168,7 +168,7 @@ class PermissionControllerTest extends ControllerBaseTest $client->followRedirect(); $rolePermissions = $em->getRepository(RolePermission::class)->findAll(); - $this->assertEquals(1, count($rolePermissions)); + $this->assertEquals(1, \count($rolePermissions)); $permission = $rolePermissions[0]; self::assertInstanceOf(RolePermission::class, $permission); self::assertEquals('view_user', $permission->getPermission()); @@ -185,7 +185,7 @@ class PermissionControllerTest extends ControllerBaseTest $client->followRedirect(); $rolePermissions = $em->getRepository(RolePermission::class)->findAll(); - $this->assertEquals(1, count($rolePermissions)); + $this->assertEquals(1, \count($rolePermissions)); $permission = $rolePermissions[0]; self::assertInstanceOf(RolePermission::class, $permission); self::assertEquals('view_user', $permission->getPermission()); diff --git a/tests/Controller/ProfileControllerTest.php b/tests/Controller/ProfileControllerTest.php index 08da5a18..369cef0d 100644 --- a/tests/Controller/ProfileControllerTest.php +++ b/tests/Controller/ProfileControllerTest.php @@ -53,9 +53,9 @@ class ProfileControllerTest extends ControllerBaseTest foreach ($dates as $start) { $fixture = new TimesheetFixtures(); $fixture->setAmount(10); - $fixture->setUser($this->getUserByRole($em, User::ROLE_USER)); + $fixture->setUser($this->getUserByRole(User::ROLE_USER)); $fixture->setStartDate($start); - $this->importFixture($client, $fixture); + $this->importFixture($fixture); } $this->request($client, '/profile/' . UserFixtures::USERNAME_USER); @@ -111,7 +111,7 @@ class ProfileControllerTest extends ControllerBaseTest $this->assertTrue($client->getResponse()->isSuccessful()); $tabs = $client->getCrawler()->filter('div.nav-tabs-custom ul.nav-tabs li'); - $this->assertEquals(count($expectedTabs), $tabs->count()); + $this->assertEquals(\count($expectedTabs), $tabs->count()); $foundTabs = []; /** @var \DOMElement $tab */ @@ -135,7 +135,7 @@ class ProfileControllerTest extends ControllerBaseTest $em = $this->getEntityManager(); /** @var User $user */ - $user = $this->getUserByRole($em, User::ROLE_USER); + $user = $this->getUserByRole(User::ROLE_USER); $this->assertEquals(UserFixtures::USERNAME_USER, $user->getUsername()); $this->assertEquals('John Doe', $user->getAlias()); @@ -161,7 +161,7 @@ class ProfileControllerTest extends ControllerBaseTest $this->assertHasFlashSuccess($client); $em = $this->getEntityManager(); - $user = $this->getUserByRole($em, User::ROLE_USER); + $user = $this->getUserByRole(User::ROLE_USER); $this->assertEquals(UserFixtures::USERNAME_USER, $user->getUsername()); $this->assertEquals('Johnny', $user->getAlias()); @@ -194,7 +194,7 @@ class ProfileControllerTest extends ControllerBaseTest $this->assertHasFlashSuccess($client); $em = $this->getEntityManager(); - $user = $this->getUserByRole($em, User::ROLE_USER); + $user = $this->getUserByRole(User::ROLE_USER); $this->assertEquals(UserFixtures::USERNAME_USER, $user->getUsername()); $this->assertEquals('Johnny', $user->getAlias()); @@ -211,7 +211,7 @@ class ProfileControllerTest extends ControllerBaseTest $em = $this->getEntityManager(); /** @var User $user */ - $user = $this->getUserByRole($em, User::ROLE_USER); + $user = $this->getUserByRole(User::ROLE_USER); /** @var EncoderFactoryInterface $passwordEncoder */ $passwordEncoder = static::$kernel->getContainer()->get('test.PasswordEncoder'); @@ -237,7 +237,7 @@ class ProfileControllerTest extends ControllerBaseTest $this->assertHasFlashSuccess($client); $em = $this->getEntityManager(); - $user = $this->getUserByRole($em, User::ROLE_USER); + $user = $this->getUserByRole(User::ROLE_USER); $this->assertFalse($passwordEncoder->getEncoder($user)->isPasswordValid($user->getPassword(), UserFixtures::DEFAULT_PASSWORD, $user->getSalt())); $this->assertTrue($passwordEncoder->getEncoder($user)->isPasswordValid($user->getPassword(), 'test1234', $user->getSalt())); @@ -250,7 +250,7 @@ class ProfileControllerTest extends ControllerBaseTest $em = $this->getEntityManager(); /** @var User $user */ - $user = $this->getUserByRole($em, User::ROLE_USER); + $user = $this->getUserByRole(User::ROLE_USER); /** @var EncoderFactoryInterface $passwordEncoder */ $passwordEncoder = static::$kernel->getContainer()->get('test.PasswordEncoder'); @@ -275,7 +275,7 @@ class ProfileControllerTest extends ControllerBaseTest $this->assertHasFlashSuccess($client); $em = $this->getEntityManager(); - $user = $this->getUserByRole($em, User::ROLE_USER); + $user = $this->getUserByRole(User::ROLE_USER); $this->assertFalse($passwordEncoder->getEncoder($user)->isPasswordValid($user->getApiToken(), UserFixtures::DEFAULT_API_TOKEN, $user->getSalt())); $this->assertTrue($passwordEncoder->getEncoder($user)->isPasswordValid($user->getApiToken(), 'test123', $user->getSalt())); @@ -295,7 +295,7 @@ class ProfileControllerTest extends ControllerBaseTest $em = $this->getEntityManager(); /** @var User $user */ - $user = $this->getUserByRole($em, User::ROLE_USER); + $user = $this->getUserByRole(User::ROLE_USER); $this->assertEquals(['ROLE_USER'], $user->getRoles()); @@ -314,7 +314,7 @@ class ProfileControllerTest extends ControllerBaseTest $this->assertHasFlashSuccess($client); $em = $this->getEntityManager(); - $user = $this->getUserByRole($em, User::ROLE_USER); + $user = $this->getUserByRole(User::ROLE_USER); $this->assertEquals(['ROLE_TEAMLEAD', 'ROLE_SUPER_ADMIN', 'ROLE_USER'], $user->getRoles()); } @@ -335,19 +335,19 @@ class ProfileControllerTest extends ControllerBaseTest $em = $this->getEntityManager(); /** @var User $user */ - $user = $this->getUserByRole($em, User::ROLE_USER); + $user = $this->getUserByRole(User::ROLE_USER); $fixture = new TeamFixtures(); $fixture->setAmount(3); $fixture->setAddCustomer(true); $fixture->setAddUser(false); $fixture->addUserToIgnore($user); - $this->importFixture($client, $fixture); + $this->importFixture($fixture); $this->request($client, '/profile/' . UserFixtures::USERNAME_USER . '/teams'); /** @var User $user */ - $user = $this->getUserByRole($em, User::ROLE_USER); + $user = $this->getUserByRole(User::ROLE_USER); $this->assertEquals([], $user->getTeams()->toArray()); $form = $client->getCrawler()->filter('form[name=user_teams]')->form(); @@ -364,7 +364,7 @@ class ProfileControllerTest extends ControllerBaseTest $this->assertHasFlashSuccess($client); $em = $this->getEntityManager(); - $user = $this->getUserByRole($em, User::ROLE_USER); + $user = $this->getUserByRole(User::ROLE_USER); $this->assertEquals(1, $user->getTeams()->count()); } diff --git a/tests/Controller/ProjectControllerTest.php b/tests/Controller/ProjectControllerTest.php index 2aa6fa13..50e49991 100644 --- a/tests/Controller/ProjectControllerTest.php +++ b/tests/Controller/ProjectControllerTest.php @@ -62,7 +62,7 @@ class ProjectControllerTest extends ControllerBaseTest $project->setMetaField((new ProjectMeta())->setName('location')->setValue('homeoffice')); $project->setMetaField((new ProjectMeta())->setName('feature')->setValue('timetracking')); }); - $this->importFixture($client, $fixture); + $this->importFixture($fixture); $this->assertAccessIsGranted($client, '/admin/project/'); @@ -91,14 +91,14 @@ class ProjectControllerTest extends ControllerBaseTest $fixture = new TimesheetFixtures(); $fixture->setAmount(10); $fixture->setProjects([$project]); - $fixture->setUser($this->getUserByRole($em, User::ROLE_ADMIN)); - $this->importFixture($client, $fixture); + $fixture->setUser($this->getUserByRole(User::ROLE_ADMIN)); + $this->importFixture($fixture); $project = $em->getRepository(Project::class)->find(1); $fixture = new ActivityFixtures(); $fixture->setAmount(6); // to trigger a second page $fixture->setProjects([$project]); - $this->importFixture($client, $fixture); + $this->importFixture($fixture); $this->assertAccessIsGranted($client, '/admin/project/1/details'); self::assertHasProgressbar($client); @@ -154,7 +154,7 @@ class ProjectControllerTest extends ControllerBaseTest $project->setEnd(new \DateTime()); $em->persist($project); $team = new Team(); - $team->setTeamLead($this->getUserByRole($em, User::ROLE_ADMIN)); + $team->setTeamLead($this->getUserByRole(User::ROLE_ADMIN)); $team->addProject($project); $team->setName('project 1'); $em->persist($team); @@ -275,7 +275,7 @@ class ProjectControllerTest extends ControllerBaseTest $fixture = new ActivityFixtures(); $fixture->setAmount(9); // to trigger a second page (every third activity is hidden) $fixture->setProjects([$project]); - $this->importFixture($client, $fixture); + $this->importFixture($fixture); $this->assertAccessIsGranted($client, '/admin/project/1/activities/1'); @@ -321,7 +321,7 @@ class ProjectControllerTest extends ControllerBaseTest $fixture = new CustomerFixtures(); $fixture->setAmount(10); - $this->importFixture($client, $fixture); + $this->importFixture($fixture); $this->assertAccessIsGranted($client, '/admin/project/create'); $form = $client->getCrawler()->filter('form[name=project_edit_form]')->form(); @@ -377,7 +377,7 @@ class ProjectControllerTest extends ControllerBaseTest $fixture = new TeamFixtures(); $fixture->setAmount(2); $fixture->setAddCustomer(false); - $this->importFixture($client, $fixture); + $this->importFixture($fixture); $this->assertAccessIsGranted($client, '/admin/project/1/permissions'); $form = $client->getCrawler()->filter('form[name=project_team_permission_form]')->form(); @@ -404,7 +404,7 @@ class ProjectControllerTest extends ControllerBaseTest $fixture = new ProjectFixtures(); $fixture->setAmount(1); - $this->importFixture($client, $fixture); + $this->importFixture($fixture); $this->request($client, '/admin/project/2/edit'); $this->assertTrue($client->getResponse()->isSuccessful()); @@ -429,12 +429,12 @@ class ProjectControllerTest extends ControllerBaseTest $em = $this->getEntityManager(); $fixture = new TimesheetFixtures(); - $fixture->setUser($this->getUserByRole($em, User::ROLE_USER)); + $fixture->setUser($this->getUserByRole(User::ROLE_USER)); $fixture->setAmount(10); - $this->importFixture($client, $fixture); + $this->importFixture($fixture); $timesheets = $em->getRepository(Timesheet::class)->findAll(); - $this->assertEquals(10, count($timesheets)); + $this->assertEquals(10, \count($timesheets)); /** @var Timesheet $entry */ foreach ($timesheets as $entry) { @@ -468,15 +468,15 @@ class ProjectControllerTest extends ControllerBaseTest $em = $this->getEntityManager(); $fixture = new TimesheetFixtures(); - $fixture->setUser($this->getUserByRole($em, User::ROLE_USER)); + $fixture->setUser($this->getUserByRole(User::ROLE_USER)); $fixture->setAmount(10); - $this->importFixture($client, $fixture); + $this->importFixture($fixture); $fixture = new ProjectFixtures(); $fixture->setAmount(1)->setIsVisible(true); - $this->importFixture($client, $fixture); + $this->importFixture($fixture); $timesheets = $em->getRepository(Timesheet::class)->findAll(); - $this->assertEquals(10, count($timesheets)); + $this->assertEquals(10, \count($timesheets)); /** @var Timesheet $entry */ foreach ($timesheets as $entry) { @@ -500,7 +500,7 @@ class ProjectControllerTest extends ControllerBaseTest $this->assertHasFlashSuccess($client); $timesheets = $em->getRepository(Timesheet::class)->findAll(); - $this->assertEquals(10, count($timesheets)); + $this->assertEquals(10, \count($timesheets)); /** @var Timesheet $entry */ foreach ($timesheets as $entry) { diff --git a/tests/Controller/SystemConfigurationControllerTest.php b/tests/Controller/SystemConfigurationControllerTest.php index 1c555fbf..5e6b2594 100644 --- a/tests/Controller/SystemConfigurationControllerTest.php +++ b/tests/Controller/SystemConfigurationControllerTest.php @@ -35,14 +35,14 @@ class SystemConfigurationControllerTest extends ControllerBaseTest $expectedForms = $this->getTestDataForms(); $result = $client->getCrawler()->filter('section.content div.box.box-primary'); - $this->assertEquals(count($expectedForms), count($result)); + $this->assertEquals(\count($expectedForms), \count($result)); $result = $client->getCrawler()->filter('section.content div.box.box-primary form'); - $this->assertEquals(count($expectedForms), count($result)); + $this->assertEquals(\count($expectedForms), \count($result)); foreach ($expectedForms as $formConfig) { $result = $client->getCrawler()->filter($formConfig[0]); - $this->assertEquals(1, count($result)); + $this->assertEquals(1, \count($result)); $form = $result->form(); $this->assertStringEndsWith($formConfig[1], $form->getUri()); $this->assertEquals('POST', $form->getMethod()); @@ -57,13 +57,13 @@ class SystemConfigurationControllerTest extends ControllerBaseTest $expectedForms = $this->getTestDataForms(); $result = $client->getCrawler()->filter('section.content div.box.box-primary'); - $this->assertEquals(1, count($result)); + $this->assertEquals(1, \count($result)); $result = $client->getCrawler()->filter('section.content div.box.box-primary form'); - $this->assertEquals(1, count($result)); + $this->assertEquals(1, \count($result)); $result = $client->getCrawler()->filter('form[name=system_configuration_form_timesheet]'); - $this->assertEquals(1, count($result)); + $this->assertEquals(1, \count($result)); $form = $result->form(); $this->assertEquals('POST', $form->getMethod()); } diff --git a/tests/Controller/TagControllerTest.php b/tests/Controller/TagControllerTest.php index 089d47f1..1a6613ab 100644 --- a/tests/Controller/TagControllerTest.php +++ b/tests/Controller/TagControllerTest.php @@ -26,7 +26,7 @@ class TagControllerTest extends ControllerBaseTest $fixture = new TagFixtures(); $fixture->setTagArray($tagList); - $this->importFixture($client, $fixture); + $this->importFixture($fixture); } public function testIsSecure() diff --git a/tests/Controller/TeamControllerTest.php b/tests/Controller/TeamControllerTest.php index 375b7800..f6a74e70 100644 --- a/tests/Controller/TeamControllerTest.php +++ b/tests/Controller/TeamControllerTest.php @@ -37,7 +37,7 @@ class TeamControllerTest extends ControllerBaseTest $em = $this->getEntityManager(); $fixture = new TeamFixtures(); $fixture->setAmount(5); - $this->importFixture($em, $fixture); + $this->importFixture($fixture); $this->assertAccessIsGranted($client, '/admin/teams/'); $this->assertPageActions($client, [ @@ -58,7 +58,7 @@ class TeamControllerTest extends ControllerBaseTest $fixture->setCallback(function (Team $team) { $team->setName($team->getName() . '- fantastic team with foooo bar magic'); }); - $this->importFixture($em, $fixture); + $this->importFixture($fixture); $this->assertAccessIsGranted($client, '/admin/teams/'); @@ -109,7 +109,7 @@ class TeamControllerTest extends ControllerBaseTest $em = $this->getEntityManager(); $fixture = new TeamFixtures(); $fixture->setAmount(2); - $this->importFixture($em, $fixture); + $this->importFixture($fixture); $this->assertAccessIsGranted($client, '/admin/teams/1/edit'); $form = $client->getCrawler()->filter('form[name=team_edit_form]')->form(); @@ -132,7 +132,7 @@ class TeamControllerTest extends ControllerBaseTest $em = $this->getEntityManager(); $fixture = new TeamFixtures(); $fixture->setAmount(2); - $this->importFixture($em, $fixture); + $this->importFixture($fixture); $this->assertAccessIsGranted($client, '/admin/teams/1/edit_member'); $form = $client->getCrawler()->filter('form[name=team_edit_form]')->form(); @@ -158,10 +158,10 @@ class TeamControllerTest extends ControllerBaseTest $fixture = new TeamFixtures(); $fixture->setAmount(2); $fixture->setAddCustomer(false); - $this->importFixture($em, $fixture); + $this->importFixture($fixture); $team = $em->getRepository(Team::class)->find(1); - self::assertEquals(0, count($team->getCustomers())); + self::assertEquals(0, \count($team->getCustomers())); $this->assertAccessIsGranted($client, '/admin/teams/1/edit'); $form = $client->getCrawler()->filter('form[name=team_customer_form]')->form(); @@ -174,7 +174,7 @@ class TeamControllerTest extends ControllerBaseTest $this->assertIsRedirect($client, $this->createUrl('/admin/teams/1/edit')); $team = $em->getRepository(Team::class)->find(1); - self::assertEquals(1, count($team->getCustomers())); + self::assertEquals(1, \count($team->getCustomers())); } public function testEditProjectAccessAction() @@ -187,10 +187,10 @@ class TeamControllerTest extends ControllerBaseTest $fixture = new TeamFixtures(); $fixture->setAmount(2); $fixture->setAddCustomer(false); - $this->importFixture($em, $fixture); + $this->importFixture($fixture); $team = $em->getRepository(Team::class)->find(1); - self::assertEquals(0, count($team->getProjects())); + self::assertEquals(0, \count($team->getProjects())); $this->assertAccessIsGranted($client, '/admin/teams/1/edit'); $form = $client->getCrawler()->filter('form[name=team_project_form]')->form(); @@ -203,6 +203,6 @@ class TeamControllerTest extends ControllerBaseTest $this->assertIsRedirect($client, $this->createUrl('/admin/teams/1/edit')); $team = $em->getRepository(Team::class)->find(1); - self::assertEquals(1, count($team->getProjects())); + self::assertEquals(1, \count($team->getProjects())); } } diff --git a/tests/Controller/TimesheetControllerTest.php b/tests/Controller/TimesheetControllerTest.php index cd10d6af..12b03eae 100644 --- a/tests/Controller/TimesheetControllerTest.php +++ b/tests/Controller/TimesheetControllerTest.php @@ -55,9 +55,9 @@ class TimesheetControllerTest extends ControllerBaseTest $fixture = new TimesheetFixtures(); $fixture->setAmount(5); $fixture->setAmountRunning(2); - $fixture->setUser($this->getUserByRole($em, User::ROLE_USER)); + $fixture->setUser($this->getUserByRole(User::ROLE_USER)); $fixture->setStartDate($start); - $this->importFixture($em, $fixture); + $this->importFixture($fixture); $this->request($client, '/timesheet/'); $this->assertTrue($client->getResponse()->isSuccessful()); @@ -91,20 +91,20 @@ class TimesheetControllerTest extends ControllerBaseTest $em = $this->getEntityManager(); $fixture = new TimesheetFixtures(); $fixture->setAmount(5); - $fixture->setUser($this->getUserByRole($em, User::ROLE_USER)); + $fixture->setUser($this->getUserByRole(User::ROLE_USER)); $fixture->setStartDate($start); $fixture->setCallback(function (Timesheet $timesheet) { $timesheet->setDescription('I am a foobar with tralalalala some more content'); $timesheet->setMetaField((new TimesheetMeta())->setName('location')->setValue('homeoffice')); $timesheet->setMetaField((new TimesheetMeta())->setName('feature')->setValue('timetracking')); }); - $this->importFixture($em, $fixture); + $this->importFixture($fixture); $fixture = new TimesheetFixtures(); $fixture->setAmount(5); $fixture->setAmountRunning(5); - $fixture->setUser($this->getUserByRole($em, User::ROLE_USER)); + $fixture->setUser($this->getUserByRole(User::ROLE_USER)); $fixture->setStartDate($start); - $this->importFixture($em, $fixture); + $this->importFixture($fixture); $this->request($client, '/timesheet/'); $this->assertTrue($client->getResponse()->isSuccessful()); @@ -128,9 +128,9 @@ class TimesheetControllerTest extends ControllerBaseTest $em = $this->getEntityManager(); $fixture = new TimesheetFixtures(); $fixture->setAmount(5); - $fixture->setUser($this->getUserByRole($em, User::ROLE_USER)); + $fixture->setUser($this->getUserByRole(User::ROLE_USER)); $fixture->setStartDate(new \DateTime('-10 days')); - $this->importFixture($em, $fixture); + $this->importFixture($fixture); $this->request($client, '/timesheet/'); $this->assertTrue($client->getResponse()->isSuccessful()); @@ -154,7 +154,7 @@ class TimesheetControllerTest extends ControllerBaseTest $this->assertEquals('invoice_print', $body->getAttribute('class')); $result = $node->filter('section.invoice table.table tbody tr'); - $this->assertEquals(5, count($result)); + $this->assertEquals(5, \count($result)); } public function testCreateAction() @@ -293,9 +293,9 @@ class TimesheetControllerTest extends ControllerBaseTest $em = $this->getEntityManager(); $fixture = new TimesheetFixtures(); $fixture->setAmount(10); - $fixture->setUser($this->getUserByRole($em, User::ROLE_USER)); + $fixture->setUser($this->getUserByRole(User::ROLE_USER)); $fixture->setStartDate('2017-05-01'); - $this->importFixture($em, $fixture); + $this->importFixture($fixture); $this->request($client, '/timesheet/1/edit'); @@ -332,11 +332,11 @@ class TimesheetControllerTest extends ControllerBaseTest $client = $this->getClientForAuthenticatedUser(User::ROLE_USER); $em = $this->getEntityManager(); - $user = $this->getUserByRole($em, User::ROLE_USER); + $user = $this->getUserByRole(User::ROLE_USER); $fixture = new TimesheetFixtures(); $fixture->setAmount(10); $fixture->setUser($user); - $this->importFixture($em, $fixture); + $this->importFixture($fixture); $this->assertAccessIsGranted($client, '/timesheet/'); @@ -371,11 +371,11 @@ class TimesheetControllerTest extends ControllerBaseTest $client = $this->getClientForAuthenticatedUser(User::ROLE_SUPER_ADMIN); $em = $this->getEntityManager(); - $user = $this->getUserByRole($em, User::ROLE_SUPER_ADMIN); + $user = $this->getUserByRole(User::ROLE_SUPER_ADMIN); $fixture = new TimesheetFixtures(); $fixture->setAmount(10); $fixture->setUser($user); - $this->importFixture($em, $fixture); + $this->importFixture($fixture); $this->assertAccessIsGranted($client, '/timesheet/'); diff --git a/tests/Controller/TimesheetTeamControllerTest.php b/tests/Controller/TimesheetTeamControllerTest.php index 22e623d7..e2f68d86 100644 --- a/tests/Controller/TimesheetTeamControllerTest.php +++ b/tests/Controller/TimesheetTeamControllerTest.php @@ -59,13 +59,13 @@ class TimesheetTeamControllerTest extends ControllerBaseTest $start = new \DateTime('first day of this month'); $em = $this->getEntityManager(); - $user = $this->getUserByRole($em, User::ROLE_USER); + $user = $this->getUserByRole(User::ROLE_USER); $fixture = new TimesheetFixtures(); $fixture->setAmount(10); $fixture->setAmountRunning(3); $fixture->setUser($user); $fixture->setStartDate($start); - $this->importFixture($em, $fixture); + $this->importFixture($fixture); $this->request($client, '/team/timesheet/'); $this->assertTrue($client->getResponse()->isSuccessful()); @@ -98,20 +98,20 @@ class TimesheetTeamControllerTest extends ControllerBaseTest $em = $this->getEntityManager(); $fixture = new TimesheetFixtures(); $fixture->setAmount(5); - $fixture->setUser($this->getUserByRole($em, User::ROLE_USER)); + $fixture->setUser($this->getUserByRole(User::ROLE_USER)); $fixture->setStartDate($start); $fixture->setCallback(function (Timesheet $timesheet) { $timesheet->setDescription('I am a foobar with tralalalala some more content'); $timesheet->setMetaField((new TimesheetMeta())->setName('location')->setValue('homeoffice')); $timesheet->setMetaField((new TimesheetMeta())->setName('feature')->setValue('timetracking')); }); - $this->importFixture($em, $fixture); + $this->importFixture($fixture); $fixture = new TimesheetFixtures(); $fixture->setAmount(5); $fixture->setAmountRunning(5); - $fixture->setUser($this->getUserByRole($em, User::ROLE_USER)); + $fixture->setUser($this->getUserByRole(User::ROLE_USER)); $fixture->setStartDate($start); - $this->importFixture($em, $fixture); + $this->importFixture($fixture); $this->request($client, '/team/timesheet/'); $this->assertTrue($client->getResponse()->isSuccessful()); @@ -135,14 +135,14 @@ class TimesheetTeamControllerTest extends ControllerBaseTest $em = $this->getEntityManager(); $fixture = new TimesheetFixtures(); $fixture->setAmount(7); - $fixture->setUser($this->getUserByRole($em, User::ROLE_USER)); + $fixture->setUser($this->getUserByRole(User::ROLE_USER)); $fixture->setStartDate(new \DateTime('-10 days')); - $this->importFixture($em, $fixture); + $this->importFixture($fixture); $fixture = new TimesheetFixtures(); $fixture->setAmount(3); - $fixture->setUser($this->getUserByRole($em, User::ROLE_TEAMLEAD)); + $fixture->setUser($this->getUserByRole(User::ROLE_TEAMLEAD)); $fixture->setStartDate(new \DateTime('-10 days')); - $this->importFixture($em, $fixture); + $this->importFixture($fixture); $this->request($client, '/team/timesheet/'); $this->assertTrue($client->getResponse()->isSuccessful()); @@ -166,7 +166,7 @@ class TimesheetTeamControllerTest extends ControllerBaseTest $this->assertEquals('invoice_print', $body->getAttribute('class')); $result = $node->filter('section.invoice table.table tbody tr'); - $this->assertEquals(10, count($result)); + $this->assertEquals(10, \count($result)); } public function testCreateAction() @@ -205,13 +205,13 @@ class TimesheetTeamControllerTest extends ControllerBaseTest $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN); $em = $this->getEntityManager(); - $user = $this->getUserByRole($em, User::ROLE_USER); - $teamlead = $this->getUserByRole($em, User::ROLE_TEAMLEAD); + $user = $this->getUserByRole(User::ROLE_USER); + $teamlead = $this->getUserByRole(User::ROLE_TEAMLEAD); $fixture = new TimesheetFixtures(); $fixture->setAmount(10); $fixture->setUser($user); $fixture->setStartDate('2017-05-01'); - $this->importFixture($em, $fixture); + $this->importFixture($fixture); $this->request($client, '/team/timesheet/1/edit'); @@ -250,11 +250,11 @@ class TimesheetTeamControllerTest extends ControllerBaseTest $client = $this->getClientForAuthenticatedUser(User::ROLE_TEAMLEAD); $em = $this->getEntityManager(); - $user = $this->getUserByRole($em, User::ROLE_TEAMLEAD); + $user = $this->getUserByRole(User::ROLE_TEAMLEAD); $fixture = new TimesheetFixtures(); $fixture->setAmount(10); $fixture->setUser($user); - $this->importFixture($em, $fixture); + $this->importFixture($fixture); $this->assertAccessIsGranted($client, '/team/timesheet/'); @@ -289,11 +289,11 @@ class TimesheetTeamControllerTest extends ControllerBaseTest $client = $this->getClientForAuthenticatedUser(User::ROLE_SUPER_ADMIN); $em = $this->getEntityManager(); - $user = $this->getUserByRole($em, User::ROLE_TEAMLEAD); + $user = $this->getUserByRole(User::ROLE_TEAMLEAD); $fixture = new TimesheetFixtures(); $fixture->setAmount(10); $fixture->setUser($user); - $this->importFixture($em, $fixture); + $this->importFixture($fixture); $this->assertAccessIsGranted($client, '/team/timesheet/'); @@ -320,7 +320,7 @@ class TimesheetTeamControllerTest extends ControllerBaseTest ]); $this->assertTrue($client->getResponse()->isSuccessful()); - $newUser = $this->getUserByRole($em, User::ROLE_USER); + $newUser = $this->getUserByRole(User::ROLE_USER); $form = $client->getCrawler()->filter('form[name=timesheet_multi_update]')->form(); $client->submit($form, [ 'timesheet_multi_update' => [ diff --git a/tests/Controller/UserControllerTest.php b/tests/Controller/UserControllerTest.php index 606732e7..4b556475 100644 --- a/tests/Controller/UserControllerTest.php +++ b/tests/Controller/UserControllerTest.php @@ -87,7 +87,7 @@ class UserControllerTest extends ControllerBaseTest $expectedTabs = ['#settings', '#password', '#api-token', '#teams', '#roles']; $tabs = $client->getCrawler()->filter('div.nav-tabs-custom ul.nav-tabs li'); - $this->assertEquals(count($expectedTabs), $tabs->count()); + $this->assertEquals(\count($expectedTabs), $tabs->count()); $foundTabs = []; /** @var \DOMElement $tab */ foreach ($tabs->filter('a') as $tab) { @@ -146,15 +146,15 @@ class UserControllerTest extends ControllerBaseTest $client = $this->getClientForAuthenticatedUser(User::ROLE_SUPER_ADMIN); $em = $this->getEntityManager(); - $user = $this->getUserByRole($em, User::ROLE_USER); + $user = $this->getUserByRole(User::ROLE_USER); $fixture = new TimesheetFixtures(); $fixture->setUser($user); $fixture->setAmount(10); - $this->importFixture($client, $fixture); + $this->importFixture($fixture); $timesheets = $em->getRepository(Timesheet::class)->findAll(); - $this->assertEquals(10, count($timesheets)); + $this->assertEquals(10, \count($timesheets)); $this->request($client, '/admin/user/' . $user->getId() . '/delete'); $this->assertTrue($client->getResponse()->isSuccessful()); diff --git a/tests/DataFixtures/ActivityFixtures.php b/tests/DataFixtures/ActivityFixtures.php index 7ad70570..8d3dc466 100644 --- a/tests/DataFixtures/ActivityFixtures.php +++ b/tests/DataFixtures/ActivityFixtures.php @@ -123,7 +123,7 @@ final class ActivityFixtures extends Fixture ; if (null !== $this->callback) { - call_user_func($this->callback, $activity); + \call_user_func($this->callback, $activity); } $manager->persist($activity); } diff --git a/tests/DataFixtures/CustomerFixtures.php b/tests/DataFixtures/CustomerFixtures.php index 2c8b45ee..467b60b9 100644 --- a/tests/DataFixtures/CustomerFixtures.php +++ b/tests/DataFixtures/CustomerFixtures.php @@ -89,7 +89,7 @@ final class CustomerFixtures extends Fixture ; if (null !== $this->callback) { - call_user_func($this->callback, $customer); + \call_user_func($this->callback, $customer); } $manager->persist($customer); } diff --git a/tests/DataFixtures/ProjectFixtures.php b/tests/DataFixtures/ProjectFixtures.php index 17e9ac27..0acde063 100644 --- a/tests/DataFixtures/ProjectFixtures.php +++ b/tests/DataFixtures/ProjectFixtures.php @@ -106,7 +106,7 @@ final class ProjectFixtures extends Fixture ; if (null !== $this->callback) { - call_user_func($this->callback, $project); + \call_user_func($this->callback, $project); } $manager->persist($project); } diff --git a/tests/DataFixtures/TagFixtures.php b/tests/DataFixtures/TagFixtures.php index 29cb7cc7..4389dbf6 100644 --- a/tests/DataFixtures/TagFixtures.php +++ b/tests/DataFixtures/TagFixtures.php @@ -68,7 +68,7 @@ final class TagFixtures extends Fixture $tag = $this->createTagEntry($tagName); if (null !== $this->callback) { - call_user_func($this->callback, $tag); + \call_user_func($this->callback, $tag); } $manager->persist($tag); } diff --git a/tests/DataFixtures/TeamFixtures.php b/tests/DataFixtures/TeamFixtures.php index 3fc280d4..baa9aa4a 100644 --- a/tests/DataFixtures/TeamFixtures.php +++ b/tests/DataFixtures/TeamFixtures.php @@ -101,7 +101,7 @@ final class TeamFixtures extends Fixture $lead = null; while (null === $lead) { $tmp = $user[array_rand($user)]; - if (!in_array($tmp, $this->skipUser)) { + if (!\in_array($tmp, $this->skipUser)) { $lead = $tmp; } } @@ -116,7 +116,7 @@ final class TeamFixtures extends Fixture $userToAdd = null; while (null === $userToAdd) { $tmp = $user[array_rand($user)]; - if (!in_array($tmp, $this->skipUser)) { + if (!\in_array($tmp, $this->skipUser)) { $userToAdd = $tmp; } } @@ -128,7 +128,7 @@ final class TeamFixtures extends Fixture } if (null !== $this->callback) { - call_user_func($this->callback, $team); + \call_user_func($this->callback, $team); } $manager->persist($team); } diff --git a/tests/DataFixtures/TimesheetFixtures.php b/tests/DataFixtures/TimesheetFixtures.php index 881bd85f..0efd0ac7 100644 --- a/tests/DataFixtures/TimesheetFixtures.php +++ b/tests/DataFixtures/TimesheetFixtures.php @@ -241,7 +241,7 @@ final class TimesheetFixtures extends Fixture ); if (null !== $this->callback) { - call_user_func($this->callback, $timesheet); + \call_user_func($this->callback, $timesheet); } $manager->persist($timesheet); } @@ -267,7 +267,7 @@ final class TimesheetFixtures extends Fixture ); if (null !== $this->callback) { - call_user_func($this->callback, $timesheet); + \call_user_func($this->callback, $timesheet); } $manager->persist($timesheet); } @@ -279,7 +279,7 @@ final class TimesheetFixtures extends Fixture { if (true === $this->useTags) { $tagObject = new Tag(); - $tagObject->setName($this->tags[($cnt % count($this->tags))]); + $tagObject->setName($this->tags[($cnt % \count($this->tags))]); return [$tagObject]; } @@ -355,7 +355,7 @@ final class TimesheetFixtures extends Fixture ->setRate($rate) ->setBegin($start); - if (count($tagArray) > 0) { + if (\count($tagArray) > 0) { foreach ($tagArray as $item) { $entry->addTag($item); } diff --git a/tests/Doctrine/SqliteSessionInitSubscriberTest.php b/tests/Doctrine/SqliteSessionInitSubscriberTest.php index fba889b0..6bbc01b5 100644 --- a/tests/Doctrine/SqliteSessionInitSubscriberTest.php +++ b/tests/Doctrine/SqliteSessionInitSubscriberTest.php @@ -26,7 +26,7 @@ class SqliteSessionInitSubscriberTest extends TestCase { $sut = new SqliteSessionInitSubscriber(); $events = $sut->getSubscribedEvents(); - $this->assertTrue(in_array(Events::postConnect, $events)); + $this->assertTrue(\in_array(Events::postConnect, $events)); } public function testPostConnectWithSqlite() diff --git a/tests/Doctrine/TimesheetSubscriberTest.php b/tests/Doctrine/TimesheetSubscriberTest.php index be108046..0bd50ee4 100644 --- a/tests/Doctrine/TimesheetSubscriberTest.php +++ b/tests/Doctrine/TimesheetSubscriberTest.php @@ -22,6 +22,6 @@ class TimesheetSubscriberTest extends TestCase { $sut = new TimesheetSubscriber([]); $events = $sut->getSubscribedEvents(); - $this->assertTrue(in_array(Events::onFlush, $events)); + $this->assertTrue(\in_array(Events::onFlush, $events)); } } diff --git a/tests/Entity/EntityValidationTestTrait.php b/tests/Entity/EntityValidationTestTrait.php index a06623b2..a67cfbd7 100644 --- a/tests/Entity/EntityValidationTestTrait.php +++ b/tests/Entity/EntityValidationTestTrait.php @@ -27,11 +27,11 @@ trait EntityValidationTestTrait $violations = $validator->validate($entity); - if (!is_array($fieldNames)) { + if (!\is_array($fieldNames)) { $fieldNames = [$fieldNames]; } - $expected = count($fieldNames); + $expected = \count($fieldNames); $actual = $violations->count(); $violatedFields = []; @@ -39,11 +39,11 @@ trait EntityValidationTestTrait foreach ($violations as $validation) { $violatedFields[$validation->getPropertyPath()] = $validation->getPropertyPath(); } - $countViolations = count($violatedFields); + $countViolations = \count($violatedFields); foreach ($fieldNames as $id => $propertyPath) { $foundField = false; - if (in_array($propertyPath, $violatedFields)) { + if (\in_array($propertyPath, $violatedFields)) { $foundField = true; unset($violatedFields[$propertyPath]); } diff --git a/tests/Entity/UserTest.php b/tests/Entity/UserTest.php index 1010c7ab..260b6431 100644 --- a/tests/Entity/UserTest.php +++ b/tests/Entity/UserTest.php @@ -184,13 +184,13 @@ class UserTest extends TestCase { $sut = new User(); $sut->setAlias('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); - self::assertEquals(60, strlen($sut->getAlias())); + self::assertEquals(60, \strlen($sut->getAlias())); $sut->setAlias('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxAAAAA'); - self::assertEquals(60, strlen($sut->getAlias())); + self::assertEquals(60, \strlen($sut->getAlias())); $sut->setTitle('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); - self::assertEquals(50, strlen($sut->getTitle())); + self::assertEquals(50, \strlen($sut->getTitle())); $sut->setTitle('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxAAAAAA'); - self::assertEquals(50, strlen($sut->getTitle())); + self::assertEquals(50, \strlen($sut->getTitle())); } public function testPreferencesCollectionIsCreatedOnBrokenUser() diff --git a/tests/EventSubscriber/DashboardSubscriberTest.php b/tests/EventSubscriber/DashboardSubscriberTest.php index 331dd36b..5de4b4a3 100644 --- a/tests/EventSubscriber/DashboardSubscriberTest.php +++ b/tests/EventSubscriber/DashboardSubscriberTest.php @@ -37,9 +37,9 @@ class DashboardSubscriberTest extends TestCase $sut = $this->getSubscriber(false, 13, 28, 37, 5); $event = new DashboardEvent(new User()); - $this->assertEquals(0, count($event->getSections())); + $this->assertEquals(0, \count($event->getSections())); $sut->onDashboardEvent($event); - $this->assertEquals(0, count($event->getSections())); + $this->assertEquals(0, \count($event->getSections())); } public function testWithAdminUser() @@ -47,14 +47,14 @@ class DashboardSubscriberTest extends TestCase $sut = $this->getSubscriber(true, 13, 28, 37, 5); $event = new DashboardEvent(new User()); - $this->assertEquals(0, count($event->getSections())); + $this->assertEquals(0, \count($event->getSections())); $sut->onDashboardEvent($event); $sections = $event->getSections(); $widgets = $sections[0]->getWidgets(); - $this->assertEquals(1, count($sections)); - $this->assertEquals(4, count($widgets)); + $this->assertEquals(1, \count($sections)); + $this->assertEquals(4, \count($widgets)); $this->assertEquals('stats.userTotal', $widgets[0]->getTitle()); $this->assertEquals(13, $widgets[0]->getData()); diff --git a/tests/Export/Renderer/CsvRendererTest.php b/tests/Export/Renderer/CsvRendererTest.php index a935443e..219173df 100644 --- a/tests/Export/Renderer/CsvRendererTest.php +++ b/tests/Export/Renderer/CsvRendererTest.php @@ -101,9 +101,9 @@ class CsvRendererTest extends AbstractRendererTest 20 => 'activity-bar', ]; - self::assertEquals(7, count($all)); + self::assertEquals(7, \count($all)); self::assertEquals($expected, $all[5]); - self::assertEquals(count($expected), count($all[0])); + self::assertEquals(\count($expected), \count($all[0])); self::assertEquals('foo', $all[4][12]); } } diff --git a/tests/Export/ServiceExportTest.php b/tests/Export/ServiceExportTest.php index 1771111f..238791c4 100644 --- a/tests/Export/ServiceExportTest.php +++ b/tests/Export/ServiceExportTest.php @@ -40,7 +40,7 @@ class ServiceExportTest extends TestCase $renderer = new HtmlRenderer($this->createMock(Environment::class), new EventDispatcher(), $this->createMock(ProjectRepository::class)); $sut->addRenderer($renderer); - self::assertEquals(1, count($sut->getRenderer())); + self::assertEquals(1, \count($sut->getRenderer())); self::assertSame($renderer, $sut->getRendererById('html')); } @@ -51,7 +51,7 @@ class ServiceExportTest extends TestCase $exporter = new HtmlExporter($this->createMock(Environment::class), new EventDispatcher()); $sut->addTimesheetExporter($exporter); - self::assertEquals(1, count($sut->getTimesheetExporter())); + self::assertEquals(1, \count($sut->getTimesheetExporter())); self::assertSame($exporter, $sut->getTimesheetExporterById('print')); } } diff --git a/tests/Export/Timesheet/CsvRendererTest.php b/tests/Export/Timesheet/CsvRendererTest.php index 3ee4c536..f4c53371 100644 --- a/tests/Export/Timesheet/CsvRendererTest.php +++ b/tests/Export/Timesheet/CsvRendererTest.php @@ -98,9 +98,9 @@ class CsvRendererTest extends AbstractRendererTest 20 => 'activity-bar', ]; - self::assertEquals(7, count($all)); + self::assertEquals(7, \count($all)); self::assertEquals($expected, $all[5]); - self::assertEquals(count($expected), count($all[0])); + self::assertEquals(\count($expected), \count($all[0])); self::assertEquals('foo', $all[4][12]); } } diff --git a/tests/Invoice/Calculator/AbstractCalculatorTest.php b/tests/Invoice/Calculator/AbstractCalculatorTest.php index e9dccd87..0ff02372 100644 --- a/tests/Invoice/Calculator/AbstractCalculatorTest.php +++ b/tests/Invoice/Calculator/AbstractCalculatorTest.php @@ -34,7 +34,7 @@ abstract class AbstractCalculatorTest extends TestCase $this->assertEquals(0, $sut->getVat()); $this->assertEquals(0, $sut->getSubtotal()); $this->assertEquals(0, $sut->getTimeWorked()); - $this->assertEquals(0, count($sut->getEntries())); + $this->assertEquals(0, \count($sut->getEntries())); $this->assertEquals(0, $sut->getTax()); } @@ -95,7 +95,7 @@ abstract class AbstractCalculatorTest extends TestCase $model->setQuery($query); $sut->setModel($model); - $this->assertEquals(1, count($sut->getEntries())); + $this->assertEquals(1, \count($sut->getEntries())); /** @var Timesheet $result */ $result = $sut->getEntries()[0]; diff --git a/tests/Invoice/Calculator/ActivityInvoiceCalculatorTest.php b/tests/Invoice/Calculator/ActivityInvoiceCalculatorTest.php index ac302c10..f44d7b9f 100644 --- a/tests/Invoice/Calculator/ActivityInvoiceCalculatorTest.php +++ b/tests/Invoice/Calculator/ActivityInvoiceCalculatorTest.php @@ -149,7 +149,7 @@ class ActivityInvoiceCalculatorTest extends AbstractCalculatorTest $this->assertEquals('EUR', $model->getCurrency()); $this->assertEquals(2521.12, $sut->getSubtotal()); $this->assertEquals(6600, $sut->getTimeWorked()); - $this->assertEquals(5, count($sut->getEntries())); + $this->assertEquals(5, \count($sut->getEntries())); $entries = $sut->getEntries(); $this->assertEquals(404.38, $entries[0]->getRate()); diff --git a/tests/Invoice/Calculator/DateInvoiceCalculatorTest.php b/tests/Invoice/Calculator/DateInvoiceCalculatorTest.php index 4db5aae7..3db1045d 100644 --- a/tests/Invoice/Calculator/DateInvoiceCalculatorTest.php +++ b/tests/Invoice/Calculator/DateInvoiceCalculatorTest.php @@ -122,7 +122,7 @@ class DateInvoiceCalculatorTest extends AbstractCalculatorTest $this->assertEquals('EUR', $model->getCurrency()); $this->assertEquals(2521.12, $sut->getSubtotal()); $this->assertEquals(6600, $sut->getTimeWorked()); - $this->assertEquals(3, count($sut->getEntries())); + $this->assertEquals(3, \count($sut->getEntries())); $entries = $sut->getEntries(); self::assertCount(3, $entries); diff --git a/tests/Invoice/Calculator/ProjectInvoiceCalculatorTest.php b/tests/Invoice/Calculator/ProjectInvoiceCalculatorTest.php index 069375d9..a5ec506c 100644 --- a/tests/Invoice/Calculator/ProjectInvoiceCalculatorTest.php +++ b/tests/Invoice/Calculator/ProjectInvoiceCalculatorTest.php @@ -122,7 +122,7 @@ class ProjectInvoiceCalculatorTest extends AbstractCalculatorTest $this->assertEquals('EUR', $model->getCurrency()); $this->assertEquals(2521.12, $sut->getSubtotal()); $this->assertEquals(6600, $sut->getTimeWorked()); - $this->assertEquals(3, count($sut->getEntries())); + $this->assertEquals(3, \count($sut->getEntries())); $entries = $sut->getEntries(); self::assertCount(3, $entries); diff --git a/tests/Invoice/Calculator/ShortInvoiceCalculatorTest.php b/tests/Invoice/Calculator/ShortInvoiceCalculatorTest.php index 3808206b..8f77e52a 100644 --- a/tests/Invoice/Calculator/ShortInvoiceCalculatorTest.php +++ b/tests/Invoice/Calculator/ShortInvoiceCalculatorTest.php @@ -102,7 +102,7 @@ class ShortInvoiceCalculatorTest extends AbstractCalculatorTest $this->assertEquals('EUR', $model->getCurrency()); $this->assertEquals(472.5, $sut->getSubtotal()); $this->assertEquals(5800, $sut->getTimeWorked()); - $this->assertEquals(1, count($sut->getEntries())); + $this->assertEquals(1, \count($sut->getEntries())); /** @var InvoiceItem $result */ $result = $sut->getEntries()[0]; @@ -183,7 +183,7 @@ class ShortInvoiceCalculatorTest extends AbstractCalculatorTest $this->assertEquals('EUR', $model->getCurrency()); $this->assertEquals(488.38, $sut->getSubtotal()); $this->assertEquals(5800, $sut->getTimeWorked()); - $this->assertEquals(1, count($sut->getEntries())); + $this->assertEquals(1, \count($sut->getEntries())); /** @var InvoiceItem $result */ $result = $sut->getEntries()[0]; @@ -262,7 +262,7 @@ class ShortInvoiceCalculatorTest extends AbstractCalculatorTest $this->assertEquals('EUR', $model->getCurrency()); $this->assertEquals(488.38, $sut->getSubtotal()); $this->assertEquals(5400, $sut->getTimeWorked()); - $this->assertEquals(1, count($sut->getEntries())); + $this->assertEquals(1, \count($sut->getEntries())); /** @var InvoiceItem $result */ $result = $sut->getEntries()[0]; diff --git a/tests/Invoice/Calculator/UserInvoiceCalculatorTest.php b/tests/Invoice/Calculator/UserInvoiceCalculatorTest.php index 2dc4e4d7..f74f4c1a 100644 --- a/tests/Invoice/Calculator/UserInvoiceCalculatorTest.php +++ b/tests/Invoice/Calculator/UserInvoiceCalculatorTest.php @@ -120,7 +120,7 @@ class UserInvoiceCalculatorTest extends AbstractCalculatorTest $this->assertEquals('EUR', $model->getCurrency()); $this->assertEquals(2521.12, $sut->getSubtotal()); $this->assertEquals(6600, $sut->getTimeWorked()); - $this->assertEquals(3, count($sut->getEntries())); + $this->assertEquals(3, \count($sut->getEntries())); $entries = $sut->getEntries(); $this->assertEquals(404.38, $entries[0]->getRate()); diff --git a/tests/Invoice/Hydrator/InvoiceItemDefaultHydratorTest.php b/tests/Invoice/Hydrator/InvoiceItemDefaultHydratorTest.php index 496f4cd9..92254b94 100644 --- a/tests/Invoice/Hydrator/InvoiceItemDefaultHydratorTest.php +++ b/tests/Invoice/Hydrator/InvoiceItemDefaultHydratorTest.php @@ -91,6 +91,6 @@ class InvoiceItemDefaultHydratorTest extends TestCase sort($givenKeys); $this->assertEquals($expectedKeys, $givenKeys); - $this->assertEquals(count($keys), count($givenKeys)); + $this->assertEquals(\count($keys), \count($givenKeys)); } } diff --git a/tests/Invoice/NumberGenerator/ConfigurableNumberGeneratorTest.php b/tests/Invoice/NumberGenerator/ConfigurableNumberGeneratorTest.php index 2483513c..96a3a963 100644 --- a/tests/Invoice/NumberGenerator/ConfigurableNumberGeneratorTest.php +++ b/tests/Invoice/NumberGenerator/ConfigurableNumberGeneratorTest.php @@ -68,8 +68,10 @@ class ConfigurableNumberGeneratorTest extends TestCase ['{cd}', '2', $invoiceDate], // number formatting (not testing the lower case versions, as the tests might break depending on the date) ['{date,10}', '0000' . $invoiceDate->format('ymd'), $invoiceDate], + ['{date,a}', $invoiceDate->format('ymd'), $invoiceDate], // invalid formatter length ['{Y,6}', '00' . $invoiceDate->format('Y'), $invoiceDate], ['{M,3}', '0' . $invoiceDate->format('m'), $invoiceDate], + ['{M,#}', $invoiceDate->format('m'), $invoiceDate], // invalid formatter length ['{D,3}', '0' . $invoiceDate->format('d'), $invoiceDate], ['{c,2}', '02', $invoiceDate], ['{cy,2}', '02', $invoiceDate], @@ -81,6 +83,7 @@ class ConfigurableNumberGeneratorTest extends TestCase ['{Y}-{cy}/{m}', $invoiceDate->format('Y') . '-2/' . $invoiceDate->format('n'), $invoiceDate], ['{Y}-{cy}/{m}', $invoiceDate->format('Y') . '-2/' . $invoiceDate->format('n'), $invoiceDate], ['{Y,5}/{cy,5}', '0' . $invoiceDate->format('Y') . '/00002', $invoiceDate], + ['{Y,!}/{cy,o}', $invoiceDate->format('Y') . '/2', $invoiceDate], // invalid formatter length ]; } diff --git a/tests/Invoice/Renderer/DebugRendererTest.php b/tests/Invoice/Renderer/DebugRendererTest.php index 0ad49b0c..e6034430 100644 --- a/tests/Invoice/Renderer/DebugRendererTest.php +++ b/tests/Invoice/Renderer/DebugRendererTest.php @@ -58,9 +58,9 @@ class DebugRendererTest extends TestCase $response = $sut->render($document, $model); $data = json_decode($response->getContent(), true); - $this->assertModelStructure($data['model'], count($model->getQuery()->getProjects()), count($model->getQuery()->getActivities())); + $this->assertModelStructure($data['model'], \count($model->getQuery()->getProjects()), \count($model->getQuery()->getActivities())); $rows = $data['entries']; - $this->assertEquals($expectedRows, count($rows)); + $this->assertEquals($expectedRows, \count($rows)); $i = 0; foreach ($rows as $row) { @@ -246,6 +246,6 @@ class DebugRendererTest extends TestCase sort($givenKeys); $this->assertEquals($expectedKeys, $givenKeys); - $this->assertEquals(count($keys), count($givenKeys)); + $this->assertEquals(\count($keys), \count($givenKeys)); } } diff --git a/tests/Invoice/Renderer/TextRendererTest.php b/tests/Invoice/Renderer/TextRendererTest.php index 3f281c3c..fd49fd3e 100644 --- a/tests/Invoice/Renderer/TextRendererTest.php +++ b/tests/Invoice/Renderer/TextRendererTest.php @@ -74,6 +74,6 @@ class TextRendererTest extends KernelTestCase self::assertStringContainsString(sprintf("%s:\n %s", $key, explode("\n", $value)[0]), $content); } } - self::assertEquals(count($model->getCalculator()->getEntries()), substr_count($content, PHP_EOL . '---' . PHP_EOL)); + self::assertEquals(\count($model->getCalculator()->getEntries()), substr_count($content, PHP_EOL . '---' . PHP_EOL)); } } diff --git a/tests/Invoice/Renderer/XmlRendererTest.php b/tests/Invoice/Renderer/XmlRendererTest.php index 2cf531e0..45e34385 100644 --- a/tests/Invoice/Renderer/XmlRendererTest.php +++ b/tests/Invoice/Renderer/XmlRendererTest.php @@ -78,6 +78,6 @@ class XmlRendererTest extends KernelTestCase } self::assertEquals((string) $expected[$name], (string) $element); } - self::assertEquals(count($model->getCalculator()->getEntries()), count($xml->items->item)); + self::assertEquals(\count($model->getCalculator()->getEntries()), \count($xml->items->item)); } } diff --git a/tests/Invoice/ServiceInvoiceTest.php b/tests/Invoice/ServiceInvoiceTest.php index dac27eef..48739402 100644 --- a/tests/Invoice/ServiceInvoiceTest.php +++ b/tests/Invoice/ServiceInvoiceTest.php @@ -88,12 +88,12 @@ class ServiceInvoiceTest extends TestCase ) ); - $this->assertEquals(1, count($sut->getCalculator())); + $this->assertEquals(1, \count($sut->getCalculator())); $this->assertInstanceOf(DefaultCalculator::class, $sut->getCalculatorByName('default')); - $this->assertEquals(1, count($sut->getNumberGenerator())); + $this->assertEquals(1, \count($sut->getNumberGenerator())); $this->assertInstanceOf(DateNumberGenerator::class, $sut->getNumberGeneratorByName('date')); - $this->assertEquals(1, count($sut->getRenderer())); + $this->assertEquals(1, \count($sut->getRenderer())); } } diff --git a/tests/KernelTestTrait.php b/tests/KernelTestTrait.php index d97293b3..74ad05e2 100644 --- a/tests/KernelTestTrait.php +++ b/tests/KernelTestTrait.php @@ -14,10 +14,8 @@ use App\Entity\User; use Doctrine\Bundle\FixturesBundle\Fixture; use Doctrine\Common\DataFixtures\Executor\ORMExecutor; use Doctrine\Common\DataFixtures\Loader; -use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; -use Symfony\Component\HttpKernel\HttpKernelBrowser; /** * A trait to be used in all tests that extend the KernelTestCase. @@ -33,19 +31,9 @@ trait KernelTestTrait return $this::$container->get('doctrine.orm.entity_manager'); } - /** - * @param HttpKernelBrowser|EntityManager|KernelTestCase $client - * @param Fixture $fixture - */ - protected function importFixture($client, Fixture $fixture) + protected function importFixture(Fixture $fixture) { - if ($client instanceof EntityManager) { - $em = $client; - } elseif ($this instanceof KernelTestCase) { - $em = $this::$container->get('doctrine.orm.entity_manager'); - } else { - throw new \InvalidArgumentException('Need an EntityManager to import fixtures'); - } + $em = $this::$container->get('doctrine.orm.entity_manager'); $loader = new Loader(); $loader->addFixture($fixture); @@ -60,11 +48,10 @@ trait KernelTestTrait } /** - * @param EntityManager $em * @param string $role * @return User|null */ - protected function getUserByRole(EntityManager $em, string $role = User::ROLE_USER) + protected function getUserByRole(string $role = User::ROLE_USER) { $name = null; diff --git a/tests/Model/Statistic/YearTest.php b/tests/Model/Statistic/YearTest.php index 27b534ef..e25405df 100644 --- a/tests/Model/Statistic/YearTest.php +++ b/tests/Model/Statistic/YearTest.php @@ -34,11 +34,11 @@ class YearTest extends TestCase $sut->setMonth(new Month('01')); $sut->setMonth(new Month('02')); $sut->setMonth(new Month('03')); - $this->assertEquals(3, count($sut->getMonths())); + $this->assertEquals(3, \count($sut->getMonths())); $sut->setMonth(new Month('01')); - $this->assertEquals(3, count($sut->getMonths())); + $this->assertEquals(3, \count($sut->getMonths())); $this->assertInstanceOf(Month::class, $sut->getMonth(1)); $this->assertInstanceOf(Month::class, $sut->getMonth(2)); diff --git a/tests/Plugin/PluginManagerTest.php b/tests/Plugin/PluginManagerTest.php index bb0a58c0..51dc7d79 100644 --- a/tests/Plugin/PluginManagerTest.php +++ b/tests/Plugin/PluginManagerTest.php @@ -50,7 +50,7 @@ class PluginManagerTest extends TestCase $sut->addPlugin(new TestPlugin()); // make sure a plugin with the same name is not added twice, the first one wins! - $this->assertEquals(2, count($sut->getPlugins())); + $this->assertEquals(2, \count($sut->getPlugins())); $foo = $sut->getPlugin('foo'); $this->assertInstanceOf(Plugin::class, $foo); diff --git a/tests/Repository/InvoiceDocumentRepositoryTest.php b/tests/Repository/InvoiceDocumentRepositoryTest.php index db0fffc9..5ef6d2a5 100644 --- a/tests/Repository/InvoiceDocumentRepositoryTest.php +++ b/tests/Repository/InvoiceDocumentRepositoryTest.php @@ -44,10 +44,10 @@ class InvoiceDocumentRepositoryTest extends TestCase { $sut = new InvoiceDocumentRepository(self::$defaultDirectories); $all = $sut->findAll(); - $this->assertEquals(count(self::$defaultDocuments), count($all)); + $this->assertEquals(\count(self::$defaultDocuments), \count($all)); foreach ($all as $document) { - $this->assertTrue(in_array($document->getName(), self::$defaultDocuments)); + $this->assertTrue(\in_array($document->getName(), self::$defaultDocuments)); } foreach (self::$defaultDocuments as $filename) { diff --git a/tests/Repository/Query/BaseFormTypeQueryTest.php b/tests/Repository/Query/BaseFormTypeQueryTest.php index 9fa7e65d..236a3a3c 100644 --- a/tests/Repository/Query/BaseFormTypeQueryTest.php +++ b/tests/Repository/Query/BaseFormTypeQueryTest.php @@ -44,11 +44,11 @@ abstract class BaseFormTypeQueryTest extends TestCase self::assertEmpty($sut->getTeams()); self::assertInstanceOf(BaseFormTypeQuery::class, $sut->addTeam(new Team())); - self::assertEquals(1, count($sut->getTeams())); + self::assertEquals(1, \count($sut->getTeams())); $team = new Team(); self::assertInstanceOf(BaseFormTypeQuery::class, $sut->addTeam($team)); - self::assertEquals(1, count($sut->getTeams())); + self::assertEquals(1, \count($sut->getTeams())); self::assertSame($team, $sut->getTeams()[0]); } diff --git a/tests/Repository/Query/BaseQueryTest.php b/tests/Repository/Query/BaseQueryTest.php index 577d914e..a8de6998 100644 --- a/tests/Repository/Query/BaseQueryTest.php +++ b/tests/Repository/Query/BaseQueryTest.php @@ -105,7 +105,7 @@ class BaseQueryTest extends TestCase self::assertEmpty($sut->getTeams()); self::assertInstanceOf(BaseQuery::class, $sut->addTeam(new Team())); - self::assertEquals(1, count($sut->getTeams())); + self::assertEquals(1, \count($sut->getTeams())); $sut->setTeams(null); self::assertEmpty($sut->getTeams()); @@ -114,7 +114,7 @@ class BaseQueryTest extends TestCase $team = new Team(); self::assertInstanceOf(BaseQuery::class, $sut->setTeams([$team])); - self::assertEquals(1, count($sut->getTeams())); + self::assertEquals(1, \count($sut->getTeams())); self::assertSame($team, $sut->getTeams()[0]); } diff --git a/tests/Repository/TagRepositoryTest.php b/tests/Repository/TagRepositoryTest.php index 036ef266..20a1cfd9 100644 --- a/tests/Repository/TagRepositoryTest.php +++ b/tests/Repository/TagRepositoryTest.php @@ -25,7 +25,7 @@ class TagRepositoryTest extends AbstractRepositoryTest $em = $this->getEntityManager(); $data = new TagFixtures(); $data->setTagArray(['Test', 'Travel', '#2018-001', '#2018-002', '#2018-003', '#2018-004', '#2018-005', 'Administration', 'Support', 'PR', '#2018-012']); - $this->importFixture($em, $data); + $this->importFixture($data); } public function testFindIds() @@ -37,7 +37,7 @@ class TagRepositoryTest extends AbstractRepositoryTest $result = $repository->findIdsByTagNameList('2018,Test'); $this->assertIsArray($result); $this->assertNotEmpty($result); - $this->assertEquals(7, count($result)); + $this->assertEquals(7, \count($result)); $this->assertEquals(1, $result[0]); $this->assertEquals(3, $result[1]); $this->assertEquals(4, $result[2]); @@ -56,7 +56,7 @@ class TagRepositoryTest extends AbstractRepositoryTest $result = $repository->findIdsByTagNameList('Simply'); $this->assertIsArray($result); $this->assertEmpty($result); - $this->assertEquals(0, count($result)); + $this->assertEquals(0, \count($result)); } public function testFindAllTagNames() @@ -68,7 +68,7 @@ class TagRepositoryTest extends AbstractRepositoryTest $result = $repository->findAllTagNames('2018'); $this->assertIsArray($result); $this->assertNotEmpty($result); - $this->assertEquals(6, count($result)); + $this->assertEquals(6, \count($result)); $this->assertEquals('#2018-001', $result[0]); $this->assertEquals('#2018-002', $result[1]); $this->assertEquals('#2018-003', $result[2]); @@ -86,6 +86,6 @@ class TagRepositoryTest extends AbstractRepositoryTest $result = $repository->findAllTagNames('Nothing'); $this->assertIsArray($result); $this->assertEmpty($result); - $this->assertEquals(0, count($result)); + $this->assertEquals(0, \count($result)); } } diff --git a/tests/Repository/TimesheetRepositoryTest.php b/tests/Repository/TimesheetRepositoryTest.php index 1ad7272d..285fd81c 100644 --- a/tests/Repository/TimesheetRepositoryTest.php +++ b/tests/Repository/TimesheetRepositoryTest.php @@ -46,7 +46,7 @@ class TimesheetRepositoryTest extends AbstractRepositoryTest public function testStoppedEntriesCannotBeStoppedAgain() { $em = $this->getEntityManager(); - $user = $this->getUserByRole($em, User::ROLE_USER); + $user = $this->getUserByRole(User::ROLE_USER); /** @var TimesheetRepository $repository */ $repository = $em->getRepository(Timesheet::class); @@ -54,7 +54,7 @@ class TimesheetRepositoryTest extends AbstractRepositoryTest $fixtures->setUser($user); $fixtures->setAmount(1); - $this->importFixture($em, $fixtures); + $this->importFixture($fixtures); $query = new TimesheetQuery(); $query->setUser($user); @@ -75,14 +75,14 @@ class TimesheetRepositoryTest extends AbstractRepositoryTest public function testStopRecording() { $em = $this->getEntityManager(); - $user = $this->getUserByRole($em, User::ROLE_USER); + $user = $this->getUserByRole(User::ROLE_USER); /** @var TimesheetRepository $repository */ $repository = $em->getRepository(Timesheet::class); - $fixtures = new TimesheetFixtures(); - $fixtures->setUser($user); - $fixtures->setAmountRunning(1); - $this->importFixture($em, $fixtures); + $fixture = new TimesheetFixtures(); + $fixture->setUser($user); + $fixture->setAmountRunning(1); + $this->importFixture($fixture); $timesheet = $repository->find(1); $this->assertInstanceOf(Timesheet::class, $timesheet); @@ -103,7 +103,7 @@ class TimesheetRepositoryTest extends AbstractRepositoryTest $projectRepository = $em->getRepository(Project::class); $project = $projectRepository->find(1); - $user = $this->getUserByRole($em, User::ROLE_USER); + $user = $this->getUserByRole(User::ROLE_USER); /** @var TimesheetRepository $repository */ $repository = $em->getRepository(Timesheet::class); $timesheet = new Timesheet(); @@ -130,7 +130,7 @@ class TimesheetRepositoryTest extends AbstractRepositoryTest $projectRepository = $em->getRepository(Project::class); $project = $projectRepository->find(1); - $user = $this->getUserByRole($em, User::ROLE_USER); + $user = $this->getUserByRole(User::ROLE_USER); /** @var TimesheetRepository $repository */ $repository = $em->getRepository(Timesheet::class); $tagOne = new Tag(); diff --git a/tests/Saml/Logout/SamlLogoutHandlerTest.php b/tests/Saml/Logout/SamlLogoutHandlerTest.php index a4b5cb3d..dcae9ef9 100644 --- a/tests/Saml/Logout/SamlLogoutHandlerTest.php +++ b/tests/Saml/Logout/SamlLogoutHandlerTest.php @@ -43,7 +43,7 @@ class SamlLogoutHandlerTest extends TestCase $auth->expects($this->once())->method('processSLO')->willThrowException(new Error('blub')); $auth->expects($this->once())->method('getSLOurl')->willReturn('/logout'); $auth->expects($this->once())->method('logout')->willReturnCallback(function () { - $args = func_get_args(); + $args = \func_get_args(); self::assertEquals(null, $args[0]); self::assertEquals([], $args[1]); self::assertEquals('tony', $args[2]); diff --git a/tests/Saml/Security/SamlAuthenticationSuccessHandlerTest.php b/tests/Saml/Security/SamlAuthenticationSuccessHandlerTest.php index ebe268ec..487fae3f 100644 --- a/tests/Saml/Security/SamlAuthenticationSuccessHandlerTest.php +++ b/tests/Saml/Security/SamlAuthenticationSuccessHandlerTest.php @@ -95,7 +95,7 @@ class SamlAuthenticationSuccessHandlerTest extends TestCase $options = $reflection->getProperty('options'); $options->setAccessible(true); $arr = $options->getValue($handler); - if (!is_array($arr) || !isset($arr[$name])) { + if (!\is_array($arr) || !isset($arr[$name])) { return $default; } diff --git a/tests/Twig/AvatarExtensionTest.php b/tests/Twig/AvatarExtensionTest.php index 98a52b28..e874d9e9 100644 --- a/tests/Twig/AvatarExtensionTest.php +++ b/tests/Twig/AvatarExtensionTest.php @@ -41,7 +41,7 @@ class AvatarExtensionTest extends TestCase $functions = ['avatar']; $sut = $this->getSut(0); $twigFunctions = $sut->getFunctions(); - self::assertCount(count($functions), $twigFunctions); + self::assertCount(\count($functions), $twigFunctions); $i = 0; /** @var TwigFunction $filter */ foreach ($twigFunctions as $filter) { diff --git a/tests/Twig/ConfigExtensionTest.php b/tests/Twig/ConfigExtensionTest.php index d1bae8e2..8aabd518 100644 --- a/tests/Twig/ConfigExtensionTest.php +++ b/tests/Twig/ConfigExtensionTest.php @@ -33,7 +33,7 @@ class ConfigExtensionTest extends TestCase $functions = ['theme_config']; $sut = $this->getSut([], []); $twigFunctions = $sut->getFunctions(); - self::assertCount(count($functions), $twigFunctions); + self::assertCount(\count($functions), $twigFunctions); $i = 0; /** @var TwigFunction $filter */ foreach ($twigFunctions as $filter) { diff --git a/tests/Twig/DatatableExtensionsTest.php b/tests/Twig/DatatableExtensionsTest.php index bce29d8f..dd6ce134 100644 --- a/tests/Twig/DatatableExtensionsTest.php +++ b/tests/Twig/DatatableExtensionsTest.php @@ -35,7 +35,7 @@ class DatatableExtensionsTest extends TestCase $functions = ['is_visible_column', 'is_datatable_configured']; $sut = $this->getSut('de'); $twigFunctions = $sut->getFunctions(); - $this->assertCount(count($functions), $twigFunctions); + $this->assertCount(\count($functions), $twigFunctions); $i = 0; /** @var TwigFunction $function */ foreach ($twigFunctions as $function) { diff --git a/tests/Twig/DateExtensionsTest.php b/tests/Twig/DateExtensionsTest.php index 1525b969..d25b4d7d 100644 --- a/tests/Twig/DateExtensionsTest.php +++ b/tests/Twig/DateExtensionsTest.php @@ -45,7 +45,7 @@ class DateExtensionsTest extends TestCase $filters = ['month_name', 'date_short', 'date_time', 'date_full', 'date_format', 'time', 'hour24']; $sut = $this->getSut('de', []); $twigFilters = $sut->getFilters(); - $this->assertCount(count($filters), $twigFilters); + $this->assertCount(\count($filters), $twigFilters); $i = 0; foreach ($twigFilters as $filter) { $this->assertInstanceOf(TwigFilter::class, $filter); @@ -58,7 +58,7 @@ class DateExtensionsTest extends TestCase $functions = ['get_format_duration']; $sut = $this->getSut('de', []); $twigFunctions = $sut->getFunctions(); - $this->assertCount(count($functions), $twigFunctions); + $this->assertCount(\count($functions), $twigFunctions); $i = 0; /** @var TwigFunction $filter */ foreach ($twigFunctions as $filter) { diff --git a/tests/Twig/EncoreExtensionTest.php b/tests/Twig/EncoreExtensionTest.php index fa9ba6e8..524910ed 100644 --- a/tests/Twig/EncoreExtensionTest.php +++ b/tests/Twig/EncoreExtensionTest.php @@ -42,7 +42,7 @@ class EncoreExtensionTest extends TestCase $functions = ['encore_entry_css_source']; $sut = $this->getSut(); $twigFunctions = $sut->getFunctions(); - self::assertCount(count($functions), $twigFunctions); + self::assertCount(\count($functions), $twigFunctions); $i = 0; /** @var TwigFunction $filter */ foreach ($twigFunctions as $filter) { diff --git a/tests/Twig/ExtensionsTest.php b/tests/Twig/ExtensionsTest.php index 92a1be91..aeea4f81 100644 --- a/tests/Twig/ExtensionsTest.php +++ b/tests/Twig/ExtensionsTest.php @@ -53,7 +53,7 @@ class ExtensionsTest extends TestCase $filters = ['duration', 'duration_decimal', 'money', 'currency', 'country', 'language', 'amount', 'docu_link', 'multiline_indent']; $sut = $this->getSut($this->localeDe); $twigFilters = $sut->getFilters(); - $this->assertCount(count($filters), $twigFilters); + $this->assertCount(\count($filters), $twigFilters); $i = 0; /** @var TwigFilter $filter */ foreach ($twigFilters as $filter) { @@ -67,7 +67,7 @@ class ExtensionsTest extends TestCase $functions = ['locales', 'class_name']; $sut = $this->getSut($this->localeDe); $twigFunctions = $sut->getFunctions(); - $this->assertCount(count($functions), $twigFunctions); + $this->assertCount(\count($functions), $twigFunctions); $i = 0; /** @var TwigFunction $filter */ foreach ($twigFunctions as $filter) { diff --git a/tests/Twig/IconExtensionTest.php b/tests/Twig/IconExtensionTest.php index 7bccc0fe..aa3c9a72 100644 --- a/tests/Twig/IconExtensionTest.php +++ b/tests/Twig/IconExtensionTest.php @@ -23,7 +23,7 @@ class IconExtensionTest extends TestCase $filters = ['icon']; $sut = new IconExtension(); $twigFilters = $sut->getFilters(); - $this->assertCount(count($filters), $twigFilters); + $this->assertCount(\count($filters), $twigFilters); $i = 0; /** @var TwigFilter $filter */ foreach ($twigFilters as $filter) { diff --git a/tests/Twig/PaginationExtensionTest.php b/tests/Twig/PaginationExtensionTest.php index 623efc4f..3b36f330 100644 --- a/tests/Twig/PaginationExtensionTest.php +++ b/tests/Twig/PaginationExtensionTest.php @@ -50,7 +50,7 @@ class PaginationExtensionTest extends TestCase $functions = ['pagerfanta', 'pagination']; $sut = $this->getSut(); $twigFunctions = $sut->getFunctions(); - self::assertCount(count($functions), $twigFunctions); + self::assertCount(\count($functions), $twigFunctions); $i = 0; /** @var TwigFunction $filter */ foreach ($twigFunctions as $filter) { diff --git a/tests/Twig/TitleExtensionTest.php b/tests/Twig/TitleExtensionTest.php index 808672eb..c6261b4c 100644 --- a/tests/Twig/TitleExtensionTest.php +++ b/tests/Twig/TitleExtensionTest.php @@ -43,7 +43,7 @@ class TitleExtensionTest extends TestCase $functions = ['get_title']; $sut = $this->getSut(); $twigFunctions = $sut->getFunctions(); - $this->assertCount(count($functions), $twigFunctions); + $this->assertCount(\count($functions), $twigFunctions); $i = 0; /** @var TwigFunction $function */ foreach ($twigFunctions as $function) { diff --git a/tests/Twig/WidgetExtensionTest.php b/tests/Twig/WidgetExtensionTest.php index 956e8b39..c1b7b555 100644 --- a/tests/Twig/WidgetExtensionTest.php +++ b/tests/Twig/WidgetExtensionTest.php @@ -43,7 +43,7 @@ class WidgetExtensionTest extends TestCase $functions = ['render_widget']; $sut = $this->getSut(); $twigFunctions = $sut->getFunctions(); - $this->assertCount(count($functions), $twigFunctions); + $this->assertCount(\count($functions), $twigFunctions); $i = 0; /** @var TwigFunction $function */ foreach ($twigFunctions as $function) { diff --git a/tests/Validator/Constraints/DateTimeFormatValidatorTest.php b/tests/Validator/Constraints/DateTimeFormatValidatorTest.php index bf6b2c25..7863869c 100644 --- a/tests/Validator/Constraints/DateTimeFormatValidatorTest.php +++ b/tests/Validator/Constraints/DateTimeFormatValidatorTest.php @@ -76,7 +76,7 @@ class DateTimeFormatValidatorTest extends ConstraintValidatorTestCase $this->validator->validate($input, $constraint); - $expectedFormat = is_string($input) ? '"' . $input . '"' : $input; + $expectedFormat = \is_string($input) ? '"' . $input . '"' : $input; $this->buildViolation('The given value is not a valid datetime format.') ->setCode(DateTimeFormat::INVALID_FORMAT) diff --git a/tests/Validator/Constraints/DurationValidatorTest.php b/tests/Validator/Constraints/DurationValidatorTest.php index 0c4493dc..da21de03 100644 --- a/tests/Validator/Constraints/DurationValidatorTest.php +++ b/tests/Validator/Constraints/DurationValidatorTest.php @@ -92,7 +92,7 @@ class DurationValidatorTest extends ConstraintValidatorTestCase $this->validator->validate($input, $constraint); - $expectedFormat = is_string($input) ? '"' . $input . '"' : $input; + $expectedFormat = \is_string($input) ? '"' . $input . '"' : $input; $this->buildViolation('myMessage') ->setParameter('{{ value }}', $expectedFormat) diff --git a/tests/Validator/Constraints/RoleValidatorTest.php b/tests/Validator/Constraints/RoleValidatorTest.php index 0fd9d757..cec4ead1 100644 --- a/tests/Validator/Constraints/RoleValidatorTest.php +++ b/tests/Validator/Constraints/RoleValidatorTest.php @@ -92,7 +92,7 @@ class RoleValidatorTest extends ConstraintValidatorTestCase $this->validator->validate($role, $constraint); - $expectedFormat = is_string($role) ? '"' . $role . '"' : $role; + $expectedFormat = \is_string($role) ? '"' . $role . '"' : $role; $this->buildViolation('myMessage') ->setParameter('{{ value }}', $expectedFormat) diff --git a/tests/Widget/Renderer/SimpleWidgetRendererTest.php b/tests/Widget/Renderer/SimpleWidgetRendererTest.php index 4c9602cf..c26653c8 100644 --- a/tests/Widget/Renderer/SimpleWidgetRendererTest.php +++ b/tests/Widget/Renderer/SimpleWidgetRendererTest.php @@ -41,7 +41,7 @@ class SimpleWidgetRendererTest extends TestCase $sut = new SimpleWidgetRenderer($twig); - $data = uniqid(get_class($widget)); + $data = uniqid(\get_class($widget)); $widget->setData($data); $result = $sut->render($widget, ['color' => $color]); $result = json_decode($result, true);