Skip to content

Commit

Permalink
Enable phpstan max level (#100)
Browse files Browse the repository at this point in the history
* set phpstan level to max
* add types and fix code accordingly.
  • Loading branch information
nicolaasuni authored Nov 27, 2023
1 parent 2fae563 commit 8bece74
Show file tree
Hide file tree
Showing 11 changed files with 918 additions and 297 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ jobs:
coverage-extension: [pcov]
steps:
- uses: actions/checkout@v4
- name: Install pdfinfo
run: sudo apt-get install -y poppler-utils
#- name: Install pdfinfo
# run: sudo apt-get install -y poppler-utils
- name: Use php ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.0.47
8.0.49
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
parameters:
level: 5
level: max
paths:
- src
- test
Expand Down
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-tecnickcom-tc-lib-barcode (<< 2.0.0), php-tecnickcom-tc-lib-barcode (>= 2.1.1), php-tecnickcom-tc-lib-color (<< 2.0.0), php-tecnickcom-tc-lib-color (>= 2.0.4), php-tecnickcom-tc-lib-pdf-image (<< 2.0.0), php-tecnickcom-tc-lib-pdf-image (>= 2.0.7), php-tecnickcom-tc-lib-pdf-font (<< 2.0.0), php-tecnickcom-tc-lib-pdf-font (>= 2.0.8), php-tecnickcom-tc-lib-file (<< 2.0.0), php-tecnickcom-tc-lib-file (>= 2.0.7), php-tecnickcom-tc-lib-pdf-encrypt (<< 2.0.0), php-tecnickcom-tc-lib-pdf-encrypt (>= 2.0.7), php-tecnickcom-tc-lib-unicode-data (<< 2.0.0), php-tecnickcom-tc-lib-unicode-data (>= 2.0.7), php-tecnickcom-tc-lib-unicode (<< 2.0.0), php-tecnickcom-tc-lib-unicode (>= 2.0.7), php-tecnickcom-tc-lib-pdf-page (<< 3.0.0), php-tecnickcom-tc-lib-pdf-page (>= 4.0.4), php-tecnickcom-tc-lib-pdf-graph (<< 2.0.0), php-tecnickcom-tc-lib-pdf-graph (>= 2.0.8), ${misc:Depends}
Depends: php (>= 8.0.0), php-date, php-tecnickcom-tc-lib-barcode (<< 2.0.0), php-tecnickcom-tc-lib-barcode (>= 2.1.1), php-tecnickcom-tc-lib-color (<< 2.0.0), php-tecnickcom-tc-lib-color (>= 2.0.4), php-tecnickcom-tc-lib-pdf-image (<< 2.0.0), php-tecnickcom-tc-lib-pdf-image (>= 2.0.7), php-tecnickcom-tc-lib-pdf-font (<< 2.0.0), php-tecnickcom-tc-lib-pdf-font (>= 2.0.9), php-tecnickcom-tc-lib-file (<< 2.0.0), php-tecnickcom-tc-lib-file (>= 2.0.7), php-tecnickcom-tc-lib-pdf-encrypt (<< 2.0.0), php-tecnickcom-tc-lib-pdf-encrypt (>= 2.0.7), php-tecnickcom-tc-lib-unicode-data (<< 2.0.0), php-tecnickcom-tc-lib-unicode-data (>= 2.0.7), php-tecnickcom-tc-lib-unicode (<< 2.0.0), php-tecnickcom-tc-lib-unicode (>= 2.0.7), php-tecnickcom-tc-lib-pdf-page (<< 3.0.0), php-tecnickcom-tc-lib-pdf-page (>= 4.0.4), php-tecnickcom-tc-lib-pdf-graph (<< 2.0.0), php-tecnickcom-tc-lib-pdf-graph (>= 2.0.8), ${misc:Depends}
Description: PHP Barcode library
This library includes PHP classes to generate PDF documents.
2 changes: 1 addition & 1 deletion resources/rpm/rpm.spec
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Requires: php-composer(%{c_vendor}/tc-lib-color) >= 2.0.4
Requires: php-composer(%{c_vendor}/tc-lib-pdf-image) < 2.0.0
Requires: php-composer(%{c_vendor}/tc-lib-pdf-image) >= 2.0.7
Requires: php-composer(%{c_vendor}/tc-lib-pdf-font) < 2.0.0
Requires: php-composer(%{c_vendor}/tc-lib-pdf-font) >= 2.0.8
Requires: php-composer(%{c_vendor}/tc-lib-pdf-font) >= 2.0.9
Requires: php-composer(%{c_vendor}/tc-lib-file) < 2.0.0
Requires: php-composer(%{c_vendor}/tc-lib-file) >= 2.0.7
Requires: php-composer(%{c_vendor}/tc-lib-pdf-encrypt) < 2.0.0
Expand Down
107 changes: 94 additions & 13 deletions src/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,34 @@
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-pdf
*
* @phpstan-type TViewerPref array{
* 'HideToolbar'?: bool,
* 'HideMenubar'?: bool,
* 'HideWindowUI'?: bool,
* 'FitWindow'?: bool,
* 'CenterWindow'?: bool,
* 'DisplayDocTitle'?: bool,
* 'NonFullScreenPageMode'?: string,
* 'Direction'?: string,
* 'ViewArea'?: string,
* 'ViewClip'?: string,
* 'PrintArea'?: string,
* 'PrintClip'?: string,
* 'PrintScaling'?: string,
* 'Duplex'?: string,
* 'PickTrayByPDFSize'?: bool,
* 'PrintPageRange'?: array<int>,
* 'NumCopies'?: int,
* }
*
* @phpstan-import-type TEmbeddedFile from Output
* @phpstan-import-type TOutline from Output
* @phpstan-import-type TAnnot from Output
* @phpstan-import-type TXOBject from Output
* @phpstan-import-type TSignature from Output
* @phpstan-import-type TUserRights from Output
* @phpstan-import-type TObjID from Output
*
* @SuppressWarnings(PHPMD)
*/
abstract class Base
Expand Down Expand Up @@ -97,7 +125,7 @@ abstract class Base
/**
* TCPDF version.
*/
protected string $version = '8.0.28';
protected string $version = '8.0.49';

/**
* Time is seconds since EPOCH when the document was created.
Expand Down Expand Up @@ -154,9 +182,9 @@ abstract class Base

/**
* Viewer preferences dictionary controlling the way the document is to be presented on the screen or in print.
* (Section 8.1 of PDF reference, "Viewer Preferences").
* (PDF reference, "Viewer Preferences").
*
* @var array Viewer Preferences
* @var TViewerPref
*/
protected array $viewerpref = [];

Expand Down Expand Up @@ -251,11 +279,15 @@ abstract class Base

/**
* Embedded files data.
*
* @var array<string, TEmbeddedFile>
*/
protected array $embeddedfiles = [];

/**
* Annotations indexed bu object IDs.
*
* @var array<int, TAnnot>
*/
protected array $annotation = [];

Expand Down Expand Up @@ -286,16 +318,32 @@ abstract class Base

/**
* Array containing the ID of some named PDF objects.
*/
protected array $objid = [];
*
* @var TObjID
*/
protected array $objid = [
'catalog' => 0,
'dests' => 0,
'form' => [],
'info' => 0,
'pages' => 0,
'resdic' => 0,
'signature' => 0,
'srgbicc' => 0,
'xmp' => 0,
];

/**
* Store XObject.
*
* @var array<string, TXOBject>
*/
protected array $xobject = [];

/**
* Outlines Data.
*
* @var array<int, TOutline>
*/
protected array $outlines = [];

Expand All @@ -309,15 +357,36 @@ abstract class Base
*/
protected string $jstree = '';

/**
* Embedded files Object IDs by name.
*/
protected array $efnames = [];
// /**
// * Embedded files Object IDs by name.
// */
// protected array $efnames = [];

/**
* Signature Data.
*/
protected array $signature = [];
*
* @var TSignature
*/
protected array $signature = [
'appearance' => [
'empty' => [],
'name' => '',
'page' => 0,
'rect' => '',
],
'approval' => '',
'cert_type' => -1,
'extracerts' => '',
'info' => [
'ContactInfo' => '',
'Location' => '',
'Name' => '',
'Reason' => '',
],
'password' => '',
'privkey' => '',
'signcert' => '',
];

/**
* ByteRange placemark used during digital signature process.
Expand All @@ -335,11 +404,23 @@ abstract class Base

/**
* User rights Data.
*/
protected array $userrights = [];
*
* @var TUserRights
*/
protected array $userrights = [
'annots' => '',
'document' => '',
'ef' => '',
'enabled' => false,
'form' => '',
'formex' => '',
'signature' => '',
];

/**
* XObjects data.
*
* @var array<string, TXOBject>
*/
protected array $xobjects = [];

Expand Down
Loading

0 comments on commit 8bece74

Please sign in to comment.