Skip to content

Commit

Permalink
Update phpstan and simplify phpdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaasuni committed Nov 17, 2023
1 parent cafce89 commit e2b84d8
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 1,057 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0.3
4.0.4
2 changes: 1 addition & 1 deletion resources/debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -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.
4 changes: 2 additions & 2 deletions resources/rpm/rpm.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
177 changes: 100 additions & 77 deletions src/Box.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>,
* }
*
* @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<int,int>,
* 'autobreak': bool,
* 'box': array<string, array{
* 'llx': float,
* 'lly': float,
* 'urx': float,
* 'ury': float,
* 'bci': PageBci,
* }>,
* 'columns': int,
* 'content': array<string>,
* 'content_mark': array<int>,
* '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<int, RegionData>,
* 'rotation': int,
* 'time': int,
* 'transition': TransitionData,
* 'width': float,
* 'zoom': float,
* }
*/
abstract class Box extends \Com\Tecnick\Pdf\Page\Mode
{
Expand Down Expand Up @@ -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<string, array{
* 'llx': float,
* 'lly': float,
* 'urx': float,
* 'ury': float,
* 'bci'?: array{
* 'color': string,
* 'width': float,
* 'style': string,
* 'dash': array<int>,
* },
* }> $dims Array of page dimensions.
* @param array<string, PageBox> $dims Array of page dimensions.
*
* @return array<string, array{
* 'llx': float,
* 'lly': float,
* 'urx': float,
* 'ury': float,
* 'bci'?: array{
* 'color': string,
* 'width': float,
* 'style': string,
* 'dash': array<int>,
* },
* }> Page dimensions.
* @return array<string, PageBox> Page dimensions.
*/
public function swapCoordinates(array $dims): array
{
Expand All @@ -104,42 +170,15 @@ public function swapCoordinates(array $dims): array
/**
* Set page boundaries.
*
* @param array<string, array{
* 'llx': float,
* 'lly': float,
* 'urx': float,
* 'ury': float,
* 'bci'?: array{
* 'color': string,
* 'width': float,
* 'style': string,
* 'dash': array<int>,
* },
* }> $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<int>,
* } $bci BoxColorInfo: guideline style (color, width, style, dash).
* @param array<string, PageBox> $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<string, array{
* 'llx': float,
* 'lly': float,
* 'urx': float,
* 'ury': float,
* 'bci': array{
* 'color': string,
* 'width': float,
* 'style': string,
* 'dash': array<int>,
* },
* }> Page dimensions.
* @return array<string, PageBox> Page dimensions.
*/
public function setBox(
array $dims,
Expand Down Expand Up @@ -185,18 +224,7 @@ public function setBox(
* @param float $width Page width in points.
* @param float $height Page height in points.
*
* @return array<string, array{
* 'llx': float,
* 'lly': float,
* 'urx': float,
* 'ury': float,
* 'bci'?: array{
* 'color': string,
* 'width': float,
* 'style': string,
* 'dash': array<int>,
* },
* }> Page boxes.
* @return array<string, PageBox> Page boxes.
*/
public function setPageBoxes(float $width, float $height): array
{
Expand Down Expand Up @@ -244,12 +272,7 @@ protected function getBox(array $dims): string
* Returns the PDF command to output the specified page BoxColorInfo.
*
* @param array<string, array{
* 'bci': array{
* 'color': string,
* 'width': float,
* 'style': string,
* 'dash': array<int>,
* },
* 'bci': PageBci,
* }> $dims Array of page dimensions.
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
Expand Down
Loading

0 comments on commit e2b84d8

Please sign in to comment.