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 6c21457 commit 2ec42b1
Show file tree
Hide file tree
Showing 8 changed files with 184 additions and 452 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 @@
2.0.6
2.0.7
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-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-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 Graph Library
PHP library containing PDF graphic and geometric methods.
4 changes: 2 additions & 2 deletions resources/rpm/rpm.spec
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ BuildArch: noarch
Requires: php(language) >= 8.0.0
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
131 changes: 48 additions & 83 deletions src/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,46 @@
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-pdf-graph
*
* @phpstan-type StyleData array{
* 'lineWidth': float,
* 'lineCap': string,
* 'lineJoin': string,
* 'miterLimit': float,
* 'dashArray': array<int>,
* 'dashPhase': float,
* 'lineColor': string,
* 'fillColor': string,
* }
*
* @phpstan-type StyleDataOpt array{
* 'lineWidth'?: float,
* 'lineCap'?: string,
* 'lineJoin'?: string,
* 'miterLimit'?: float,
* 'dashArray'?: array<int>,
* 'dashPhase'?: float,
* 'lineColor'?: string,
* 'fillColor'?: string,
* }
*
* @phpstan-type GradientData array{
* 'antialias': bool,
* 'background': ?\Com\Tecnick\Color\Model,
* 'colors': array<int, array{
* 'color': string,
* 'exponent'?: float,
* 'opacity'?: float,
* 'offset'?: float,
* }>,
* 'colspace': string,
* 'coords': array<float>,
* 'id': int,
* 'pattern': int,
* 'stream': string,
* 'transparency': bool,
* 'type': int,
* }
*
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
*/
abstract class Base
Expand Down Expand Up @@ -70,16 +110,7 @@ abstract class Base
/**
* Stack containing style data.
*
* @var array<array{
* 'lineWidth'?: float,
* 'lineCap'?: string,
* 'lineJoin'?: string,
* 'miterLimit'?: float,
* 'dashArray'?: array<int>,
* 'dashPhase'?: float,
* 'lineColor'?: string,
* 'fillColor'?: string,
* }>
* @var array<StyleDataOpt>
*/
protected array $style = [];

Expand All @@ -97,23 +128,7 @@ abstract class Base
/**
* Array of gradients
*
* @var array<int, array{
* 'antialias': bool,
* 'background': ?\Com\Tecnick\Color\Model,
* 'colors': array<int, array{
* 'color': string,
* 'exponent'?: float,
* 'opacity'?: float,
* 'offset'?: float,
* }>,
* 'colspace': string,
* 'coords': array<float>,
* 'id': int,
* 'pattern': int,
* 'stream': string,
* 'transparency': bool,
* 'type': int,
* }>
* @var array<int, GradientData>
*/
protected array $gradients = [];

Expand Down Expand Up @@ -159,27 +174,9 @@ public function initStyle(): void
/**
* Returns the default style.
*
* @param array{
* 'lineWidth'?: float,
* 'lineCap'?: string,
* 'lineJoin'?: string,
* 'miterLimit'?: float,
* 'dashArray'?: array<int>,
* 'dashPhase'?: float,
* 'lineColor'?: string,
* 'fillColor'?: string,
* } $style Style parameters to merge to the default ones.
* @param StyleDataOpt $style Style parameters to merge to the default ones.
*
* @return array{
* 'lineWidth': float,
* 'lineCap': string,
* 'lineJoin': string,
* 'miterLimit': float,
* 'dashArray': array<int>,
* 'dashPhase': float,
* 'lineColor': string,
* 'fillColor': string,
* }
* @return StyleData
*/
public function getDefaultStyle(array $style = []): array
{
Expand Down Expand Up @@ -332,24 +329,8 @@ public function getOutGradientResources(): string
/**
* Get the PDF output string for gradient colors and transparency
*
* @param array{
* 'antialias': bool,
* 'background': ?\Com\Tecnick\Color\Model,
* 'colors': array<int, array{
* 'color': string,
* 'exponent'?: float,
* 'opacity'?: float,
* 'offset'?: float,
* }>,
* 'colspace': string,
* 'coords': array<float>,
* 'id': int,
* 'pattern': int,
* 'stream': string,
* 'transparency': bool,
* 'type': int,
* } $grad Array of gradient colors
* @param string $type Type of output: 'color' or 'opacity'
* @param GradientData $grad Array of gradient colors
* @param string $type Type of output: 'color' or 'opacity'
*
* @return string PDF command
*
Expand Down Expand Up @@ -424,24 +405,8 @@ protected function getOutGradientCols(array $grad, string $type): string
/**
* Get the PDF output string for the pattern and shading object
*
* @param array{
* 'antialias': bool,
* 'background': ?\Com\Tecnick\Color\Model,
* 'colors': array<int, array{
* 'color': string,
* 'exponent'?: float,
* 'opacity'?: float,
* 'offset'?: float,
* }>,
* 'colspace': string,
* 'coords': array<float>,
* 'id': int,
* 'pattern': int,
* 'stream': string,
* 'transparency': bool,
* 'type': int,
* } $grad Array of gradient colors
* @param int $objref Refrence object number
* @param GradientData $grad Array of gradient colors
* @param int $objref Refrence object number
*
* @return string PDF command
*/
Expand Down
Loading

0 comments on commit 2ec42b1

Please sign in to comment.