Skip to content

Commit 95a7713

Browse files
authoredFeb 29, 2024··
Merge pull request #2 from artemeon/phpstan
feat: PHPStan
2 parents 2a7d4d4 + 822f846 commit 95a7713

File tree

8 files changed

+49
-41
lines changed

8 files changed

+49
-41
lines changed
 

‎.github/workflows/ci.yml

+20-12
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,41 @@
11
name: CI
22
on:
3-
- pull_request
4-
- push
3+
pull_request:
4+
push:
5+
branches:
6+
- master
57
jobs:
6-
psalm:
7-
name: Psalm
8+
phpstan:
9+
name: PHPStan
810
runs-on: ubuntu-latest
911
steps:
1012
- name: Checkout
11-
uses: actions/checkout@v2
13+
uses: actions/checkout@v4
1214
- name: Install PHP
1315
uses: shivammathur/setup-php@v2
1416
with:
15-
php-version: 8.0
17+
php-version: 8.2
1618
coverage: none
1719
- name: Composer install
1820
run: composer install --no-interaction --no-ansi --no-progress
19-
- name: Run Psalm
20-
run: vendor/bin/psalm --no-progress --show-info=false
21+
- name: Run PHPStan
22+
run: composer run phpstan
2123
phpunit:
22-
name: PHPUnit
23-
runs-on: ubuntu-latest
24+
strategy:
25+
fail-fast: true
26+
matrix:
27+
os: [ ubuntu-latest ]
28+
php: [ 8.3, 8.2, 8.1, 8.0 ]
29+
stability: [ prefer-stable ]
30+
name: PHPUnit - PHP ${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.os }}
31+
runs-on: ${{ matrix.os }}
2432
steps:
2533
- name: Checkout
26-
uses: actions/checkout@v2
34+
uses: actions/checkout@v4
2735
- name: Install PHP
2836
uses: shivammathur/setup-php@v2
2937
with:
30-
php-version: 8.0
38+
php-version: ${{ matrix.php }}
3139
coverage: none
3240
- name: Composer install
3341
run: composer install --no-interaction --no-ansi --no-progress

‎.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.idea
2+
vendor
3+
composer.lock

‎LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2018 ARTEMEON
3+
Copyright (c) 2024 ARTEMEON Management Partner GmbH
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

‎composer.json

+11-1
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,18 @@
55
"keywords": ["pdf"],
66
"homepage": "https://github.com/artemeon/pdf",
77
"license": "MIT",
8+
"scripts": {
9+
"phpstan": "php ./vendor/bin/phpstan analyse --memory-limit=4G"
10+
},
811
"require": {
912
"php": ">=8.0",
1013
"tecnickcom/tcpdf": "^6.4"
1114
},
1215
"require-dev": {
1316
"phpunit/phpunit": "^8.0",
14-
"vimeo/psalm": "^4.22"
17+
"phpstan/phpstan": "^1.10",
18+
"phpstan/extension-installer": "^1.3",
19+
"phpstan/phpstan-phpunit": "^1.3"
1520
},
1621
"autoload": {
1722
"psr-4": {
@@ -22,5 +27,10 @@
2227
"psr-4": {
2328
"Artemeon\\Pdf\\Tests\\": "tests"
2429
}
30+
},
31+
"config": {
32+
"allow-plugins": {
33+
"phpstan/extension-installer": true
34+
}
2535
}
2636
}

‎phpstan.neon

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
includes:
2+
- phar://phpstan.phar/conf/bleedingEdge.neon
3+
4+
parameters:
5+
level: 5
6+
paths:
7+
- src
8+
- tests

‎psalm.xml

-15
This file was deleted.

‎src/Pdf.php

+2-6
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,7 @@ public function setStrKeywords($strKeywords)
107107
$this->objPdf->SetKeywords($strKeywords);
108108
}
109109

110-
/**
111-
* @return bool
112-
* @return void
113-
*/
114-
public function getBitHeader()
110+
public function getBitHeader(): bool
115111
{
116112
return $this->objPdf->getBitHeader();
117113
}
@@ -256,7 +252,7 @@ public function addCell($strContent = '', $intWidth = 0, $intHeight = 0, $bitBor
256252
$strBorders = 0;
257253
}
258254

259-
$this->objPdf->Cell($intWidth, $intHeight, $strContent, $strBorders, 1, $strAlign, $bitFill);
255+
$this->objPdf->Cell($intWidth, $intHeight, $strContent, $strBorders, 1, $strAlign, (bool) $bitFill);
260256
}
261257

262258
/**

‎src/PdfTcpdf.php

+4-6
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,12 @@ class PdfTcpdf extends TCPDF
3333
protected $bitFooter = true;
3434

3535
/**
36-
*
37-
* @var PdfHeaderInterface
36+
* @var ?PdfHeaderInterface
3837
*/
3938
protected $objHeader = null;
4039

4140
/**
42-
*
43-
* @var PdfFooterInterface
41+
* @var ?PdfFooterInterface
4442
*/
4543
protected $objFooter = null;
4644

@@ -65,7 +63,7 @@ public function Header()
6563
$intStyle = $this->FontStyle;
6664

6765

68-
if ($this->objHeader != null && $this->objHeader instanceof PdfHeaderInterface) {
66+
if ($this->objHeader instanceof PdfHeaderInterface) {
6967
$this->objHeader->writeHeader($this);
7068
}
7169

@@ -86,7 +84,7 @@ public function Footer()
8684
$intSize = $this->FontSize;
8785
$intStyle = $this->FontStyle;
8886

89-
if ($this->objFooter != null && $this->objFooter instanceof PdfFooterInterface) {
87+
if ($this->objFooter instanceof PdfFooterInterface) {
9088
$this->objFooter->writeFooter($this);
9189
}
9290

0 commit comments

Comments
 (0)
Please sign in to comment.