diff --git a/README.md b/README.md index 03cfff188..9f99969c7 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ Ce programme est distribué avec une [licence propriétaire](LICENSE.md) et une [![PHP](https://img.shields.io/badge/PHP-8.2.16-informational?logo=php)](https://www.php.net) [![MySQL](https://img.shields.io/badge/MySQL-5.7.32-informational?logo=mysql)](https://www.mysql.com) [![Apache](https://img.shields.io/badge/Apache-2.4.51-informational?logo=apache)](https://httpd.apache.org) +[![PhpStorm](https://img.shields.io/badge/PhpStorm-2024.1.1-informational?logo=phpstorm)](https://www.jetbrains.com/phpstorm) ## Qualité du code diff --git a/composer.lock b/composer.lock index 7344c3265..7ba5b3913 100644 --- a/composer.lock +++ b/composer.lock @@ -11865,16 +11865,16 @@ }, { "name": "spatie/array-to-xml", - "version": "3.2.3", + "version": "3.3.0", "source": { "type": "git", "url": "https://github.com/spatie/array-to-xml.git", - "reference": "c95fd4db94ec199f798d4b5b4a81757bd20d88ab" + "reference": "f56b220fe2db1ade4c88098d83413ebdfc3bf876" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spatie/array-to-xml/zipball/c95fd4db94ec199f798d4b5b4a81757bd20d88ab", - "reference": "c95fd4db94ec199f798d4b5b4a81757bd20d88ab", + "url": "https://api.github.com/repos/spatie/array-to-xml/zipball/f56b220fe2db1ade4c88098d83413ebdfc3bf876", + "reference": "f56b220fe2db1ade4c88098d83413ebdfc3bf876", "shasum": "" }, "require": { @@ -11887,6 +11887,11 @@ "spatie/pest-plugin-snapshots": "^1.1" }, "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.x-dev" + } + }, "autoload": { "psr-4": { "Spatie\\ArrayToXml\\": "src" @@ -11912,7 +11917,7 @@ "xml" ], "support": { - "source": "https://github.com/spatie/array-to-xml/tree/3.2.3" + "source": "https://github.com/spatie/array-to-xml/tree/3.3.0" }, "funding": [ { @@ -11924,7 +11929,7 @@ "type": "github" } ], - "time": "2024-02-07T10:39:02+00:00" + "time": "2024-05-01T10:20:27+00:00" }, { "name": "symfony/browser-kit", @@ -12503,16 +12508,16 @@ }, { "name": "vimeo/psalm", - "version": "5.23.1", + "version": "5.24.0", "source": { "type": "git", "url": "https://github.com/vimeo/psalm.git", - "reference": "8471a896ccea3526b26d082f4461eeea467f10a4" + "reference": "462c80e31c34e58cc4f750c656be3927e80e550e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vimeo/psalm/zipball/8471a896ccea3526b26d082f4461eeea467f10a4", - "reference": "8471a896ccea3526b26d082f4461eeea467f10a4", + "url": "https://api.github.com/repos/vimeo/psalm/zipball/462c80e31c34e58cc4f750c656be3927e80e550e", + "reference": "462c80e31c34e58cc4f750c656be3927e80e550e", "shasum": "" }, "require": { @@ -12609,7 +12614,7 @@ "issues": "https://github.com/vimeo/psalm/issues", "source": "https://github.com/vimeo/psalm" }, - "time": "2024-03-11T20:33:46+00:00" + "time": "2024-05-01T19:32:08+00:00" }, { "name": "vincentlanglet/twig-cs-fixer", diff --git a/public/js/extensions/bootstrap-table-extensions.js b/public/js/extensions/bootstrap-table-extensions.js index ed7e8abd1..83eaa4f9f 100644 --- a/public/js/extensions/bootstrap-table-extensions.js +++ b/public/js/extensions/bootstrap-table-extensions.js @@ -44,7 +44,7 @@ function loadingTemplate(message) { } /** - * JQuery extension for Bootstrap tables, rows and cells. + * JQuery extension for Bootstrap tables rows and cells. */ (function ($) { 'use strict'; @@ -204,7 +204,7 @@ function loadingTemplate(message) { // data? if (data.length !== 0) { - // hide empty data message + // hide the empty data message $this.hideCustomViewMessage(); const params = $this.getParameters(); const selector = '.custom-view-actions:eq(%index%)'; @@ -230,7 +230,7 @@ function loadingTemplate(message) { } $this.highlight(); } else { - // show empty data message + // show the empty data message $this.showCustomViewMessage(); } $this.saveParameters(); @@ -932,8 +932,26 @@ function loadingTemplate(message) { options = options ? options : $this.getOptions(); pageNumber = pageNumber || options.pageNumber; const text = $('#modal-page').data('page'); - return text.replace('%page%', pageNumber) - .replace('%pages%', options.totalPages); + return text.replace('%page%', $.formatInt(pageNumber)) + .replace('%pages%', $.formatInt(options.totalPages)); + }, + + /** + * Format the records range. + * + * @param {Options} [options] the options to get pages from. + * @param {number} [pageNumber] the optional current page. + */ + formatRecords: function (options, pageNumber) { + const $this = $(this); + options = options ? options : $this.getOptions(); + pageNumber = pageNumber || options.pageNumber; + const pageSize = options.pageSize; + const record = Math.max(1 + (pageNumber - 1) * pageSize, 1); + const records = Math.min(record + pageSize - 1, options.totalRows); + const text = $('#modal-page').data('record'); + return text.replace('%record%', $.formatInt(record)) + .replace('%records%', $.formatInt(records)); }, /** @@ -948,7 +966,8 @@ function loadingTemplate(message) { const $this = $(this); const $range = $('#page-range'); - const $label = $('#page-label'); + const $labelRecord = $('#page-record'); + const $labelLabel = $('#page-label'); const $button = $('#page-button'); $dialog.on('keydown', function (e) { if (e.key === 'Enter') { @@ -982,9 +1001,12 @@ function loadingTemplate(message) { } $range.on('input', function () { - const title = $this.formatPages($range.data('options'), $range.intVal()); + const value = $range.intVal(); + const title = $this.formatPages($range.data('options'), value); + const records = $this.formatRecords($range.data('options'), value); $range.attr('title', title); - $label.text(title); + $labelLabel.text(title); + $labelRecord.text(records); }); $button.on('click', function () { diff --git a/public/js/extensions/jquery-extensions.js b/public/js/extensions/jquery-extensions.js index bb8b8cdd3..eb4c53e9c 100644 --- a/public/js/extensions/jquery-extensions.js +++ b/public/js/extensions/jquery-extensions.js @@ -48,10 +48,10 @@ }, /** - * Returns if the given data is a boolean. + * Returns if the given data is boolean. * * @param {any} data - The data to evaluate. - * @return {boolean} true if a boolean. + * @return {boolean} true if boolean. */ isBoolean: function (data) { return typeof data === 'boolean'; @@ -102,7 +102,7 @@ }, /** - * Format a value with 0 decimal and grouping separator. + * Format a value with 0 decimal and the grouping separator. * * @param {number} value - the value to format. * @returns {string} the formatted value. @@ -145,7 +145,7 @@ $.fn.extend({ /** - * Check if the element is visible into area of the browser window. + * Check if the element is visible into the area of the browser window. * * @param {int} bottomMargin - The bottom margin (default to 50). * @return {boolean} true if visible, false if not. @@ -395,7 +395,7 @@ return false; } - // check type (copied from accept method) + // check the type (copied from accept method) let type = $(this).attr('accept') || false; if (type) { type = type.replace(/[\-\[\]\/\{\}\(\)\+\?\.\\\^\$\|]/g, '\\$&') @@ -520,7 +520,7 @@ }, /** - * Returns if the given attribute exist and is not false or null. + * Returns if the given attribute exists and is not false or null. * * @param {string} name - the attribute name to check existence for. * @return {boolean} true if the attribute name is set. diff --git a/src/Controller/AbstractController.php b/src/Controller/AbstractController.php index 443950fef..56afe8689 100644 --- a/src/Controller/AbstractController.php +++ b/src/Controller/AbstractController.php @@ -79,16 +79,6 @@ public function getAddressFrom(): Address return new Address($email, $name); } - /** - * Gets the application service. - * - * @throws \LogicException if the service can not be found - */ - public function getApplication(): ApplicationService - { - return $this->getUserService()->getApplication(); - } - /** * Gets the application name and version. */ @@ -105,18 +95,28 @@ public function getApplicationOwnerUrl(): string return $this->getParameterString('app_owner_url'); } + /** + * Gets the application service. + * + * @throws \LogicException if the service cannot be found + */ + public function getApplicationService(): ApplicationService + { + return $this->getUserService()->getApplication(); + } + /** * Gets the minimum margin, in percent, for a calculation. */ public function getMinMargin(): float { - return $this->getApplication()->getMinMargin(); + return $this->getApplicationService()->getMinMargin(); } /** * Gets the request stack. * - * @throws \LogicException if the service can not be found + * @throws \LogicException if the service cannot be found * * @psalm-suppress MixedAssignment * @psalm-suppress MixedReturnStatement @@ -137,17 +137,18 @@ public function getRequestStack(): RequestStack public static function getSubscribedServices(): array { - return \array_merge(parent::getSubscribedServices(), [ + return [ + ...parent::getSubscribedServices(), UserService::class, TranslatorInterface::class, UrlGeneratorService::class, - ]); + ]; } /** * Gets the translator. * - * @throws \LogicException if the service can not be found + * @throws \LogicException if the service cannot be found */ public function getTranslator(): TranslatorInterface { @@ -165,7 +166,7 @@ public function getTranslator(): TranslatorInterface /** * Gets the URL generator service. * - * @throws \LogicException if the service can not be found + * @throws \LogicException if the service cannot be found */ public function getUrlGenerator(): UrlGeneratorService { @@ -193,7 +194,7 @@ public function getUserIdentifier(): ?string /** * Gets the user service. * - * @throws \LogicException if the service can not be found + * @throws \LogicException if the service cannot be found */ public function getUserService(): UserService { @@ -209,7 +210,7 @@ public function getUserService(): UserService } /** - * Display a message, if not empty; and redirect to the home page. + * Display a message, if not empty, and redirect to the home page. * * If the request is not null, and the caller parameter is set, redirect to it. */ @@ -316,7 +317,7 @@ protected function jsonException(\Exception $e, ?string $message = null): JsonRe } /** - * Returns a Json response with false as result. + * Returns a Json response with false as the result. * * @param array $data the data to merge within the response */ @@ -326,7 +327,7 @@ protected function jsonFalse(array $data = []): JsonResponse } /** - * Returns a Json response with true as result. + * Returns a Json response with true as the result. * * @param array $data the data to merge within the response */ diff --git a/src/Controller/AbstractEntityController.php b/src/Controller/AbstractEntityController.php index 30d30f3bc..49dc95c60 100644 --- a/src/Controller/AbstractEntityController.php +++ b/src/Controller/AbstractEntityController.php @@ -130,7 +130,7 @@ protected function deleteEntity( } /** - * This function delete the given entity from the database. + * This function deletes the given entity from the database. * * @psalm-param TEntity $item */ @@ -286,9 +286,9 @@ protected function renderWordDocument(WordDocument $doc, bool $inline = true, st } /** - * This function save the given entity to the database. + * This function saves the given entity to the database. * - * Derived class can update entity before it is saved to the database. + * Derived class can update the entity before it is saved to the database. * * @psalm-param TEntity $item */ diff --git a/src/Controller/AdminController.php b/src/Controller/AdminController.php index 2dd72ec54..2219bc838 100644 --- a/src/Controller/AdminController.php +++ b/src/Controller/AdminController.php @@ -64,7 +64,7 @@ public function clearCache( $form = $this->createForm(FormType::class); if ($this->handleRequestForm($request, $form)) { $this->getUserService()->clearCache(); - $this->getApplication()->clearCache(); + $this->getApplicationService()->clearCache(); try { if ($service->clear()) { @@ -130,7 +130,7 @@ public function dumpSql(KernelInterface $kernel): Response #[GetPost(path: '/parameters', name: 'admin_parameters')] public function parameters(Request $request): Response { - $application = $this->getApplication(); + $application = $this->getApplicationService(); $data = $application->getProperties(); $form = $this->createForm(ApplicationParametersType::class, $data); if ($this->handleRequestForm($request, $form)) { @@ -156,7 +156,7 @@ public function parameters(Request $request): Response #[GetPost(path: '/rights/admin', name: 'admin_rights_admin')] public function rightsAdmin(Request $request, RoleBuilderService $service): Response { - $application = $this->getApplication(); + $application = $this->getApplicationService(); $roleName = RoleInterface::ROLE_ADMIN; $rights = $application->getAdminRights(); $default = $service->getRoleAdmin(); @@ -171,7 +171,7 @@ public function rightsAdmin(Request $request, RoleBuilderService $service): Resp #[GetPost(path: '/rights/user', name: 'admin_rights_user')] public function rightsUser(Request $request, RoleBuilderService $service): Response { - $application = $this->getApplication(); + $application = $this->getApplicationService(); $roleName = RoleInterface::ROLE_USER; $rights = $application->getUserRights(); $default = $service->getRoleUser(); diff --git a/src/Controller/AjaxCalculationController.php b/src/Controller/AjaxCalculationController.php index 90122aeb0..52ffc78d1 100644 --- a/src/Controller/AjaxCalculationController.php +++ b/src/Controller/AjaxCalculationController.php @@ -67,6 +67,8 @@ public function renderTaskDialog(TaskRepository $repository): JsonResponse /** * Update the total of a calculation. + * + * @throws \Doctrine\ORM\Exception\ORMException */ #[Post(path: '/update', name: 'ajax_update')] public function update(Request $request, CalculationService $service, LoggerInterface $logger): JsonResponse diff --git a/src/Controller/AjaxTranslateController.php b/src/Controller/AjaxTranslateController.php index 51db2835b..6275998c1 100644 --- a/src/Controller/AjaxTranslateController.php +++ b/src/Controller/AjaxTranslateController.php @@ -40,7 +40,7 @@ public function __construct(private readonly TranslatorFactory $factory) } /** - * Identifies the language of a piece of text. + * Identifies the language for a piece of text. * * @throws ServiceNotFoundException if the service is not found */ diff --git a/src/Controller/CalculationArchiveController.php b/src/Controller/CalculationArchiveController.php index 9e22b2294..b00661224 100644 --- a/src/Controller/CalculationArchiveController.php +++ b/src/Controller/CalculationArchiveController.php @@ -48,7 +48,7 @@ public function invoke(Request $request, CalculationArchiveService $service): Re } $query = $service->createQuery(); - $application = $this->getApplication(); + $application = $this->getApplicationService(); $form = $this->createQueryForm($service, $query); if ($this->handleRequestForm($request, $form)) { $service->saveQuery($query); diff --git a/src/Controller/CalculationBelowController.php b/src/Controller/CalculationBelowController.php index 67e74dea0..7b8c9a08b 100644 --- a/src/Controller/CalculationBelowController.php +++ b/src/Controller/CalculationBelowController.php @@ -44,7 +44,7 @@ class CalculationBelowController extends AbstractController /** * Export the calculations to a Spreadsheet document. * - * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException if the report can not be rendered + * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException if the report cannot be rendered * @throws \Doctrine\ORM\Exception\ORMException * @throws \PhpOffice\PhpSpreadsheet\Exception */ diff --git a/src/Controller/CalculationController.php b/src/Controller/CalculationController.php index a6eba495e..a5e6c799f 100644 --- a/src/Controller/CalculationController.php +++ b/src/Controller/CalculationController.php @@ -65,7 +65,7 @@ public function __construct(CalculationRepository $repository, private readonly public function add(Request $request): Response { $item = new Calculation(); - $application = $this->getApplication(); + $application = $this->getApplicationService(); $state = $application->getDefaultState(); if ($state instanceof CalculationState) { $item->setState($state); @@ -88,7 +88,7 @@ public function add(Request $request): Response public function clone(Request $request, Calculation $item): Response { $description = $this->trans('common.clone_description', ['%description%' => $item->getDescription()]); - $state = $this->getApplication()->getDefaultState(); + $state = $this->getApplicationService()->getDefaultState(); $clone = $item->clone($state, $description); $parameters = [ 'title' => 'calculation.clone.title', @@ -293,6 +293,6 @@ private function getQrCode(UrlGeneratorInterface $generator, Calculation $calcul private function isMarginBelow(Calculation $calculation): bool { - return $this->getApplication()->isMarginBelow($calculation); + return $this->getApplicationService()->isMarginBelow($calculation); } } diff --git a/src/Controller/CalculationStateController.php b/src/Controller/CalculationStateController.php index 31d36de03..3b0250c20 100644 --- a/src/Controller/CalculationStateController.php +++ b/src/Controller/CalculationStateController.php @@ -178,7 +178,7 @@ public function table( */ protected function deleteFromDatabase(EntityInterface $item): void { - $this->getApplication()->updateDeletedState($item); + $this->getApplicationService()->updateDeletedState($item); parent::deleteFromDatabase($item); } } diff --git a/src/Controller/CalculationUpdateController.php b/src/Controller/CalculationUpdateController.php index f8f230521..24cab7999 100644 --- a/src/Controller/CalculationUpdateController.php +++ b/src/Controller/CalculationUpdateController.php @@ -28,7 +28,7 @@ use Symfony\Component\Security\Http\Attribute\IsGranted; /** - * Controller to update overall total of calculations. + * Controller to update the overall total of calculations. */ #[AsController] #[Route(path: '/admin')] @@ -42,7 +42,7 @@ class CalculationUpdateController extends AbstractController public function update(Request $request, CalculationUpdateService $service): Response { $query = $service->createQuery(); - $application = $this->getApplication(); + $application = $this->getApplicationService(); $form = $this->createQueryForm($query); if ($this->handleRequestForm($request, $form)) { $service->saveQuery($query); diff --git a/src/Controller/CategoryController.php b/src/Controller/CategoryController.php index 7c0d3936a..655de34ee 100644 --- a/src/Controller/CategoryController.php +++ b/src/Controller/CategoryController.php @@ -191,7 +191,7 @@ public function table( */ protected function deleteFromDatabase(EntityInterface $item): void { - $this->getApplication()->updateDeletedCategory($item); + $this->getApplicationService()->updateDeletedCategory($item); parent::deleteFromDatabase($item); } } diff --git a/src/Controller/GroupController.php b/src/Controller/GroupController.php index e23a60c54..89818f909 100644 --- a/src/Controller/GroupController.php +++ b/src/Controller/GroupController.php @@ -132,8 +132,7 @@ public function excel(): SpreadsheetResponse { $entities = $this->getEntities('code'); if ([] === $entities) { - $message = $this->trans('group.list.empty'); - throw $this->createNotFoundException($message); + throw $this->createNotFoundException($this->trans('group.list.empty')); } $doc = new GroupsDocument($this, $entities); @@ -143,7 +142,7 @@ public function excel(): SpreadsheetResponse /** * Export the groups to a PDF document. * - * @throws NotFoundHttpException if no group is found + * @throws NotFoundHttpException * @throws \Doctrine\ORM\Exception\ORMException */ #[Get(path: '/pdf', name: 'group_pdf')] @@ -151,8 +150,7 @@ public function pdf(): PdfResponse { $entities = $this->getEntities('code'); if ([] === $entities) { - $message = $this->trans('group.list.empty'); - throw $this->createNotFoundException($message); + throw $this->createNotFoundException($this->trans('group.list.empty')); } $doc = new GroupsReport($this, $entities); diff --git a/src/Controller/ImportAddressController.php b/src/Controller/ImportAddressController.php index fdeb7c128..967e36b83 100644 --- a/src/Controller/ImportAddressController.php +++ b/src/Controller/ImportAddressController.php @@ -52,7 +52,7 @@ public function invoke(Request $request, SwissPostUpdater $updater): Response } return $this->render('admin/import_query.html.twig', [ - 'last_import' => $this->getApplication()->getLastImport(), + 'last_import' => $this->getApplicationService()->getLastImport(), 'data_url' => self::DATA_URL, 'form' => $form, ]); diff --git a/src/Controller/IndexController.php b/src/Controller/IndexController.php index 2e5a5e150..31341418f 100644 --- a/src/Controller/IndexController.php +++ b/src/Controller/IndexController.php @@ -192,7 +192,7 @@ private function checkAjaxRequest(Request $request): void */ private function count($className): int { - return $this->manager->getRepository($className)->count([]); + return $this->manager->getRepository($className)->count(); } private function getCalculations(int $maxResults, ?UserInterface $user): array diff --git a/src/Controller/OpenWeatherController.php b/src/Controller/OpenWeatherController.php index 23fda9135..f9470b7c7 100644 --- a/src/Controller/OpenWeatherController.php +++ b/src/Controller/OpenWeatherController.php @@ -98,7 +98,7 @@ public function __construct(private readonly OpenWeatherService $service) } /** - * Returns current conditions data for a specific location. + * Returns the current conditions data for a specific location. * * @psalm-api */ @@ -143,7 +143,7 @@ public function apiDaily(Request $request): JsonResponse } /** - * Returns 5 days / 3 hours forecast conditions data for a specific location. + * Returns 5-days / 3-hour forecast conditions data for a specific location. * * @psalm-api */ @@ -233,7 +233,7 @@ public function apiSearch(Request $request, UrlGeneratorInterface $generator): J } /** - * Returns current conditions data for a specific location. + * Returns the current conditions data for a specific location. */ #[Get(path: '/current', name: 'openweather_current')] public function current(Request $request): Response diff --git a/src/Controller/ProductController.php b/src/Controller/ProductController.php index 72647ba1d..328b56eb0 100644 --- a/src/Controller/ProductController.php +++ b/src/Controller/ProductController.php @@ -56,7 +56,7 @@ public function __construct(ProductRepository $repository) public function add(Request $request): Response { $item = new Product(); - $category = $this->getApplication()->getDefaultCategory(); + $category = $this->getApplicationService()->getDefaultCategory(); if ($category instanceof Category) { $item->setCategory($category); } @@ -162,7 +162,7 @@ public function table( */ protected function deleteFromDatabase(EntityInterface $item): void { - $this->getApplication()->updateDeletedProduct($item); + $this->getApplicationService()->updateDeletedProduct($item); parent::deleteFromDatabase($item); } } diff --git a/src/Controller/ProductUpdateController.php b/src/Controller/ProductUpdateController.php index fcae43e66..cc99d8323 100644 --- a/src/Controller/ProductUpdateController.php +++ b/src/Controller/ProductUpdateController.php @@ -40,7 +40,7 @@ class ProductUpdateController extends AbstractController public function invoke(Request $request, ProductUpdateService $service): Response { $query = $service->createQuery(); - $application = $this->getApplication(); + $application = $this->getApplicationService(); $form = $this->createQueryForm($service, $query); if ($this->handleRequestForm($request, $form)) { $service->saveQuery($query); diff --git a/src/Controller/ProfileController.php b/src/Controller/ProfileController.php index 42da9046b..346346087 100644 --- a/src/Controller/ProfileController.php +++ b/src/Controller/ProfileController.php @@ -34,7 +34,7 @@ class ProfileController extends AbstractController { /** - * Change password of the current user (if any). + * Change the password of the current user (if any). */ #[GetPost(path: '/change-password', name: 'user_profile_change_password')] public function changePassword(Request $request, #[CurrentUser] User $user, EntityManagerInterface $manager): Response diff --git a/src/Controller/ResetPasswordController.php b/src/Controller/ResetPasswordController.php index 67f86420e..1bcbde2e8 100644 --- a/src/Controller/ResetPasswordController.php +++ b/src/Controller/ResetPasswordController.php @@ -76,7 +76,7 @@ public function checkEmail(): Response } /** - * Display and process form to request a password reset. + * Display and process the form to request a password reset. */ #[GetPost(path: '', name: self::ROUTE_REQUEST)] public function request(Request $request, AuthenticationUtils $utils): Response diff --git a/src/Controller/TaskController.php b/src/Controller/TaskController.php index 7214eeb58..5fa813151 100644 --- a/src/Controller/TaskController.php +++ b/src/Controller/TaskController.php @@ -60,7 +60,7 @@ public function __construct(TaskRepository $repository) public function add(Request $request): Response { $item = new Task(); - $category = $this->getApplication()->getDefaultCategory(); + $category = $this->getApplicationService()->getDefaultCategory(); if ($category instanceof Category) { $item->setCategory($category); } diff --git a/src/Database/AbstractDatabase.php b/src/Database/AbstractDatabase.php index 5cd960b8b..f079da920 100644 --- a/src/Database/AbstractDatabase.php +++ b/src/Database/AbstractDatabase.php @@ -39,9 +39,11 @@ abstract class AbstractDatabase extends \SQLite3 implements \Stringable /** * Instantiates and opens the database. * - * @param string $filename Path to the SQLite database, or :memory: to use in-memory database. - * If filename is an empty string, then a private, temporary on-disk database will be created. - * This private database will be automatically deleted as soon as the database connection is closed. + * @param string $filename Path to the SQLite database, or :memory: to use the in-memory database. + * If filename is an empty string, then a private, temporary on-disk database will be + * created. + * This private database will be automatically deleted as soon as the database + * connection is closed. * @param bool $readonly true open the database for reading only. Note that if the file name * does not exist, the database is opened with the * SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE flags. @@ -180,7 +182,7 @@ public function isTransaction(): bool * @param string $name the pragma name * @param mixed|null $value the optional pragma value * - * @return bool true if the succeeded; false on failure + * @return bool true if succeeded; false on failure */ public function pragma(string $name, mixed $value = null): bool { diff --git a/src/Database/SwissDatabase.php b/src/Database/SwissDatabase.php index d96a11317..617b70dbb 100644 --- a/src/Database/SwissDatabase.php +++ b/src/Database/SwissDatabase.php @@ -229,7 +229,7 @@ public function findZip(string $zip, int $limit = 25): array } /** - * Gets the records count for all tables. + * Gets the record's count for all tables. * * @return array{state: int, city: int, street: int} */ diff --git a/src/Entity/AbstractProperty.php b/src/Entity/AbstractProperty.php index 4c65d9b64..3c7b4742c 100644 --- a/src/Entity/AbstractProperty.php +++ b/src/Entity/AbstractProperty.php @@ -58,7 +58,7 @@ public function __construct(?string $name = null) } /** - * Gets this property value as an array. Internally the array is decoded from a JSON string. + * Gets this property value as an array. Internally, the array is decoded from a JSON string. * * @psalm-api */ @@ -130,7 +130,7 @@ public function getValue(): ?string } /** - * Sets the property value as an array. Internally the array is encoded as JSON string. + * Sets the property value as an array. Internally, the array is encoded as JSON string. */ public function setArray(?array $value): static { @@ -184,7 +184,7 @@ public function setString(?string $value): static /** * Sets the property value. * - * This function try first to convert the value to an appropriate type (bool, int, etc...). + * This function tries first to convert the value to an appropriate type (bool, int, etc...). */ public function setValue(mixed $value): static { diff --git a/src/Entity/Calculation.php b/src/Entity/Calculation.php index 0ecdb3c3f..a9b799177 100644 --- a/src/Entity/Calculation.php +++ b/src/Entity/Calculation.php @@ -181,7 +181,7 @@ public function contains(CalculationGroup $group): bool */ public function findCategory(Category $category): CalculationCategory { - // find group + // find the group /** @var Group $categoryGroup */ $categoryGroup = $category->getGroup(); $group = $this->findGroup($categoryGroup); @@ -208,7 +208,7 @@ public function findCategory(Category $category): CalculationCategory */ public function findGroup(Group $group): CalculationGroup { - // find group + // find the group $code = $group->getCode(); foreach ($this->groups as $current) { if ($code === $current->getCode()) { @@ -216,7 +216,7 @@ public function findGroup(Group $group): CalculationGroup } } - // create group + // create the group $newGroup = CalculationGroup::create($group); $this->addGroup($newGroup); @@ -266,7 +266,7 @@ public function getDisplay(): string } /** - * Gets the duplicates items. + * Gets the duplicate items. * * Items are duplicate when two or more item descriptions are equal, ignoring case considerations. * @@ -547,7 +547,7 @@ public function getStateColor(): ?string } /** - * Get total net. This is total of the groups multiplied by the global margin. + * Get total net. This is the total of the groups multiplied by the global margin. */ public function getTotalNet(): float { @@ -641,7 +641,7 @@ public function isEditable(): bool /** * Checks whether the groups are empty (contains no elements). * - * @return bool true if the groups is empty, false otherwise + * @return bool true if groups are empty, false otherwise */ public function isEmpty(): bool { @@ -803,7 +803,7 @@ public function setGlobalMargin(float $globalMargin): self } /** - * Sets the items total. + * Sets the item's total. */ public function setItemsTotal(float $itemsTotal): self { @@ -867,7 +867,7 @@ public function sort(): bool /** * Update the group and category codes. * - * @return int the number of update + * @return int the number of updates * * @psalm-api */ diff --git a/src/Entity/CalculationCategory.php b/src/Entity/CalculationCategory.php index 159c2c0ef..1bf209008 100644 --- a/src/Entity/CalculationCategory.php +++ b/src/Entity/CalculationCategory.php @@ -182,7 +182,7 @@ public function getParentEntity(): ?Calculation /** * Checks whether the category is empty (contains no items). * - * @return bool true if the groups is empty, false otherwise + * @return bool true if groups are empty, false otherwise */ public function isEmpty(): bool { @@ -265,7 +265,7 @@ public function setGroup(?CalculationGroup $group): self } /** - * Sorts this items by the alphabetical order of descriptions. + * Sorts items by the alphabetical order of descriptions. * * @return bool true if the order has changed */ diff --git a/src/Entity/CalculationGroup.php b/src/Entity/CalculationGroup.php index c952286fa..337f1f822 100644 --- a/src/Entity/CalculationGroup.php +++ b/src/Entity/CalculationGroup.php @@ -206,7 +206,7 @@ public function getTotal(): float /** * Checks whether the categories are empty (contains no categories). * - * @return bool true if the groups is empty, false otherwise + * @return bool true if the groups are empty, false otherwise */ public function isEmpty(): bool { diff --git a/src/Entity/CalculationItem.php b/src/Entity/CalculationItem.php index b95ec5ca7..ea6f6c035 100644 --- a/src/Entity/CalculationItem.php +++ b/src/Entity/CalculationItem.php @@ -144,7 +144,7 @@ public function getUnit(): ?string } /** - * Returns if the price or the quantity are equal to zero. + * Returns if the price or the quantity is equal to zero. */ public function isEmpty(): bool { diff --git a/src/Entity/Customer.php b/src/Entity/Customer.php index a452663ce..8ab3bb5b4 100644 --- a/src/Entity/Customer.php +++ b/src/Entity/Customer.php @@ -92,7 +92,7 @@ public function getAddress(): ?string } /** - * Get age or null if birthday is null. + * Get age or null if the birthday is null. */ public function getAge(): ?int { diff --git a/src/Entity/Group.php b/src/Entity/Group.php index d6f37b8b3..59207cea1 100644 --- a/src/Entity/Group.php +++ b/src/Entity/Group.php @@ -200,7 +200,7 @@ public function findMargin(float $amount): ?GroupMargin * * @param float $amount the amount to get percent for * - * @return float the percent of the group margin, if found; 0 otherwise + * @return float the percentage of the group margin, if found; 0 otherwise * * @see Group::findMargin() */ diff --git a/src/Entity/User.php b/src/Entity/User.php index 67738666c..ef2c0346e 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -412,7 +412,7 @@ public function setEnabled(bool $enabled): self /** * Sets image file. * - * If manually uploading a file (i.e., not using Symfony Form) ensure an instance + * If manually uploading a file (i.e., not using Symfony Form), ensure an instance * of 'UploadedFile' is injected into this setter to trigger the update. If this * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter * must be able to accept an instance of 'File' as the bundle will inject one here diff --git a/src/Enums/EntityName.php b/src/Enums/EntityName.php index 241fde941..6c608ed9f 100644 --- a/src/Enums/EntityName.php +++ b/src/Enums/EntityName.php @@ -119,7 +119,7 @@ public static function constants(): array } /** - * Gets the rights field name. + * Gets rights field name. */ public function getRightsField(): string { diff --git a/src/Enums/EntityPermission.php b/src/Enums/EntityPermission.php index 2316c583c..3696636cc 100644 --- a/src/Enums/EntityPermission.php +++ b/src/Enums/EntityPermission.php @@ -32,37 +32,37 @@ enum EntityPermission: int implements EnumConstantsInterface, EnumSortableInterf use TranslatableEnumTrait; /** - * Allow to add an entity. + * Allows adding an entity. */ #[EnumCase('add')] case ADD = 1 << 0; /** - * Allow to delete an entity. + * Allows deleting an entity. */ #[EnumCase('delete')] case DELETE = 1 << 1; /** - * Allow to edit an entity. + * Allows editing an entity. */ #[EnumCase('edit')] case EDIT = 1 << 2; /** - * Allow to export entities. + * Allows exporting entities. */ #[EnumCase('export')] case EXPORT = 1 << 3; /** - * Allow to list entities. + * Allows listing entities. */ #[EnumCase('list')] case LIST = 1 << 4; /** - * Allow to show an entity. + * Allows showing an entity. */ #[EnumCase('show')] case SHOW = 1 << 5; diff --git a/src/Enums/Environment.php b/src/Enums/Environment.php index bf2679a84..3ef1e6b61 100644 --- a/src/Enums/Environment.php +++ b/src/Enums/Environment.php @@ -50,7 +50,7 @@ public function isDevelopment(): bool } /** - * Returns if this is enumeration the production environment. + * Returns if this enumeration is the production environment. * * @return bool true if production environment */ diff --git a/src/Enums/FlashType.php b/src/Enums/FlashType.php index b4366f605..277d2661a 100644 --- a/src/Enums/FlashType.php +++ b/src/Enums/FlashType.php @@ -46,7 +46,7 @@ enum FlashType: string implements TranslatableEnumInterface case SUCCESS = 'success'; /** - * Warning flash bag. + * Warning flash-bag. */ #[EnumCase(extras: ['icon' => 'fas fa-lg fa-exclamation-circle'])] case WARNING = 'warning'; diff --git a/src/Enums/MessagePosition.php b/src/Enums/MessagePosition.php index da941ea94..32011d5da 100644 --- a/src/Enums/MessagePosition.php +++ b/src/Enums/MessagePosition.php @@ -21,7 +21,7 @@ use Elao\Enum\Bridge\Symfony\Translation\TranslatableEnumTrait; /** - * The message position for flash bag. + * The message position for flash-bag. * * @implements EnumDefaultInterface * @implements EnumSortableInterface diff --git a/src/Form/AbstractChoiceType.php b/src/Form/AbstractChoiceType.php index cd15cdd62..6671bb5de 100644 --- a/src/Form/AbstractChoiceType.php +++ b/src/Form/AbstractChoiceType.php @@ -36,9 +36,9 @@ public function getParent(): ?string } /** - * Gets the choices array. + * Gets the choice array. * - * @return array an array, where the array key is the item's label and the array value is the item's value + * @return array an array, where the array key is the item's label, and the array value is the item's value */ abstract protected function getChoices(): array; } diff --git a/src/Form/Extension/AbstractFileTypeExtension.php b/src/Form/Extension/AbstractFileTypeExtension.php index 4ab855bbd..3e62e5a19 100644 --- a/src/Form/Extension/AbstractFileTypeExtension.php +++ b/src/Form/Extension/AbstractFileTypeExtension.php @@ -85,11 +85,11 @@ protected function updateAttributes(array $options, array $attributes): array /** * Normalize the given size. * - * @param int|string $size the size to normalize + * @param int|string $size the value to normalize * * @return int|null the normalized size * - * @throws InvalidOptionsException if the $size can not be parsed + * @throws InvalidOptionsException if the $size cannot be parsed * * @see https://symfony.com/doc/current/reference/constraints/File.html#maxsize */ diff --git a/src/Form/FormHelper.php b/src/Form/FormHelper.php index ab04a0ad1..a42362334 100644 --- a/src/Form/FormHelper.php +++ b/src/Form/FormHelper.php @@ -159,7 +159,7 @@ public function addCheckboxType(bool $notRequired = true, bool $switch = true): /** * Adds a choice type to the builder and reset all values to default. * - * @param array $choices an array, where the array key is the item's label and the array value is the item's value + * @param array $choices an array, where the array key is the item's label, and the array value is the item's value */ public function addChoiceType(array $choices): self { @@ -170,7 +170,7 @@ public function addChoiceType(array $choices): self /** * Add a collection type to the builder with the given entry type and reset all values to default. * - * @param string $entryType the entry type class, must be a subclass of FormTypeInterface class + * @param string $entryType the entry type class must be a subclass of FormTypeInterface class * @param array $options the default options to override * * @throws UnexpectedValueException if the entry type is not an instance of FormTypeInterface class @@ -337,8 +337,9 @@ public function addPercentType(?int $min = null, ?int $max = null, float $step = /** * Add a plain type to the builder and reset all values to default. + * * This type just renders the field as a span tag. This is useful for - * forms where certain field need to be shown but not editable. + * forms where certain field needs to be shown but not editable. * * @param bool $expanded true to render the plain type within the label */ @@ -453,7 +454,7 @@ public function addTrueFalseType( /** * Add an Url type to the builder and reset all values to default. * - * @param string $protocol If a value is submitted, that doesn't begin with some protocol + * @param string $protocol If a value is submitted, that doesn't begin with some protocol, * (e.g. http://, ftp://, etc.), this protocol will be prepended to the string when the * data is submitted to the form. */ @@ -523,7 +524,7 @@ public function autocomplete(bool|string $autocomplete): self } /** - * Sets the constraints option. + * Sets constraints option. */ public function constraints(Constraint ...$constrains): self { @@ -587,7 +588,7 @@ public function field(string $field): self } /** - * Gets the underlaying form builder. + * Gets the underlying form builder. */ public function getBuilder(): FormBuilderInterface { @@ -657,7 +658,7 @@ public function labelClass(string $classNames): self * Adds a pre-set-data event listener to this form builder. * * @param callable(PreSetDataEvent): void $listener the event listener to add - * @param int $priority The priority of the listener. Listeners with a higher + * @param int $priority The priority of the listener. Listeners with the higher * priority are called before listeners with a lower priority. */ public function listenerPreSetData(callable $listener, int $priority = 0): self @@ -671,7 +672,7 @@ public function listenerPreSetData(callable $listener, int $priority = 0): self * Adds a pre-submit event listener to this form builder. * * @param callable(PreSubmitEvent): void $listener $listener the event listener to add - * @param int $priority The priority of the listener. Listeners with a higher + * @param int $priority The priority of the listener. Listeners with the higher * priority are called before listeners with a lower priority. */ public function listenerPreSubmit(callable $listener, int $priority = 0): self @@ -747,8 +748,9 @@ public function percent(bool $visible): self /** * Sets the priority. * - * @param int $priority the priority to set. Fields with higher priorities are rendered first and fields with same - * priority are rendered in their original order. + * @param int $priority the priority to set. + * Fields with higher priorities are rendered first, and fields with the same priority + * are rendered in their original order. */ public function priority(int $priority): self { @@ -896,7 +898,7 @@ public function widgetClass(string $classNames): self } /** - * Add one or more classes. Do nothing if the given classe names is empty. + * Add one or more classes. Do nothing if the given class names are empty. * * @psalm-param array $array */ diff --git a/src/Form/Task/TaskItemMarginType.php b/src/Form/Task/TaskItemMarginType.php index c7efadf0d..abae20a2b 100644 --- a/src/Form/Task/TaskItemMarginType.php +++ b/src/Form/Task/TaskItemMarginType.php @@ -30,7 +30,7 @@ public function __construct() protected function addFormFields(FormHelper $helper): void { - // must-validate class ? + // must-validate class? $helper->field('minimum') ->widgetClass('validate-minimum') ->addNumberType(); diff --git a/src/Form/Type/PlainType.php b/src/Form/Type/PlainType.php index 1e9796a7b..4c7aed952 100644 --- a/src/Form/Type/PlainType.php +++ b/src/Form/Type/PlainType.php @@ -24,7 +24,7 @@ /** * A form type that just renders the field as a span tag. * - * This is useful for forms where certain field need to be shown but not editable. + * This is useful for forms where certain field needs to be shown but not editable. * If the 'expanded' option is set to true, a div tag is added around the span tag. * * @extends AbstractType @@ -298,7 +298,7 @@ private function formatPercent(float|int|string $value, array $options): string } /** - * @throws TransformationFailedException if the value can not be mapped to a string + * @throws TransformationFailedException if the value cannot be mapped to a string * * @psalm-param OptionsType $options */ diff --git a/src/Form/Type/RepeatPasswordType.php b/src/Form/Type/RepeatPasswordType.php index 654c370f5..9db2ffd3a 100644 --- a/src/Form/Type/RepeatPasswordType.php +++ b/src/Form/Type/RepeatPasswordType.php @@ -22,14 +22,14 @@ use Symfony\Component\Validator\Constraints\NotBlank; /** - * Repeat password type. + * Repeat a password type. * * @extends AbstractType */ class RepeatPasswordType extends AbstractType { /** - * The default translatable confirm label. + * The default translatable confirmation label. */ final public const CONFIRM_LABEL = 'user.password.confirmation'; diff --git a/src/Form/Type/SimpleEditorType.php b/src/Form/Type/SimpleEditorType.php index a3b916305..03894bf66 100644 --- a/src/Form/Type/SimpleEditorType.php +++ b/src/Form/Type/SimpleEditorType.php @@ -95,7 +95,7 @@ private function getDefaultActions(): array } /** - * Filter, update and group actions. + * Filters, updates, and groups actions. * * @psalm-param array{actions?: array, ...} $options */ diff --git a/src/Form/User/ProfileChangePasswordType.php b/src/Form/User/ProfileChangePasswordType.php index 7747cb252..26f494df2 100644 --- a/src/Form/User/ProfileChangePasswordType.php +++ b/src/Form/User/ProfileChangePasswordType.php @@ -91,7 +91,7 @@ private function validate(ExecutionContextInterface $context): void $violations = $context->getValidator() ->validate($password->getData(), new NotCompromisedPassword()); - // if compromised assign the error to the password field + // if compromised, assign the error to the password field if ($violations->count() > 0) { $password->addError(new FormError((string) $violations)); } diff --git a/src/Form/User/UserChangePasswordType.php b/src/Form/User/UserChangePasswordType.php index 7f260d76b..0e666886e 100644 --- a/src/Form/User/UserChangePasswordType.php +++ b/src/Form/User/UserChangePasswordType.php @@ -17,7 +17,7 @@ use App\Form\FormHelper; /** - * Change user password type. + * Change the user password type. * * @template-extends AbstractEntityType */ diff --git a/src/Interfaces/MimeTypeInterface.php b/src/Interfaces/MimeTypeInterface.php index 249140249..490cfb8d4 100644 --- a/src/Interfaces/MimeTypeInterface.php +++ b/src/Interfaces/MimeTypeInterface.php @@ -13,7 +13,7 @@ namespace App\Interfaces; /** - * Class implementing this interface provides function to download document. + * Class implementing this interface provides functions to download the document. */ interface MimeTypeInterface { diff --git a/src/Interfaces/PropertyServiceInterface.php b/src/Interfaces/PropertyServiceInterface.php index f5d6021b3..81fb7c778 100644 --- a/src/Interfaces/PropertyServiceInterface.php +++ b/src/Interfaces/PropertyServiceInterface.php @@ -162,7 +162,7 @@ interface PropertyServiceInterface final public const P_DATE_CALCULATION = 'archive_calculation'; /** - * The property name for the last date of import of Swiss cities (date). + * The property name for the last date import of Swiss cities (date). */ final public const P_DATE_IMPORT = 'last_import'; @@ -262,7 +262,7 @@ interface PropertyServiceInterface final public const P_MIN_STRENGTH = 'min_strength'; /** - * The property name for the numbers of displayed calculation in the home page (int). + * The property name for the numbers of displayed calculations in the home page (int). */ final public const P_PANEL_CALCULATION = 'panel_calculation'; @@ -369,7 +369,7 @@ public function getMessageProgress(): int; public function getMessageTimeout(): int; /** - * Returns a value indicating numbers of displayed calculation in the home page. + * Returns a value indicating numbers of displayed calculations in the home page. */ public function getPanelCalculation(): int; diff --git a/src/Interfaces/RoleInterface.php b/src/Interfaces/RoleInterface.php index acf8c4d66..7a72c41fc 100644 --- a/src/Interfaces/RoleInterface.php +++ b/src/Interfaces/RoleInterface.php @@ -49,11 +49,11 @@ public function getRole(): string; public function getRoles(): array; /** - * Checks if this has the given role. + * Checks if this has a given role. * * @param string $role the role name to be tested * - * @return bool true if this has the given role + * @return bool true if this has a given role * * @psalm-param RoleInterface::ROLE_* $role */ diff --git a/src/Listener/SwitchUserListener.php b/src/Listener/SwitchUserListener.php index f3b340969..994b632d3 100644 --- a/src/Listener/SwitchUserListener.php +++ b/src/Listener/SwitchUserListener.php @@ -49,7 +49,7 @@ public function onSwitchUser(SwitchUserEvent $event): void $original = $this->getOriginalUsername($event); $action = $request->query->getString(self::SWITCH_USER); - // get message + // get the message if (self::EXIT_VALUE === $action) { $id = 'user.switch.exit.success'; } elseif (null !== $original) { diff --git a/src/Logger/UserRequestProcessor.php b/src/Logger/UserRequestProcessor.php index 95073e32c..0adcda49f 100644 --- a/src/Logger/UserRequestProcessor.php +++ b/src/Logger/UserRequestProcessor.php @@ -19,7 +19,7 @@ use Symfony\Component\Security\Core\User\UserInterface; /** - * Log record processor to add user identifier, if any; to extra data. + * Log record processor to add user identifier, if any, to extra data. */ readonly class UserRequestProcessor implements ProcessorInterface { diff --git a/src/Mime/NotificationEmail.php b/src/Mime/NotificationEmail.php index ff7a92552..3c39880f5 100644 --- a/src/Mime/NotificationEmail.php +++ b/src/Mime/NotificationEmail.php @@ -21,7 +21,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; /** - * Extends the NotificationEmail class with translated subject and custom footer. + * Extends the NotificationEmail class with the translated subject and custom footer. */ class NotificationEmail extends BaseNotificationEmail { diff --git a/src/Model/CalculationArchiveResult.php b/src/Model/CalculationArchiveResult.php index 2d35deb0d..446f41186 100644 --- a/src/Model/CalculationArchiveResult.php +++ b/src/Model/CalculationArchiveResult.php @@ -16,7 +16,7 @@ use App\Entity\CalculationState; /** - * Contains result of archive calculations. + * Contains the result of archive calculations. * * @psalm-type ResultsType = array}> */ diff --git a/src/Model/CalculationUpdateQuery.php b/src/Model/CalculationUpdateQuery.php index 2a2ab5531..2cd41ef16 100644 --- a/src/Model/CalculationUpdateQuery.php +++ b/src/Model/CalculationUpdateQuery.php @@ -19,7 +19,7 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface; /** - * Contains parameters to update overall total of calculations. + * Contains parameters to update the overall total of calculations. */ class CalculationUpdateQuery extends AbstractSimulateQuery { diff --git a/src/Model/CalculationUpdateResult.php b/src/Model/CalculationUpdateResult.php index 58efd6de4..0889adc8d 100644 --- a/src/Model/CalculationUpdateResult.php +++ b/src/Model/CalculationUpdateResult.php @@ -15,7 +15,7 @@ use App\Entity\Calculation; /** - * Contains result of update overall total of calculations. + * Contains the result of an update overall total of calculations. */ class CalculationUpdateResult implements \Countable { diff --git a/src/Model/CommandResult.php b/src/Model/CommandResult.php index 5b814ddc3..8d0f9ffeb 100644 --- a/src/Model/CommandResult.php +++ b/src/Model/CommandResult.php @@ -16,7 +16,7 @@ use Symfony\Component\Console\Command\Command; /** - * Contains result of executing a command. + * Contains the result of executing a command. * * @see CommandService::execute() */ diff --git a/src/Model/Comment.php b/src/Model/Comment.php index 2d40e4e38..a4f8a94f7 100644 --- a/src/Model/Comment.php +++ b/src/Model/Comment.php @@ -33,7 +33,7 @@ class Comment private ?array $attachments = null; /** - * The from address. + * The address from. */ #[Assert\NotNull] private ?Address $fromAddress = null; @@ -57,7 +57,7 @@ class Comment private ?string $subject = null; /** - * The to address. + * The address to. */ #[Assert\NotNull] private ?Address $toAddress = null; diff --git a/src/Model/ProductUpdateQuery.php b/src/Model/ProductUpdateQuery.php index e878915b4..9ee71673a 100644 --- a/src/Model/ProductUpdateQuery.php +++ b/src/Model/ProductUpdateQuery.php @@ -134,7 +134,7 @@ public function isAllProducts(): bool } /** - * Returns a value indicating if update is apply with the fixed amount. + * Returns a value indicating if update is applied with the fixed amount. */ public function isFixed(): bool { @@ -142,7 +142,7 @@ public function isFixed(): bool } /** - * Returns a value indicating if update is apply with the percent. + * Returns a value indicating if update is applied with the percent. */ public function isPercent(): bool { diff --git a/src/Model/ProductUpdateResult.php b/src/Model/ProductUpdateResult.php index 7529ea738..3f5dd0f54 100644 --- a/src/Model/ProductUpdateResult.php +++ b/src/Model/ProductUpdateResult.php @@ -13,7 +13,7 @@ namespace App\Model; /** - * Contains result of updated products. + * Contains the result of updated products. * * @psalm-type ProductType = array{description: string|null, oldPrice: float, newPrice: float, delta: float} */ diff --git a/src/Model/SessionQuery.php b/src/Model/SessionQuery.php index b88651b78..2cb3e0050 100644 --- a/src/Model/SessionQuery.php +++ b/src/Model/SessionQuery.php @@ -30,7 +30,7 @@ public function __construct( /** * Get the JSON decoded value. * - * @throws \JsonException if an error occur while decoding this value + * @throws \JsonException if an error occurs while decoding this value */ public function decode(): mixed { diff --git a/src/Model/SwissPostUpdateResult.php b/src/Model/SwissPostUpdateResult.php index ea2e26e58..f9c5aec0a 100644 --- a/src/Model/SwissPostUpdateResult.php +++ b/src/Model/SwissPostUpdateResult.php @@ -13,7 +13,7 @@ namespace App\Model; /** - * Contains result of updated states, cities and streets. + * Contains the result of updated states, cities and streets. * * @psalm-type SwissPostResultType = array{state: int, city: int, street: int} */ @@ -160,7 +160,7 @@ public function getValidity(): ?\DateTimeInterface } /** - * Gets the overwrite option. + * Gets the overwritten option. */ public function isOverwrite(): bool { @@ -202,7 +202,7 @@ public function setOldEntries(array $oldEntries): self } /** - * Sets the overwrite option. + * Sets the overwritten option. * * @psalm-api */ diff --git a/src/Model/TaskComputeResult.php b/src/Model/TaskComputeResult.php index ae3bbb64c..337a636e0 100644 --- a/src/Model/TaskComputeResult.php +++ b/src/Model/TaskComputeResult.php @@ -16,7 +16,7 @@ use App\Entity\TaskItem; /** - * Contains result of a computed task. + * Contains the result of a computed task. * * @psalm-type ResultType = array{ * id: int, diff --git a/src/Pdf/Colors/AbstractPdfColor.php b/src/Pdf/Colors/AbstractPdfColor.php index f9060bbcd..3c84c3d46 100644 --- a/src/Pdf/Colors/AbstractPdfColor.php +++ b/src/Pdf/Colors/AbstractPdfColor.php @@ -67,7 +67,7 @@ public function asInt(): int /** * Gets the black color. * - * Value is RGB(0, 0, 0). + * The value is RGB(0, 0, 0). * * @return static */ @@ -79,7 +79,7 @@ public static function black(): self /** * Gets the blue color. * - * Value is RGB(255, 0, 0). + * The value is RGB(255, 0, 0). * * @return static */ @@ -91,7 +91,7 @@ public static function blue(): self /** * Gets the border cell color. * - * Value is RGB(221, 221, 221). + * The value is RGB(221, 221, 221). * * @return static */ @@ -136,7 +136,7 @@ public static function create(array|int|string|null $rgb): ?static /** * Gets the dark-gray color. * - * Value is RGB(169, 169, 169). + * The value is RGB(169, 169, 169). * * @return static */ @@ -148,7 +148,7 @@ public static function darkGray(): self /** * Gets the dark-green color. * - * Value is RGB(0, 128, 0). + * The value is RGB(0, 128, 0). * * @return static */ @@ -160,7 +160,7 @@ public static function darkGreen(): self /** * Gets the dark-red color. * - * Value is RGB(128, 0, 0). + * The value is RGB(128, 0, 0). * * @return static * @@ -179,7 +179,7 @@ abstract public static function default(): self; /** * Gets the green color. * - * Value is RGB(0, 255, 0). + * The value is RGB(0, 255, 0). * * @return static */ @@ -191,7 +191,7 @@ public static function green(): self /** * Gets the header fill color. * - * Value is RGB(245, 245, 245). + * The value is RGB(245, 245, 245). * * @return static */ @@ -203,7 +203,7 @@ public static function header(): self /** * Gets the link color (blue). * - * Value is RGB(0, 0, 255). + * The value is RGB(0, 0, 255). * * @return static */ @@ -215,7 +215,7 @@ public static function link(): self /** * Gets the red color. * - * Value is RGB(255, 0, 0). + * The value is RGB(255, 0, 0). * * @return static */ @@ -227,7 +227,7 @@ public static function red(): self /** * Gets the white color. * - * Value is RGB(255, 255, 255). + * The value is RGB(255, 255, 255). * * @return static */ diff --git a/src/Pdf/Html/HtmlBrChunk.php b/src/Pdf/Html/HtmlBrChunk.php index a8bd49795..e9b7d96b6 100644 --- a/src/Pdf/Html/HtmlBrChunk.php +++ b/src/Pdf/Html/HtmlBrChunk.php @@ -13,7 +13,7 @@ namespace App\Pdf\Html; /** - * Specialized chunk for HTML line break (br). + * The specialized chunk for HTML line break (br). */ class HtmlBrChunk extends AbstractHtmlChunk { diff --git a/src/Pdf/Html/HtmlMargins.php b/src/Pdf/Html/HtmlMargins.php index 6a87dc3fd..f98762095 100644 --- a/src/Pdf/Html/HtmlMargins.php +++ b/src/Pdf/Html/HtmlMargins.php @@ -115,7 +115,7 @@ public function setMargins(float $margin): self } /** - * Sets right margin. + * Sets the right margin. */ public function setRight(float $right): self { diff --git a/src/Pdf/Html/HtmlPageBreakChunk.php b/src/Pdf/Html/HtmlPageBreakChunk.php index 4cecbc8e0..563e17a95 100644 --- a/src/Pdf/Html/HtmlPageBreakChunk.php +++ b/src/Pdf/Html/HtmlPageBreakChunk.php @@ -15,7 +15,7 @@ use App\Report\HtmlReport; /** - * A special chunk to add a page break to report. + * A special chunk to add a page break to the report. */ class HtmlPageBreakChunk extends AbstractHtmlChunk { diff --git a/src/Pdf/Html/HtmlStyle.php b/src/Pdf/Html/HtmlStyle.php index 65d27ba20..55dc3427c 100644 --- a/src/Pdf/Html/HtmlStyle.php +++ b/src/Pdf/Html/HtmlStyle.php @@ -163,7 +163,7 @@ public function setMargins(float $margin): self } /** - * Sets right margin. + * Sets the right margin. */ public function setRightMargin(float $rightMargin): self { diff --git a/src/Pdf/Interfaces/PdfDrawCellBackgroundInterface.php b/src/Pdf/Interfaces/PdfDrawCellBackgroundInterface.php index f3ae24aa8..82fc19db1 100644 --- a/src/Pdf/Interfaces/PdfDrawCellBackgroundInterface.php +++ b/src/Pdf/Interfaces/PdfDrawCellBackgroundInterface.php @@ -15,7 +15,7 @@ use App\Pdf\Events\PdfCellBackgroundEvent; /** - * Class implementing this interface handle the draw cell background event. + * Class implementing this interface handles the draw cell background event. */ interface PdfDrawCellBackgroundInterface { @@ -24,7 +24,7 @@ interface PdfDrawCellBackgroundInterface * * @param PdfCellBackgroundEvent $event the event * - * @return bool true if listener handle the draw function; false to call the default behavior + * @return bool true if listener handles the draw function; false to call the default behavior */ public function drawCellBackground(PdfCellBackgroundEvent $event): bool; } diff --git a/src/Pdf/Interfaces/PdfDrawCellBorderInterface.php b/src/Pdf/Interfaces/PdfDrawCellBorderInterface.php index 3b51ad770..ce0828fa0 100644 --- a/src/Pdf/Interfaces/PdfDrawCellBorderInterface.php +++ b/src/Pdf/Interfaces/PdfDrawCellBorderInterface.php @@ -15,7 +15,7 @@ use App\Pdf\Events\PdfCellBorderEvent; /** - * Class implementing this interface handle the draw cell border event. + * Class implementing this interface handles the draw cell border event. */ interface PdfDrawCellBorderInterface { @@ -24,7 +24,7 @@ interface PdfDrawCellBorderInterface * * @param PdfCellBorderEvent $event the event * - * @return bool true if listener handle the draw function; false to call the default behavior + * @return bool true if listener handles the draw function; false to call the default behavior */ public function drawCellBorder(PdfCellBorderEvent $event): bool; } diff --git a/src/Pdf/Interfaces/PdfDrawCellTextInterface.php b/src/Pdf/Interfaces/PdfDrawCellTextInterface.php index 5665d8169..03a66ad1d 100644 --- a/src/Pdf/Interfaces/PdfDrawCellTextInterface.php +++ b/src/Pdf/Interfaces/PdfDrawCellTextInterface.php @@ -15,7 +15,7 @@ use App\Pdf\Events\PdfCellTextEvent; /** - * Class implementing this interface handle the draw cell text event. + * Class implementing this interface handles the draw cell text event. */ interface PdfDrawCellTextInterface { @@ -24,7 +24,7 @@ interface PdfDrawCellTextInterface * * @param PdfCellTextEvent $event the event * - * @return bool true if listener handle the draw function; false to call the default behavior + * @return bool true if listener handles the draw function; false to call the default behavior */ public function drawCellText(PdfCellTextEvent $event): bool; } diff --git a/src/Pdf/Interfaces/PdfDrawHeadersInterface.php b/src/Pdf/Interfaces/PdfDrawHeadersInterface.php index 0875e821f..fd348fc12 100644 --- a/src/Pdf/Interfaces/PdfDrawHeadersInterface.php +++ b/src/Pdf/Interfaces/PdfDrawHeadersInterface.php @@ -15,7 +15,7 @@ use App\Pdf\Events\PdfPdfDrawHeadersEvent; /** - * Class implementing this interface handle draw headers event. + * Class implementing this interface handles the draw table headers event. */ interface PdfDrawHeadersInterface { @@ -24,7 +24,7 @@ interface PdfDrawHeadersInterface * * @param PdfPdfDrawHeadersEvent $event the event * - * @return bool true if listener handle the draw function; false to call the default behavior + * @return bool true if the listener handles the draw function; false to call the default behavior */ public function drawHeaders(PdfPdfDrawHeadersEvent $event): bool; } diff --git a/src/Pdf/Interfaces/PdfGroupListenerInterface.php b/src/Pdf/Interfaces/PdfGroupListenerInterface.php index 9aece8c05..1f3c0f5c3 100644 --- a/src/Pdf/Interfaces/PdfGroupListenerInterface.php +++ b/src/Pdf/Interfaces/PdfGroupListenerInterface.php @@ -24,7 +24,7 @@ interface PdfGroupListenerInterface * * @param PdfGroupEvent $event the event * - * @return bool true if the listener handle the output; false to use the default output + * @return bool true if the listener handles the output; false to use the default output */ public function outputGroup(PdfGroupEvent $event): bool; } diff --git a/src/Pdf/Interfaces/PdfLabelTextListenerInterface.php b/src/Pdf/Interfaces/PdfLabelTextListenerInterface.php index 5236693ed..8a23f58f5 100644 --- a/src/Pdf/Interfaces/PdfLabelTextListenerInterface.php +++ b/src/Pdf/Interfaces/PdfLabelTextListenerInterface.php @@ -15,7 +15,7 @@ use App\Pdf\Events\PdfLabelTextEvent; /** - * Class implementing this interface handle the draw label texts event. + * Class implementing this interface handles the draw label texts event. */ interface PdfLabelTextListenerInterface { @@ -24,7 +24,7 @@ interface PdfLabelTextListenerInterface * * @param PdfLabelTextEvent $event the event * - * @return bool true if listener handle the draw function; false to call the default behavior + * @return bool true if listener handles the draw function; false to call the default behavior */ public function drawLabelText(PdfLabelTextEvent $event): bool; } diff --git a/src/Pdf/PdfCell.php b/src/Pdf/PdfCell.php index e275f85d1..30f7d6d5a 100644 --- a/src/Pdf/PdfCell.php +++ b/src/Pdf/PdfCell.php @@ -53,7 +53,9 @@ public function getAlignment(): ?PdfTextAlignment } /** - * Gets the columns span. + * Gets the cell columns span. + * + * @psalm-return positive-int */ public function getCols(): int { @@ -61,7 +63,7 @@ public function getCols(): int } /** - * Gets the link. + * Gets the cell link. */ public function getLink(): string|int|null { @@ -69,7 +71,7 @@ public function getLink(): string|int|null } /** - * Gets the style. + * Gets the cell style. */ public function getStyle(): ?PdfStyle { @@ -91,14 +93,4 @@ public function isLink(): bool { return PdfDocument::isLink($this->link); } - - /** - * Sets the style. - */ - public function setStyle(?PdfStyle $style): self - { - $this->style = $style; - - return $this; - } } diff --git a/src/Pdf/PdfColumn.php b/src/Pdf/PdfColumn.php index d941f1689..02f9ef0a3 100644 --- a/src/Pdf/PdfColumn.php +++ b/src/Pdf/PdfColumn.php @@ -75,7 +75,8 @@ public function getWidth(): float /** * Gets a value indicating if the column's width is fixed. - * This property is used only when the parent's table take all the printable width. + * + * This property is used only when the parent's table takes all the printable width. * * @return bool true if fixed * @@ -128,7 +129,7 @@ public function setAlignment(?PdfTextAlignment $alignment): self /** * Sets a value indicating if the column's width is fixed. - * This property is used only when the parent's table take all the printable width. + * This property is used only when the parent's table takes all the printable width. * * @param bool $fixed true if fixed * diff --git a/src/Pdf/PdfDocument.php b/src/Pdf/PdfDocument.php index b30dc654e..9ade3a640 100644 --- a/src/Pdf/PdfDocument.php +++ b/src/Pdf/PdfDocument.php @@ -33,7 +33,7 @@ class PdfDocument extends BaseDocument use PdfBookmarkTrait; /** - * The footer offset in mm. + * The footer offset in millimeters. */ final public const FOOTER_OFFSET = 15.0; @@ -65,9 +65,6 @@ class PdfDocument extends BaseDocument /** * Create a new instance. * - * It allows to set up the page orientation, the page size and the unit of measure used in all methods (except for - * font sizes). - * * @param PdfOrientation $orientation the page orientation * @param PdfUnit $unit the document unit to use * @param PdfPageSize|PdfSize $size the page size diff --git a/src/Pdf/PdfFont.php b/src/Pdf/PdfFont.php index 63b91f5a3..d6a686c18 100644 --- a/src/Pdf/PdfFont.php +++ b/src/Pdf/PdfFont.php @@ -91,7 +91,7 @@ public function getStyle(): PdfFontStyle } /** - * Returns if this font use the default size. + * Returns if this font uses the default size. */ public function isDefaultSize(): bool { diff --git a/src/Pdf/PdfImageCell.php b/src/Pdf/PdfImageCell.php index 47af58897..106371758 100644 --- a/src/Pdf/PdfImageCell.php +++ b/src/Pdf/PdfImageCell.php @@ -158,7 +158,7 @@ public function getWidth(): int /** * Resize the image. * - * If both height and width arguments are equal to 0, the new width and height are equals to original size. + * If both height and width arguments are equal to 0, the new width and height are equals to the original size. * * @param int $height the new height or 0 to take the original width as reference * @param int $width the new width or 0 to take the original height as reference diff --git a/src/Pdf/PdfLabelDocument.php b/src/Pdf/PdfLabelDocument.php index 892edef93..b4318d874 100644 --- a/src/Pdf/PdfLabelDocument.php +++ b/src/Pdf/PdfLabelDocument.php @@ -75,7 +75,7 @@ class PdfLabelDocument extends PdfDocument 'mm' => 1000.0, ]; - // the number of horizontally labels + // the number of horizontal labels private int $cols = 0; // the current column (0 based index) private int $currentCol; @@ -97,7 +97,7 @@ class PdfLabelDocument extends PdfDocument private float $marginTop = 0; // the padding inside labels private float $padding = 0; - // the number of vertically labels + // the number of vertical labels private int $rows = 0; // the horizontal space between 2 labels private float $spaceX = 0; @@ -107,14 +107,14 @@ class PdfLabelDocument extends PdfDocument private string $unit; /** - * @param array|string $format a label type or one of the predefined format name + * @param array|string $format a label type or one of the predefined format names * @param PdfUnit $unit the user unit - * @param int $startIndex the zero based index of the first label + * @param int $startIndex the zero-based index of the first label * * @psalm-param LabelType|string $format * @psalm-param non-negative-int $startIndex * - * @throws PdfException if the format name is unknown or if the format array contain invalid value + * @throws PdfException if the format name is unknown, or if the format array contains invalid value */ public function __construct(array|string $format, PdfUnit $unit = PdfUnit::MILLIMETER, int $startIndex = 0) { diff --git a/src/Pdf/PdfStyle.php b/src/Pdf/PdfStyle.php index 7da9c835e..10196a956 100644 --- a/src/Pdf/PdfStyle.php +++ b/src/Pdf/PdfStyle.php @@ -21,7 +21,7 @@ use fpdf\PdfFontStyle; /** - * This class describe a style that can be applied to a PDF document. + * This class describes a style that can be applied to a PDF document. */ class PdfStyle implements PdfDocumentUpdaterInterface { diff --git a/src/Pdf/PdfTable.php b/src/Pdf/PdfTable.php index 08c86daf0..c3603586c 100644 --- a/src/Pdf/PdfTable.php +++ b/src/Pdf/PdfTable.php @@ -474,6 +474,16 @@ public function isFullWidth(): bool return $this->fullWidth; } + /** + * Returns a value indicating if a header row is drawing. + * + * @return bool true if a header row is drawing; false otherwise + */ + public function isHeaders(): bool + { + return $this->isHeaders; + } + /** * Returns if the header row is printed when a new page is added. */ @@ -710,8 +720,7 @@ protected function drawRow( $parent->setX($x); break; case PdfTextAlignment::RIGHT: - /** @psalm-var float $w */ - $w = \array_sum($widths); + $w = (float) \array_sum($widths); $x = $parent->getPageWidth() - $parent->getRightMargin() - $w; $parent->setX($x); break; @@ -809,19 +818,19 @@ private function adjustCellWidths(array $cells, array $fixeds, array &$widths): return; } - // get fixed and resizable widths + // compute widths and check values [$fixedWidth, $resizableWidth] = $this->computeCellWidths($fixeds, $widths); + $remainingWidth = $parent->getPrintableWidth() - $fixedWidth; + if ($this->isFloatZero($resizableWidth) || $this->isFloatZero($remainingWidth) + || $resizableWidth === $remainingWidth) { + return; + } // update resizable widths - $remainingWidth = $parent->getPrintableWidth() - $fixedWidth; - if (!$this->isFloatZero($resizableWidth) - && !$this->isFloatZero($remainingWidth) - && $resizableWidth !== $remainingWidth) { - $factor = $remainingWidth / $resizableWidth; - for ($i = 0; $i < $count; ++$i) { - if (!$fixeds[$i]) { - $widths[$i] *= $factor; - } + $factor = $remainingWidth / $resizableWidth; + for ($i = 0; $i < $count; ++$i) { + if (!$fixeds[$i]) { + $widths[$i] *= $factor; } } } @@ -848,6 +857,8 @@ private function checkRowStarted(): void * 2: PdfTextAlignment[], * 3: float[], * 4: bool[]} + * + * @psalm-suppress PossiblyNullReference */ private function computeCells(array $cells, array $columns): array { diff --git a/src/Pdf/Traits/PdfBarChartTrait.php b/src/Pdf/Traits/PdfBarChartTrait.php index 7a70eb0b6..4646cfae9 100644 --- a/src/Pdf/Traits/PdfBarChartTrait.php +++ b/src/Pdf/Traits/PdfBarChartTrait.php @@ -88,7 +88,7 @@ public function renderBarChart( $h ??= 200.0; $endY = $y + $h; - // check new page + // check the new page if (!$this->isPrintable($h, $y)) { $this->addPage(); $y = $this->getY(); diff --git a/src/Pdf/Traits/PdfBookmarkTrait.php b/src/Pdf/Traits/PdfBookmarkTrait.php index 0d66817db..004145330 100644 --- a/src/Pdf/Traits/PdfBookmarkTrait.php +++ b/src/Pdf/Traits/PdfBookmarkTrait.php @@ -67,8 +67,8 @@ trait PdfBookmarkTrait * @throws PdfException if the given level is invalid. A level is not valid if: *
    *
  • Is smaller than 0.
  • - *
  • Is greater than the level of the previous bookmark plus 1. For example if the previous - * bookmark is 2; the allowed values are 0..3.
  • + *
  • Is greater than the level of the previous bookmark plus 1. For example, if the previous + * bookmark is 2, the allowed values are 0..3.
  • *
* * @see PdfDocument::addPageIndex() @@ -108,14 +108,14 @@ public function addBookmark( /** * Add an index page (as new page) containing all bookmarks. * - * Each line contain the text on the left, the page number on the right and are separate by the given separator + * Each line contains the text on the left, the page number on the right and are separate by the given separator * characters. * * Remark: Do nothing if no bookmark is defined. * * @param ?string $title the index title or null to use the default title ('Index') * @param ?PdfStyle $titleStyle the title style or null to use the default style (Font Arial 9 points Bold) - * @param ?PdfStyle $contentStyle the content style or null to use the default style (Font Arial 9 points Regular) + * @param ?PdfStyle $contentStyle the content style or null to use the default style (Font Arial 9-point Regular) * @param bool $addBookmark true to add the index page itself in the list of the bookmarks * @param string $separator the separator character used between the text and the page * diff --git a/src/Pdf/Traits/PdfCellTranslatorTrait.php b/src/Pdf/Traits/PdfCellTranslatorTrait.php index 2c5e28f5c..7c6ead2bf 100644 --- a/src/Pdf/Traits/PdfCellTranslatorTrait.php +++ b/src/Pdf/Traits/PdfCellTranslatorTrait.php @@ -19,7 +19,7 @@ use Symfony\Contracts\Translation\TranslatableInterface; /** - * Trait to allow adding a translatable cell. + * Trait to allow adding translatable cells. * * @psalm-require-extends \App\Pdf\PdfTable */ diff --git a/src/Pdf/Traits/PdfColumnTranslatorTrait.php b/src/Pdf/Traits/PdfColumnTranslatorTrait.php new file mode 100644 index 000000000..a55af60a4 --- /dev/null +++ b/src/Pdf/Traits/PdfColumnTranslatorTrait.php @@ -0,0 +1,73 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace App\Pdf\Traits; + +use App\Pdf\PdfColumn; +use App\Traits\TranslatorTrait; +use Symfony\Contracts\Translation\TranslatableInterface; + +/** + * Trait to allow adding translatable columns. + */ +trait PdfColumnTranslatorTrait +{ + use TranslatorTrait; + + /** + * Create a column with center alignment and a translated text. + * + * @param string|\Stringable|TranslatableInterface $id the identifier to translate or an empty string if none + * @param float $width the column width + * @param bool $fixed true if the column width is fixed. This property is used + * only if the parent's table uses all the document width. + */ + protected function centerColumn( + string|\Stringable|TranslatableInterface $id, + float $width, + bool $fixed = false + ): PdfColumn { + return PdfColumn::center('' !== $id ? $this->trans($id) : $id, $width, $fixed); + } + + /** + * Create a column with left alignment and a translated text. + * + * @param string|\Stringable|TranslatableInterface $id the identifier to translate or an empty string if none + * @param float $width the column width + * @param bool $fixed true if the column width is fixed. This property is used + * only if the parent's table uses all the document width. + */ + protected function leftColumn( + string|\Stringable|TranslatableInterface $id, + float $width, + bool $fixed = false + ): PdfColumn { + return PdfColumn::left('' !== $id ? $this->trans($id) : $id, $width, $fixed); + } + + /** + * Create a column with right alignment and a translated text. + * + * @param string|\Stringable|TranslatableInterface $id the identifier to translate or an empty string if none + * @param float $width the column width + * @param bool $fixed true if the column width is fixed. This property is used + * only if the parent's table uses all the document width. + */ + protected function rightColumn( + string|\Stringable|TranslatableInterface $id, + float $width, + bool $fixed = false + ): PdfColumn { + return PdfColumn::right('' !== $id ? $this->trans($id) : $id, $width, $fixed); + } +} diff --git a/src/Pdf/Traits/PdfDashLineTrait.php b/src/Pdf/Traits/PdfDashLineTrait.php index a08f5855c..6be4c48e2 100644 --- a/src/Pdf/Traits/PdfDashLineTrait.php +++ b/src/Pdf/Traits/PdfDashLineTrait.php @@ -91,7 +91,7 @@ public function dashedRectangle(PdfRectangle $rectangle, int $dashes = 15, PdfLi /** * Set the dash pattern to draw dashed lines or rectangles. * - * Call the function without parameter to restore normal drawing. + * Call the function without the parameter to restore normal drawing. * * @param float|null $black the length of dashes * @param float|null $white the length of gaps diff --git a/src/Pdf/Traits/PdfMemoryImageTrait.php b/src/Pdf/Traits/PdfMemoryImageTrait.php index fd2fbd3fc..696216875 100644 --- a/src/Pdf/Traits/PdfMemoryImageTrait.php +++ b/src/Pdf/Traits/PdfMemoryImageTrait.php @@ -25,7 +25,7 @@ trait PdfMemoryImageTrait /** * Output a GD image. * - * This function convert first the given image to the portable network graphics format ('png') before output. + * This function converts first the given image to the portable network graphics format ('png') before output. * * @param \GdImage $image the GD image to output * @param ?float $x the abscissa of the upper-left corner. If null, the current abscissa @@ -52,7 +52,7 @@ trait PdfMemoryImageTrait * * @param string|int|null $link the URL or an identifier returned by addLink() * - * @throws PdfException if the image can not be converted + * @throws PdfException if the image cannot be converted */ public function imageGD( \GdImage $image, @@ -72,7 +72,7 @@ public function imageGD( } /** - * Output an image data. + * Output image data. * * @param string $data the image data to output * @param ?float $x the abscissa of the upper-left corner. If null, the current abscissa diff --git a/src/Pdf/Traits/PdfPieChartTrait.php b/src/Pdf/Traits/PdfPieChartTrait.php index f48045c98..3c6007ef8 100644 --- a/src/Pdf/Traits/PdfPieChartTrait.php +++ b/src/Pdf/Traits/PdfPieChartTrait.php @@ -61,7 +61,7 @@ public function renderPieChart( return; } - // check new page + // check the new page if (!$this->isPrintable($radius, $centerY + $radius)) { $this->addPage(); $centerY = $this->getY() + $radius; diff --git a/src/Pdf/Traits/PdfSectorTrait.php b/src/Pdf/Traits/PdfSectorTrait.php index 5dac04124..106bb2ce0 100644 --- a/src/Pdf/Traits/PdfSectorTrait.php +++ b/src/Pdf/Traits/PdfSectorTrait.php @@ -62,7 +62,7 @@ public function sector( // put center $this->outf('%.2F %.2F m', $centerX * $scaleFactor, ($height - $centerY) * $scaleFactor); - // put first point + // put the first point $x = ($centerX + $radius * \cos($startAngle)) * $scaleFactor; $y = ($height - ($centerY - $radius * \sin($startAngle))) * $scaleFactor; $this->outf('%.2F %.2F l', $x, $y); diff --git a/src/Pivot/Field/PivotField.php b/src/Pivot/Field/PivotField.php index 2bbc8f956..bf345b571 100644 --- a/src/Pivot/Field/PivotField.php +++ b/src/Pivot/Field/PivotField.php @@ -42,7 +42,8 @@ public function __construct(protected string $name, protected ?string $title = n /** * Gets the display value. - * The default implementation returns the value as is. Subclass can override, for example to map the value. + * + * The default implementation returns the value as is. Subclass can override, for example, to map the value. * * @param mixed $value the field value * @@ -56,7 +57,7 @@ public function getDisplayValue(mixed $value): mixed /** * Gets the value method. * - * @return int one of the METHOD_XX constants + * @return int one of the METHOD_XX constants */ public function getMethod(): int { @@ -110,7 +111,7 @@ public function jsonSerialize(): array /** * Sets the value method. * - * @param int $method one of the METHOD_XX constants + * @param int $method one of the METHOD_XX constants */ public function setMethod(int $method): self { diff --git a/src/Pivot/Field/PivotFieldFactory.php b/src/Pivot/Field/PivotFieldFactory.php index 40ac8d481..18822393a 100644 --- a/src/Pivot/Field/PivotFieldFactory.php +++ b/src/Pivot/Field/PivotFieldFactory.php @@ -22,7 +22,7 @@ class PivotFieldFactory * * @param string $name the field name * @param ?string $title the field title - * @param int $method the field method (one of the PivotField::METHOD_XX) + * @param int $method the field method (one of the PivotField::METHOD_XX) */ public static function default(string $name, ?string $title = null, int $method = PivotField::METHOD_STRING): PivotField { @@ -30,7 +30,7 @@ public static function default(string $name, ?string $title = null, int $method } /** - * Creates a new instance with the METHOD_FLOAT. + * Creates a new instance with the METHOD_FLOAT. * * @param string $name the field name * @param ?string $title the field title @@ -41,7 +41,7 @@ public static function float(string $name, ?string $title = null): PivotField } /** - * Creates a new instance with the METHOD_INTEGER. + * Creates a new instance with the METHOD_INTEGER. * * @param string $name the field name * @param ?string $title the field title @@ -75,7 +75,7 @@ public static function quarter(string $name, ?string $title = null): PivotQuarte } /** - * Creates a new date instance for semester. + * Creates a new date instance for the semester. * * @param string $name the field name * @param ?string $title the field title @@ -101,7 +101,7 @@ public static function week(string $name, ?string $title = null): PivotDateField * * @param string $name the field name * @param ?string $title the field title - * @param bool $short true to display the short day name, false to display the full day name + * @param bool $short true to display the short day name, false to display the full-day name */ public static function weekday(string $name, ?string $title = null, bool $short = false): PivotWeekdayField { @@ -109,7 +109,7 @@ public static function weekday(string $name, ?string $title = null, bool $short } /** - * Creates a new date instance for year. + * Creates a new date instance for the year. * * @param string $name the field name * @param ?string $title the field title diff --git a/src/Pivot/Field/PivotMonthField.php b/src/Pivot/Field/PivotMonthField.php index 77f4f8675..1add61bab 100644 --- a/src/Pivot/Field/PivotMonthField.php +++ b/src/Pivot/Field/PivotMonthField.php @@ -15,7 +15,7 @@ use App\Utils\DateUtils; /** - * Pivot field that map month values (1...12) to month names (january, february, etc...). + * The pivot field that maps month values (1...12) to month names (january, february, etc...). */ class PivotMonthField extends PivotDateField { diff --git a/src/Pivot/Field/PivotQuarterField.php b/src/Pivot/Field/PivotQuarterField.php index 1dd034ae1..df6adc75a 100644 --- a/src/Pivot/Field/PivotQuarterField.php +++ b/src/Pivot/Field/PivotQuarterField.php @@ -13,7 +13,7 @@ namespace App\Pivot\Field; /** - * Pivot field that extract quarter (1 or 4). + * The pivot field that extracts quarter (1 or 4). */ class PivotQuarterField extends PivotDateField { @@ -45,7 +45,7 @@ public function getFormatter(): ?callable /** * Sets callback used to format a quarter. * - * The function receive the quarter (1 to 4) as parameter and must return a string. + * The function receives the quarter (1 to 4) as a parameter and must return a string. * * @param ?callable $formatter the optional callback * diff --git a/src/Pivot/Field/PivotSemesterField.php b/src/Pivot/Field/PivotSemesterField.php index 7c48e536a..69b0cc661 100644 --- a/src/Pivot/Field/PivotSemesterField.php +++ b/src/Pivot/Field/PivotSemesterField.php @@ -13,7 +13,7 @@ namespace App\Pivot\Field; /** - * Pivot field that extract semester (1 or 2). + * The Pivot field that extracts semester (1 or 2).p. */ class PivotSemesterField extends PivotDateField { @@ -45,7 +45,7 @@ public function getFormatter(): ?callable /** * Sets callback used to format a semestre. * - * The function receive the semestre (1 or 2 ) as parameter and must return a string. + * The function receives the semestre (1 or 2) as a parameter and must return a string. * * @param ?callable $formatter the optional callback * diff --git a/src/Pivot/PivotNode.php b/src/Pivot/PivotNode.php index 604314042..b4e711b85 100644 --- a/src/Pivot/PivotNode.php +++ b/src/Pivot/PivotNode.php @@ -502,7 +502,7 @@ public function setParent(?self $parent): self } /** - * Sets the sort mode and sort values if different from current sort mode. + * Sets the sort mode and sort values if different from the current sort mode. * * @psalm-api */ diff --git a/src/Pivot/PivotTable.php b/src/Pivot/PivotTable.php index d14d9610a..b0992603d 100644 --- a/src/Pivot/PivotTable.php +++ b/src/Pivot/PivotTable.php @@ -301,7 +301,7 @@ public function setDataField(PivotField $dataField): self } /** - * Sets the key field. + * Sets the key field. */ public function setKeyField(PivotField $keyField): self { diff --git a/src/Report/AbstractArrayReport.php b/src/Report/AbstractArrayReport.php index 848b0f16c..b562f038e 100644 --- a/src/Report/AbstractArrayReport.php +++ b/src/Report/AbstractArrayReport.php @@ -39,11 +39,7 @@ public function __construct( public function render(): bool { - if ([] === $this->entities) { - return false; - } - - return $this->doRender($this->entities); + return [] !== $this->entities && $this->doRender($this->entities); } /** diff --git a/src/Report/AbstractCalculationItemsReport.php b/src/Report/AbstractCalculationItemsReport.php index c89994969..6af075764 100644 --- a/src/Report/AbstractCalculationItemsReport.php +++ b/src/Report/AbstractCalculationItemsReport.php @@ -14,7 +14,6 @@ use App\Controller\AbstractController; use App\Pdf\Colors\PdfTextColor; -use App\Pdf\PdfColumn; use App\Pdf\PdfStyle; use App\Pdf\PdfTable; use App\Utils\FormatUtils; @@ -104,12 +103,12 @@ private function createTable(): PdfTable { return PdfTable::instance($this) ->addColumns( - PdfColumn::center($this->trans('calculation.fields.id'), 17, true), - PdfColumn::center($this->trans('calculation.fields.date'), 20, true), - PdfColumn::left($this->trans('calculation.fields.state'), 20, true), - PdfColumn::left($this->trans('calculation.fields.customer'), 60), - PdfColumn::left($this->trans('calculation.fields.description'), 60), - PdfColumn::left($this->trans('calculation.fields.items'), 70), + $this->centerColumn('calculation.fields.id', 17, true), + $this->centerColumn('calculation.fields.date', 20, true), + $this->leftColumn('calculation.fields.state', 20, true), + $this->leftColumn('calculation.fields.customer', 60), + $this->leftColumn('calculation.fields.description', 60), + $this->leftColumn('calculation.fields.items', 70), )->outputHeaders(); } } diff --git a/src/Report/AbstractReport.php b/src/Report/AbstractReport.php index 49189e30d..8f2d3165a 100644 --- a/src/Report/AbstractReport.php +++ b/src/Report/AbstractReport.php @@ -16,7 +16,7 @@ use App\Pdf\PdfDocument; use App\Pdf\PdfStyle; use App\Pdf\PdfTable; -use App\Traits\TranslatorTrait; +use App\Pdf\Traits\PdfColumnTranslatorTrait; use fpdf\PdfOrientation; use fpdf\PdfPageSize; use fpdf\PdfTextAlignment; @@ -28,7 +28,7 @@ */ abstract class AbstractReport extends PdfDocument { - use TranslatorTrait; + use PdfColumnTranslatorTrait; private readonly TranslatorInterface $translator; @@ -54,7 +54,7 @@ public function __construct( /** * {@inheritdoc} * - * Override the default behavior by adding a translated title if null and the page index to bookmarks. + * Override the default behavior by adding a translated title if null and the page index to the bookmarks. */ public function addPageIndex( ?string $title = null, @@ -77,33 +77,36 @@ public function getTranslator(): TranslatorInterface /** * Render this document. * - * @return bool true if rendered successfully + * @return bool true if rendered successfully */ abstract public function render(): bool; /** * Renders a single line with the given number of elements. * - * @return bool true if the given number of elements is greater than 0 + * @return bool true if the given number of elements is greater than 0 */ public function renderCount(PdfTable $table, \Countable|array|int $count, string $message = 'common.count'): bool { $this->resetStyle(); + if (!\is_int($count)) { + $count = \count($count); + } $text = $this->translateCount($count, $message); $table->singleLine($text, PdfStyle::getHeaderStyle(), PdfTextAlignment::LEFT); - return $this->toInt($count) > 0; + return $count > 0; } /** * Sets the title to be translated. * - * @param string $id the title id (may also be an object that can be cast to string) + * @param string $id the title identifier (may also be an object that can be cast to string) * @param bool $isUTF8 indicates if the title is encoded in ISO-8859-1 (false) or UTF-8 (true) */ - public function setTitleTrans(string $id, array $parameters = [], bool $isUTF8 = false, ?string $domain = null): static + public function setTitleTrans(string $id, array $parameters = [], bool $isUTF8 = false): static { - $title = $this->trans($id, $parameters, $domain); + $title = $this->trans($id, $parameters); $this->setTitle($title, $isUTF8); return $this; @@ -114,11 +117,10 @@ public function setTitleTrans(string $id, array $parameters = [], bool $isUTF8 = */ protected function translateCount(\Countable|array|int $count, string $message = 'common.count'): string { - return $this->trans($message, ['%count%' => $this->toInt($count)]); - } + if (!\is_int($count)) { + $count = \count($count); + } - private function toInt(\Countable|array|int $value): int - { - return \is_int($value) ? $value : \count($value); + return $this->trans($message, ['%count%' => $count]); } } diff --git a/src/Report/CalculationByMonthReport.php b/src/Report/CalculationByMonthReport.php index 46281c62c..8a22984e1 100644 --- a/src/Report/CalculationByMonthReport.php +++ b/src/Report/CalculationByMonthReport.php @@ -25,7 +25,6 @@ use App\Pdf\Interfaces\PdfDrawCellTextInterface; use App\Pdf\Interfaces\PdfDrawHeadersInterface; use App\Pdf\PdfCell; -use App\Pdf\PdfColumn; use App\Pdf\PdfStyle; use App\Pdf\Traits\PdfBarChartTrait; use App\Pdf\Traits\PdfChartLegendTrait; @@ -152,12 +151,12 @@ private function createTable(): ReportTable { return ReportTable::fromReport($this) ->addColumns( - PdfColumn::left($this->trans('chart.month.fields.month'), 20), - PdfColumn::right($this->trans('calculation.list.title'), 22, true), - PdfColumn::right($this->trans('calculationgroup.fields.amount'), 25, true), - PdfColumn::right($this->trans('calculation.fields.margin'), 20, true), - PdfColumn::right('', 18, true), - PdfColumn::right($this->trans('calculation.fields.total'), 25, true), + $this->leftColumn('chart.month.fields.month', 20), + $this->rightColumn('calculation.list.title', 22, true), + $this->rightColumn('calculationgroup.fields.amount', 25, true), + $this->rightColumn('calculation.fields.margin', 20, true), + $this->rightColumn('', 18, true), + $this->rightColumn('calculation.fields.total', 25, true), ) ->setHeadersListener($this) ->setTextListener($this) diff --git a/src/Report/CalculationByStateReport.php b/src/Report/CalculationByStateReport.php index b63c5e14d..1226bc614 100644 --- a/src/Report/CalculationByStateReport.php +++ b/src/Report/CalculationByStateReport.php @@ -21,7 +21,6 @@ use App\Pdf\Interfaces\PdfDrawCellTextInterface; use App\Pdf\Interfaces\PdfDrawHeadersInterface; use App\Pdf\PdfCell; -use App\Pdf\PdfColumn; use App\Pdf\PdfStyle; use App\Pdf\Traits\PdfChartLegendTrait; use App\Pdf\Traits\PdfPieChartTrait; @@ -143,14 +142,14 @@ private function createTable(): ReportTable ->setHeadersListener($this) ->setTextListener($this) ->addColumns( - PdfColumn::left($this->trans('calculation.fields.state'), 20), - PdfColumn::right($this->trans('calculation.list.title'), 18, true), - PdfColumn::right('', 18, true), - PdfColumn::right($this->trans('calculationgroup.fields.amount'), 24, true), - PdfColumn::right($this->trans('calculation.fields.margin'), 24, true), - PdfColumn::right('', 14, true), - PdfColumn::right($this->trans('calculation.fields.total'), 24, true), - PdfColumn::right('', 18, true) + $this->leftColumn('calculation.fields.state', 20), + $this->rightColumn('calculation.list.title', 18, true), + $this->rightColumn('', 18, true), + $this->rightColumn('calculationgroup.fields.amount', 24, true), + $this->rightColumn('calculation.fields.margin', 24, true), + $this->rightColumn('', 14, true), + $this->rightColumn('calculation.fields.total', 24, true), + $this->rightColumn('', 18, true) )->outputHeaders(); } @@ -191,14 +190,13 @@ private function getPercentCell( bool $bold = false, int $roundingMode = \NumberFormatter::ROUND_HALFDOWN ): PdfCell { + $text = FormatUtils::formatPercent($value, true, $decimals, $roundingMode); $style = $bold ? PdfStyle::getHeaderStyle() : PdfStyle::getCellStyle(); - $cell = new PdfCell(FormatUtils::formatPercent($value, true, $decimals, $roundingMode)); if ($useStyle && $this->isMinMargin($value)) { $style->setTextColor(PdfTextColor::red()); } - $cell->setStyle($style); - return $cell; + return new PdfCell($text, style: $style); } private function getURL(int $id): string diff --git a/src/Report/CalculationReport.php b/src/Report/CalculationReport.php index d3d99a729..b2a303f93 100644 --- a/src/Report/CalculationReport.php +++ b/src/Report/CalculationReport.php @@ -14,7 +14,6 @@ use App\Controller\AbstractController; use App\Entity\Calculation; -use App\Pdf\PdfColumn; use App\Pdf\PdfStyle; use App\Pdf\PdfTable; use App\Pdf\Traits\PdfMemoryImageTrait; @@ -145,8 +144,8 @@ private function renderCalculation(): void $calculation = $this->calculation; PdfTable::instance($this) ->addColumns( - PdfColumn::left(null, 100), - PdfColumn::right(null, 40, true) + $this->leftColumn('', 100), + $this->rightColumn('', 40, true) ) ->startHeaderRow() ->add($calculation->getCustomer(), style: $leftStyle) diff --git a/src/Report/CalculationStatesReport.php b/src/Report/CalculationStatesReport.php index 42eb05e66..128c2d825 100644 --- a/src/Report/CalculationStatesReport.php +++ b/src/Report/CalculationStatesReport.php @@ -16,7 +16,6 @@ use App\Pdf\Colors\PdfFillColor; use App\Pdf\Events\PdfCellBackgroundEvent; use App\Pdf\Interfaces\PdfDrawCellBackgroundInterface; -use App\Pdf\PdfColumn; use App\Pdf\PdfStyle; use App\Pdf\PdfTable; use fpdf\PdfRectangleStyle; @@ -52,6 +51,7 @@ protected function doRender(array $entities): bool $this->addPage(); $table = $this->createTable(); + $total = 0; foreach ($entities as $entity) { $this->currentState = $entity; $table->startRow() @@ -62,9 +62,15 @@ protected function doRender(array $entities): bool ->addCellInt($entity->countCalculations()) ->endRow(); $this->currentState = null; + $total += $entity->countCalculations(); } - return $this->renderCount($table, $entities, 'counters.states'); + $table->startHeaderRow() + ->add($this->translateCount($entities, 'counters.states'), 4) + ->addCellInt($total) + ->endRow(); + + return true; } private function createTable(): PdfTable @@ -72,11 +78,11 @@ private function createTable(): PdfTable return PdfTable::instance($this) ->setBackgroundListener($this) ->addColumns( - PdfColumn::left($this->trans('calculationstate.fields.code'), 20), - PdfColumn::left($this->trans('calculationstate.fields.description'), 80), - PdfColumn::center($this->trans('calculationstate.fields.editable'), 20, true), - PdfColumn::center($this->trans('calculationstate.fields.color'), 15, true), - PdfColumn::right($this->trans('calculationstate.fields.calculations'), 22, true) + $this->leftColumn('calculationstate.fields.code', 20), + $this->leftColumn('calculationstate.fields.description', 80), + $this->centerColumn('calculationstate.fields.editable', 20, true), + $this->centerColumn('calculationstate.fields.color', 15, true), + $this->rightColumn('calculationstate.fields.calculations', 22, true) )->outputHeaders(); } diff --git a/src/Report/CalculationsBelowReport.php b/src/Report/CalculationsBelowReport.php index 5daa1ca50..beaa12d9a 100644 --- a/src/Report/CalculationsBelowReport.php +++ b/src/Report/CalculationsBelowReport.php @@ -15,7 +15,6 @@ use App\Controller\AbstractController; use App\Entity\Calculation; use App\Pdf\Colors\PdfTextColor; -use App\Pdf\PdfColumn; use App\Pdf\PdfStyle; use App\Pdf\PdfTable; use App\Traits\MathTrait; @@ -64,14 +63,14 @@ private function createTable(): PdfTable { return PdfTable::instance($this) ->addColumns( - PdfColumn::center($this->trans('calculation.fields.id'), 17, true), - PdfColumn::center($this->trans('calculation.fields.date'), 20, true), - PdfColumn::left($this->trans('calculation.fields.state'), 20, true), - PdfColumn::left($this->trans('calculation.fields.customer'), 35), - PdfColumn::left($this->trans('calculation.fields.description'), 65), - PdfColumn::right($this->trans('report.calculation.amount'), 25, true), - PdfColumn::right($this->trans('report.calculation.margin_percent'), 20, true), - PdfColumn::right($this->trans('calculation.fields.total'), 25, true), + $this->centerColumn('calculation.fields.id', 17, true), + $this->centerColumn('calculation.fields.date', 20, true), + $this->leftColumn('calculation.fields.state', 20, true), + $this->leftColumn('calculation.fields.customer', 35), + $this->leftColumn('calculation.fields.description', 65), + $this->rightColumn('report.calculation.amount', 25, true), + $this->rightColumn('report.calculation.margin_percent', 20, true), + $this->rightColumn('calculation.fields.total', 25, true), )->outputHeaders(); } diff --git a/src/Report/CalculationsReport.php b/src/Report/CalculationsReport.php index 29d2ec4ea..f91ad90fe 100644 --- a/src/Report/CalculationsReport.php +++ b/src/Report/CalculationsReport.php @@ -15,7 +15,6 @@ use App\Controller\AbstractController; use App\Entity\Calculation; use App\Pdf\Colors\PdfTextColor; -use App\Pdf\PdfColumn; use App\Pdf\PdfGroupTable; use App\Pdf\PdfStyle; use App\Traits\MathTrait; @@ -76,13 +75,13 @@ private function createTable(): PdfGroupTable { return PdfGroupTable::instance($this) ->addColumns( - PdfColumn::center($this->trans('calculation.fields.id'), 17, true), - PdfColumn::center($this->trans('calculation.fields.date'), 20, true), - PdfColumn::left($this->trans('calculation.fields.customer'), 35), - PdfColumn::left($this->trans('calculation.fields.description'), 65), - PdfColumn::right($this->trans('report.calculation.amount'), 25, true), - PdfColumn::right($this->trans('report.calculation.margin_percent'), 20, true), - PdfColumn::right($this->trans('calculation.fields.total'), 25, true), + $this->centerColumn('calculation.fields.id', 17, true), + $this->centerColumn('calculation.fields.date', 20, true), + $this->leftColumn('calculation.fields.customer', 35), + $this->leftColumn('calculation.fields.description', 65), + $this->rightColumn('report.calculation.amount', 25, true), + $this->rightColumn('report.calculation.margin_percent', 20, true), + $this->rightColumn('calculation.fields.total', 25, true), )->outputHeaders(); } diff --git a/src/Report/CategoriesReport.php b/src/Report/CategoriesReport.php index 0edd54063..bada19b26 100644 --- a/src/Report/CategoriesReport.php +++ b/src/Report/CategoriesReport.php @@ -13,7 +13,6 @@ namespace App\Report; use App\Entity\Category; -use App\Pdf\PdfColumn; use App\Pdf\PdfGroupTable; use App\Pdf\PdfStyle; use App\Traits\GroupByTrait; @@ -74,10 +73,10 @@ private function createTable(): PdfGroupTable { return PdfGroupTable::instance($this) ->addColumns( - PdfColumn::left($this->trans('category.fields.code'), 45, true), - PdfColumn::left($this->trans('category.fields.description'), 50), - PdfColumn::right($this->trans('category.fields.products'), 26, true), - PdfColumn::right($this->trans('category.fields.tasks'), 26, true) + $this->leftColumn('category.fields.code', 45, true), + $this->leftColumn('category.fields.description', 50), + $this->rightColumn('category.fields.products', 26, true), + $this->rightColumn('category.fields.tasks', 26, true) )->outputHeaders(); } diff --git a/src/Report/CommandsReport.php b/src/Report/CommandsReport.php index 2e7ab86eb..48eff6aaf 100644 --- a/src/Report/CommandsReport.php +++ b/src/Report/CommandsReport.php @@ -249,7 +249,10 @@ private function renderStyledHelp(string $help): void $result = \preg_match_all(self::CLASS_PATTERN, $help, $matches, \PREG_SET_ORDER | \PREG_OFFSET_CAPTURE); if (false === $result || 0 === $result) { $this->outputHelp($help); - goto restore; + $this->leftMargin = $oldMargin; + $this->lineBreak(); + + return; } $offset = 0; @@ -275,7 +278,6 @@ private function renderStyledHelp(string $help): void } // restore - restore: $this->leftMargin = $oldMargin; $this->lineBreak(); } diff --git a/src/Report/CustomersReport.php b/src/Report/CustomersReport.php index 9666cd27b..ac03ea1fb 100644 --- a/src/Report/CustomersReport.php +++ b/src/Report/CustomersReport.php @@ -14,7 +14,6 @@ use App\Controller\AbstractController; use App\Entity\Customer; -use App\Pdf\PdfColumn; use App\Pdf\PdfGroupTable; use App\Pdf\PdfStyle; use App\Utils\StringUtils; @@ -47,9 +46,9 @@ protected function doRender(array $entities): bool $table = PdfGroupTable::instance($this) ->setGroupStyle(PdfStyle::getHeaderStyle()) ->addColumns( - PdfColumn::left($this->trans('customer.fields.nameAndCompany'), 50), - PdfColumn::left($this->trans('customer.fields.address'), 25), - PdfColumn::left($this->trans('customer.fields.zipCity'), 25) + $this->leftColumn('customer.fields.nameAndCompany', 50), + $this->leftColumn('customer.fields.address', 25), + $this->leftColumn('customer.fields.zipCity', 25) )->outputHeaders(); if ($this->grouped) { diff --git a/src/Report/GlobalMarginsReport.php b/src/Report/GlobalMarginsReport.php index 653fb836f..ce4ea549e 100644 --- a/src/Report/GlobalMarginsReport.php +++ b/src/Report/GlobalMarginsReport.php @@ -12,7 +12,6 @@ namespace App\Report; -use App\Pdf\PdfColumn; use App\Pdf\PdfTable; /** @@ -29,10 +28,10 @@ protected function doRender(array $entities): bool $table = PdfTable::instance($this) ->addColumns( - PdfColumn::right($this->trans('globalmargin.fields.minimum'), 50), - PdfColumn::right($this->trans('globalmargin.fields.maximum'), 50), - PdfColumn::right($this->trans('globalmargin.fields.delta'), 50), - PdfColumn::right($this->trans('globalmargin.fields.margin'), 50) + $this->rightColumn('globalmargin.fields.minimum', 50), + $this->rightColumn('globalmargin.fields.maximum', 50), + $this->rightColumn('globalmargin.fields.delta', 50), + $this->rightColumn('globalmargin.fields.margin', 50) )->outputHeaders(); foreach ($entities as $entity) { diff --git a/src/Report/GroupsReport.php b/src/Report/GroupsReport.php index fe0c5764a..3aae1ac50 100644 --- a/src/Report/GroupsReport.php +++ b/src/Report/GroupsReport.php @@ -14,14 +14,12 @@ use App\Controller\AbstractController; use App\Entity\Group; -use App\Pdf\PdfColumn; use App\Pdf\PdfStyle; use App\Pdf\PdfTable; +use App\Report\Table\ReportTable; use App\Utils\FormatUtils; use fpdf\PdfBorder; use fpdf\PdfOrientation; -use fpdf\PdfPageSize; -use fpdf\PdfUnit; /** * Report for the list of groups. @@ -35,17 +33,14 @@ class GroupsReport extends AbstractArrayReport */ public function __construct( AbstractController $controller, - array $entities, - PdfUnit $unit = PdfUnit::MILLIMETER, - PdfPageSize $size = PdfPageSize::A4 + array $entities ) { - parent::__construct($controller, $entities, PdfOrientation::LANDSCAPE, $unit, $size); + parent::__construct($controller, $entities, PdfOrientation::LANDSCAPE); + $this->setTitleTrans('group.list.title'); } protected function doRender(array $entities): bool { - $this->setTitleTrans('group.list.title', [], true); - $this->addPage(); $table = $this->createTable(); $last = \end($entities); @@ -56,38 +51,60 @@ protected function doRender(array $entities): bool $table->singleLine(null, $emptyStyle); } } - $this->renderTotal($table, $entities); + $this->outputTotals($table, $entities); return true; } - private function createTable(): PdfTable + private function createTable(): ReportTable { - return PdfTable::instance($this) + return ReportTable::fromReport($this) ->addColumns( - PdfColumn::left($this->trans('group.fields.code'), 40, true), - PdfColumn::left($this->trans('group.fields.description'), 50), - PdfColumn::right($this->trans('group.fields.categories'), 26, true), - PdfColumn::right($this->trans('category.fields.products'), 26, true), - PdfColumn::right($this->trans('category.fields.tasks'), 26, true), - PdfColumn::right($this->trans('globalmargin.fields.minimum'), 22, true), - PdfColumn::right($this->trans('globalmargin.fields.maximum'), 22, true), - PdfColumn::right($this->trans('globalmargin.fields.delta'), 22, true), - PdfColumn::right($this->trans('globalmargin.fields.margin'), 22, true) + $this->leftColumn('group.fields.code', 45, true), + $this->leftColumn('group.fields.description', 50), + $this->rightColumn('group.fields.categories', 26, true), + $this->rightColumn('category.fields.products', 26, true), + $this->rightColumn('category.fields.tasks', 26, true), + $this->rightColumn('globalmargin.fields.minimum', 22, true), + $this->rightColumn('globalmargin.fields.maximum', 22, true), + $this->rightColumn('globalmargin.fields.margin', 22, true) )->outputHeaders(); } - private function formatCount(string $id, array|int $value): string + private function formatCount(string $id, int $value): string { - return $this->trans($id, ['count' => \is_array($value) ? \count($value) : $value]); + return $this->trans($id, ['count' => $value]); } private function formatInt(int $value): string { - return 0 === $value ? '' : FormatUtils::formatInt($value); + return 0 !== $value ? FormatUtils::formatInt($value) : ''; + } + + /** + * @param Group[] $entities + * + * @return int[] + */ + private function getTotals(array $entities): array + { + return \array_reduce( + $entities, + /** @psalm-param int[] $carry */ + function (array $carry, Group $group): array { + ++$carry[0]; + $carry[1] += $group->countCategories(); + $carry[2] += $group->countProducts(); + $carry[3] += $group->countTasks(); + $carry[4] += $group->countMargins(); + + return $carry; + }, + [0, 0, 0, 0, 0] + ); } - private function outputGroup(PdfTable $table, Group $group): void + private function outputGroup(ReportTable $table, Group $group): void { $emptyValue = \array_fill(0, 5, ''); $table->startRow() @@ -106,46 +123,35 @@ private function outputGroup(PdfTable $table, Group $group): void } $table->addCellAmount($margin->getMinimum()) ->addCellAmount($margin->getMaximum()) - ->addCellAmount($margin->getDelta()) ->addCellPercent($margin->getMargin()) ->endRow(); $skip = true; } } else { - $empty = $this->trans('group.edit.empty_margins'); - $table->add($empty, 4)->endRow(); + $table->addCellTrans('group.edit.empty_margins', 3)->endRow(); } } /** * @param Group[] $entities */ - private function renderTotal(PdfTable $table, array $entities): void + private function outputTotals(PdfTable $table, array $entities): void { - $margins = 0; - $categories = 0; - $products = 0; - $tasks = 0; - - foreach ($entities as $entity) { - $margins += $entity->countMargins(); - $categories += $entity->countCategories(); - $products += $entity->countProducts(); - $tasks += $entity->countTasks(); - } - - $txtEntities = $this->formatCount('counters.groups', $entities); - $txtCategories = $this->formatCount('counters.categories', $categories); - $txtProducts = $this->formatCount('counters.products', $products); - $txtTasks = $this->formatCount('counters.tasks', $tasks); - $txtMargins = $this->formatCount('counters.margins', $margins); + $values = $this->getTotals($entities); + $texts = [ + $this->formatCount('counters.groups', $values[0]), + $this->formatCount('counters.categories', $values[1]), + $this->formatCount('counters.products', $values[2]), + $this->formatCount('counters.tasks', $values[3]), + $this->formatCount('counters.margins', $values[4]), + ]; $table->startHeaderRow() - ->add($txtEntities, 2) - ->add($txtCategories) - ->add($txtProducts) - ->add($txtTasks) - ->add($txtMargins, 4) + ->add($texts[0], 2) + ->add($texts[1]) + ->add($texts[2]) + ->add($texts[3]) + ->add($texts[4], 3) ->endRow(); } } diff --git a/src/Report/HelpReport.php b/src/Report/HelpReport.php index 8d5cb0ad5..5b66fd88c 100644 --- a/src/Report/HelpReport.php +++ b/src/Report/HelpReport.php @@ -14,7 +14,6 @@ use App\Controller\AbstractController; use App\Pdf\Colors\PdfDrawColor; -use App\Pdf\PdfColumn; use App\Pdf\PdfStyle; use App\Pdf\PdfTable; use App\Service\HelpService; @@ -144,8 +143,8 @@ private function outputActions(array $actions, string $description): void $this->outputText($description); $table = PdfTable::instance($this) ->addColumns( - PdfColumn::left($this->trans('help.fields.action'), 70, true), - PdfColumn::left($this->trans('help.fields.description'), 50) + $this->leftColumn('help.fields.action', 70, true), + $this->leftColumn('help.fields.description', 50) )->outputHeaders(); foreach ($actions as $action) { @@ -170,8 +169,8 @@ private function outputColumns(array $item, array $fields): void $table = PdfTable::instance($this) ->addColumns( - PdfColumn::left($this->trans('help.fields.column'), 30, true), - PdfColumn::left($this->trans('help.fields.description'), 50) + $this->leftColumn('help.fields.column', 30, true), + $this->leftColumn('help.fields.description', 50) )->outputHeaders(); foreach ($fields as $field) { $table->addRow( @@ -302,8 +301,8 @@ private function outputDialogFields(array $item): void $this->multiCell(text: $text); $table = PdfTable::instance($this) ->addColumns( - PdfColumn::left($this->trans('help.fields.column'), 30, true), - PdfColumn::left($this->trans('help.fields.description'), 50), + $this->leftColumn('help.fields.column', 30, true), + $this->leftColumn('help.fields.description', 50), )->outputHeaders(); foreach ($fields as $field) { $table->addRow( @@ -479,10 +478,10 @@ private function outputFields(array $item, array $fields): void $table = PdfTable::instance($this) ->addColumns( - PdfColumn::left($this->trans('help.fields.field'), 30, true), - PdfColumn::left($this->trans('help.fields.description'), 50), - PdfColumn::left($this->trans('help.fields.type'), 30, true), - PdfColumn::center($this->trans('help.fields.required'), 18, true) + $this->leftColumn('help.fields.field', 30, true), + $this->leftColumn('help.fields.description', 50), + $this->leftColumn('help.fields.type', 30, true), + $this->centerColumn('help.fields.required', 18, true) )->outputHeaders(); foreach ($fields as $field) { @@ -546,8 +545,8 @@ private function outputMainMenus(array $menus): bool $this->outputText('help.labels.edit_actions'); $table = PdfTable::instance($this) ->addColumns( - PdfColumn::left($this->trans('help.fields.action'), 60, true), - PdfColumn::left($this->trans('help.fields.description'), 50) + $this->leftColumn('help.fields.action', 60, true), + $this->leftColumn('help.fields.description', 50) )->outputHeaders(); $this->outputMenus($table, $menus); diff --git a/src/Report/LogsReport.php b/src/Report/LogsReport.php index 692510964..f0b6199b4 100644 --- a/src/Report/LogsReport.php +++ b/src/Report/LogsReport.php @@ -48,7 +48,7 @@ class LogsReport extends AbstractReport implements PdfDrawCellBorderInterface private const FULL_WIDTH = 0.5; /** - * The half borderline width. + * The half-borderline width. */ private const HALF_WIDTH = 0.25; @@ -81,6 +81,7 @@ public function __construct(AbstractController $controller, private readonly Log public function drawCellBorder(PdfCellBorderEvent $event): bool { + // cards if ($this->drawCards) { $columns = $event->table->getColumns(); $text = $columns[$event->index]->getText(); @@ -88,7 +89,12 @@ public function drawCellBorder(PdfCellBorderEvent $event): bool return $this->drawBorder($event, $text); } - return (0 === $event->index) && $this->drawBorder($event, $this->level); + // row + if (!$event->table->isHeaders() && 0 === $event->index) { + return $this->drawBorder($event, $this->level); + } + + return false; } public function render(): bool @@ -123,7 +129,7 @@ private function cellTitle(): void private function drawBorder(PdfCellBorderEvent $event, ?string $level): bool { - if (null === $level || '' === $level) { + if (!StringUtils::isString($level)) { return false; } @@ -237,11 +243,11 @@ private function outputLogs(array $logs): void $this->cellTitle(); $table = PdfTable::instance($this) ->addColumns( - PdfColumn::left($this->trans('log.fields.level'), 20, true), - PdfColumn::left($this->trans('log.fields.channel'), 20, true), - PdfColumn::left($this->trans('log.fields.createdAt'), 34, true), - PdfColumn::left($this->trans('log.fields.message'), 150), - PdfColumn::left($this->trans('log.fields.user'), 20, true) + $this->leftColumn('log.fields.createdAt', 34, true), + $this->leftColumn('log.fields.message', 150), + $this->leftColumn('log.fields.level', 20, true), + $this->leftColumn('log.fields.channel', 20, true), + $this->leftColumn('log.fields.user', 20, true) ) ->outputHeaders() ->setBorderListener($this); @@ -254,10 +260,10 @@ private function outputLogs(array $logs): void $this->addDateBookmark($date); } $table->addRow( - $log->getLevel(true), - $log->getChannel(true), $log->getFormattedDate(), $log->getMessage(), + $log->getLevel(true), + $log->getChannel(true), $log->getUser() ); } diff --git a/src/Report/ProductsReport.php b/src/Report/ProductsReport.php index e9aaf1695..fd725121b 100644 --- a/src/Report/ProductsReport.php +++ b/src/Report/ProductsReport.php @@ -13,7 +13,6 @@ namespace App\Report; use App\Pdf\Colors\PdfTextColor; -use App\Pdf\PdfColumn; use App\Pdf\PdfGroupTable; use App\Pdf\PdfStyle; @@ -29,7 +28,7 @@ protected function doRender(array $entities): bool $this->setTitleTrans('product.list.title'); $this->addPage(); $table = $this->createTable(); - $style = PdfStyle::getCellStyle() + $redStyle = PdfStyle::getCellStyle() ->setTextColor(PdfTextColor::red()); $key = ''; @@ -51,7 +50,8 @@ protected function doRender(array $entities): bool $key = $newKey; $table->setGroupKey($key); } - $style = $this->isFloatZero($entity->getPrice()) ? $style : null; + + $style = $this->isFloatZero($entity->getPrice()) ? $redStyle : null; $table->startRow() ->add($entity->getDescription()) ->addCellAmount($entity->getPrice(), style: $style) @@ -72,10 +72,10 @@ private function createTable(): PdfGroupTable { return PdfGroupTable::instance($this) ->addColumns( - PdfColumn::left($this->trans('product.fields.description'), 90), - PdfColumn::right($this->trans('product.fields.price'), 20, true), - PdfColumn::left($this->trans('product.fields.unit'), 20, true), - PdfColumn::left($this->trans('product.fields.supplier'), 40, true) + $this->leftColumn('product.fields.description', 90), + $this->rightColumn('product.fields.price', 20, true), + $this->leftColumn('product.fields.unit', 20, true), + $this->leftColumn('product.fields.supplier', 40, true) )->outputHeaders(); } } diff --git a/src/Report/SchemaReport.php b/src/Report/SchemaReport.php index a989c2ff4..4632fe394 100644 --- a/src/Report/SchemaReport.php +++ b/src/Report/SchemaReport.php @@ -135,9 +135,9 @@ private function outputAssociations(array $associations): void } $table = $this->createTable( 'schema.fields.associations', - PdfColumn::left($this->trans('schema.fields.name'), 100), - PdfColumn::left($this->trans('schema.fields.table'), 100), - PdfColumn::left($this->trans('schema.fields.relation'), 55, true) + $this->leftColumn('schema.fields.name', 100), + $this->leftColumn('schema.fields.table', 100), + $this->leftColumn('schema.fields.relation', 55, true) ); foreach ($associations as $association) { $name = $association['table']; @@ -160,10 +160,10 @@ private function outputColumns(array $columns): void } $table = $this->createTable( 'schema.fields.columns', - PdfColumn::left($this->trans('schema.fields.name'), 100), - PdfColumn::left($this->trans('schema.fields.type'), 35, true), - PdfColumn::center($this->trans('schema.fields.required'), 25, true), - PdfColumn::left($this->trans('schema.fields.default'), 30, true) + $this->leftColumn('schema.fields.name', 100), + $this->leftColumn('schema.fields.type', 35, true), + $this->centerColumn('schema.fields.required', 25, true), + $this->leftColumn('schema.fields.default', 30, true) ); foreach ($columns as $column) { $link = $this->findLink($column['foreign_table']); @@ -187,10 +187,10 @@ private function outputIndexes(array $indexes): void } $table = $this->createTable( 'schema.fields.indexes', - PdfColumn::left($this->trans('schema.fields.name'), 100), - PdfColumn::left($this->trans('schema.fields.columns'), 100), - PdfColumn::center($this->trans('schema.fields.primary'), 25, true), - PdfColumn::center($this->trans('schema.fields.unique'), 30, true), + $this->leftColumn('schema.fields.name', 100), + $this->leftColumn('schema.fields.columns', 100), + $this->centerColumn('schema.fields.primary', 25, true), + $this->centerColumn('schema.fields.unique', 30, true), ); foreach ($indexes as $index) { $table->startRow() @@ -228,11 +228,11 @@ private function outputTables(array $tables): void $this->outputTitle('schema.index.title'); $instance = PdfTable::instance($this) ->addColumns( - PdfColumn::left($this->trans('schema.fields.name'), 100), - PdfColumn::right($this->trans('schema.fields.columns'), 19, true), - PdfColumn::right($this->trans('schema.fields.records'), 30, true), - PdfColumn::right($this->trans('schema.fields.indexes'), 17, true), - PdfColumn::right($this->trans('schema.fields.associations'), 25, true) + $this->leftColumn('schema.fields.name', 100), + $this->rightColumn('schema.fields.columns', 19, true), + $this->rightColumn('schema.fields.records', 30, true), + $this->rightColumn('schema.fields.indexes', 17, true), + $this->rightColumn('schema.fields.associations', 25, true) )->outputHeaders(); foreach ($tables as $table) { $name = $table['name']; diff --git a/src/Report/SymfonyReport.php b/src/Report/SymfonyReport.php index 8da46f9de..cb2c981d0 100644 --- a/src/Report/SymfonyReport.php +++ b/src/Report/SymfonyReport.php @@ -97,7 +97,7 @@ private function outputBundles(array $bundles): void private function outputInfo(SymfonyInfoService $info): void { $this->addBookmark('Kernel'); - $app = $this->controller->getApplication(); + $app = $this->controller->getApplicationService(); $table = PdfGroupTable::instance($this) ->setGroupStyle(PdfStyle::getHeaderStyle()) ->addColumns( diff --git a/src/Report/Table/ReportGroupTable.php b/src/Report/Table/ReportGroupTable.php index 9c4c43231..4ec6dbee0 100644 --- a/src/Report/Table/ReportGroupTable.php +++ b/src/Report/Table/ReportGroupTable.php @@ -15,6 +15,7 @@ use App\Pdf\PdfDocument; use App\Pdf\PdfGroupTable; use App\Pdf\Traits\PdfCellTranslatorTrait; +use App\Pdf\Traits\PdfColumnTranslatorTrait; use App\Report\AbstractReport; use Symfony\Contracts\Translation\TranslatorInterface; @@ -24,6 +25,7 @@ class ReportGroupTable extends PdfGroupTable { use PdfCellTranslatorTrait; + use PdfColumnTranslatorTrait; /** * @param PdfDocument $parent the parent document to print in diff --git a/src/Report/Table/ReportTable.php b/src/Report/Table/ReportTable.php index 19c21c739..b2ef6a42b 100644 --- a/src/Report/Table/ReportTable.php +++ b/src/Report/Table/ReportTable.php @@ -15,6 +15,7 @@ use App\Pdf\PdfDocument; use App\Pdf\PdfTable; use App\Pdf\Traits\PdfCellTranslatorTrait; +use App\Pdf\Traits\PdfColumnTranslatorTrait; use App\Report\AbstractReport; use Symfony\Contracts\Translation\TranslatorInterface; @@ -24,6 +25,7 @@ class ReportTable extends PdfTable { use PdfCellTranslatorTrait; + use PdfColumnTranslatorTrait; /** * @param PdfDocument $parent the parent document to print in diff --git a/src/Report/Table/TableGroups.php b/src/Report/Table/TableGroups.php index 7a5449f16..4184c8754 100644 --- a/src/Report/Table/TableGroups.php +++ b/src/Report/Table/TableGroups.php @@ -14,7 +14,6 @@ use App\Entity\Calculation; use App\Entity\CalculationGroup; -use App\Pdf\PdfColumn; use App\Pdf\PdfStyle; use App\Report\CalculationReport; use fpdf\PdfBorder; @@ -75,11 +74,11 @@ public function startRow(?PdfStyle $style = null): static private function createColumns(): void { $columns = [ - PdfColumn::left($this->trans('report.calculation.resume'), 50), - PdfColumn::right($this->trans('report.calculation.amount'), 20, true), - PdfColumn::right($this->trans('report.calculation.margin_percent'), 20, true), - PdfColumn::right($this->trans('report.calculation.margin_amount'), 20, true), - PdfColumn::right($this->trans('report.calculation.total'), 20, true), + $this->leftColumn('report.calculation.resume', 50), + $this->rightColumn('report.calculation.amount', 20, true), + $this->rightColumn('report.calculation.margin_percent', 20, true), + $this->rightColumn('report.calculation.margin_amount', 20, true), + $this->rightColumn('report.calculation.total', 20, true), ]; $this->addColumns(...$columns); diff --git a/src/Report/Table/TableItems.php b/src/Report/Table/TableItems.php index 1948a5a15..011e9c6ab 100644 --- a/src/Report/Table/TableItems.php +++ b/src/Report/Table/TableItems.php @@ -19,7 +19,6 @@ use App\Pdf\Colors\PdfTextColor; use App\Pdf\Events\PdfGroupEvent; use App\Pdf\Interfaces\PdfGroupListenerInterface; -use App\Pdf\PdfColumn; use App\Pdf\PdfStyle; use App\Report\CalculationReport; use fpdf\PdfBorder; @@ -162,14 +161,14 @@ private function checkLines(int $lines): void $this->setInProgress(false); } - private function createColumns(): self + private function createColumns(): void { - return $this->addColumns( - PdfColumn::left($this->trans('calculationitem.fields.description'), 50), - PdfColumn::left($this->trans('calculationitem.fields.unit'), 20, true), - PdfColumn::right($this->trans('calculationitem.fields.price'), 20, true), - PdfColumn::right($this->trans('calculationitem.fields.quantity'), 20, true), - PdfColumn::right($this->trans('calculationitem.fields.total'), 20, true) + $this->addColumns( + $this->leftColumn('calculationitem.fields.description', 50), + $this->leftColumn('calculationitem.fields.unit', 20, true), + $this->rightColumn('calculationitem.fields.price', 20, true), + $this->rightColumn('calculationitem.fields.quantity', 20, true), + $this->rightColumn('calculationitem.fields.total', 20, true) )->outputHeaders(); } diff --git a/src/Report/Table/TableOverall.php b/src/Report/Table/TableOverall.php index 0da3c8d9f..b2ec4b4df 100644 --- a/src/Report/Table/TableOverall.php +++ b/src/Report/Table/TableOverall.php @@ -14,7 +14,6 @@ use App\Entity\Calculation; use App\Pdf\Colors\PdfTextColor; -use App\Pdf\PdfColumn; use App\Pdf\PdfStyle; use App\Report\CalculationReport; use fpdf\PdfBorder; @@ -80,11 +79,11 @@ public function startRow(?PdfStyle $style = null): static private function createColumns(): self { return $this->addColumns( - PdfColumn::left(null, 50), - PdfColumn::right(null, 20, true), - PdfColumn::right(null, 20, true), - PdfColumn::right(null, 20, true), - PdfColumn::right(null, 20, true) + $this->leftColumn('', 50), + $this->rightColumn('', 20, true), + $this->rightColumn('', 20, true), + $this->rightColumn('', 20, true), + $this->rightColumn('', 20, true), )->setRepeatHeader(false); } @@ -99,7 +98,7 @@ private function outputGlobalMargin(float $globalMargin, float $globalAmount): s ->endRow(); } - private function outputOverallTotal(Calculation $calculation, float $totalItems): self + private function outputOverallTotal(Calculation $calculation, float $totalItems): void { $style = null; if ($calculation->isMarginBelow($this->minMargin)) { @@ -112,8 +111,6 @@ private function outputOverallTotal(Calculation $calculation, float $totalItems) ->addCellAmount($calculation->getOverallMarginAmount()) ->addCellAmount($calculation->getOverallTotal()) ->endRow(); - - return $this; } private function outputUserMargin(float $userMargin, float $userAmount, float $totalNet): self diff --git a/src/Report/TasksReport.php b/src/Report/TasksReport.php index ae3c00684..19b713ef8 100644 --- a/src/Report/TasksReport.php +++ b/src/Report/TasksReport.php @@ -111,11 +111,11 @@ private function createTable(): ReportGroupTable return ReportGroupTable::fromReport($this) ->addColumns( PdfColumn::left($name, 40), - PdfColumn::left($this->trans('task.fields.category'), 50, true), - PdfColumn::left($this->trans('task.fields.unit'), 15, true), - PdfColumn::right($this->trans('taskitemmargin.fields.minimum'), 20, true), - PdfColumn::right($this->trans('taskitemmargin.fields.maximum'), 20, true), - PdfColumn::right($this->trans('taskitemmargin.fields.value'), 20, true) + $this->leftColumn('task.fields.category', 50, true), + $this->leftColumn('task.fields.unit', 15, true), + $this->rightColumn('taskitemmargin.fields.minimum', 20, true), + $this->rightColumn('taskitemmargin.fields.maximum', 20, true), + $this->rightColumn('taskitemmargin.fields.value', 20, true) )->outputHeaders() ->setGroupListener($this); } diff --git a/src/Report/UsersReport.php b/src/Report/UsersReport.php index 46735d1cd..ea4f5ffaa 100644 --- a/src/Report/UsersReport.php +++ b/src/Report/UsersReport.php @@ -16,7 +16,6 @@ use App\Entity\User; use App\Pdf\Colors\PdfTextColor; use App\Pdf\PdfCell; -use App\Pdf\PdfColumn; use App\Pdf\PdfImageCell; use App\Pdf\PdfStyle; use App\Pdf\PdfTable; @@ -60,12 +59,12 @@ private function createTable(): PdfTable { return PdfTable::instance($this) ->addColumns( - PdfColumn::center($this->trans('user.fields.imageFile'), 18, true), - PdfColumn::left($this->trans('user.fields.username'), 25), - PdfColumn::left($this->trans('user.fields.email'), 30), - PdfColumn::left($this->trans('user.fields.role'), 35, true), - PdfColumn::left($this->trans('user.fields.enabled'), 18, true), - PdfColumn::left($this->trans('user.fields.lastLogin'), 30, true) + $this->centerColumn('user.fields.imageFile', 18, true), + $this->leftColumn('user.fields.username', 25), + $this->leftColumn('user.fields.email', 30), + $this->leftColumn('user.fields.role', 35, true), + $this->leftColumn('user.fields.enabled', 18, true), + $this->leftColumn('user.fields.lastLogin', 30, true) )->outputHeaders(); } diff --git a/src/Report/UsersRightsReport.php b/src/Report/UsersRightsReport.php index 1a51e59a7..885de6aa0 100644 --- a/src/Report/UsersRightsReport.php +++ b/src/Report/UsersRightsReport.php @@ -19,7 +19,6 @@ use App\Model\Role; use App\Pdf\Events\PdfGroupEvent; use App\Pdf\Interfaces\PdfGroupListenerInterface; -use App\Pdf\PdfColumn; use App\Pdf\PdfGroupTable; use App\Pdf\PdfStyle; use App\Pdf\PdfTable; @@ -117,10 +116,10 @@ private function createTableBuilder(): PdfGroupTable $table = PdfGroupTable::instance($this) ->setGroupStyle(PdfStyle::getCellStyle()->setFontBold()) ->setGroupListener($this) - ->addColumn(PdfColumn::left($this->trans('user.rights.table_title'), 50)); + ->addColumn($this->leftColumn('user.rights.table_title', 50)); $permissions = EntityPermission::sorted(); foreach ($permissions as $permission) { - $table->addColumn(PdfColumn::center($this->trans($permission), 25, true)); + $table->addColumn($this->centerColumn($permission, 25, true)); } $table->outputHeaders(); @@ -129,7 +128,7 @@ private function createTableBuilder(): PdfGroupTable private function getApplication(): ApplicationService { - return $this->controller->getApplication(); + return $this->controller->getApplicationService(); } /** diff --git a/src/Repository/AbstractRepository.php b/src/Repository/AbstractRepository.php index 8db4a2061..9938a1dc6 100644 --- a/src/Repository/AbstractRepository.php +++ b/src/Repository/AbstractRepository.php @@ -118,7 +118,7 @@ public function getDistinctValues(string $field, string $value = '', int $limit /** * Gets the database search fields. * - * The default implementation returns the alias and the field separated by a dot ('.') character. + * The default implementation returns the alias and the field separated by a dot character ('.'). * * @param string $field the field name * @param string $alias the entity alias @@ -186,7 +186,7 @@ public function getSingleIdentifierFieldName(): string /** * Gets the database sort field. * - * The default implementation returns the alias and the field separated by a dot ('.') character. + * The default implementation returns the alias and the field separated by a dot character ('.'). * * @param string $field the field name * @param string $alias the entity alias diff --git a/src/Repository/CalculationStateRepository.php b/src/Repository/CalculationStateRepository.php index 8524a0964..f62f1ce48 100644 --- a/src/Repository/CalculationStateRepository.php +++ b/src/Repository/CalculationStateRepository.php @@ -59,7 +59,7 @@ public function __construct(ManagerRegistry $registry) } /** - * Gets states with calculations statistics. + * Gets states with the calculation statistics. * * Note: Only states with at least one calculation are returned. * diff --git a/src/Repository/CustomerRepository.php b/src/Repository/CustomerRepository.php index 6d98a01ba..949172984 100644 --- a/src/Repository/CustomerRepository.php +++ b/src/Repository/CustomerRepository.php @@ -48,7 +48,7 @@ public function __construct(ManagerRegistry $registry) } /** - * Gets all customers order by name and company. + * Gets all the customers order by name and company. * * @return Customer[] */ diff --git a/src/Repository/GlobalMarginRepository.php b/src/Repository/GlobalMarginRepository.php index 2f91bfcc1..c1b2d11c2 100644 --- a/src/Repository/GlobalMarginRepository.php +++ b/src/Repository/GlobalMarginRepository.php @@ -30,7 +30,7 @@ public function __construct(ManagerRegistry $registry) } /** - * Gets all global margins order by minimum. + * Gets all global margins ordered by the minimum. * * @return GlobalMargin[] */ diff --git a/src/Repository/GroupRepository.php b/src/Repository/GroupRepository.php index 2bcdb3506..6053f1459 100644 --- a/src/Repository/GroupRepository.php +++ b/src/Repository/GroupRepository.php @@ -48,7 +48,7 @@ public function __construct(ManagerRegistry $registry) } /** - * Gets all group order by code. + * Gets all group ordered by code. * * @return Group[] */ diff --git a/src/Repository/ProductRepository.php b/src/Repository/ProductRepository.php index bf7b305bc..764b99049 100644 --- a/src/Repository/ProductRepository.php +++ b/src/Repository/ProductRepository.php @@ -48,7 +48,7 @@ public function findByCategory(Category $category): array } /** - * Gets all products order by description. + * Gets all products ordered by description. * * @return Product[] */ @@ -58,7 +58,7 @@ public function findByDescription(): array } /** - * Gets all products order by group, category and description. + * Gets all products ordered by the group, the category and the description. * * @return Product[] */ @@ -77,7 +77,7 @@ public function findByGroup(): array } /** - * Gets the default query builder with all products order by the category code, the group code and the + * Gets the default query builder with all products ordered by the category code, the group code, and the * product description. */ public function getQueryBuilderByCategory(): QueryBuilder diff --git a/src/Repository/TaskItemRepository.php b/src/Repository/TaskItemRepository.php index 3f44d7e98..f356239fa 100644 --- a/src/Repository/TaskItemRepository.php +++ b/src/Repository/TaskItemRepository.php @@ -16,7 +16,7 @@ use Doctrine\Persistence\ManagerRegistry; /** - * Repository for task item entity. + * Repository for the task item entity. * * @template-extends AbstractRepository */ diff --git a/src/Response/CsvResponse.php b/src/Response/CsvResponse.php index 1280e3558..925834eed 100644 --- a/src/Response/CsvResponse.php +++ b/src/Response/CsvResponse.php @@ -19,9 +19,10 @@ class CsvResponse extends AbstractStreamedResponse { /** * @param callable|null $callback the callback to output content - * @param bool $inline true to send the file inline to the browser. The document viewer is - * used if available. false to send to the browser and force a file - * download with the name given. + * @param bool $inline true to send the file inline to the browser. + * The document viewer is used if available. + * false to send to the browser and force a file download with the name + * given. * @param string $name the name of the document file or '' to use the default * name ('document.csv') */ diff --git a/src/Response/PdfResponse.php b/src/Response/PdfResponse.php index b94ae49a4..ea5835728 100644 --- a/src/Response/PdfResponse.php +++ b/src/Response/PdfResponse.php @@ -24,9 +24,10 @@ class PdfResponse extends AbstractStreamedResponse { /** * @param PdfDocument $doc the document to output - * @param bool $inline true to send the file inline to the browser. The document viewer - * is used if available. false to send to the browser and force a file - * download with the name given. + * @param bool $inline true to send the file inline to the browser. + * The document viewer is used if available. + * false to send to the browser and force a file download with the name + * given. * @param string $name the name of the document file or '' to use the default name * ('document.pdf'). */ diff --git a/src/Response/SpreadsheetResponse.php b/src/Response/SpreadsheetResponse.php index 83daa6bb8..bc0ca349a 100644 --- a/src/Response/SpreadsheetResponse.php +++ b/src/Response/SpreadsheetResponse.php @@ -24,10 +24,10 @@ class SpreadsheetResponse extends AbstractStreamedResponse { /** * @param SpreadsheetDocument $doc the document to output - * @param bool $inline true to send the file inline to the browser. The document viewer - * is used if available. false to send to the browser and force - * a file - * download with the name given. + * @param bool $inline true to send the file inline to the browser. + * The document viewer is used if available. + * false to send to the browser and force a file download with + * the name given. * @param string $name the name of the document file or '' to use the default * name ('document.xlsx') */ diff --git a/src/Response/WordResponse.php b/src/Response/WordResponse.php index 528ae55db..86fb086ac 100644 --- a/src/Response/WordResponse.php +++ b/src/Response/WordResponse.php @@ -22,9 +22,10 @@ class WordResponse extends AbstractStreamedResponse { /** * @param WordDocument $doc the document to output - * @param bool $inline true to send the file inline to the browser. The document viewer is - * used if available. false to send to the browser and force a file - * download with the name given. + * @param bool $inline true to send the file inline to the browser. + * The document viewer is used if available. + * false to send to the browser and force a file download with the name + * given. * @param string $name the name of the document file or '' to use the default * name ('document.docx') */ diff --git a/src/Service/AES256EncryptorService.php b/src/Service/AES256EncryptorService.php index a6515b052..d45c01d99 100644 --- a/src/Service/AES256EncryptorService.php +++ b/src/Service/AES256EncryptorService.php @@ -59,7 +59,7 @@ public function decrypt(string $data): string|false } /** - * @throws \JsonException if the data can not be decoded + * @throws \JsonException if the data cannot be decoded */ public function decryptJson(string $data, bool $assoc = true, int $flags = 0): mixed { @@ -89,7 +89,7 @@ public function encrypt(string $data): string|false } /** - * @throws \JsonException if the data can not be encoded + * @throws \JsonException if the data cannot be encoded */ public function encryptJson(mixed $data, int $flags = 0): string|false { diff --git a/src/Service/AkismetService.php b/src/Service/AkismetService.php index 9656d7ab6..a1daf9fa7 100644 --- a/src/Service/AkismetService.php +++ b/src/Service/AkismetService.php @@ -23,7 +23,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; /** - * Service to check spams with the Akismet. + * Service to check spamming with the Akismet. * * @see https://akismet.com/ */ @@ -89,9 +89,11 @@ public function getCacheTimeout(): int * The parameters options can be one of the following: *

*
    - *
  • blog (required): The front page or home URL of the instance making the request. For a blog or wiki this would be the front page. Note: Must be a full URI, including http://.
  • + *
  • blog (required): The front page or home URL of the instance making the request. For a blog or wiki, + * this would be the front page. Note: Must be a full URI, including http://.
  • *
  • user_ip (required): IP address of the comment submitter.
  • - *
  • user_agent: User agent string of the web browser submitting the comment - typically the HTTP_USER_AGENT cgi variable. Not to be confused with the user agent of the Akismet library.
  • + *
  • user_agent: User agent string of the web browser submitting the comment - typically the + * HTTP_USER_AGENT cgi variable. Not to be confused with the user agent of the Akismet library.
  • *
  • referrer: The content of the HTTP_REFERER header should be sent here.
  • *
  • permalink: The full permanent URL of the entry the comment was submitted to.
  • *
  • comment_type: A string that describes the type of content being sent. Examples: @@ -108,11 +110,16 @@ public function getCacheTimeout(): int *
  • comment_author: Name submitted with the comment.
  • *
  • comment_author_email: Email address submitted with the comment.
  • *
  • comment_author_url: URL submitted with comment.
  • - *
  • comment_date_gmt: The UTC timestamp of the creation of the comment, in ISO 8601 format. May be omitted for comment-check requests if the comment is sent to the API at the time it is created.
  • - *
  • comment_post_modified_gmt: The UTC timestamp of the publication time for the post, page or thread on which the comment was posted.
  • - *
  • blog_lang: Indicates the language(s) in use on the blog or site, in ISO 639-1 format, comma-separated. A site with articles in English and French might use “en, fr_ca”.
  • - *
  • blog_charset: The character encoding for the form values included in comment_* parameters, such as “UTF-8” or “ISO-8859-1”.
  • - *
  • user_role: The user role of the user who submitted the comment. This is an optional parameter. If you set it to “administrator”, Akismet will always return false.
  • + *
  • comment_date_gmt: The UTC timestamp of the creation of the comment, in ISO 8601 format. May be + * omitted for comment-check requests if the comment is sent to the API at the time it is created.
  • + *
  • comment_post_modified_gmt: The UTC timestamp of the publication time for the post, page or thread + * on which the comment was posted.
  • + *
  • blog_lang: Indicates the language(s) in use on the blog or site, in ISO 639-1 format, comma-separated. + * A site with articles in English and French might use "en, fr_ca".
  • + *
  • blog_charset: The character encoding for the form values included in comment_* parameters, such as + * "UTF-8" or "ISO-8859-1".
  • + *
  • user_role: The user role of the user who submitted the comment. This is an optional parameter. + * If you set it to "administrator", Akismet will always return false.
  • *
  • is_test: This is an optional parameter. You can use it when submitting test queries.
  • *
. * diff --git a/src/Service/CaptchaImageService.php b/src/Service/CaptchaImageService.php index 2e0a1a62a..aef3fb418 100644 --- a/src/Service/CaptchaImageService.php +++ b/src/Service/CaptchaImageService.php @@ -100,7 +100,7 @@ public function clear(): self * @param int $width the image width * @param int $height the image height * - * @return ?string the image encoded with the base 64 or null if the image can not be created + * @return ?string the image encoded with base 64 or null if the image cannot be created * * @throws \Exception * diff --git a/src/Service/CountryFlagService.php b/src/Service/CountryFlagService.php index 8835e52ef..58ea88e73 100644 --- a/src/Service/CountryFlagService.php +++ b/src/Service/CountryFlagService.php @@ -25,7 +25,7 @@ class CountryFlagService * Gets choice values used by country type form. * * @param ?string $locale the locale used to translate country names or null to use default - * @param bool $flagOnly true to return flag only; false to return flags and country names + * @param bool $flagOnly true to return a flag only; false to return flags and country names * * @return array an array where key is the flag and the country name (if applicable) and value is the country code */ @@ -57,10 +57,10 @@ public static function getDefaultCode(): string /** * Gets the Emoji flag for the given country code. * - * @param string $alpha2Code the country code (ISO 3166-1 alpha-2) to get Emoji flag for + * @param string $alpha2Code the country code (ISO 3166-1 alpha-2) to get the Emoji flag for * @param bool $validate true to validate the given country code * - * @throws \InvalidArgumentException if the validate parameter is true and the given country code does not exist + * @throws \InvalidArgumentException if validate parameter is true and the given country code does not exist * * @see Countries::exists() */ diff --git a/src/Service/DatabaseInfoService.php b/src/Service/DatabaseInfoService.php index 8f4804010..f7303fb4a 100644 --- a/src/Service/DatabaseInfoService.php +++ b/src/Service/DatabaseInfoService.php @@ -14,6 +14,7 @@ use App\Utils\StringUtils; use Doctrine\DBAL\Connection; +use Doctrine\DBAL\Exception; use Doctrine\ORM\EntityManagerInterface; /** @@ -60,7 +61,7 @@ public function getConfiguration(): array default => $value }; } - } catch (\Exception) { + } catch (\Exception|Exception) { } } @@ -113,7 +114,7 @@ public function getVersion(): string if (false !== $entries) { $this->version = (string) $entries['Value']; } - } catch (\Exception) { + } catch (\Exception|Exception) { } } @@ -123,7 +124,7 @@ public function getVersion(): string /** * Prepares an SQL statement and return the result. * - * @throws \Doctrine\DBAL\Exception + * @throws Exception */ private function executeQuery(string $sql, bool $all): array|false { diff --git a/src/Service/HelpService.php b/src/Service/HelpService.php index 030cc03e2..be933b24f 100644 --- a/src/Service/HelpService.php +++ b/src/Service/HelpService.php @@ -291,7 +291,7 @@ public function getTranslator(): TranslatorInterface } /** - * Merge current item with an action; if applicable. + * Merge current item with an action, if applicable. * * @psalm-param array{action?: string, ...} $item */ diff --git a/src/Service/ImageService.php b/src/Service/ImageService.php index 1b7235107..e347e6a12 100644 --- a/src/Service/ImageService.php +++ b/src/Service/ImageService.php @@ -24,7 +24,7 @@ class ImageService { /** - * The default image resolution (96) in dot per each (DPI). + * The default image resolution (96) in the dot per each (DPI). */ final public const DEFAULT_RESOLUTION = 96; @@ -57,7 +57,7 @@ public function __destruct() /** * Allocate a color for this image. * - * The color is automatically de-allocate as soon as there are no other references to this instance. + * The color is automatically de-allocated as soon as there are no other references to this instance. * * @param int $red the value of red component * @param int $green the value of green component @@ -82,7 +82,7 @@ public function allocate(int $red, int $green, int $blue): int|false /** * Allocate a color for this image. * - * The color is automatically de-allocate as soon as there are no other references to this instance. + * The color is automatically de-allocated as soon as there are no other references to this instance. * * @param int $red the value of red component * @param int $green the value of green component @@ -181,7 +181,7 @@ public function copyResampled( /** * Fill this image's bounds with the given color. * - * @param int $color the fill color. A color identifier created with allocate. + * @param int $color the fill color. A color identifier created with the allocate method. * @param int $x the x-coordinate of start point * @param int $y the y-coordinate of start point * @@ -201,7 +201,7 @@ public function fill(int $color, int $x = 0, int $y = 0): bool * @param int $y the y-coordinate * @param int $width the rectangle width * @param int $height the rectangle height - * @param int $color the fill color. A color identifier created with allocate. + * @param int $color the fill color. A color identifier created with the allocate method. * * @return bool true on success or false on failure */ @@ -279,7 +279,7 @@ public function getImage(): \GdImage * @param int $y1 the y-coordinate for first point * @param int $x2 the x-coordinate for second point * @param int $y2 the y-coordinate for second point - * @param int $color the line color. A color identifier created with allocate. + * @param int $color the line color. A color identifier created with the allocate method. * * @return bool true on success or false on failure * @@ -297,7 +297,7 @@ public function line(int $x1, int $y1, int $x2, int $y2, int $color): bool * @param int $y the y-coordinate * @param int $width the rectangle width * @param int $height the rectangle height - * @param int $color the border color. A color identifier created with allocate. + * @param int $color the border color. A color identifier created with the allocate method. * * @return bool true on success or false on failure */ @@ -307,7 +307,7 @@ public function rectangle(int $x, int $y, int $width, int $height, int $color): } /** - * Get the horizontal resolution of this image in dot per inch (DPI). + * Get the horizontal resolution of this image in the dot per inch (DPI). * * @param int $default the default resolution to use on failure * @@ -342,7 +342,7 @@ public function saveAlpha(bool $save): bool * * @param int $x the x-coordinate * @param int $y the y-coordinate - * @param int $color a color identifier created with allocate + * @param int $color a color identifier created with the allocate method * * @return bool true on success or false on failure * @@ -356,7 +356,7 @@ public function setPixel(int $x, int $y, int $color): bool /** * Define a color as transparent. * - * @param int $color a color identifier created with allocate + * @param int $color a color identifier created with the allocate method * * @return int the identifier of the new (or current, if none is specified) transparent color is returned. If color * is null, and the image has no transparent color, the returned identifier will be -1. @@ -374,7 +374,7 @@ public function transparent(int $color): int * @param string $fontFile the path to the TrueType font * @param string $text the string to be measured * - * @return int[]|false an array with 8 elements representing four points making the bounding box of the + * @return int[]|false an array with 8 elements representing four points making the bounding box of * text on success and false on error.
* The points are relative to the text regardless of the angle, so "upper left" means in the * top left-hand corner seeing the text horizontally.

@@ -465,9 +465,9 @@ public function ttfSize(float $size, float $angle, string $fontFile, string $tex * value of 90 would result in bottom-to-top reading text. * @param int $x The coordinates given by x and y will define the base point of the first * character (roughly the lower-left corner of the character) - * @param int $y The y-coordinate. This sets the position of the font baseline, not the + * @param int $y The y-coordinate. This sets the position of the font baseline, not * very bottom of the character. - * @param int $color a color identifier created with allocate + * @param int $color a color identifier created with the allocate method * @param string $fontFile the path to the TrueType font * @param string $text The text string in UTF-8 encoding. *
@@ -483,7 +483,7 @@ public function ttfSize(float $size, float $angle, string $fontFile, string $tex * If a character is used in the string which is not supported by the * font, a hollow rectangle will replace the character. * - * @return array|false an array with 8 elements representing four points making the bounding box of the + * @return array|false an array with 8 elements representing four points making the bounding box of * text on success and false on error.
* The points are relative to the text regardless of the angle, so "upper left" means in the * top left-hand corner seeing the text horizontally.
diff --git a/src/Service/PhpInfoService.php b/src/Service/PhpInfoService.php index e0c54fc7a..e8944a8e5 100644 --- a/src/Service/PhpInfoService.php +++ b/src/Service/PhpInfoService.php @@ -20,15 +20,15 @@ final class PhpInfoService { /** - * The replace string for sensitive parameters. + * The replaced string for sensitive parameters. */ public const REDACTED = '********'; /** - * Gets PHP information as array. + * Gets PHP information as the array. * - * @param int $what The output may be customized by passing one or more of the following constants bitwise values summed - * together in the optional what parameter. + * @param int $what The output may be customized by passing one or more of the following constants bitwise values + * summed together in the optional what parameter. * One can also combine the respective constants or bitwise values * together with the bitwise or operator. * @@ -86,8 +86,8 @@ public function asArray(int $what = \INFO_ALL): array /** * Gets PHP information as HTML. * - * @param int $what The output may be customized by passing one or more of the following constants bitwise values summed - * together in the optional what parameter. + * @param int $what The output may be customized by passing one or more of the following constants bitwise + * values summed together in the optional what parameter. * One can also combine the respective constants or bitwise values * together with the bitwise or operator. */ @@ -133,8 +133,8 @@ public function asHtml(int $what = \INFO_ALL): string /** * Gets PHP information as text (raw data). * - * @param int $what The output may be customized by passing one or more of the following constants bitwise values summed - * together in the optional what parameter. + * @param int $what The output may be customized by passing one or more of the following constants bitwise values + * summed together in the optional what parameter. * One can also combine the respective constants or bitwise values * together with the bitwise or operator. */ diff --git a/src/Service/ResetPasswordService.php b/src/Service/ResetPasswordService.php index fb2c804fa..a416f11bb 100644 --- a/src/Service/ResetPasswordService.php +++ b/src/Service/ResetPasswordService.php @@ -72,7 +72,7 @@ public function generateFakeResetToken(?int $resetRequestLifetime = null): Reset } /** - * Gets the translated expires lifetime. + * Gets translated lifetime expires. */ public function getExpiresLifeTime(ResetPasswordToken $token): string { @@ -112,7 +112,7 @@ public function getThrottleLifeTime(): string } /** - * Handle an exception by set the authentication error to the session, if applicable; and log it. + * Handle an exception by set the authentication error to the session, if applicable, and log it. */ public function handleException(Request $request, \Throwable $e): void { @@ -120,9 +120,9 @@ public function handleException(Request $request, \Throwable $e): void } /** - * Send email to the user for resetting the password. + * Send the email to the user for resetting the password. * - * @return ResetPasswordToken|false|null false if the user can not be found; the token on success; null on error + * @return ResetPasswordToken|false|null false if the user cannot be found; the token on success; null on error */ public function sendEmail(Request $request, User|string $user): ResetPasswordToken|false|null { diff --git a/src/Service/RoleBuilderService.php b/src/Service/RoleBuilderService.php index 7c100494b..95bfe8bfb 100644 --- a/src/Service/RoleBuilderService.php +++ b/src/Service/RoleBuilderService.php @@ -50,7 +50,7 @@ public function getRoleAdmin(): Role } /** - * Gets disabled role with the no access right. + * Gets the disabled role with the no access right. */ public function getRoleDisabled(): Role { diff --git a/src/Service/RoleHierarchyService.php b/src/Service/RoleHierarchyService.php index 11b583565..1369ae2e6 100644 --- a/src/Service/RoleHierarchyService.php +++ b/src/Service/RoleHierarchyService.php @@ -17,7 +17,7 @@ use Symfony\Component\Security\Core\User\UserInterface; /** - * Service to deals with roles and hierarchy. + * Service to deal with roles and hierarchy. */ readonly class RoleHierarchyService { @@ -30,7 +30,7 @@ public function __construct(private RoleHierarchyInterface $service) * * @param mixed $data the data to get reachable role names * - * @return string[] an array, maybe empty; of reachable role names + * @return string[] an array, maybe empty, of reachable role names * * @pslam-return RoleInterface::ROLE_*[] */ @@ -44,7 +44,7 @@ public function getReachableRoleNames(mixed $data): array /** * Gets the role names for the given data. * - * @return string[] an array, maybe empty; of role names + * @return string[] an array, maybe empty, of role names * * @pslam-return RoleInterface::ROLE_*[] */ diff --git a/src/Service/SwissPostService.php b/src/Service/SwissPostService.php index 312087700..d88214f63 100644 --- a/src/Service/SwissPostService.php +++ b/src/Service/SwissPostService.php @@ -87,7 +87,7 @@ public function getDatabaseName(): string } /** - * Gets the records count for all tables. + * Gets the record's count for all tables. * * @return array{state: int, city: int, street: int} */ diff --git a/src/Service/SwissPostUpdater.php b/src/Service/SwissPostUpdater.php index 5d37509a8..2b6e34072 100644 --- a/src/Service/SwissPostUpdater.php +++ b/src/Service/SwissPostUpdater.php @@ -221,7 +221,7 @@ private function getLastImport(SwissPostUpdateResult $result): ?\DateTimeInterfa } /** - * Gets the records count for all tables. + * Gets the record's count for all tables. * * @return array{city: int, state: int, street: int} */ diff --git a/src/Service/SymfonyInfoService.php b/src/Service/SymfonyInfoService.php index 6bbbbb31a..113ebc780 100644 --- a/src/Service/SymfonyInfoService.php +++ b/src/Service/SymfonyInfoService.php @@ -345,7 +345,7 @@ public function isDebug(): bool } /** - * Returns if the long term support is enabled. + * Returns if the long-term support is enabled. */ public function isLongTermSupport(): bool { diff --git a/src/Spreadsheet/CellBuilder.php b/src/Spreadsheet/CellBuilder.php index 0d1500fe9..e4007afbb 100644 --- a/src/Spreadsheet/CellBuilder.php +++ b/src/Spreadsheet/CellBuilder.php @@ -75,7 +75,7 @@ public function __construct(private readonly Worksheet $sheet) /** * Sets the cell value and style at the given coordinate. * - * @param string $coordinate the coordinate of the cell, eg: 'A1' + * @param string $coordinate the coordinate of the cell (like 'A1') * @param mixed $value the value of the cell */ public function apply(string $coordinate, mixed $value): self diff --git a/src/Spreadsheet/GroupsDocument.php b/src/Spreadsheet/GroupsDocument.php index 6c8c16ef5..5f2ff4377 100644 --- a/src/Spreadsheet/GroupsDocument.php +++ b/src/Spreadsheet/GroupsDocument.php @@ -35,10 +35,8 @@ protected function doRender(array $entities): bool 'group.fields.categories' => HeaderFormat::int(), 'category.fields.products' => HeaderFormat::int(), 'category.fields.tasks' => HeaderFormat::int(), - 'globalmargin.fields.minimum' => HeaderFormat::amount(), 'globalmargin.fields.maximum' => HeaderFormat::amount(), - 'globalmargin.fields.delta' => HeaderFormat::amount(), 'globalmargin.fields.margin' => HeaderFormat::percent(), ]); @@ -50,18 +48,22 @@ protected function doRender(array $entities): bool $entity->countProducts(), $entity->countTasks(), ]); - $first = true; - foreach ($entity->getMargins() as $margin) { - if (!$first) { - ++$row; + if ($entity->hasMargins()) { + $first = true; + foreach ($entity->getMargins() as $margin) { + if (!$first) { + ++$row; + } + $sheet->setRowValues($row, [ + $margin->getMinimum(), + $margin->getMaximum(), + $margin->getMargin(), + ], 6); + $first = false; } - $sheet->setRowValues($row, [ - $margin->getMinimum(), - $margin->getMaximum(), - $margin->getDelta(), - $margin->getMargin(), - ], 6); - $first = false; + } else { + $sheet->setCellValue([6, $row], $this->trans('group.edit.empty_margins')); + $sheet->mergeContent(6, 8, $row); } ++$row; } diff --git a/src/Spreadsheet/SpreadsheetDocument.php b/src/Spreadsheet/SpreadsheetDocument.php index b55da4a24..ba23648df 100644 --- a/src/Spreadsheet/SpreadsheetDocument.php +++ b/src/Spreadsheet/SpreadsheetDocument.php @@ -50,7 +50,7 @@ public function __construct(private readonly TranslatorInterface $translator) * @param Worksheet $worksheet the external sheet to add * @param ?int $sheetIndex the index where sheet should go (0, 1, ... or null for last) * - * @throws Exception if the given worksheet is not instance of WorksheetDocument + * @throws Exception if the given worksheet is not an instance of WorksheetDocument */ public function addExternalSheet(Worksheet $worksheet, ?int $sheetIndex = null): WorksheetDocument { @@ -69,7 +69,7 @@ public function addExternalSheet(Worksheet $worksheet, ?int $sheetIndex = null): * @param Worksheet $worksheet the worksheet to add * @param ?int $sheetIndex the index where sheet should go (0, 1, ... or null for last) * - * @throws Exception if the given worksheet is not instance of WorksheetDocument + * @throws Exception if the given worksheet is not an instance of WorksheetDocument */ public function addSheet(Worksheet $worksheet, ?int $sheetIndex = null): WorksheetDocument { @@ -148,7 +148,7 @@ public function getAllSheets(): array } /** - * Get sheet by the given index. + * Get a sheet by the given index. * * @param int $sheetIndex Sheet index * @@ -163,7 +163,7 @@ public function getSheet(int $sheetIndex): WorksheetDocument } /** - * Get sheet by name. + * Get a sheet by name. * * @param string $worksheetName Sheet name */ @@ -176,7 +176,7 @@ public function getSheetByName(string $worksheetName): ?WorksheetDocument } /** - * Get sheet by name, throwing exception if not found. + * Get a sheet by name, throwing exception if not found. * * @throws Exception */ diff --git a/src/Spreadsheet/SymfonyDocument.php b/src/Spreadsheet/SymfonyDocument.php index 061d0c8f7..758d08258 100644 --- a/src/Spreadsheet/SymfonyDocument.php +++ b/src/Spreadsheet/SymfonyDocument.php @@ -94,7 +94,7 @@ private function outputGroup(WorksheetDocument $sheet, int $row, string $group): */ private function outputInfo(SymfonyInfoService $info): void { - $app = $this->controller->getApplication(); + $app = $this->controller->getApplicationService(); $this->setActiveTitle('Symfony', $this->controller); $sheet = $this->getActiveSheet(); $row = $sheet->setHeaders([ diff --git a/src/Spreadsheet/UserRightsDocument.php b/src/Spreadsheet/UserRightsDocument.php index c5e50fa1e..32cf14574 100644 --- a/src/Spreadsheet/UserRightsDocument.php +++ b/src/Spreadsheet/UserRightsDocument.php @@ -56,7 +56,7 @@ protected function doRender(array $entities): bool } $row = $sheet->setHeaders($headers); - $service = $this->controller->getApplication(); + $service = $this->controller->getApplicationService(); $this->outputRole($sheet, $service->getAdminRole(), $row); $this->outputRole($sheet, $service->getUserRole(), $row); foreach ($entities as $entity) { diff --git a/src/Spreadsheet/UsersDocument.php b/src/Spreadsheet/UsersDocument.php index 260ea1f72..bc946eea5 100644 --- a/src/Spreadsheet/UsersDocument.php +++ b/src/Spreadsheet/UsersDocument.php @@ -134,7 +134,7 @@ private function formatLastLogin(?\DateTimeInterface $date): string /** * Gets the user's image full path. * - * @param User $user the user to get image path for + * @param User $user the user to get the image path for * * @return string|null the image path, if exists; null otherwise */ diff --git a/src/Spreadsheet/WorksheetDocument.php b/src/Spreadsheet/WorksheetDocument.php index 71025df8e..8887be787 100644 --- a/src/Spreadsheet/WorksheetDocument.php +++ b/src/Spreadsheet/WorksheetDocument.php @@ -119,7 +119,7 @@ public function getPercentFormat(bool $decimals = false): string * @param int $startColumn the index of the first column ('A' = First column) * @param int $endColumn the index of the last column * @param int $startRow the index of first row (1 = First row) - * @param ?int $endRow the index of the last cell or null to use the start row + * @param ?int $endRow the index of the last row or null to use the start row * * @throws Exception if an exception occurs */ @@ -133,7 +133,7 @@ public function mergeContent(int $startColumn, int $endColumn, int $startRow, ?i /** * Re-bind parent. * - * @throws Exception if the given $parent is not instance of WorksheetDocument + * @throws Exception if the given $parent is not an instance of WorksheetDocument */ public function rebindParent(Spreadsheet $parent): static { @@ -184,7 +184,7 @@ public function setCellContent(int $columnIndex, int $rowIndex, mixed $value): s * Sets image at the given coordinate. * * @param string $path the image path - * @param string $coordinates the coordinates (for example: 'A1') + * @param string $coordinates the coordinates of the cell (like 'A1') * @param int $width the image width * @param int $height the image height * diff --git a/src/Table/AbstractEntityTable.php b/src/Table/AbstractEntityTable.php index 1d53f330e..68c1d4c43 100644 --- a/src/Table/AbstractEntityTable.php +++ b/src/Table/AbstractEntityTable.php @@ -99,7 +99,7 @@ protected function addSearch(DataQuery $query, QueryBuilder $builder, string $al */ protected function count(): int { - return $this->repository->count([]); + return $this->repository->count(); } /** diff --git a/src/Traits/AwareTrait.php b/src/Traits/AwareTrait.php index 6c0bceffd..de403b922 100644 --- a/src/Traits/AwareTrait.php +++ b/src/Traits/AwareTrait.php @@ -28,7 +28,7 @@ trait AwareTrait * * @return T * - * @throws \LogicException if the service can not be found + * @throws \LogicException if the service cannot be found * * @psalm-suppress MixedInferredReturnType */ diff --git a/src/Traits/CacheKeyTrait.php b/src/Traits/CacheKeyTrait.php index 371364f8d..7f279be0c 100644 --- a/src/Traits/CacheKeyTrait.php +++ b/src/Traits/CacheKeyTrait.php @@ -15,7 +15,7 @@ use Symfony\Contracts\Cache\ItemInterface; /** - * Trait to clean cache key. + * Trait to get clean cache key. */ trait CacheKeyTrait { diff --git a/src/Traits/CookieTrait.php b/src/Traits/CookieTrait.php index 2e156ccd3..b0410292b 100644 --- a/src/Traits/CookieTrait.php +++ b/src/Traits/CookieTrait.php @@ -74,7 +74,7 @@ protected function getCookieString( /** * Add or remove a cookie depending on the value. * - * If value is null or empty ('') the cookie is removed. + * If the value is null or empty (''), the cookie is removed. */ protected function updateCookie( Response $response, diff --git a/src/Traits/EmptyItemsTrait.php b/src/Traits/EmptyItemsTrait.php index c7ff57345..598c7a0e1 100644 --- a/src/Traits/EmptyItemsTrait.php +++ b/src/Traits/EmptyItemsTrait.php @@ -15,7 +15,7 @@ use App\Utils\StringUtils; /** - * Trait to format empty items for table, PDF report and Excel document. + * Trait to format empty items for the table, the PDF report, and the Excel document. */ trait EmptyItemsTrait { diff --git a/src/Traits/EnumExtrasTrait.php b/src/Traits/EnumExtrasTrait.php index 1be1e81eb..f3333c672 100644 --- a/src/Traits/EnumExtrasTrait.php +++ b/src/Traits/EnumExtrasTrait.php @@ -15,7 +15,7 @@ use Elao\Enum\ExtrasTrait; /** - * Extends extras trait with typed values. + * Extends the extra trait with typed values. */ trait EnumExtrasTrait { diff --git a/src/Traits/ExceptionContextTrait.php b/src/Traits/ExceptionContextTrait.php index bc06248e0..378c9f3fe 100644 --- a/src/Traits/ExceptionContextTrait.php +++ b/src/Traits/ExceptionContextTrait.php @@ -20,7 +20,7 @@ trait ExceptionContextTrait { /** - * Gets the context, as array; for the given exception. + * Gets the context, as the array; for the given exception. * * @param \Throwable $e the exception to get the context for * diff --git a/src/Traits/GroupByTrait.php b/src/Traits/GroupByTrait.php index d846ffe8a..53c73b5aa 100644 --- a/src/Traits/GroupByTrait.php +++ b/src/Traits/GroupByTrait.php @@ -20,7 +20,7 @@ trait GroupByTrait /** * Groups an array by the given key. * - * Any additional keys will be used for grouping the next set of sub-arrays. + * Any additional keys will be used for grouping the next set of subarrays. * * @psalm-template T of array|object * diff --git a/src/Traits/RequestTrait.php b/src/Traits/RequestTrait.php index f5c0bbf8c..817a4df4b 100644 --- a/src/Traits/RequestTrait.php +++ b/src/Traits/RequestTrait.php @@ -75,7 +75,7 @@ protected function getRequestString(Request $request, string $key, string $defau } /** - * Returns the request parameter value. + * Return the request parameter value. * * @psalm-return ($default is null ? (scalar|null) : scalar) */ diff --git a/src/Traits/RoleTranslatorTrait.php b/src/Traits/RoleTranslatorTrait.php index d6f113419..4f27afabc 100644 --- a/src/Traits/RoleTranslatorTrait.php +++ b/src/Traits/RoleTranslatorTrait.php @@ -15,7 +15,7 @@ use App\Interfaces\RoleInterface; /** - * Trait get translated and icon role. + * A trait to get translated and icon role. */ trait RoleTranslatorTrait { diff --git a/src/Traits/TranslatorFlashMessageAwareTrait.php b/src/Traits/TranslatorFlashMessageAwareTrait.php index 378175775..170d51b9a 100644 --- a/src/Traits/TranslatorFlashMessageAwareTrait.php +++ b/src/Traits/TranslatorFlashMessageAwareTrait.php @@ -23,7 +23,7 @@ trait TranslatorFlashMessageAwareTrait /** * Add a translated error message to the session flash bag. * - * @param string $id the message id (may also be an object that can be cast to string) + * @param string $id the message identifier (may also be an object that can be cast to string) * @param array $parameters an array of parameters for the message * @param ?string $domain the domain for the message or null to use the default * @param ?string $locale the locale or null to use the default @@ -47,7 +47,7 @@ protected function errorTrans( /** * Add a translated information message to the session flash bag. * - * @param string $id the message id (may also be an object that can be cast to string) + * @param string $id the message identifier (may also be an object that can be cast to string) * @param array $parameters an array of parameters for the message * @param ?string $domain the domain for the message or null to use the default * @param ?string $locale the locale or null to use the default @@ -71,7 +71,7 @@ protected function infoTrans( /** * Add a translated success message to the session flash bag. * - * @param string $id the message id (may also be an object that can be cast to string) + * @param string $id the message identifier (may also be an object that can be cast to string) * @param array $parameters an array of parameters for the message * @param ?string $domain the domain for the message or null to use the default * @param ?string $locale the locale or null to use the default @@ -95,7 +95,7 @@ protected function successTrans( /** * Add a translated warning message to the session flash bag. * - * @param string $id the message id (may also be an object that can be cast to string) + * @param string $id the message identifier (may also be an object that can be cast to string) * @param array $parameters an array of parameters for the message * @param ?string $domain the domain for the message or null to use the default * @param ?string $locale the locale or null to use the default diff --git a/src/Translator/AbstractTranslatorService.php b/src/Translator/AbstractTranslatorService.php index 628e56b96..1dbf84e52 100644 --- a/src/Translator/AbstractTranslatorService.php +++ b/src/Translator/AbstractTranslatorService.php @@ -26,7 +26,7 @@ abstract class AbstractTranslatorService extends AbstractHttpClientService implements TranslatorServiceInterface { /** - * The field not found status code. + * The not found field status code. */ final protected const ERROR_NOT_FOUND = 199; diff --git a/src/Translator/TranslatorServiceInterface.php b/src/Translator/TranslatorServiceInterface.php index 5ec950745..b0fd449fe 100644 --- a/src/Translator/TranslatorServiceInterface.php +++ b/src/Translator/TranslatorServiceInterface.php @@ -32,7 +32,7 @@ interface TranslatorServiceInterface { /** - * Identifies the language of a piece of text. + * Identifies the language for a piece of text. * * @param string $text the text to detect * @@ -50,7 +50,7 @@ public static function getApiUrl(): string; /** * Gets the set of languages supported by other operations of the service. * - * @return array|false an array containing the language name as key and the BCP 47 + * @return array|false an array containing the language name as the key and the BCP 47 * language tag as value; false if an error occurs */ public function getLanguages(): array|false; diff --git a/src/Utils/BitSet.php b/src/Utils/BitSet.php index 216b32903..7f64ad5ff 100644 --- a/src/Utils/BitSet.php +++ b/src/Utils/BitSet.php @@ -18,7 +18,7 @@ class BitSet implements \Stringable { /** - * The number of bits per word. + * The number of bits by words. */ private const WORD_BITS = 31; @@ -262,7 +262,7 @@ public function sets(array $bits): self /** * Gets the "logical size". * - * @return int the index of the highest set bit plus one + * @return int the index of the highest-set bit plus one */ public function size(): int { @@ -373,7 +373,7 @@ private function applyLogical(self $other, callable $callable): self } /** - * Apply a function to the given range. + * Apply a function to the given range. * * @param int $fromIndex the start index (inclusive) * @param int $toIndex the end index (exclusive) @@ -413,7 +413,7 @@ private function expand(int $size): void } /** - * Gets the words index for the given bit. + * Gets words index for the given bit. * * @throws \InvalidArgumentException If the bit argument is negative */ diff --git a/src/Utils/CSVReader.php b/src/Utils/CSVReader.php index f0aaca32f..bedaceb2a 100644 --- a/src/Utils/CSVReader.php +++ b/src/Utils/CSVReader.php @@ -31,9 +31,11 @@ class CSVReader extends AbstractReader /** * @param \SplFileInfo|string|resource $file the CSV file to open or an opened resource * @param bool $binary true to open the file with binary mode - * @param int $length the line length. Must be greater than the longest line (in characters) to be found in - * the CSV file (allowing for trailing line-end characters). Setting it to 0, - * the maximum line length is not limited, which is slightly slower. + * @param int $length the line length. + * Must be greater than the longest line (in characters) to be found + * in the CSV file (allowing for trailing line-end characters). + * Setting it to 0, the maximum line length is not limited, which is + * slightly slower. * @param string $separator the field delimiter (one character only) * @param string $enclosure the field enclosure character (one character only) * @param string $escape the escape character (one character only) diff --git a/src/Utils/DateUtils.php b/src/Utils/DateUtils.php index 1d7d0a7df..34f5504fe 100644 --- a/src/Utils/DateUtils.php +++ b/src/Utils/DateUtils.php @@ -77,7 +77,7 @@ public static function add(\DateTimeInterface $date, \DateInterval|string $inter /** * Complete the give year with four digits. * - * For example, if year is set with 2 digits (10); the return value will be 2010. + * For example, if the year is set with 2 digits (10), the return value will be 2010. * * @param int $year the year to complet * @param int $change the year change limit @@ -123,7 +123,7 @@ public static function getMonth(\DateTimeInterface $date): int /** * Gets the localized month names. - * For example with 'fr' as locale, return + * For example, with 'fr' as locale, return *
      * Janvier
      * Février
@@ -143,7 +143,7 @@ public static function getMonths(): array
 
     /**
      * Gets the localized short month names.
-     * For example with 'fr' as locale, return
+     * For example, with 'fr' as locale, return
      * 
      * Janv.
      * Févr.
@@ -163,7 +163,7 @@ public static function getShortMonths(): array
 
     /**
      * Gets the localized short week day names.
-     * For example with 'fr' as locale and 'sunday' as first day, return
+     * For example, with 'fr' as locale and 'sunday' as first day, return
      * 
      * Dim.
      * Lun.
@@ -171,7 +171,7 @@ public static function getShortMonths(): array
      * ...
      * 
. * - * @param string $firstDay The first day of the week, in english, like 'sunday' or 'monday' + * @param string $firstDay The first day of the week, in english, like 'sunday' or 'monday' * * @return array */ @@ -189,7 +189,7 @@ public static function getShortWeekdays(string $firstDay = 'monday'): array * * The weeks are starting on Monday. * - * @return int a value 1 through 53 + * @return int value 1 through 53 */ public static function getWeek(\DateTimeInterface $date): int { @@ -198,7 +198,7 @@ public static function getWeek(\DateTimeInterface $date): int /** * Gets the localized week day names. - * For example with 'fr' as locale and 'sunday' as first day, return + * For example, with 'fr' as locale and 'sunday' as first day, return *
      * Dimanche
      * Lundi
@@ -220,7 +220,7 @@ public static function getWeekdays(string $firstDay = 'monday'): array
     }
 
     /**
-     * Gets the full numeric representation of a year with 4 digit for the given date.
+     * Gets the full numeric representation of a year with 4 digits for the given date.
      */
     public static function getYear(\DateTimeInterface $date): int
     {
diff --git a/src/Utils/FileUtils.php b/src/Utils/FileUtils.php
index 4e446b575..d8b73ae62 100644
--- a/src/Utils/FileUtils.php
+++ b/src/Utils/FileUtils.php
@@ -97,7 +97,7 @@ public static function decodeJson(string|\SplFileInfo $file, bool $assoc = true)
 
         // file or url?
         if (!self::isFile($file) && false === \filter_var($file, \FILTER_VALIDATE_URL)) {
-            throw new \InvalidArgumentException(\sprintf("The file '%s' can not be found.", $file));
+            throw new \InvalidArgumentException(\sprintf("The file '%s' cannot be found.", $file));
         }
         $content = \file_get_contents($file);
         if (false === $content) {
@@ -160,7 +160,7 @@ public static function formatSize(string|\SplFileInfo|int $path): string
     }
 
     /**
-     * Returns the extension from a file path (without leading dot).
+     * Returns the extension from a file path (without the leading dot).
      *
      * @param bool $forceLowerCase forces the extension to be lower-case
      */
diff --git a/src/Utils/ReverseReader.php b/src/Utils/ReverseReader.php
index d1c255aa1..fcc3ed572 100644
--- a/src/Utils/ReverseReader.php
+++ b/src/Utils/ReverseReader.php
@@ -20,7 +20,7 @@
  * 
  * $reader = new ReverseReader("path/to/file_name.txt");
  * foreach ($reader as $data) {
- *     echo $data ."\n";
+ *     echo $data . "\n";
  * }
  * 
  *
diff --git a/src/Word/AbstractWordDocument.php b/src/Word/AbstractWordDocument.php
index eb199a5e6..20a07f73c 100644
--- a/src/Word/AbstractWordDocument.php
+++ b/src/Word/AbstractWordDocument.php
@@ -43,7 +43,7 @@ public function __construct(protected readonly AbstractController $controller)
     {
         parent::__construct();
         $this->translator = $this->controller->getTranslator();
-        $this->customer = $this->controller->getApplication()->getCustomer();
+        $this->customer = $this->controller->getApplicationService()->getCustomer();
         $this->printAddress = $this->controller->getUserService()->isPrintAddress();
         $this->header = new WordHeader($this);
         $this->footer = new WordFooter($this);
@@ -78,7 +78,7 @@ public function setPrintAddress(bool $printAddress): static
     /**
      * Sets the title to be translated.
      *
-     * @param string  $id         the message id (may also be an object that can be cast to string)
+     * @param string  $id         the message identifier (may also be an object that can be cast to string)
      * @param array   $parameters an array of parameters for the message
      * @param ?string $domain     the domain for the message or null to use the default
      */
@@ -144,7 +144,7 @@ protected function initialize(): void
         if (null !== $user) {
             $properties->setCreator($user);
         }
-        $customer = $this->controller->getApplication()->getCustomerName();
+        $customer = $this->controller->getApplicationService()->getCustomerName();
         if (null !== $customer) {
             $properties->setCompany($customer);
         }
diff --git a/src/Word/HtmlWordParser.php b/src/Word/HtmlWordParser.php
index b9d9e4633..2d7dd8a3d 100644
--- a/src/Word/HtmlWordParser.php
+++ b/src/Word/HtmlWordParser.php
@@ -174,7 +174,7 @@ private function parseBorders(string $class): string
     }
 
     /**
-     * Parses the margins class.
+     * Parses margins class.
      */
     private function parseMargins(string $class): string
     {
diff --git a/src/Word/WordFooter.php b/src/Word/WordFooter.php
index 347f16127..dbdbdb418 100644
--- a/src/Word/WordFooter.php
+++ b/src/Word/WordFooter.php
@@ -21,7 +21,7 @@
 /**
  * Class to output footer in Word documents.
  *
- * This footer add the following texts:
+ * This footer adds the following texts:
  * 
    *
  • The current and total pages at the left.
  • *
  • The application name at the center
  • diff --git a/src/Word/WordHeader.php b/src/Word/WordHeader.php index 71eace160..cd6ff0afd 100644 --- a/src/Word/WordHeader.php +++ b/src/Word/WordHeader.php @@ -22,14 +22,14 @@ /** * Class to output header in Word documents. * - * This header add the following texts, depending on the printing address state: + * This header adds the following texts, depending on the printing address state: *
      *
    • The customer's name at the left and the address if applicable.
    • *
    • The document's title at the center, if applicable; at the right else.
    • *
    • The phone, the fax and the email at the right if applicable.
    • *
    * - * Do nothing if the document's title and the customer's name are empty. + * Do nothing if the document's title and the customer's name is empty. */ class WordHeader extends AbstractHeaderFooter { diff --git a/templates/admin/archive_result.html.twig b/templates/admin/archive_result.html.twig index 3d8c7c027..d4ca6e812 100644 --- a/templates/admin/archive_result.html.twig +++ b/templates/admin/archive_result.html.twig @@ -52,7 +52,8 @@