diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index b89bae1f..9e877561 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -49,44 +49,69 @@ true ) ->addRules([ - '@PHP81Migration' => true, - '@PSR12' => true, - 'declare_strict_types' => true, - //'fully_qualified_strict_types' => true, // conflicts currently with Rector - 'global_namespace_import' => [ - 'import_classes' => true, - 'import_constants' => true, - 'import_functions' => true, + '@DoctrineAnnotation' => true, + // @todo: Switch to @PER-CS2.0 once php-cs-fixer's todo list is done: https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7247 + '@PER-CS1.0' => true, + 'array_indentation' => true, + 'array_syntax' => ['syntax' => 'short'], + 'cast_spaces' => ['space' => 'none'], + // @todo: Can be dropped once we enable @PER-CS2.0 + 'concat_space' => ['spacing' => 'one'], + 'declare_equal_normalize' => ['space' => 'none'], + 'declare_parentheses' => true, + 'dir_constant' => true, + // @todo: Can be dropped once we enable @PER-CS2.0 + 'function_declaration' => [ + 'closure_fn_spacing' => 'none', ], - 'no_unneeded_import_alias' => true, - 'phpdoc_align' => true, - 'phpdoc_annotation_without_dot' => true, - 'phpdoc_indent' => true, - 'phpdoc_inline_tag_normalizer' => true, - 'phpdoc_line_span' => true, - 'phpdoc_no_useless_inheritdoc' => true, - 'phpdoc_order' => true, - 'phpdoc_order_by_value' => true, - 'phpdoc_separation' => true, - 'phpdoc_single_line_var_spacing' => true, - 'phpdoc_summary' => true, - 'phpdoc_tag_casing' => true, - 'phpdoc_tag_type' => true, - 'phpdoc_to_comment' => [ - 'ignored_tags' => [ - 'phpstan-ignore-line', - 'phpstan-ignore-next-line', - 'todo', - ], + 'function_to_constant' => ['functions' => ['get_called_class', 'get_class', 'get_class_this', 'php_sapi_name', 'phpversion', 'pi']], + 'type_declaration_spaces' => true, + 'global_namespace_import' => ['import_classes' => false, 'import_constants' => false, 'import_functions' => false], + 'list_syntax' => ['syntax' => 'short'], + // @todo: Can be dropped once we enable @PER-CS2.0 + 'method_argument_space' => true, + 'modernize_strpos' => true, + 'modernize_types_casting' => true, + 'native_function_casing' => true, + 'no_alias_functions' => true, + 'no_blank_lines_after_phpdoc' => true, + 'no_empty_phpdoc' => true, + 'no_empty_statement' => true, + 'no_extra_blank_lines' => true, + 'no_leading_namespace_whitespace' => true, + 'no_null_property_initialization' => true, + 'no_short_bool_cast' => true, + 'no_singleline_whitespace_before_semicolons' => true, + 'no_superfluous_elseif' => true, + 'no_trailing_comma_in_singleline' => true, + 'no_unneeded_control_parentheses' => true, + 'no_unused_imports' => true, + 'no_useless_else' => true, + 'no_useless_nullsafe_operator' => true, + 'nullable_type_declaration' => [ + 'syntax' => 'question_mark', ], - 'phpdoc_trim_consecutive_blank_line_separation' => true, - 'phpdoc_types_order' => [ - 'null_adjustment' => 'always_last', - 'sort_algorithm' => 'alpha', - ], - 'phpdoc_var_annotation_correct_order' => true, - 'phpdoc_var_without_name' => true, - 'self_accessor' => true, + 'nullable_type_declaration_for_default_null_value' => true, + 'ordered_imports' => ['imports_order' => ['class', 'function', 'const'], 'sort_algorithm' => 'alpha'], + 'php_unit_construct' => ['assertions' => ['assertEquals', 'assertSame', 'assertNotEquals', 'assertNotSame']], + 'php_unit_mock_short_will_return' => true, + 'php_unit_test_case_static_method_calls' => ['call_type' => 'self'], + 'phpdoc_no_access' => true, + 'phpdoc_no_empty_return' => true, + 'phpdoc_no_package' => true, + 'phpdoc_scalar' => true, + 'phpdoc_trim' => true, + 'phpdoc_types' => true, + 'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'], + 'return_type_declaration' => ['space_before' => 'none'], + 'single_quote' => true, + 'single_space_around_construct' => true, + 'single_line_comment_style' => ['comment_types' => ['hash']], + // @todo: Can be dropped once we enable @PER-CS2.0 + 'single_line_empty_body' => true, + 'trailing_comma_in_multiline' => ['elements' => ['arrays']], + 'whitespace_after_comma_in_array' => ['ensure_single_space' => true], + 'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false], ]) ; $config->getFinder() diff --git a/src/Command/ExtensionsTerJsonCreateCommand.php b/src/Command/ExtensionsTerJsonCreateCommand.php index 64dc8dcc..6d76bd48 100644 --- a/src/Command/ExtensionsTerJsonCreateCommand.php +++ b/src/Command/ExtensionsTerJsonCreateCommand.php @@ -25,18 +25,12 @@ use Composer\Semver\Semver; use Composer\Semver\VersionParser; -use DateTimeImmutable; use GuzzleHttp\Client; -use RuntimeException; -use SimpleXMLElement; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use function is_array; -use function is_string; - /** * @codeCoverageIgnore */ @@ -83,12 +77,12 @@ class ExtensionsTerJsonCreateCommand extends Command private const ALIASES_FILE = 'aliases.json'; /** - * @var array + * @var array */ protected array $extensions = []; /** - * @var array + * @var array */ protected array $extensionKeys = []; @@ -199,7 +193,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int /** @var string $outputDir */ $outputDir = $input->getArgument('output-dir'); if (($outputPath = realpath($outputDir)) === false) { - throw new RuntimeException(\sprintf('Path "%s" not found.', $outputDir), 1_660_250_640); + throw new \RuntimeException(\sprintf('Path "%s" not found.', $outputDir), 1_660_250_640); } $this->outputDir = $outputPath; @@ -241,27 +235,27 @@ protected function fetchComposerNames(): void ); $responseBody = $response->getBody()->getContents(); - if (!is_array($json = \json_decode($responseBody, true, 512, JSON_THROW_ON_ERROR))) { - throw new RuntimeException('Invalid response.', 1_660_251_247); + if (!\is_array($json = \json_decode($responseBody, true, 512, JSON_THROW_ON_ERROR))) { + throw new \RuntimeException('Invalid response.', 1_660_251_247); } if ($json['meta'] !== null) { - throw new RuntimeException($json['meta']['error']); + throw new \RuntimeException($json['meta']['error']); } - if (is_array($json['data'])) { + if (\is_array($json['data'])) { // Assign core extensions foreach (self::$coreExtensions as $extKey => $composerName) { $json['data'][$extKey]['composer_name'] = $composerName; } foreach ($json['data'] as $extKey => $settings) { - if (!is_string($extKey)) { - throw new RuntimeException('Invalid extension key.', 1_660_251_470); + if (!\is_string($extKey)) { + throw new \RuntimeException('Invalid extension key.', 1_660_251_470); } - if (!is_string($settings['composer_name'])) { - throw new RuntimeException('Invalid package name.', 1_660_251_471); + if (!\is_string($settings['composer_name'])) { + throw new \RuntimeException('Invalid package name.', 1_660_251_471); } self::$abandonedExtensionKeys[$extKey] = $settings['composer_name']; @@ -287,7 +281,7 @@ protected function saveAliases(): string } /** - * @return SimpleXMLElement[] + * @return \SimpleXMLElement[] */ protected function getExtensions(): array { @@ -302,10 +296,10 @@ protected function getExtensions(): array ] ); if (($extensionsXml = gzdecode($response->getBody()->getContents())) === false) { - throw new RuntimeException('Invalid response.', 1_660_251_597); + throw new \RuntimeException('Invalid response.', 1_660_251_597); } - $extensionsObject = new SimpleXMLElement($extensionsXml); + $extensionsObject = new \SimpleXMLElement($extensionsXml); $this->extensions = $extensionsObject->xpath('/extensions/extension'); $this->initExtensionKeys($this->extensions); } @@ -314,7 +308,7 @@ protected function getExtensions(): array } /** - * @param SimpleXMLElement[] $extensions + * @param \SimpleXMLElement[] $extensions */ protected function initExtensionKeys(array $extensions): void { @@ -328,7 +322,7 @@ protected function initExtensionKeys(array $extensions): void } /** - * @param SimpleXMLElement[] $extensions + * @param \SimpleXMLElement[] $extensions * * @return array&mixed[]>&mixed[]> */ @@ -336,7 +330,7 @@ protected function getPackages(array $extensions): array { $packages = []; //$quarter = mktime(0, 0, 0, floor((date('m') - 1) / 3) * 3 + 1, 1, date('Y')); - $dateTimeToday = new DateTimeImmutable(); + $dateTimeToday = new \DateTimeImmutable(); $new = $dateTimeToday->modify('yesterday')->getTimestamp(); foreach ($extensions as $extension) { @@ -410,7 +404,7 @@ protected function getPackages(array $extensions): array * dist: array * }|array{} */ - protected function getPackageArray(SimpleXMLElement $extension, SimpleXMLElement $version): array + protected function getPackageArray(\SimpleXMLElement $extension, \SimpleXMLElement $version): array { $extKey = (string)$extension['extensionkey']; $autoload = [ @@ -424,7 +418,7 @@ protected function getPackageArray(SimpleXMLElement $extension, SimpleXMLElement ]; if ($version->composerinfo !== null) { $composerInfo = json_decode((string)$version->composerinfo, true, 512); - if (is_array($composerInfo) && is_array($composerInfo['autoload'] ?? null)) { + if (\is_array($composerInfo) && \is_array($composerInfo['autoload'] ?? null)) { $autoload = $composerInfo['autoload']; } } @@ -463,7 +457,7 @@ protected function getPackageArray(SimpleXMLElement $extension, SimpleXMLElement $dependencies = unserialize((string)$version->dependencies); - if (!is_array($dependencies)) { + if (!\is_array($dependencies)) { // Ignore extensions with invalid dependencies return []; } diff --git a/src/Command/ListMissingDownloadsCommand.php b/src/Command/ListMissingDownloadsCommand.php index 011dd70f..4760e284 100644 --- a/src/Command/ListMissingDownloadsCommand.php +++ b/src/Command/ListMissingDownloadsCommand.php @@ -30,7 +30,6 @@ use Symfony\Component\HttpClient\Exception\RedirectionException; use Symfony\Component\HttpClient\HttpClient; use Symfony\Component\Yaml\Yaml; -use Exception; /** * @codeCoverageIgnore @@ -115,7 +114,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $yaml = Yaml::dump($result, 4); file_put_contents('missing-downloads.yaml', $yaml); } else { - throw new Exception( + throw new \Exception( 'Invalid response with status code ' . $statusCode . ' and content type ' . $contentType ); } @@ -146,7 +145,7 @@ private function getFixedUrl(string $url, string $release, int $format): string } return 'redirect failed for ' . $url; - } catch (Exception $exception) { + } catch (\Exception $exception) { return $exception->getMessage(); } } @@ -158,7 +157,7 @@ private function checkRedirect(string $url): bool try { $client->request('GET', $url, ['max_redirects' => 0]); - throw new Exception('something went wrong while calling ' . $url); + throw new \Exception('something went wrong while calling ' . $url); } catch (RedirectionException) { return true; } catch (ClientException) { diff --git a/src/Command/SatisBuildCommand.php b/src/Command/SatisBuildCommand.php index 0a82d97b..41b236b7 100644 --- a/src/Command/SatisBuildCommand.php +++ b/src/Command/SatisBuildCommand.php @@ -23,7 +23,6 @@ namespace App\Command; -use DateTimeImmutable; use Symfony\Component\Console\Application; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\ArrayInput; @@ -32,7 +31,6 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Process\Process; -use RuntimeException; /** * @codeCoverageIgnore @@ -99,12 +97,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int /** @var bool $autoBuildAll */ $autoBuildAll = $input->getOption('auto'); - if ($autoBuildAll && (new DateTimeImmutable())->format('G') === '3') { + if ($autoBuildAll && (new \DateTimeImmutable())->format('G') === '3') { $buildAll = \true; } if (!($application = $this->getApplication()) instanceof Application) { - throw new RuntimeException('Application is not initialized.', 1_660_125_012); + throw new \RuntimeException('Application is not initialized.', 1_660_125_012); } // Run extensions:ter:json:create diff --git a/src/Command/SatisJsonCreateCommand.php b/src/Command/SatisJsonCreateCommand.php index b949fb2e..5a9d45e6 100644 --- a/src/Command/SatisJsonCreateCommand.php +++ b/src/Command/SatisJsonCreateCommand.php @@ -28,7 +28,6 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use RuntimeException; /** * @codeCoverageIgnore @@ -75,7 +74,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } if (!is_writable($configFile)) { - throw new RuntimeException(sprintf('File "%s" is not writable', $configFile), 1_438_441_994); + throw new \RuntimeException(sprintf('File "%s" is not writable', $configFile), 1_438_441_994); } $repositories = [ @@ -96,7 +95,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $satis->useProviders(); if (file_put_contents($configFile, (string)$satis) === false) { - throw new RuntimeException(sprintf('File "%s" could not be written, reason unknown', $configFile), 1_438_442_238); + throw new \RuntimeException(sprintf('File "%s" could not be written, reason unknown', $configFile), 1_438_442_238); } $output->writeln(sprintf('Successfully created "%s" with repository dir "%s"', $configFile, $repositoryDir)); diff --git a/src/Controller/Admin/DashboardController.php b/src/Controller/Admin/DashboardController.php index 96d0b9de..a40ed37a 100644 --- a/src/Controller/Admin/DashboardController.php +++ b/src/Controller/Admin/DashboardController.php @@ -32,7 +32,6 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; -use Iterator; #[IsGranted('ROLE_ADMIN')] class DashboardController extends AbstractDashboardController @@ -50,7 +49,7 @@ public function configureDashboard(): Dashboard } /** - * @return Iterator<\EasyCorp\Bundle\EasyAdminBundle\Config\Menu\CrudMenuItem|\EasyCorp\Bundle\EasyAdminBundle\Config\Menu\DashboardMenuItem> + * @return \Iterator<\EasyCorp\Bundle\EasyAdminBundle\Config\Menu\CrudMenuItem|\EasyCorp\Bundle\EasyAdminBundle\Config\Menu\DashboardMenuItem> */ public function configureMenuItems(): iterable { diff --git a/src/Controller/Admin/MajorVersionCrudController.php b/src/Controller/Admin/MajorVersionCrudController.php index ae55fc0a..28152ee2 100644 --- a/src/Controller/Admin/MajorVersionCrudController.php +++ b/src/Controller/Admin/MajorVersionCrudController.php @@ -32,10 +32,8 @@ use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField; use EasyCorp\Bundle\EasyAdminBundle\Field\IdField; use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; -use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField; - -use function in_array; +use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; class MajorVersionCrudController extends AbstractCrudController { @@ -64,7 +62,7 @@ public function configureFields(string $pageName): iterable yield TextField::new('title', 'Title'); yield TextField::new('subtitle', 'Subtitle'); - if (in_array($pageName, [Crud::PAGE_DETAIL, Crud::PAGE_EDIT, Crud::PAGE_NEW], true)) { + if (\in_array($pageName, [Crud::PAGE_DETAIL, Crud::PAGE_EDIT, Crud::PAGE_NEW], true)) { yield TextareaField::new('description', 'Description'); } diff --git a/src/Controller/Admin/ReleaseCrudController.php b/src/Controller/Admin/ReleaseCrudController.php index 9d059514..dce6d2be 100644 --- a/src/Controller/Admin/ReleaseCrudController.php +++ b/src/Controller/Admin/ReleaseCrudController.php @@ -35,13 +35,10 @@ use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField; use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField; use EasyCorp\Bundle\EasyAdminBundle\Field\IdField; -use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField; +use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; use EasyCorp\Bundle\EasyAdminBundle\Field\UrlField; -use function array_flip; -use function in_array; - class ReleaseCrudController extends AbstractCrudController { public static function getEntityFqcn(): string @@ -72,11 +69,11 @@ public function configureFields(string $pageName): iterable yield IdField::new('version', 'Release Version'); yield DateTimeField::new('date', 'Release Date'); yield ChoiceField::new('type', 'Release Type')->setChoices( - static fn () => array_flip(ReleaseTypeEnum::getAvailableOptions(true)) + static fn() => \array_flip(ReleaseTypeEnum::getAvailableOptions(true)) ); yield BooleanField::new('elts', 'ELTS Release'); - if (in_array($pageName, [Crud::PAGE_DETAIL, Crud::PAGE_EDIT, Crud::PAGE_NEW], true)) { + if (\in_array($pageName, [Crud::PAGE_DETAIL, Crud::PAGE_EDIT, Crud::PAGE_NEW], true)) { yield TextField::new('tarPackage.md5sum', 'Tar Package MD5 Checksum'); yield TextField::new('tarPackage.sha1sum', 'Tar Package SHA1 Checksum'); yield TextField::new('tarPackage.sha256sum', 'Tar Package SHA256 Checksum'); diff --git a/src/Controller/Admin/RequirementCrudController.php b/src/Controller/Admin/RequirementCrudController.php index c0372e64..246539bc 100644 --- a/src/Controller/Admin/RequirementCrudController.php +++ b/src/Controller/Admin/RequirementCrudController.php @@ -34,8 +34,6 @@ use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField; use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; -use function array_flip; - class RequirementCrudController extends AbstractCrudController { public static function getEntityFqcn(): string @@ -70,7 +68,7 @@ public function configureFields(string $pageName): iterable { yield AssociationField::new('version', 'Major Version'); yield ChoiceField::new('category', 'Category')->setChoices( - static fn () => array_flip(RequirementCategoryEnum::getAvailableOptions(true)) + static fn() => \array_flip(RequirementCategoryEnum::getAvailableOptions(true)) ); yield TextField::new('name', 'Name'); yield TextField::new('min', 'Lower Bound'); diff --git a/src/Controller/Api/AbstractController.php b/src/Controller/Api/AbstractController.php index 9dd785c7..e361458c 100644 --- a/src/Controller/Api/AbstractController.php +++ b/src/Controller/Api/AbstractController.php @@ -38,12 +38,6 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\Validator\ConstraintViolationInterface; use Symfony\Contracts\Cache\TagAwareCacheInterface; -use DateTime; -use DateTimeImmutable; - -use function iterator_apply; -use function iterator_to_array; -use function is_string; abstract class AbstractController extends \Symfony\Bundle\FrameworkBundle\Controller\AbstractController { @@ -112,13 +106,13 @@ protected function validateObject(object $object): void if ($violations->count() > 0) { $messages = ''; - iterator_apply( + \iterator_apply( $violations, static function (ConstraintViolationInterface $violation) use (&$messages): bool { $messages .= \sprintf("%s: %s\n", $violation->getPropertyPath(), $violation->getMessage()); return true; }, - iterator_to_array($violations) + \iterator_to_array($violations) ); throw new BadRequestHttpException(trim($messages)); @@ -137,12 +131,12 @@ protected function mapObjects(object $baseObject, array $data): void foreach ($metadata->getFieldNames() as $field) { $fieldName = $inflector->tableize($field); - if (array_key_exists($fieldName, $data) && is_string($data[$fieldName])) { + if (array_key_exists($fieldName, $data) && \is_string($data[$fieldName])) { if (isset($metadata->fieldMappings[$field]['type'])) { if ($metadata->fieldMappings[$field]['type'] == 'datetime') { - $data[$fieldName] = new DateTime($data[$fieldName]); + $data[$fieldName] = new \DateTime($data[$fieldName]); } elseif ($metadata->fieldMappings[$field]['type'] == 'datetime_immutable') { - $data[$fieldName] = new DateTimeImmutable($data[$fieldName]); + $data[$fieldName] = new \DateTimeImmutable($data[$fieldName]); } } diff --git a/src/Controller/Api/SitepackageController.php b/src/Controller/Api/SitepackageController.php index cfe39df9..c90d04d2 100644 --- a/src/Controller/Api/SitepackageController.php +++ b/src/Controller/Api/SitepackageController.php @@ -38,8 +38,6 @@ use Symfony\Component\Validator\ConstraintViolationInterface; use Symfony\Component\Validator\Validation; -use function count; - #[Route(path: '/api/v1/sitepackage', defaults: ['_format' => 'json'])] class SitepackageController extends AbstractController { @@ -81,8 +79,8 @@ protected function validateObject(mixed $object): void ->enableAttributeMapping() ->getValidator(); $errors = $validator->validate($object); - if (count($errors) > 0) { - $errorsString = implode("\n", array_map(static fn (ConstraintViolationInterface $x) => $x->getMessage(), (array)$errors)); + if (\count($errors) > 0) { + $errorsString = implode("\n", array_map(static fn(ConstraintViolationInterface $x) => $x->getMessage(), (array)$errors)); throw new BadRequestHttpException($errorsString); } } diff --git a/src/Controller/DefaultController.php b/src/Controller/DefaultController.php index 5ad5ec09..2c8689b5 100644 --- a/src/Controller/DefaultController.php +++ b/src/Controller/DefaultController.php @@ -35,8 +35,6 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\Routing\Annotation\Route; -use function array_keys; - /** * Regular content and download pages. */ @@ -176,7 +174,7 @@ public function composerHelperAjax(Request $request): JsonResponse throw new BadRequestHttpException('Missing or invalid request body.'); } - $keys = preg_replace('#^(typo3)-#', '$1/', array_keys($formData)); + $keys = preg_replace('#^(typo3)-#', '$1/', \array_keys($formData)); if (!is_array($keys)) { throw new BadRequestHttpException('Missing or invalid request body.'); } diff --git a/src/Controller/DownloadController.php b/src/Controller/DownloadController.php index 571e42d7..17accd31 100644 --- a/src/Controller/DownloadController.php +++ b/src/Controller/DownloadController.php @@ -25,14 +25,10 @@ use App\Entity\Release; use App\Utility\VersionUtility; -use InvalidArgumentException; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; -use Throwable; - -use function sprintf; final class DownloadController extends AbstractController { @@ -67,7 +63,7 @@ public function download( // Get information about version to download try { $redirectData = $this->getDownloadRedirect($requestedVersion, $requestedFormat); - } catch (Throwable) { + } catch (\Throwable) { throw $this->createNotFoundException(); } @@ -106,7 +102,7 @@ private function createEltsVersionResponse(Request $request, Release $release): } /** - * @throws InvalidArgumentException + * @throws \InvalidArgumentException * * @return array{ * url: string, @@ -131,7 +127,7 @@ private function getDownloadRedirect(string $versionName, string $format): array $content = $this->legacyDataService->getReleaseJson(); $releases = json_decode($content, true, 512, JSON_THROW_ON_ERROR); if (!is_array($releases)) { - throw new InvalidArgumentException('Error while decoding the release json.', 1_638_038_670); + throw new \InvalidArgumentException('Error while decoding the release json.', 1_638_038_670); } // defaults @@ -168,7 +164,7 @@ private function getDownloadRedirect(string $versionName, string $format): array // named version detection if ($versionName === 'stable') { if (!isset($releases['latest_stable'])) { - throw new InvalidArgumentException('Invalid release json.', 1_638_038_671); + throw new \InvalidArgumentException('Invalid release json.', 1_638_038_671); } $versionName = $releases['latest_stable']; @@ -184,7 +180,7 @@ private function getDownloadRedirect(string $versionName, string $format): array if ($isValidVersion && in_array($format, ['tar.gz', 'zip', 'tar.gz.sig', 'zip.sig'], true)) { $branchName = (int)$versionParts[0] >= 7 ? $versionParts[0] : $versionParts[0] . '.' . $versionParts[1]; if (!isset($releases[$branchName])) { - throw new InvalidArgumentException('Invalid release json.', 1_638_038_672); + throw new \InvalidArgumentException('Invalid release json.', 1_638_038_672); } $branch = $releases[$branchName]; @@ -220,8 +216,8 @@ private function getDownloadRedirect(string $versionName, string $format): array } } - throw new InvalidArgumentException( - sprintf('No download found for version %s with format %s.', $versionName, $format), + throw new \InvalidArgumentException( + \sprintf('No download found for version %s with format %s.', $versionName, $format), 1_660_745_735 ); } diff --git a/src/Controller/LoginController.php b/src/Controller/LoginController.php index 1e743ebb..d11b5e1e 100644 --- a/src/Controller/LoginController.php +++ b/src/Controller/LoginController.php @@ -26,7 +26,6 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; -use Exception; class LoginController extends AbstractController { @@ -51,6 +50,6 @@ public function index(): Response public function logout(): void { // controller can be blank: it will never be called! - throw new Exception("Don't forget to activate logout in security.yaml"); + throw new \Exception("Don't forget to activate logout in security.yaml"); } } diff --git a/src/DataFixtures/MajorVersionFixtures.php b/src/DataFixtures/MajorVersionFixtures.php index a9fa71d7..3baf4073 100644 --- a/src/DataFixtures/MajorVersionFixtures.php +++ b/src/DataFixtures/MajorVersionFixtures.php @@ -28,8 +28,6 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Persistence\ObjectManager; use Faker\Factory as FakerFactory; -use DateTimeImmutable; -use Iterator; final class MajorVersionFixtures extends Fixture { @@ -90,12 +88,12 @@ public static function getVersions(): array } /** - * @return Iterator + * @return \Iterator */ protected function getData(): iterable { $faker = FakerFactory::create(); - $today = new DateTimeImmutable(); + $today = new \DateTimeImmutable(); yield new MajorVersionFixturesData( self::MAJOR_VERSION_SPRINT, diff --git a/src/DataFixtures/ReleaseFixtures.php b/src/DataFixtures/ReleaseFixtures.php index 130babb4..20182337 100644 --- a/src/DataFixtures/ReleaseFixtures.php +++ b/src/DataFixtures/ReleaseFixtures.php @@ -31,9 +31,6 @@ use Doctrine\Bundle\FixturesBundle\Fixture; use Doctrine\Common\DataFixtures\DependentFixtureInterface; use Doctrine\Persistence\ObjectManager; -use DateTime; -use DateTimeInterface; -use RuntimeException; final class ReleaseFixtures extends Fixture implements DependentFixtureInterface { @@ -86,13 +83,13 @@ protected function generateReleasesForMajorVersion( $fakeVersion[1] = $faker->numberBetween($versionData[1], $ltsVersionData[1]); $fakeVersion[2] = $i; $version = implode('.', $fakeVersion); - $date = DateTime::createFromFormat( - DateTimeInterface::ATOM, - $majorVersion->getReleaseDate()->modify('+' . ($i * 3) . ' months')->format(DateTimeInterface::ATOM) + $date = \DateTime::createFromFormat( + \DateTimeInterface::ATOM, + $majorVersion->getReleaseDate()->modify('+' . ($i * 3) . ' months')->format(\DateTimeInterface::ATOM) ); if ($date === false) { - throw new RuntimeException('Can not calculate date.', 1_624_354_915); + throw new \RuntimeException('Can not calculate date.', 1_624_354_915); } $release = new Release(); diff --git a/src/DataFixtures/RequirementFixtures.php b/src/DataFixtures/RequirementFixtures.php index 47a6cc01..882e225a 100644 --- a/src/DataFixtures/RequirementFixtures.php +++ b/src/DataFixtures/RequirementFixtures.php @@ -29,7 +29,6 @@ use Doctrine\Bundle\FixturesBundle\Fixture; use Doctrine\Common\DataFixtures\DependentFixtureInterface; use Doctrine\Persistence\ObjectManager; -use Iterator; final class RequirementFixtures extends Fixture implements DependentFixtureInterface { @@ -68,7 +67,7 @@ public function getDependencies(): array } /** - * @return Iterator + * @return \Iterator */ protected function getData(): iterable { diff --git a/src/Entity/Embeddables/Package.php b/src/Entity/Embeddables/Package.php index f964fbc5..9db4755c 100644 --- a/src/Entity/Embeddables/Package.php +++ b/src/Entity/Embeddables/Package.php @@ -27,10 +27,9 @@ use JMS\Serializer\Annotation as Serializer; use OpenApi\Annotations as OA; use Symfony\Component\Validator\Constraints as Assert; -use JsonSerializable; #[ORM\Embeddable] -class Package implements JsonSerializable +class Package implements \JsonSerializable { public function __construct( /** diff --git a/src/Entity/MajorVersion.php b/src/Entity/MajorVersion.php index ba8b7443..ec9d0094 100644 --- a/src/Entity/MajorVersion.php +++ b/src/Entity/MajorVersion.php @@ -31,9 +31,6 @@ use Doctrine\ORM\Mapping as ORM; use JMS\Serializer\Annotation as Serializer; use OpenApi\Annotations as OA; -use JsonSerializable; -use DateTimeImmutable; -use Stringable; /** * @OA\Schema( @@ -43,7 +40,7 @@ */ #[ORM\Entity(repositoryClass: MajorVersionRepository::class)] #[ORM\EntityListeners([MajorVersionListener::class])] -class MajorVersion implements JsonSerializable, Stringable +class MajorVersion implements \JsonSerializable, \Stringable { /** * For example 7 or 8 or 4.3. @@ -57,7 +54,7 @@ class MajorVersion implements JsonSerializable, Stringable public static function create(float $version = 0.0): self { - $now = (new DateTimeImmutable())->setTime(0, 0, 0); + $now = (new \DateTimeImmutable())->setTime(0, 0, 0); $emptyCollection = new ArrayCollection(); return new self( $version, @@ -106,7 +103,7 @@ public function __construct( #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE)] #[Serializer\Groups(['data', 'content', 'patch'])] #[Serializer\Type("DateTimeImmutable<'Y-m-d\\TH:i:sP'>")] - private DateTimeImmutable $releaseDate, + private \DateTimeImmutable $releaseDate, /** * @OA\Property(example="2017-12-12T16:48:22+00:00") * @@ -115,21 +112,21 @@ public function __construct( #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: true)] #[Serializer\Groups(['data', 'content', 'patch'])] #[Serializer\Type("DateTimeImmutable<'Y-m-d\\TH:i:sP'>")] - private ?DateTimeImmutable $regularMaintenanceUntil, + private ?\DateTimeImmutable $regularMaintenanceUntil, /** * @OA\Property(example="2017-12-12T16:48:22+00:00") */ #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: true)] #[Serializer\Groups(['data', 'content', 'patch'])] #[Serializer\Type("DateTimeImmutable<'Y-m-d\\TH:i:sP'>")] - private ?DateTimeImmutable $maintainedUntil, + private ?\DateTimeImmutable $maintainedUntil, /** * @OA\Property(example="2017-12-12T16:48:22+00:00") */ #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: true)] #[Serializer\Groups(['data', 'content', 'patch'])] #[Serializer\Type("DateTimeImmutable<'Y-m-d\\TH:i:sP'>")] - private ?DateTimeImmutable $eltsUntil, + private ?\DateTimeImmutable $eltsUntil, /** * @var Collection */ @@ -220,44 +217,44 @@ public function getDescription(): string return $this->description; } - public function setRegularMaintenanceUntil(?DateTimeImmutable $regularMaintenanceUntil): void + public function setRegularMaintenanceUntil(?\DateTimeImmutable $regularMaintenanceUntil): void { $this->regularMaintenanceUntil = $regularMaintenanceUntil; } - public function getRegularMaintenanceUntil(): ?DateTimeImmutable + public function getRegularMaintenanceUntil(): ?\DateTimeImmutable { return $this->regularMaintenanceUntil; } - public function setMaintainedUntil(?DateTimeImmutable $maintainedUntil): void + public function setMaintainedUntil(?\DateTimeImmutable $maintainedUntil): void { $this->maintainedUntil = $maintainedUntil; } - public function getMaintainedUntil(): ?DateTimeImmutable + public function getMaintainedUntil(): ?\DateTimeImmutable { return $this->maintainedUntil; } - public function setEltsUntil(?DateTimeImmutable $eltsUntil): void + public function setEltsUntil(?\DateTimeImmutable $eltsUntil): void { $this->eltsUntil = $eltsUntil; } - public function getEltsUntil(): ?DateTimeImmutable + public function getEltsUntil(): ?\DateTimeImmutable { return $this->eltsUntil ?? ( $this->getMaintainedUntil() !== null ? $this->getMaintainedUntil()->modify('+3 years') : null ); } - public function setReleaseDate(DateTimeImmutable $releaseDate): void + public function setReleaseDate(\DateTimeImmutable $releaseDate): void { $this->releaseDate = $releaseDate; } - public function getReleaseDate(): DateTimeImmutable + public function getReleaseDate(): \DateTimeImmutable { return $this->releaseDate; } @@ -267,7 +264,7 @@ public function getLatestRelease(): ?Release $array = $this->releases->toArray(); usort( $array, - static fn ($a, $b): int => version_compare($b->getVersion(), $a->getVersion()) + static fn($a, $b): int => version_compare($b->getVersion(), $a->getVersion()) ); return $array !== [] ? reset($array) : null; } @@ -305,7 +302,7 @@ public function getLts(): ?float public function isActive(): bool { - $dateTime = new DateTimeImmutable(); + $dateTime = new \DateTimeImmutable(); if ($this->getMaintainedUntil() === null) { return true; } @@ -315,7 +312,7 @@ public function isActive(): bool public function isElts(): bool { - $dateTime = new DateTimeImmutable(); + $dateTime = new \DateTimeImmutable(); if ($this->getMaintainedUntil() == null) { return false; } @@ -381,7 +378,7 @@ public function jsonSerialize(): array uksort( $releaseData, - static fn (string $a, string $b): int => version_compare($a, $b) + static fn(string $a, string $b): int => version_compare($a, $b) ); $desc = array_reverse($releaseData); $latest = $this->getLatestRelease(); diff --git a/src/Entity/Release.php b/src/Entity/Release.php index d8245732..71334cb6 100644 --- a/src/Entity/Release.php +++ b/src/Entity/Release.php @@ -32,12 +32,6 @@ use JMS\Serializer\Annotation as Serializer; use OpenApi\Annotations as OA; use Symfony\Component\Validator\Constraints as Assert; -use JsonSerializable; -use DateTimeInterface; -use InvalidArgumentException; -use DateTimeImmutable; -use DateTime; -use Stringable; /** * @OA\Schema( @@ -47,7 +41,7 @@ */ #[ORM\Entity(repositoryClass: ReleaseRepository::class)] #[ORM\EntityListeners([ReleaseListener::class])] -class Release implements JsonSerializable, Stringable +class Release implements \JsonSerializable, \Stringable { /** * Version in a semver/version_compare compatible format. @@ -65,12 +59,12 @@ class Release implements JsonSerializable, Stringable /** * @OA\Property(example="2017-12-12T16:48:22+00:00") * - * @var DateTime|DateTimeImmutable + * @var \DateTime|\DateTimeImmutable */ #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_MUTABLE)] #[Serializer\Groups(['data', 'content'])] #[Serializer\Type("DateTime<'Y-m-d\\TH:i:sP'>")] - private DateTimeInterface $date; + private \DateTimeInterface $date; #[Assert\Choice(callback: [ReleaseTypeEnum::class, 'getAvailableOptions'])] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)] @@ -129,15 +123,15 @@ public function getReleaseNotes(): ReleaseNotes return $this->releaseNotes; } - public function setDate(DateTime|DateTimeImmutable $date): void + public function setDate(\DateTime|\DateTimeImmutable $date): void { $this->date = $date; } /** - * @return DateTime|DateTimeImmutable + * @return \DateTime|\DateTimeImmutable */ - public function getDate(): DateTimeInterface + public function getDate(): \DateTimeInterface { return $this->date; } @@ -175,7 +169,7 @@ public function setMajorVersion(MajorVersion $majorVersion): void public function setType(string $type): void { if (!in_array($type, ReleaseTypeEnum::getAvailableOptions(), true)) { - throw new InvalidArgumentException('Invalid type'); + throw new \InvalidArgumentException('Invalid type'); } $this->type = $type; diff --git a/src/Entity/Requirement.php b/src/Entity/Requirement.php index 47cd16b3..70c8e83f 100644 --- a/src/Entity/Requirement.php +++ b/src/Entity/Requirement.php @@ -30,11 +30,6 @@ use JMS\Serializer\Annotation as Serializer; use OpenApi\Annotations as OA; use Symfony\Component\Validator\Constraints as Assert; -use JsonSerializable; -use InvalidArgumentException; -use Stringable; - -use function ucfirst; /** * @OA\Schema( @@ -45,9 +40,9 @@ #[ORM\Entity(repositoryClass: RequirementRepository::class)] #[ORM\EntityListeners([RequirementListener::class])] #[ORM\UniqueConstraint(columns: ['version', 'category', 'name'])] -class Requirement implements JsonSerializable, Stringable +class Requirement implements \JsonSerializable, \Stringable { - public static function create(MajorVersion $version = null): self + public static function create(?MajorVersion $version = null): self { return new self( null, @@ -110,7 +105,7 @@ public function getVersion(): ?MajorVersion public function setCategory(string $category): void { if (!in_array($category, RequirementCategoryEnum::getAvailableOptions(), true)) { - throw new InvalidArgumentException('Invalid category'); + throw new \InvalidArgumentException('Invalid category'); } $this->category = $category; @@ -142,7 +137,7 @@ public function getTitle(): string 'mariadb' => 'MariaDB', 'sqlite' => 'SQLite', 'ram' => 'RAM', - default => ucfirst($this->getName()), + default => \ucfirst($this->getName()), }; } @@ -176,7 +171,7 @@ public function jsonSerialize(): array public function __toString(): string { - $result = ucfirst($this->getCategory()) . ' / ' . $this->getTitle(); + $result = \ucfirst($this->getCategory()) . ' / ' . $this->getTitle(); if (($min = $this->getMin()) !== \null) { $result .= ': ' . $min; diff --git a/src/Entity/Sitepackage.php b/src/Entity/Sitepackage.php index e25b1a60..e3b06272 100644 --- a/src/Entity/Sitepackage.php +++ b/src/Entity/Sitepackage.php @@ -27,12 +27,11 @@ use JMS\Serializer\Annotation as Serializer; use OpenApi\Attributes as OA; use Symfony\Component\Validator\Constraints as Assert; -use JsonSerializable; /** * Sitepackage. */ -class Sitepackage implements JsonSerializable +class Sitepackage implements \JsonSerializable { #[Assert\NotBlank] #[Assert\Choice(['bootstrap_package', 'fluid_styled_content'])] diff --git a/src/Entity/Sitepackage/Author.php b/src/Entity/Sitepackage/Author.php index 8282cb48..bb59ff33 100644 --- a/src/Entity/Sitepackage/Author.php +++ b/src/Entity/Sitepackage/Author.php @@ -26,12 +26,11 @@ use JMS\Serializer\Annotation as Serializer; use OpenApi\Attributes as OA; use Symfony\Component\Validator\Constraints as Assert; -use JsonSerializable; /** * Author. */ -class Author implements JsonSerializable +class Author implements \JsonSerializable { #[Assert\NotBlank(message: "Please enter the authors' name.")] #[Assert\Length(min: 3)] diff --git a/src/Model/SatisJson.php b/src/Model/SatisJson.php index b11b4b9f..89ab4915 100644 --- a/src/Model/SatisJson.php +++ b/src/Model/SatisJson.php @@ -23,15 +23,10 @@ namespace App\Model; -use Stringable; -use InvalidArgumentException; - -use function json_encode; - /** * @codeCoverageIgnore */ -class SatisJson implements Stringable +class SatisJson implements \Stringable { /** * @var array{ @@ -52,7 +47,7 @@ class SatisJson implements Stringable public function __construct($name) { if (!is_string($name)) { - throw new InvalidArgumentException(sprintf( + throw new \InvalidArgumentException(sprintf( 'Argument "$name" must be of type "string", "%s" given', gettype($name) )); @@ -121,6 +116,6 @@ public function __toString(): string unset($this->data['require']); } - return (string)json_encode($this->data, JSON_PRETTY_PRINT); + return (string)\json_encode($this->data, JSON_PRETTY_PRINT); } } diff --git a/src/Repository/MajorVersionRepository.php b/src/Repository/MajorVersionRepository.php index 24efffd0..e333ff46 100644 --- a/src/Repository/MajorVersionRepository.php +++ b/src/Repository/MajorVersionRepository.php @@ -28,10 +28,6 @@ use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Common\Collections\Criteria; use Doctrine\Persistence\ManagerRegistry; -use RuntimeException; -use DateTimeImmutable; - -use function in_array; /** * @extends ServiceEntityRepository @@ -70,13 +66,13 @@ public function findVersion(string $version): ?MajorVersion } /** - * @throws RuntimeException + * @throws \RuntimeException * * @return array */ public function findAllActive(): array { - $date = (new DateTimeImmutable())->format('Y-m-d'); + $date = (new \DateTimeImmutable())->format('Y-m-d'); $qb = $this->createQueryBuilder('m'); $qb->where( $qb->expr()->orX( @@ -92,20 +88,20 @@ public function findAllActive(): array $qb->addOrderBy('m.version', Criteria::DESC); if (!is_array($result = $qb->getQuery()->execute())) { - throw new RuntimeException('Query not returned an array type.', 1_638_022_065); + throw new \RuntimeException('Query not returned an array type.', 1_638_022_065); } return $this->removeVersionsWithoutReleases($result); } /** - * @throws RuntimeException + * @throws \RuntimeException * * @return array */ public function findAllActiveCommunity(): array { - $date = (new DateTimeImmutable())->format('Y-m-d'); + $date = (new \DateTimeImmutable())->format('Y-m-d'); $qb = $this->createQueryBuilder('m'); $qb->where( $qb->expr()->orX( @@ -117,20 +113,20 @@ public function findAllActiveCommunity(): array $qb->addOrderBy('m.version', Criteria::DESC); if (!is_array($result = $qb->getQuery()->execute())) { - throw new RuntimeException('Query not returned an array type.', 1_638_022_066); + throw new \RuntimeException('Query not returned an array type.', 1_638_022_066); } return $this->removeVersionsWithoutReleases($result); } /** - * @throws RuntimeException + * @throws \RuntimeException * * @return array */ public function findAllActiveElts(): array { - $date = (new DateTimeImmutable())->format('Y-m-d'); + $date = (new \DateTimeImmutable())->format('Y-m-d'); $qb = $this->createQueryBuilder('m'); $qb->where( $qb->expr()->andX( @@ -142,7 +138,7 @@ public function findAllActiveElts(): array $qb->addOrderBy('m.version', Criteria::DESC); if (!is_array($result = $qb->getQuery()->execute())) { - throw new RuntimeException('Query not returned an array type.', 1_638_022_067); + throw new \RuntimeException('Query not returned an array type.', 1_638_022_067); } return $result; @@ -172,7 +168,7 @@ public function findAllGroupedByMajor(): array uksort( $data, - static fn (string $a, string $b): int => version_compare($a, $b) + static fn(string $a, string $b): int => version_compare($a, $b) ); return array_reverse($data); } @@ -190,13 +186,13 @@ public function findCommunityVersionsGroupedByMajor(): array uksort( $data, - static fn (string $a, string $b): int => version_compare($a, $b) + static fn(string $a, string $b): int => version_compare($a, $b) ); return array_reverse($data); } /** - * @throws RuntimeException + * @throws \RuntimeException * * @return array */ @@ -210,14 +206,14 @@ public function findAllComposerSupported(): array $qb->addOrderBy('m.version', Criteria::DESC); if (!is_array($result = $qb->getQuery()->execute())) { - throw new RuntimeException('Query not returned an array type.', 1_638_022_068); + throw new \RuntimeException('Query not returned an array type.', 1_638_022_068); } return $result; } /** - * @throws RuntimeException + * @throws \RuntimeException */ public function findLatestLtsComposerSupported(): ?MajorVersion { @@ -232,14 +228,14 @@ public function findLatestLtsComposerSupported(): ?MajorVersion $qb->setMaxResults(1)->orderBy('m.version', Criteria::DESC); if (!is_array($result = $qb->getQuery()->execute())) { - throw new RuntimeException('Query not returned an array type.', 1_638_022_069); + throw new \RuntimeException('Query not returned an array type.', 1_638_022_069); } return array_pop($result); } /** - * @throws RuntimeException + * @throws \RuntimeException * * @return array{latest_stable: string, latest_old_stable: string|null} */ @@ -249,13 +245,13 @@ private function findStableReleases(): array $qb->setMaxResults(2)->orderBy('m.version', Criteria::DESC); if (!is_array($result = $qb->getQuery()->execute())) { - throw new RuntimeException('Query not returned an array type.', 1_638_022_070); + throw new \RuntimeException('Query not returned an array type.', 1_638_022_070); } $result = $this->removeVersionsWithoutReleases($result); if (!($latestMajor = reset($result)) instanceof MajorVersion) { - throw new RuntimeException('No version found.', 1_638_022_071); + throw new \RuntimeException('No version found.', 1_638_022_071); } $releases = $this->majorVersionDescending($latestMajor); @@ -268,13 +264,13 @@ private function findStableReleases(): array } /** - * @throws RuntimeException + * @throws \RuntimeException * * @return array{latest_lts: string, latest_old_lts: string} */ private function findLtsReleases(): array { - $date = (new DateTimeImmutable())->format('Y-m-d'); + $date = (new \DateTimeImmutable())->format('Y-m-d'); $qb = $this->createQueryBuilder('m'); $qb->setMaxResults(2) ->where( @@ -286,7 +282,7 @@ private function findLtsReleases(): array $qb->orderBy('m.maintainedUntil', Criteria::DESC); if (!is_array($result = $qb->getQuery()->execute())) { - throw new RuntimeException('Query not returned an array type.', 1_638_022_071); + throw new \RuntimeException('Query not returned an array type.', 1_638_022_071); } $latestLts = array_shift($result); @@ -313,7 +309,7 @@ private function formatVersion(float|int|string $version): string { $version = (string)$version; if (!str_contains($version, '.')) { - if (in_array((int)$version, [7, 8, 9, 10, 11, 12, 13], true)) { + if (\in_array((int)$version, [7, 8, 9, 10, 11, 12, 13], true)) { $version .= '.0000'; } else { $version .= '.0'; @@ -326,7 +322,7 @@ private function formatVersion(float|int|string $version): string private function removeEltsReleases(MajorVersion $version): MajorVersion { $version->setReleases($version->getReleases()->filter( - static fn (Release $release): bool => !$release->isElts() + static fn(Release $release): bool => !$release->isElts() )); return $version; @@ -341,7 +337,7 @@ private function majorVersionDescending(MajorVersion $version): array usort( $releases, - static fn (Release $a, Release $b): int => version_compare($b->getVersion(), $a->getVersion()) + static fn(Release $a, Release $b): int => version_compare($b->getVersion(), $a->getVersion()) ); return $releases; diff --git a/src/Service/CacheWarmupService.php b/src/Service/CacheWarmupService.php index 1aa0e004..b46fe58f 100644 --- a/src/Service/CacheWarmupService.php +++ b/src/Service/CacheWarmupService.php @@ -33,7 +33,6 @@ use Psr\Log\LoggerInterface; use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface; use Symfony\Component\Routing\RouterInterface; -use Exception; class CacheWarmupService implements CacheWarmerInterface { @@ -156,7 +155,7 @@ private function warmUpLoopWithVersions(array $routes, array $versions): void try { $promise->wait(); - } catch (Exception $exception) { + } catch (\Exception $exception) { $this->logger->warning($exception->getMessage(), $exception->getTrace()); } } diff --git a/src/Service/ComposerPackagesService.php b/src/Service/ComposerPackagesService.php index d0cac64f..77c1cf2b 100644 --- a/src/Service/ComposerPackagesService.php +++ b/src/Service/ComposerPackagesService.php @@ -32,12 +32,6 @@ use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormInterface; -use RuntimeException; - -use function is_null; -use function ltrim; -use function preg_match; -use function sprintf; final class ComposerPackagesService { @@ -759,12 +753,12 @@ public function buildForm(FormBuilderInterface $builder): FormInterface { $majorVersion = $this->majorVersions->findLatestLtsComposerSupported(); if (!$majorVersion instanceof MajorVersion) { - throw new RuntimeException('No LTS release with Composer support found.', 1_624_353_394); + throw new \RuntimeException('No LTS release with Composer support found.', 1_624_353_394); } $release = $majorVersion->getLatestRelease(); if (!$release instanceof Release) { - throw new RuntimeException('No release found.', 1_624_353_494); + throw new \RuntimeException('No release found.', 1_624_353_494); } $versionChoices = [ @@ -789,7 +783,7 @@ public function buildForm(FormBuilderInterface $builder): FormInterface foreach ($versions as $version) { if ( - $version->getLatestRelease() instanceof Release && preg_match( + $version->getLatestRelease() instanceof Release && \preg_match( '#^(\d+)\.(\d+)\.(\d+)#', $version->getLatestRelease()->getVersion(), $matches @@ -798,7 +792,7 @@ public function buildForm(FormBuilderInterface $builder): FormInterface $nextMinor = $matches[1] . '.' . (((int)$matches[2]) + 1); $nextPatch = $matches[1] . '.' . $matches[2] . '.' . (((int)$matches[3]) + 1); - if (is_null($version->getLatestRelease()->getMajorVersion()->getLts())) { + if (\is_null($version->getLatestRelease()->getMajorVersion()->getLts())) { $versionChoices['choices'][self::SPECIAL_VERSIONS_GROUP] [$version->getTitle() . ' - next minor release (' . $nextMinor . ')'] = $this->getComposerVersionConstraint($nextMinor, true); @@ -847,7 +841,7 @@ public function getBundles(): array $sanitizedBundles = []; foreach (self::BUNDLES as $bundleName => $packages) { $sanitizedBundles[$bundleName] = Utils::jsonEncode( - array_map(static fn ($name): string => str_replace('/', '-', $name), $packages) + array_map(static fn($name): string => str_replace('/', '-', $name), $packages) ); } @@ -863,21 +857,21 @@ public function cleanPackagesForVersions(array $packages): array { $stability = 'stable'; - if (is_string($version = $packages['typo3_version']) && preg_match('#^\^(\d+)#', $version, $matches) > 0) { + if (is_string($version = $packages['typo3_version']) && \preg_match('#^\^(\d+)#', $version, $matches) > 0) { $stability = VersionParser::parseStability($version); $majorVersion = (int)$matches[1]; } else { $composerVersions = $this->majorVersions->findAllComposerSupported(); if ($composerVersions === []) { - throw new RuntimeException('No release found.', 1_624_353_639); + throw new \RuntimeException('No release found.', 1_624_353_639); } $release = $composerVersions[0]->getLatestRelease(); if (!$release instanceof Release) { - throw new RuntimeException('No release found.', 1_624_353_801); + throw new \RuntimeException('No release found.', 1_624_353_801); } - preg_match('#^\d+#', $release->getVersion(), $matches); + \preg_match('#^\d+#', $release->getVersion(), $matches); $majorVersion = (int)$matches[0]; } @@ -894,7 +888,7 @@ public function cleanPackagesForVersions(array $packages): array if (array_key_exists($packageName, $packages) && $packages[$packageName] === true) { if ($version !== '*' && $packageName === 'typo3/minimal') { - $packageVersion = sprintf('^%s', $majorVersion); + $packageVersion = \sprintf('^%s', $majorVersion); if ($stability !== 'stable') { $packageVersion .= '@' . $stability; } @@ -903,14 +897,14 @@ public function cleanPackagesForVersions(array $packages): array } if ($version === '') { - $composerPackages .= sprintf(' "%s"', $packageName); + $composerPackages .= \sprintf(' "%s"', $packageName); } else { - $composerPackages .= sprintf(' "%s:%s"', $packageName, $packageVersion); + $composerPackages .= \sprintf(' "%s:%s"', $packageName, $packageVersion); } } } - $packages['composer_packages'] = ltrim($composerPackages); + $packages['composer_packages'] = \ltrim($composerPackages); return $packages; } @@ -933,7 +927,7 @@ private function getComposerVersionConstraint(string $version, bool $development { if ($development) { $result = '^' . $version . '@dev'; - } elseif (preg_match('#^\d+\.\d+#', $version, $matches) > 0) { + } elseif (\preg_match('#^\d+\.\d+#', $version, $matches) > 0) { $result = '^' . $matches[0]; } else { $result = ''; diff --git a/src/Service/SitepackageGenerator.php b/src/Service/SitepackageGenerator.php index 7d61a605..5da216c0 100644 --- a/src/Service/SitepackageGenerator.php +++ b/src/Service/SitepackageGenerator.php @@ -28,8 +28,6 @@ use Symfony\Component\HttpKernel\KernelInterface; use Twig\Environment; use Twig\Loader\ArrayLoader; -use ZipArchive; -use RuntimeException; class SitepackageGenerator { @@ -49,13 +47,13 @@ public function create(Sitepackage $package): void $sourceDir = $this->kernel->getProjectDir() . '/resources/packages/' . $package->getBasePackage() . '/' . (string)$package->getTypo3Version() . '/src/'; $tempFileName = tempnam(sys_get_temp_dir(), $this->filename); if ($tempFileName === false) { - throw new RuntimeException(sprintf('Cannot create temporary name for %s/%s' . sys_get_temp_dir(), $this->filename), 1732123721); + throw new \RuntimeException(sprintf('Cannot create temporary name for %s/%s' . sys_get_temp_dir(), $this->filename), 1732123721); } $this->zipPath = $tempFileName; $fileList = FileUtility::listDirectory($sourceDir); - $zipFile = new ZipArchive(); - $opened = $zipFile->open($this->zipPath, ZipArchive::CREATE); + $zipFile = new \ZipArchive(); + $opened = $zipFile->open($this->zipPath, \ZipArchive::CREATE); if ($opened === true) { foreach ($fileList as $file) { if ($file !== $this->zipPath && file_exists($file)) { diff --git a/src/Twig/Extension/ReleaseNotesExtension.php b/src/Twig/Extension/ReleaseNotesExtension.php index 001a4b9d..f236fe29 100644 --- a/src/Twig/Extension/ReleaseNotesExtension.php +++ b/src/Twig/Extension/ReleaseNotesExtension.php @@ -35,7 +35,7 @@ public function getFilters(): array { return [ // format filters - new TwigFilter('removeWikiLink', fn (string $data): ?string => $this->removeWikiLink($data)), + new TwigFilter('removeWikiLink', fn(string $data): ?string => $this->removeWikiLink($data)), ]; } diff --git a/src/Twig/Extension/RequirementExtension.php b/src/Twig/Extension/RequirementExtension.php index 65ee9b08..6549e971 100644 --- a/src/Twig/Extension/RequirementExtension.php +++ b/src/Twig/Extension/RequirementExtension.php @@ -30,15 +30,6 @@ use Twig\Extension\AbstractExtension; use Twig\TwigFilter; -use function array_key_exists; -use function implode; -use function in_array; -use function sprintf; -use function substr; -use function str_ends_with; - -use const null; - class RequirementExtension extends AbstractExtension { /** @@ -49,11 +40,11 @@ public function getFilters(): array return [ new TwigFilter( 'prepareRequirements', - fn (Collection $requirements): array => $this->prepareRequirements($requirements) + fn(Collection $requirements): array => $this->prepareRequirements($requirements) ), new TwigFilter( 'prepareRequirementsShort', - fn (Collection $requirements): array => $this->prepareRequirementsShort($requirements) + fn(Collection $requirements): array => $this->prepareRequirementsShort($requirements) ), ]; } @@ -87,7 +78,7 @@ public function prepareRequirementsShort(Collection $requirements): array foreach ($categories as $category => $categoryRequirements) { if ( - array_key_exists( + \array_key_exists( $category, $result ) @@ -120,10 +111,10 @@ public function prepareRequirementsShort(Collection $requirements): array } } - $result[$requirement->getCategory()] = sprintf( + $result[$requirement->getCategory()] = \sprintf( '%s %s', $requirement->getTitle(), - implode(', ', $supportedVersions) + \implode(', ', $supportedVersions) ); break; @@ -131,12 +122,12 @@ public function prepareRequirementsShort(Collection $requirements): array $result[$requirement->getCategory()] .= $result[$requirement->getCategory()] !== '' ? ' / ' : ''; $result[$requirement->getCategory()] .= $requirement->getTitle(); - if ($requirement->getMin() !== null) { + if ($requirement->getMin() !== \null) { $version = VersionUtility::normalize($requirement->getMin(), 3) ?? ''; - if (str_ends_with($version, '.0')) { - $version = substr($version, 0, -2); + if (\str_ends_with($version, '.0')) { + $version = \substr($version, 0, -2); } - $result[$requirement->getCategory()] .= sprintf( + $result[$requirement->getCategory()] .= \sprintf( ' %s+', $version ); @@ -201,7 +192,7 @@ private function normalizeVersionHelper(array &$requirements): void { foreach ($requirements as &$requirement) { if ( - in_array( + \in_array( $requirement->getCategory(), [ RequirementCategoryEnum::OPTION_PHP, @@ -231,6 +222,6 @@ private function normalizeVersionHelper(array &$requirements): void */ private function sortByTitleHelper(array &$data): void { - usort($data, static fn ($a, $b): int => strcasecmp($a->getTitle(), $b->getTitle())); + usort($data, static fn($a, $b): int => strcasecmp($a->getTitle(), $b->getTitle())); } } diff --git a/src/Twig/Filter/ChangeHighlighter.php b/src/Twig/Filter/ChangeHighlighter.php index 79f30aa8..c34fe1aa 100644 --- a/src/Twig/Filter/ChangeHighlighter.php +++ b/src/Twig/Filter/ChangeHighlighter.php @@ -36,7 +36,7 @@ public function getFilters(): array return [ new TwigFilter( 'changehighlighter', - fn (string $changeList): ?string => $this->highlightChanges($changeList) + fn(string $changeList): ?string => $this->highlightChanges($changeList) ), ]; } diff --git a/src/Twig/Filter/CommitLinker.php b/src/Twig/Filter/CommitLinker.php index 72c5a6d9..2532df98 100644 --- a/src/Twig/Filter/CommitLinker.php +++ b/src/Twig/Filter/CommitLinker.php @@ -34,7 +34,7 @@ class CommitLinker extends AbstractExtension public function getFilters(): array { return [ - new TwigFilter('commitlinker', fn (string $changeList): ?string => $this->linkCommits($changeList)), + new TwigFilter('commitlinker', fn(string $changeList): ?string => $this->linkCommits($changeList)), ]; } @@ -44,7 +44,7 @@ public function linkCommits(string $changeList): ?string return preg_replace_callback( $pattern, - static fn (array $matches): string => sprintf( + static fn(array $matches): string => sprintf( '%1$s', $matches['commit'] ), diff --git a/src/Twig/Filter/Parsedown.php b/src/Twig/Filter/Parsedown.php index 62c648fe..6aa1a665 100644 --- a/src/Twig/Filter/Parsedown.php +++ b/src/Twig/Filter/Parsedown.php @@ -34,7 +34,7 @@ class Parsedown extends AbstractExtension public function getFilters(): array { return [ - new TwigFilter('parsedown', fn (string $markdown): string => $this->parse($markdown)), + new TwigFilter('parsedown', fn(string $markdown): string => $this->parse($markdown)), ]; } diff --git a/src/Twig/Filter/SortByVersion.php b/src/Twig/Filter/SortByVersion.php index b397a869..18801619 100644 --- a/src/Twig/Filter/SortByVersion.php +++ b/src/Twig/Filter/SortByVersion.php @@ -36,7 +36,7 @@ class SortByVersion extends AbstractExtension public function getFilters(): array { return [ - new TwigFilter('sortByVersion', fn ($releases): array => $this->sort($releases)), + new TwigFilter('sortByVersion', fn($releases): array => $this->sort($releases)), ]; } @@ -48,7 +48,7 @@ public function getFilters(): array public function sort(Collection $releases): array { $array = $releases->toArray(); - usort($array, static fn ($a, $b): int => version_compare($b->getVersion(), $a->getVersion())); + usort($array, static fn($a, $b): int => version_compare($b->getVersion(), $a->getVersion())); return $array; } diff --git a/tests/Functional/AbstractCase.php b/tests/Functional/AbstractCase.php index 2312d798..31c84172 100644 --- a/tests/Functional/AbstractCase.php +++ b/tests/Functional/AbstractCase.php @@ -28,7 +28,6 @@ use Doctrine\Common\DataFixtures\Purger\ORMPurger; use Doctrine\ORM\EntityManagerInterface; use Doctrine\Persistence\ManagerRegistry; -use LogicException; use Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader; use Symfony\Bundle\FrameworkBundle\KernelBrowser; use Symfony\Component\Panther\PantherTestCase; @@ -53,7 +52,7 @@ protected function logIn(): void { $userProvider = static::getContainer()->get(UserProviderInterface::class); if (!$userProvider instanceof UserProviderInterface) { - throw new LogicException('UserProvider instance is not a UserProviderInterface'); + throw new \LogicException('UserProvider instance is not a UserProviderInterface'); } $testUser = $userProvider->loadUserByIdentifier('test-user'); @@ -80,12 +79,12 @@ private function getFixtureExecutor(): ORMExecutor if ($this->fixtureExecutor === null) { $managerRegistry = static::getContainer()->get('doctrine'); if (!$managerRegistry instanceof ManagerRegistry) { - throw new LogicException('Doctrine instance is not a ManagerRegistry'); + throw new \LogicException('Doctrine instance is not a ManagerRegistry'); } $entityManager = $managerRegistry->getManager(); if (!$entityManager instanceof EntityManagerInterface) { - throw new LogicException('Manager instance is not a EntityManagerInterface'); + throw new \LogicException('Manager instance is not a EntityManagerInterface'); } $this->fixtureExecutor = new ORMExecutor($entityManager, new ORMPurger($entityManager)); diff --git a/tests/Functional/Controller/Api/ApiCase.php b/tests/Functional/Controller/Api/ApiCase.php index ee569c2a..15594483 100644 --- a/tests/Functional/Controller/Api/ApiCase.php +++ b/tests/Functional/Controller/Api/ApiCase.php @@ -24,7 +24,6 @@ namespace App\Tests\Functional\Controller\Api; use App\Tests\Functional\AbstractCase; -use LogicException; use Symfony\Component\HttpFoundation\Response; class ApiCase extends AbstractCase @@ -34,7 +33,7 @@ private function loadFixture(string $fileName): string $contents = file_get_contents($fileName); if ($contents === false) { - throw new LogicException(sprintf('Fixture "%s" not accessible', $fileName)); + throw new \LogicException(sprintf('Fixture "%s" not accessible', $fileName)); } return $contents; diff --git a/tests/Functional/Controller/Web/DownloadControllerTest.php b/tests/Functional/Controller/Web/DownloadControllerTest.php index 072138cf..792dca9e 100644 --- a/tests/Functional/Controller/Web/DownloadControllerTest.php +++ b/tests/Functional/Controller/Web/DownloadControllerTest.php @@ -23,11 +23,11 @@ namespace App\Tests\Functional\Controller\Web; +use App\Tests\Functional\AbstractCase; use App\Tests\Functional\Fixtures\MajorVersionFixtures; use App\Tests\Functional\Fixtures\ReleaseFixtures; -use App\Tests\Functional\AbstractCase; -use Symfony\Component\HttpFoundation\Response; use Iterator; +use Symfony\Component\HttpFoundation\Response; class DownloadControllerTest extends AbstractCase { @@ -66,7 +66,7 @@ public function webDownloadVersion( * expectedCode: int * }> */ - public function webDownloadVersionDataProvider(): Iterator + public function webDownloadVersionDataProvider(): \Iterator { yield 'Sprint version' => [ 'requestVersion' => '10.0.0', diff --git a/tests/Functional/Controller/Web/JsonControllerTest.php b/tests/Functional/Controller/Web/JsonControllerTest.php index 47f389b7..0e87da5d 100644 --- a/tests/Functional/Controller/Web/JsonControllerTest.php +++ b/tests/Functional/Controller/Web/JsonControllerTest.php @@ -26,11 +26,8 @@ use App\Tests\Functional\AbstractCase; use App\Tests\Functional\Fixtures\MajorVersionFixtures; use App\Tests\Functional\Fixtures\ReleaseFixtures; -use RuntimeException; use Symfony\Component\HttpFoundation\Response; -use function is_array; - class JsonControllerTest extends AbstractCase { protected function setUp(): void @@ -50,11 +47,11 @@ public function index(): void $response = $this->client->getResponse(); if (($json = $response->getContent()) === false) { - throw new RuntimeException('Error no response content.', 1_657_642_832); + throw new \RuntimeException('Error no response content.', 1_657_642_832); } - if (!is_array($content = json_decode($json, true, 512, JSON_THROW_ON_ERROR))) { - throw new RuntimeException('Error array expected.', 1_657_642_833); + if (!\is_array($content = json_decode($json, true, 512, JSON_THROW_ON_ERROR))) { + throw new \RuntimeException('Error array expected.', 1_657_642_833); } self::assertSame(Response::HTTP_OK, $response->getStatusCode()); diff --git a/tests/Functional/DatabasePrimer.php b/tests/Functional/DatabasePrimer.php index 05ada4a2..db9cbed4 100644 --- a/tests/Functional/DatabasePrimer.php +++ b/tests/Functional/DatabasePrimer.php @@ -26,7 +26,6 @@ use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Tools\SchemaTool; use Symfony\Component\HttpKernel\KernelInterface; -use LogicException; /** * Class DatabasePrimer. @@ -39,13 +38,13 @@ public static function prime(KernelInterface $kernel): void { // Make sure we are in the test environment if ($kernel->getEnvironment() !== 'test') { - throw new LogicException('Primer must be executed in the test environment'); + throw new \LogicException('Primer must be executed in the test environment'); } // Get the entity manager from the service container $entityManager = $kernel->getContainer()->get('doctrine.orm.entity_manager'); if (!$entityManager instanceof EntityManagerInterface) { - throw new LogicException('EntityManager could not be retrieved'); + throw new \LogicException('EntityManager could not be retrieved'); } // Recreate the database diff --git a/tests/Functional/Fixtures/MajorVersionFixtures.php b/tests/Functional/Fixtures/MajorVersionFixtures.php index 335fb397..9aed3ff8 100644 --- a/tests/Functional/Fixtures/MajorVersionFixtures.php +++ b/tests/Functional/Fixtures/MajorVersionFixtures.php @@ -27,8 +27,6 @@ use Doctrine\Bundle\FixturesBundle\Fixture; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Persistence\ObjectManager; -use DateTimeImmutable; -use Iterator; final class MajorVersionFixtures extends Fixture { @@ -77,11 +75,11 @@ public static function getVersions(): array } /** - * @return Iterator + * @return \Iterator */ protected function getData(): iterable { - $today = new DateTimeImmutable(); + $today = new \DateTimeImmutable(); yield new MajorVersionFixturesData( self::MAJOR_VERSION_SPRINT, diff --git a/tests/Functional/Fixtures/ReleaseFixtures.php b/tests/Functional/Fixtures/ReleaseFixtures.php index 96fe1b4f..f1fb33d2 100644 --- a/tests/Functional/Fixtures/ReleaseFixtures.php +++ b/tests/Functional/Fixtures/ReleaseFixtures.php @@ -29,9 +29,6 @@ use Doctrine\Bundle\FixturesBundle\Fixture; use Doctrine\Common\DataFixtures\DependentFixtureInterface; use Doctrine\Persistence\ObjectManager; -use DateTime; -use DateTimeInterface; -use RuntimeException; final class ReleaseFixtures extends Fixture implements DependentFixtureInterface { @@ -78,13 +75,13 @@ protected function generateReleasesForMajorVersion( $fakeVersion = $ltsVersionData; $fakeVersion[2] = $i; $version = implode('.', $fakeVersion); - $date = DateTime::createFromFormat( - DateTimeInterface::ATOM, - $majorVersion->getReleaseDate()->modify('+' . ($i * 2) . ' months')->format(DateTimeInterface::ATOM) + $date = \DateTime::createFromFormat( + \DateTimeInterface::ATOM, + $majorVersion->getReleaseDate()->modify('+' . ($i * 2) . ' months')->format(\DateTimeInterface::ATOM) ); if ($date === false) { - throw new RuntimeException('Can not calculate date.', 1_624_354_915); + throw new \RuntimeException('Can not calculate date.', 1_624_354_915); } $release = new Release(); diff --git a/tests/Unit/Entity/MajorVersionExpected.php b/tests/Unit/Entity/MajorVersionExpected.php index c936e3e4..fd571bcd 100644 --- a/tests/Unit/Entity/MajorVersionExpected.php +++ b/tests/Unit/Entity/MajorVersionExpected.php @@ -23,17 +23,15 @@ namespace App\Tests\Unit\Entity; -use DateTimeImmutable; - class MajorVersionExpected { public function __construct( public readonly float $version, public readonly string $title, - public readonly DateTimeImmutable $releaseDate, - public readonly ?DateTimeImmutable $regularMaintenanceUntil, - public readonly ?DateTimeImmutable $maintainedUntil, - public readonly ?DateTimeImmutable $eltsUntil, + public readonly \DateTimeImmutable $releaseDate, + public readonly ?\DateTimeImmutable $regularMaintenanceUntil, + public readonly ?\DateTimeImmutable $maintainedUntil, + public readonly ?\DateTimeImmutable $eltsUntil, public readonly bool $active, public readonly bool $elts, ) {} diff --git a/tests/Unit/Entity/MajorVersionTest.php b/tests/Unit/Entity/MajorVersionTest.php index 3ba32a49..bee69d04 100644 --- a/tests/Unit/Entity/MajorVersionTest.php +++ b/tests/Unit/Entity/MajorVersionTest.php @@ -25,10 +25,7 @@ use App\Entity\MajorVersion; use Doctrine\Common\Collections\ArrayCollection; -use Iterator; -use LogicException; use PHPUnit\Framework\TestCase; -use DateTimeImmutable; class MajorVersionTest extends TestCase { @@ -78,7 +75,7 @@ public function entityToJsonTest(MajorVersion $majorVersion, MajorVersionExpecte $majorVersion = json_decode($majorVersion, true, 512, JSON_THROW_ON_ERROR); if (!is_array($majorVersion)) { - throw new LogicException('Array expected'); + throw new \LogicException('Array expected'); } self::assertEquals($expectedResult->active, $majorVersion['active'] ?? null); @@ -86,11 +83,11 @@ public function entityToJsonTest(MajorVersion $majorVersion, MajorVersionExpecte } /** - * @return Iterator> + * @return \Iterator> */ - public function entityTestDataProvider(): Iterator + public function entityTestDataProvider(): \Iterator { - $dateTimeToday = new DateTimeImmutable(); + $dateTimeToday = new \DateTimeImmutable(); $collection = new ArrayCollection(); yield 'SPRINT' => [ diff --git a/tests/Unit/Utility/VersionUtilityTest.php b/tests/Unit/Utility/VersionUtilityTest.php index 7b68cd58..357dea61 100644 --- a/tests/Unit/Utility/VersionUtilityTest.php +++ b/tests/Unit/Utility/VersionUtilityTest.php @@ -24,7 +24,6 @@ namespace App\Tests\Unit\Utility; use App\Utility\VersionUtility; -use Iterator; use PHPUnit\Framework\TestCase; class VersionUtilityTest extends TestCase @@ -41,9 +40,9 @@ public function extractMajorVersionNumberTest(string $version, float $expectedRe } /** - * @return Iterator> + * @return \Iterator> */ - public function extractMajorVersionNumberTestDataProvider(): Iterator + public function extractMajorVersionNumberTestDataProvider(): \Iterator { yield 'Minor 4' => ['4.5', 4.5]; yield 'Patch 4' => ['4.5.35', 4.5]; @@ -70,9 +69,9 @@ public function isValidSemverVersionTest(string $version, bool $expectedResult): } /** - * @return Iterator> + * @return \Iterator> */ - public function isValidSemverVersionTestDataProvider(): Iterator + public function isValidSemverVersionTestDataProvider(): \Iterator { yield 'Patch 6' => ['6.2.0', true]; yield 'Dev 6' => ['6.99.99-dev', true]; diff --git a/tests/bootstrap.php b/tests/bootstrap.php index ee694b5f..2d759861 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -26,15 +26,12 @@ use Symfony\Component\Dotenv\Dotenv; use Symfony\Component\Filesystem\Filesystem; -use function file_exists; -use function dirname; +require \dirname(__DIR__) . '/vendor/autoload.php'; -require dirname(__DIR__) . '/vendor/autoload.php'; - -if (file_exists(dirname(__DIR__) . '/config/bootstrap.php')) { - require dirname(__DIR__) . '/config/bootstrap.php'; +if (\file_exists(\dirname(__DIR__) . '/config/bootstrap.php')) { + require \dirname(__DIR__) . '/config/bootstrap.php'; } else { - (new Dotenv())->bootEnv(dirname(__DIR__) . '/.env'); + (new Dotenv())->bootEnv(\dirname(__DIR__) . '/.env'); } // ensure a fresh cache when debug mode is disabled