From e2b84d8dd3cdd34964d170473f164608905256c0 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Fri, 17 Nov 2023 18:46:03 +0000 Subject: [PATCH] Update phpstan and simplify phpdoc --- Makefile | 2 +- VERSION | 2 +- resources/debian/control | 2 +- resources/rpm/rpm.spec | 4 +- src/Box.php | 177 ++++++++------- src/Page.php | 427 ++----------------------------------- src/Region.php | 450 +-------------------------------------- src/Settings.php | 135 ++---------- 8 files changed, 142 insertions(+), 1057 deletions(-) diff --git a/Makefile b/Makefile index 6423756..ca59b25 100644 --- a/Makefile +++ b/Makefile @@ -163,7 +163,7 @@ endif deps: ensuretarget rm -rf ./vendor/* ($(COMPOSER) install -vvv --no-interaction) - curl --silent --show-error --fail --location --output ./vendor/phpstan.phar https://github.com/phpstan/phpstan/releases/download/1.10.38/phpstan.phar \ + curl --silent --show-error --fail --location --output ./vendor/phpstan.phar https://github.com/phpstan/phpstan/releases/download/1.10.41/phpstan.phar \ && chmod +x ./vendor/phpstan.phar # Generate source code documentation diff --git a/VERSION b/VERSION index c4e41f9..c5106e6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.0.3 +4.0.4 diff --git a/resources/debian/control b/resources/debian/control index afe00de..c8afb43 100644 --- a/resources/debian/control +++ b/resources/debian/control @@ -10,6 +10,6 @@ Vcs-Git: https://github.com/~#VENDOR#~/~#PROJECT#~.git Package: ~#PKGNAME#~ Provides: php-~#PROJECT#~ Architecture: all -Depends: php (>= 8.0.0), php-date, php-zip, php-tecnickcom-tc-lib-color (<< 2.0.0), php-tecnickcom-tc-lib-color (>= 2.0.3), php-tecnickcom-tc-lib-pdf-encrypt (<< 2.0.0), php-tecnickcom-tc-lib-pdf-encrypt (>= 2.0.6), ${misc:Depends} +Depends: php (>= 8.0.0), php-date, php-zip, php-tecnickcom-tc-lib-color (<< 2.0.0), php-tecnickcom-tc-lib-color (>= 2.0.4), php-tecnickcom-tc-lib-pdf-encrypt (<< 2.0.0), php-tecnickcom-tc-lib-pdf-encrypt (>= 2.0.7), ${misc:Depends} Description: PHP PDF Page Library PHP library containing PDF page formats and definitions. diff --git a/resources/rpm/rpm.spec b/resources/rpm/rpm.spec index a06561a..3d7df2a 100644 --- a/resources/rpm/rpm.spec +++ b/resources/rpm/rpm.spec @@ -20,9 +20,9 @@ Requires: php(language) >= 8.0.0 Requires: php-date Requires: php-zlib Requires: php-composer(%{c_vendor}/tc-lib-color) < 2.0.0 -Requires: php-composer(%{c_vendor}/tc-lib-color) >= 2.0.3 +Requires: php-composer(%{c_vendor}/tc-lib-color) >= 2.0.4 Requires: php-composer(%{c_vendor}/tc-lib-pdf-encrypt) < 2.0.0 -Requires: php-composer(%{c_vendor}/tc-lib-pdf-encrypt) >= 2.0.6 +Requires: php-composer(%{c_vendor}/tc-lib-pdf-encrypt) >= 2.0.7 Provides: php-composer(%{c_vendor}/%{gh_project}) = %{version} Provides: php-%{gh_project} = %{version} diff --git a/src/Box.php b/src/Box.php index 3f2d0aa..141c7fc 100644 --- a/src/Box.php +++ b/src/Box.php @@ -29,6 +29,94 @@ * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) * @link https://github.com/tecnickcom/tc-lib-pdf-page + * + * @phpstan-type PageBci array{ + * 'color': string, + * 'width': float, + * 'style': string, + * 'dash': array, + * } + * + * @phpstan-type PageBox array{ + * 'llx': float, + * 'lly': float, + * 'urx': float, + * 'ury': float, + * 'bci'?: PageBci, + * } + * + * @phpstan-type MarginData array{ + * 'CB': float, + * 'CT': float, + * 'FT': float, + * 'HB': float, + * 'PB': float, + * 'PL': float, + * 'PR': float, + * 'PT': float, + * } + * + * @phpstan-type RegionData array{ + * 'RB': float, + * 'RH': float, + * 'RL': float, + * 'RR': float, + * 'RT': float, + * 'RW': float, + * 'RX': float, + * 'RY': float, + * 'x' : float, + * 'y' : float, + * } + * + + * @phpstan-type TransitionData array{ + * 'B': bool, + * 'D': int, + * 'Di': string|int, + * 'Dm': string, + * 'Dur': float, + * 'M': string, + * 'S': string, + * 'SS': float, + * } + * + * @phpstan-type PageData array{ + * 'annotrefs': array, + * 'autobreak': bool, + * 'box': array, + * 'columns': int, + * 'content': array, + * 'content_mark': array, + * 'ContentHeight': float, + * 'ContentWidth': float, + * 'FooterHeight': float, + * 'HeaderHeight': float, + * 'currentRegion': int, + * 'format': string, + * 'group': int, + * 'height': float, + * 'margin': MarginData, + * 'n': int, + * 'num': int, + * 'orientation': string, + * 'pagenum': int, + * 'pheight': float, + * 'pid': int, + * 'pwidth': float, + * 'region': array, + * 'rotation': int, + * 'time': int, + * 'transition': TransitionData, + * 'width': float, + * 'zoom': float, + * } */ abstract class Box extends \Com\Tecnick\Pdf\Page\Mode { @@ -58,31 +146,9 @@ abstract class Box extends \Com\Tecnick\Pdf\Page\Mode /** * Swap X and Y coordinates of page boxes (change page boxes orientation). * - * @param array, - * }, - * }> $dims Array of page dimensions. + * @param array $dims Array of page dimensions. * - * @return array, - * }, - * }> Page dimensions. + * @return array Page dimensions. */ public function swapCoordinates(array $dims): array { @@ -104,42 +170,15 @@ public function swapCoordinates(array $dims): array /** * Set page boundaries. * - * @param array, - * }, - * }> $dims Array of page dimensions to modify. - * @param string $type Box type: MediaBox, CropBox, BleedBox, TrimBox, ArtBox. - * @param float $llx Lower-left x coordinate in user units. - * @param float $lly Lower-left y coordinate in user units. - * @param float $urx Upper-right x coordinate in user units. - * @param float $ury Upper-right y coordinate in user units. - * @param array{ - * 'color': string, - * 'width': float, - * 'style': string, - * 'dash': array, - * } $bci BoxColorInfo: guideline style (color, width, style, dash). + * @param array $dims Array of page dimensions to modify. + * @param string $type Box type: MediaBox, CropBox, BleedBox, TrimBox, ArtBox. + * @param float $llx Lower-left x coordinate in user units. + * @param float $lly Lower-left y coordinate in user units. + * @param float $urx Upper-right x coordinate in user units. + * @param float $ury Upper-right y coordinate in user units. + * @param PageBci $bci BoxColorInfo: guideline style (color, width, style, dash). * - * @return array, - * }, - * }> Page dimensions. + * @return array Page dimensions. */ public function setBox( array $dims, @@ -185,18 +224,7 @@ public function setBox( * @param float $width Page width in points. * @param float $height Page height in points. * - * @return array, - * }, - * }> Page boxes. + * @return array Page boxes. */ public function setPageBoxes(float $width, float $height): array { @@ -244,12 +272,7 @@ protected function getBox(array $dims): string * Returns the PDF command to output the specified page BoxColorInfo. * * @param array, - * }, + * 'bci': PageBci, * }> $dims Array of page dimensions. * * @SuppressWarnings(PHPMD.CyclomaticComplexity) diff --git a/src/Page.php b/src/Page.php index f844c24..ff4d3df 100644 --- a/src/Page.php +++ b/src/Page.php @@ -31,6 +31,13 @@ * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) * @link https://github.com/tecnickcom/tc-lib-pdf-page * + * @phpstan-import-type PageBci from \Com\Tecnick\Pdf\Page\Box + * @phpstan-import-type PageBox from \Com\Tecnick\Pdf\Page\Box + * @phpstan-import-type MarginData from \Com\Tecnick\Pdf\Page\Box + * @phpstan-import-type RegionData from \Com\Tecnick\Pdf\Page\Box + * @phpstan-import-type TransitionData from \Com\Tecnick\Pdf\Page\Box + * @phpstan-import-type PageData from \Com\Tecnick\Pdf\Page\Box + * * @SuppressWarnings(PHPMD.TooManyPublicMethods) */ class Page extends \Com\Tecnick\Pdf\Page\Region @@ -87,75 +94,7 @@ public function enableSignatureApproval(bool $sigapp): static * * @param int $pid page index. Omit or set it to -1 for the current page ID. * - * @return array{ - * 'annotrefs': array, - * 'autobreak': bool, - * 'box': array, - * }, - * }>, - * 'columns': int, - * 'content': array, - * 'content_mark': array, - * 'ContentHeight': float, - * 'ContentWidth': float, - * 'FooterHeight': float, - * 'HeaderHeight': float, - * 'currentRegion': int, - * 'format': string, - * 'group': int, - * 'height': float, - * 'margin': array{ - * 'CB': float, - * 'CT': float, - * 'FT': float, - * 'HB': float, - * 'PB': float, - * 'PL': float, - * 'PR': float, - * 'PT': float, - * }, - * 'n': int, - * 'num': int, - * 'orientation': string, - * 'pagenum': int, - * 'pheight': float, - * 'pid': int, - * 'pwidth': float, - * 'region': array, - * 'rotation': int, - * 'time': int, - * 'transition': array{'B': bool, - * 'D': int, - * 'Di': string|int, - * 'Dm': string, - * 'Dur': float, - * 'M': string, - * 'S': string, - * 'SS': float, - * }, - * 'width': float, - * 'zoom': float, - * } Removed page. + * @return PageData Removed page. */ public function delete(int $pid = -1): array { @@ -171,75 +110,7 @@ public function delete(int $pid = -1): array /** * Remove and return last page. * - * @return array{ - * 'annotrefs': array, - * 'autobreak': bool, - * 'box': array, - * }, - * }>, - * 'columns': int, - * 'content': array, - * 'content_mark': array, - * 'ContentHeight': float, - * 'ContentWidth': float, - * 'FooterHeight': float, - * 'HeaderHeight': float, - * 'currentRegion': int, - * 'format': string, - * 'group': int, - * 'height': float, - * 'margin': array{ - * 'CB': float, - * 'CT': float, - * 'FT': float, - * 'HB': float, - * 'PB': float, - * 'PL': float, - * 'PR': float, - * 'PT': float, - * }, - * 'n': int, - * 'num': int, - * 'orientation': string, - * 'pagenum': int, - * 'pheight': float, - * 'pid': int, - * 'pwidth': float, - * 'region': array, - * 'rotation': int, - * 'time': int, - * 'transition': array{'B': bool, - * 'D': int, - * 'Di': string|int, - * 'Dm': string, - * 'Dur': float, - * 'M': string, - * 'S': string, - * 'SS': float, - * }, - * 'width': float, - * 'zoom': float, - * } Removed page. + * @return PageData Removed page. */ public function pop(): array { @@ -271,75 +142,7 @@ public function move(int $from, int $new): void /** * Returns the array (stack) containing all pages data. * - * @return array, - * 'autobreak': bool, - * 'box': array, - * }, - * }>, - * 'columns': int, - * 'content': array, - * 'content_mark': array, - * 'ContentHeight': float, - * 'ContentWidth': float, - * 'FooterHeight': float, - * 'HeaderHeight': float, - * 'currentRegion': int, - * 'format': string, - * 'group': int, - * 'height': float, - * 'margin': array{ - * 'CB': float, - * 'CT': float, - * 'FT': float, - * 'HB': float, - * 'PB': float, - * 'PL': float, - * 'PR': float, - * 'PT': float, - * }, - * 'n': int, - * 'num': int, - * 'orientation': string, - * 'pagenum': int, - * 'pheight': float, - * 'pid': int, - * 'pwidth': float, - * 'region': array, - * 'rotation': int, - * 'time': int, - * 'transition': array{'B': bool, - * 'D': int, - * 'Di': string|int, - * 'Dm': string, - * 'Dur': float, - * 'M': string, - * 'S': string, - * 'SS': float, - * }, - * 'width': float, - * 'zoom': float, - * }> Pages. + * @return array Pages. */ public function getPages(): array { @@ -486,75 +289,7 @@ public function getRootObjID(): int /** * Returns the PDF command to output the page content. * - * @param array{ - * 'annotrefs': array, - * 'autobreak': bool, - * 'box': array, - * }, - * }>, - * 'columns': int, - * 'content': array, - * 'content_mark': array, - * 'ContentHeight': float, - * 'ContentWidth': float, - * 'FooterHeight': float, - * 'HeaderHeight': float, - * 'currentRegion': int, - * 'format': string, - * 'group': int, - * 'height': float, - * 'margin': array{ - * 'CB': float, - * 'CT': float, - * 'FT': float, - * 'HB': float, - * 'PB': float, - * 'PL': float, - * 'PR': float, - * 'PT': float, - * }, - * 'n': int, - * 'num': int, - * 'orientation': string, - * 'pagenum': int, - * 'pheight': float, - * 'pid': int, - * 'pwidth': float, - * 'region': array, - * 'rotation': int, - * 'time': int, - * 'transition': array{'B': bool, - * 'D': int, - * 'Di': string|int, - * 'Dm': string, - * 'Dur': float, - * 'M': string, - * 'S': string, - * 'SS': float, - * }, - * 'width': float, - * 'zoom': float, - * } $page Page data. + * @param PageData $page Page data. * * @return string PDF command. */ @@ -586,75 +321,7 @@ protected function getPageTransition(array $page): string /** * Get references to page annotations. * - * @param array{ - * 'annotrefs': array, - * 'autobreak': bool, - * 'box': array, - * }, - * }>, - * 'columns': int, - * 'content': array, - * 'content_mark': array, - * 'ContentHeight': float, - * 'ContentWidth': float, - * 'FooterHeight': float, - * 'HeaderHeight': float, - * 'currentRegion': int, - * 'format': string, - * 'group': int, - * 'height': float, - * 'margin': array{ - * 'CB': float, - * 'CT': float, - * 'FT': float, - * 'HB': float, - * 'PB': float, - * 'PL': float, - * 'PR': float, - * 'PT': float, - * }, - * 'n': int, - * 'num': int, - * 'orientation': string, - * 'pagenum': int, - * 'pheight': float, - * 'pid': int, - * 'pwidth': float, - * 'region': array, - * 'rotation': int, - * 'time': int, - * 'transition': array{'B': bool, - * 'D': int, - * 'Di': string|int, - * 'Dm': string, - * 'Dur': float, - * 'M': string, - * 'S': string, - * 'SS': float, - * }, - * 'width': float, - * 'zoom': float, - * } $page Page data. + * @param PageData $page Page data. * * @return string PDF command. */ @@ -727,75 +394,7 @@ protected function getPageRootObj(int &$pon): string /** * Replace page templates and numbers. * - * @param array{ - * 'annotrefs': array, - * 'autobreak': bool, - * 'box': array, - * }, - * }>, - * 'columns': int, - * 'content': array, - * 'content_mark': array, - * 'ContentHeight': float, - * 'ContentWidth': float, - * 'FooterHeight': float, - * 'HeaderHeight': float, - * 'currentRegion': int, - * 'format': string, - * 'group': int, - * 'height': float, - * 'margin': array{ - * 'CB': float, - * 'CT': float, - * 'FT': float, - * 'HB': float, - * 'PB': float, - * 'PL': float, - * 'PR': float, - * 'PT': float, - * }, - * 'n': int, - * 'num': int, - * 'orientation': string, - * 'pagenum': int, - * 'pheight': float, - * 'pid': int, - * 'pwidth': float, - * 'region': array, - * 'rotation': int, - * 'time': int, - * 'transition': array{'B': bool, - * 'D': int, - * 'Di': string|int, - * 'Dm': string, - * 'Dur': float, - * 'M': string, - * 'S': string, - * 'SS': float, - * }, - * 'width': float, - * 'zoom': float, - * } $data Page data. + * @param PageData $data Page data. */ protected function replacePageTemplates(array $data): string { diff --git a/src/Region.php b/src/Region.php index c82cbdc..70ccf15 100644 --- a/src/Region.php +++ b/src/Region.php @@ -29,6 +29,9 @@ * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) * @link https://github.com/tecnickcom/tc-lib-pdf-page * + * @phpstan-import-type RegionData from \Com\Tecnick\Pdf\Page\Box + * @phpstan-import-type PageData from \Com\Tecnick\Pdf\Page\Box + * * A page region defines the writable area of the page. */ abstract class Region extends \Com\Tecnick\Pdf\Page\Settings @@ -139,76 +142,7 @@ abstract class Region extends \Com\Tecnick\Pdf\Page\Settings * * NOTE: if $data is null, then the last page format will be cloned. * - * @return array{ - * 'annotrefs': array, - * 'autobreak': bool, - * 'box': array, - * }, - * }>, - * 'columns': int, - * 'content': array, - * 'content_mark': array, - * 'ContentHeight': float, - * 'ContentWidth': float, - * 'FooterHeight': float, - * 'HeaderHeight': float, - * 'currentRegion': int, - * 'format': string, - * 'group': int, - * 'height': float, - * 'margin': array{ - * 'CB': float, - * 'CT': float, - * 'FT': float, - * 'HB': float, - * 'PB': float, - * 'PL': float, - * 'PR': float, - * 'PT': float, - * }, - * 'n': int, - * 'num': int, - * 'orientation': string, - * 'pagenum': int, - * 'pheight': float, - * 'pid': int, - * 'pwidth': float, - * 'region': array, - * 'rotation': int, - * 'time': int, - * 'transition': array{ - * 'B': bool, - * 'D': int, - * 'Di': string|int, - * 'Dm': string, - * 'Dur': float, - * 'M': string, - * 'S': string, - * 'SS': float, - * }, - * 'width': float, - * 'zoom': float, - * } Page data with additional Page ID property 'pid'. + * @return PageData Page data with additional Page ID property 'pid'. */ public function add(array $data = []): array { @@ -250,75 +184,7 @@ public function add(array $data = []): array * * @param int $pid page index. Omit or set it to -1 for the current page ID. * - * @return array{ - * 'annotrefs': array, - * 'autobreak': bool, - * 'box': array, - * }, - * }>, - * 'columns': int, - * 'content': array, - * 'content_mark': array, - * 'ContentHeight': float, - * 'ContentWidth': float, - * 'FooterHeight': float, - * 'HeaderHeight': float, - * 'currentRegion': int, - * 'format': string, - * 'group': int, - * 'height': float, - * 'margin': array{ - * 'CB': float, - * 'CT': float, - * 'FT': float, - * 'HB': float, - * 'PB': float, - * 'PL': float, - * 'PR': float, - * 'PT': float, - * }, - * 'n': int, - * 'num': int, - * 'orientation': string, - * 'pagenum': int, - * 'pheight': float, - * 'pid': int, - * 'pwidth': float, - * 'region': array, - * 'rotation': int, - * 'time': int, - * 'transition': array{'B': bool, - * 'D': int, - * 'Di': string|int, - * 'Dm': string, - * 'Dur': float, - * 'M': string, - * 'S': string, - * 'SS': float, - * }, - * 'width': float, - * 'zoom': float, - * } Page data. + * @return PageData Page data. */ public function setCurrentPage(int $pid = -1): array { @@ -332,75 +198,7 @@ public function setCurrentPage(int $pid = -1): array * * @param int $pid page index. Omit or set it to -1 for the current page ID. * - * @return array{ - * 'annotrefs': array, - * 'autobreak': bool, - * 'box': array, - * }, - * }>, - * 'columns': int, - * 'content': array, - * 'content_mark': array, - * 'ContentHeight': float, - * 'ContentWidth': float, - * 'FooterHeight': float, - * 'HeaderHeight': float, - * 'currentRegion': int, - * 'format': string, - * 'group': int, - * 'height': float, - * 'margin': array{ - * 'CB': float, - * 'CT': float, - * 'FT': float, - * 'HB': float, - * 'PB': float, - * 'PL': float, - * 'PR': float, - * 'PT': float, - * }, - * 'n': int, - * 'num': int, - * 'orientation': string, - * 'pagenum': int, - * 'pheight': float, - * 'pid': int, - * 'pwidth': float, - * 'region': array, - * 'rotation': int, - * 'time': int, - * 'transition': array{'B': bool, - * 'D': int, - * 'Di': string|int, - * 'Dm': string, - * 'Dur': float, - * 'M': string, - * 'S': string, - * 'SS': float, - * }, - * 'width': float, - * 'zoom': float, - * } Page data. + * @return PageData Page data. */ public function getPage(int $pid = -1): array { @@ -434,18 +232,7 @@ protected function sanitizePageID(int $pid = -1): int * @param int $idr ID of the region. * @param int $pid page index. Omit or set it to -1 for the current page ID. * - * @return array{ - * 'RB': float, - * 'RH': float, - * 'RL': float, - * 'RR': float, - * 'RT': float, - * 'RW': float, - * 'RX': float, - * 'RY': float, - * 'x' : float, - * 'y' : float, - * } Selected region data. + * @return RegionData Selected region data. */ public function selectRegion(int $idr, int $pid = -1): array { @@ -459,18 +246,7 @@ public function selectRegion(int $idr, int $pid = -1): array * * @param int $pid page index. Omit or set it to -1 for the current page ID. * - * @return array{ - * 'RB': float, - * 'RH': float, - * 'RL': float, - * 'RR': float, - * 'RT': float, - * 'RW': float, - * 'RX': float, - * 'RY': float, - * 'x' : float, - * 'y' : float, - * } Region. + * @return RegionData Region. */ public function getRegion(int $pid = -1): array { @@ -484,75 +260,7 @@ public function getRegion(int $pid = -1): array * * @param int $pid page index. Omit or set it to -1 for the current page ID. * - * @return array{ - * 'annotrefs': array, - * 'autobreak': bool, - * 'box': array, - * }, - * }>, - * 'columns': int, - * 'content': array, - * 'content_mark': array, - * 'ContentHeight': float, - * 'ContentWidth': float, - * 'FooterHeight': float, - * 'HeaderHeight': float, - * 'currentRegion': int, - * 'format': string, - * 'group': int, - * 'height': float, - * 'margin': array{ - * 'CB': float, - * 'CT': float, - * 'FT': float, - * 'HB': float, - * 'PB': float, - * 'PL': float, - * 'PR': float, - * 'PT': float, - * }, - * 'n': int, - * 'num': int, - * 'orientation': string, - * 'pagenum': int, - * 'pheight': float, - * 'pid': int, - * 'pwidth': float, - * 'region': array, - * 'rotation': int, - * 'time': int, - * 'transition': array{'B': bool, - * 'D': int, - * 'Di': string|int, - * 'Dm': string, - * 'Dur': float, - * 'M': string, - * 'S': string, - * 'SS': float, - * }, - * 'width': float, - * 'zoom': float, - * } Page data. + * @return PageData Page data. */ public function getNextPage(int $pid = -1): array { @@ -576,75 +284,7 @@ public function getNextPage(int $pid = -1): array * * @param int $pid page index. Omit or set it to -1 for the current page ID. * - * @return array{ - * 'annotrefs': array, - * 'autobreak': bool, - * 'box': array, - * }, - * }>, - * 'columns': int, - * 'content': array, - * 'content_mark': array, - * 'ContentHeight': float, - * 'ContentWidth': float, - * 'FooterHeight': float, - * 'HeaderHeight': float, - * 'currentRegion': int, - * 'format': string, - * 'group': int, - * 'height': float, - * 'margin': array{ - * 'CB': float, - * 'CT': float, - * 'FT': float, - * 'HB': float, - * 'PB': float, - * 'PL': float, - * 'PR': float, - * 'PT': float, - * }, - * 'n': int, - * 'num': int, - * 'orientation': string, - * 'pagenum': int, - * 'pheight': float, - * 'pid': int, - * 'pwidth': float, - * 'region': array, - * 'rotation': int, - * 'time': int, - * 'transition': array{'B': bool, - * 'D': int, - * 'Di': string|int, - * 'Dm': string, - * 'Dur': float, - * 'M': string, - * 'S': string, - * 'SS': float, - * }, - * 'width': float, - * 'zoom': float, - * } Current page data. + * @return PageData Current page data. */ public function getNextRegion(int $pid = -1): array { @@ -665,75 +305,7 @@ public function getNextRegion(int $pid = -1): array * @param ?float $ypos Starting Y position or NULL for current position. * @param int $pid Page index. Omit or set it to -1 for the current page ID. * - * @return array{ - * 'annotrefs': array, - * 'autobreak': bool, - * 'box': array, - * }, - * }>, - * 'columns': int, - * 'content': array, - * 'content_mark': array, - * 'ContentHeight': float, - * 'ContentWidth': float, - * 'FooterHeight': float, - * 'HeaderHeight': float, - * 'currentRegion': int, - * 'format': string, - * 'group': int, - * 'height': float, - * 'margin': array{ - * 'CB': float, - * 'CT': float, - * 'FT': float, - * 'HB': float, - * 'PB': float, - * 'PL': float, - * 'PR': float, - * 'PT': float, - * }, - * 'n': int, - * 'num': int, - * 'orientation': string, - * 'pagenum': int, - * 'pheight': float, - * 'pid': int, - * 'pwidth': float, - * 'region': array, - * 'rotation': int, - * 'time': int, - * 'transition': array{'B': bool, - * 'D': int, - * 'Di': string|int, - * 'Dm': string, - * 'Dur': float, - * 'M': string, - * 'S': string, - * 'SS': float, - * }, - * 'width': float, - * 'zoom': float, - * } Page data. + * @return PageData Page data. */ public function checkRegionBreak( float $height = 0.0, diff --git a/src/Settings.php b/src/Settings.php index 4947cb8..41fb51b 100644 --- a/src/Settings.php +++ b/src/Settings.php @@ -29,6 +29,13 @@ * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) * @link https://github.com/tecnickcom/tc-lib-pdf-page * + * @phpstan-import-type PageBci from \Com\Tecnick\Pdf\Page\Box + * @phpstan-import-type PageBox from \Com\Tecnick\Pdf\Page\Box + * @phpstan-import-type MarginData from \Com\Tecnick\Pdf\Page\Box + * @phpstan-import-type RegionData from \Com\Tecnick\Pdf\Page\Box + * @phpstan-import-type TransitionData from \Com\Tecnick\Pdf\Page\Box + * @phpstan-import-type PageData from \Com\Tecnick\Pdf\Page\Box + * * @SuppressWarnings(PHPMD) */ abstract class Settings extends \Com\Tecnick\Pdf\Page\Box @@ -55,75 +62,7 @@ abstract class Settings extends \Com\Tecnick\Pdf\Page\Box /** * Array of pages (stack). * - * @var array, - * 'autobreak': bool, - * 'box': array, - * }, - * }>, - * 'columns': int, - * 'content': array, - * 'content_mark': array, - * 'ContentHeight': float, - * 'ContentWidth': float, - * 'FooterHeight': float, - * 'HeaderHeight': float, - * 'currentRegion': int, - * 'format': string, - * 'group': int, - * 'height': float, - * 'margin': array{ - * 'CB': float, - * 'CT': float, - * 'FT': float, - * 'HB': float, - * 'PB': float, - * 'PL': float, - * 'PR': float, - * 'PT': float, - * }, - * 'n': int, - * 'num': int, - * 'orientation': string, - * 'pagenum': int, - * 'pheight': float, - * 'pid': int, - * 'pwidth': float, - * 'region': array, - * 'rotation': int, - * 'time': int, - * 'transition': array{'B': bool, - * 'D': int, - * 'Di': string|int, - * 'Dm': string, - * 'Dur': float, - * 'M': string, - * 'S': string, - * 'SS': float, - * }, - * 'width': float, - * 'zoom': float, - * }> + * @var array */ protected array $page = []; @@ -277,15 +216,7 @@ public function sanitizeZoom(array &$data): void * Sanitize or set the page transitions. * * @param array{ - * 'transition': array{'B': bool, - * 'D': int, - * 'Di': string|int, - * 'Dm': string, - * 'Dur': float, - * 'M': string, - * 'S': string, - * 'SS': float, - * }, + * 'transition': TransitionData, * } $data Page data. */ public function sanitizeTransitions(array &$data): void @@ -366,16 +297,7 @@ public function sanitizeTransitions(array &$data): void * 'FooterHeight': float, * 'HeaderHeight': float, * 'height': float, - * 'margin'?: array{ - * 'CB': float, - * 'CT': float, - * 'FT': float, - * 'HB': float, - * 'PB': float, - * 'PL': float, - * 'PR': float, - * 'PT': float, - * }, + * 'margin'?: MarginData, * 'orientation': string, * 'pheight': float, * 'pwidth': float, @@ -431,28 +353,8 @@ public function sanitizeMargins(array &$data): void * 'ContentHeight': float, * 'ContentWidth': float, * 'height': float, - * 'margin': array{ - * 'CB': float, - * 'CT': float, - * 'FT': float, - * 'HB': float, - * 'PB': float, - * 'PL': float, - * 'PR': float, - * 'PT': float, - * }, - * 'region'?: array, + * 'margin': MarginData, + * 'region'?: array, * 'width': float, * } $data Page data. */ @@ -523,18 +425,7 @@ public function sanitizeRegions(array &$data): void * Sanitize or set the page boxes containing the page boundaries. * * @param array{ - * 'box'?: array, - * }, - * }>, + * 'box'?: array, * 'format'?: string, * 'height': float, * 'orientation': string,