Skip to content

Commit c6376d0

Browse files
authored
php compatibility (#131)
* add HTML list (li) symbol types * fix indirect access to variable compatibility error * update dependencies + PHP compatibility check * remove deprecated functions * check for null keys
1 parent bf8c95a commit c6376d0

File tree

12 files changed

+88
-48
lines changed

12 files changed

+88
-48
lines changed

.github/workflows/check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
strategy:
2424
fail-fast: false
2525
matrix:
26-
php-version: ["8.1", "8.2", "8.3", "8.4"]
26+
php-version: ["8.1", "8.2", "8.3", "8.4", "8.5"]
2727
experimental: [false]
2828
os: [ubuntu-latest]
2929
coverage-extension: [pcov]

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ COMPOSER=$(PHP) -d "apc.enable_cli=0" $(shell which composer)
8484
PHPDOC=$(shell which phpDocumentor)
8585

8686
# phpstan version
87-
PHPSTANVER=2.1.32
87+
PHPSTANVER=2.1.33
8888

8989
# --- MAKE TARGETS ---
9090

@@ -126,7 +126,7 @@ x: buildall
126126
# Full build and test sequence
127127
.PHONY: buildall
128128
buildall: deps
129-
cd vendor/tecnickcom/tc-lib-pdf-font/ && make buildall
129+
cd vendor/tecnickcom/tc-lib-pdf-font/ && make deps fonts
130130
$(MAKE) codefix qa bz2 rpm deb
131131

132132
# Package the library in a compressed bz2 archive
@@ -223,7 +223,7 @@ endif
223223
.PHONY: lint
224224
lint:
225225
./vendor/bin/phpcbf --config-set ignore_non_auto_fixable_on_exit 1
226-
./vendor/bin/phpcs --ignore="\./vendor/" --standard=phpcs.xml src test
226+
./vendor/bin/phpcs --standard=phpcs.xml
227227
./vendor/bin/phpmd src text unusedcode,naming,design --exclude vendor
228228
./vendor/bin/phpmd test text unusedcode,naming,design --exclude */vendor/*
229229
php -r 'exit((int)version_compare(PHP_MAJOR_VERSION, "7", ">"));' || ./vendor/phpstan.phar analyse

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8.2.8
1+
8.3.1

composer.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,17 @@
3333
"tecnickcom/tc-lib-pdf-page": "^4.3",
3434
"tecnickcom/tc-lib-pdf-graph": "^2.4"
3535
},
36+
"config": {
37+
"allow-plugins": {
38+
"dealerdirect/phpcodesniffer-composer-installer": true
39+
}
40+
},
3641
"require-dev": {
3742
"pdepend/pdepend": "2.16.2",
3843
"phpmd/phpmd": "2.15.0",
3944
"phpunit/phpunit": "12.4.4 || 11.5.44 || 10.5.58",
40-
"squizlabs/php_codesniffer": "4.0.1"
45+
"squizlabs/php_codesniffer": "4.0.1",
46+
"phpcompatibility/php-compatibility": "^10.0.0@dev"
4147
},
4248
"autoload": {
4349
"psr-4": {

phpcs.xml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<?xml version="1.0"?>
2-
<ruleset name="backward-compatibility">
3-
<description>PSR-12 for PHP less than 7.1</description>
4-
<rule ref="PSR12">
5-
<exclude name="PSR12.Properties.ConstantVisibility"/>
6-
</rule>
2+
<ruleset name="PHP-compatibility">
3+
<description>Test code for compatibility with supported PHP versions</description>
4+
<rule ref="PHPCompatibility"/>
5+
<config name="testVersion" value="8.1-8.5"/>
6+
<file>src</file>
7+
<file>test</file>
8+
<exclude-pattern>./vendor/*</exclude-pattern>
9+
<arg value="ps"/>
710
</ruleset>

resources/debian/control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ Vcs-Git: https://github.com/~#VENDOR#~/~#PROJECT#~.git
1010
Package: ~#PKGNAME#~
1111
Provides: php-~#PROJECT#~
1212
Architecture: all
13-
Depends: php (>= 8.1.0), php-date, php-tecnickcom-tc-lib-barcode (<< 3.0.0), php-tecnickcom-tc-lib-barcode (>= 2.4.17), php-tecnickcom-tc-lib-color (<< 3.0.0), php-tecnickcom-tc-lib-color (>= 2.3.3), php-tecnickcom-tc-lib-pdf-image (<< 3.0.0), php-tecnickcom-tc-lib-pdf-image (>= 2.1.23), php-tecnickcom-tc-lib-pdf-font (<< 3.0.0), php-tecnickcom-tc-lib-pdf-font (>= 2.6.21), php-tecnickcom-tc-lib-file (<< 3.0.0), php-tecnickcom-tc-lib-file (>= 2.2.11), php-tecnickcom-tc-lib-pdf-encrypt (<< 3.0.0), php-tecnickcom-tc-lib-pdf-encrypt (>= 2.1.25), php-tecnickcom-tc-lib-unicode-data (<< 3.0.0), php-tecnickcom-tc-lib-unicode-data (>= 2.0.33), php-tecnickcom-tc-lib-unicode (<< 3.0.0), php-tecnickcom-tc-lib-unicode (>= 2.0.34), php-tecnickcom-tc-lib-pdf-page (<< 5.0.0), php-tecnickcom-tc-lib-pdf-page (>= 4.3.2), php-tecnickcom-tc-lib-pdf-graph (<< 3.0.0), php-tecnickcom-tc-lib-pdf-graph (>= 2.4.1), ${misc:Depends}
13+
Depends: php (>= 8.1.0), php-date, php-tecnickcom-tc-lib-barcode (<< 3.0.0), php-tecnickcom-tc-lib-barcode (>= 2.4.18), php-tecnickcom-tc-lib-color (<< 3.0.0), php-tecnickcom-tc-lib-color (>= 2.3.2), php-tecnickcom-tc-lib-pdf-image (<< 3.0.0), php-tecnickcom-tc-lib-pdf-image (>= 2.1.24), php-tecnickcom-tc-lib-pdf-font (<< 3.0.0), php-tecnickcom-tc-lib-pdf-font (>= 2.6.22), php-tecnickcom-tc-lib-file (<< 3.0.0), php-tecnickcom-tc-lib-file (>= 2.2.12), php-tecnickcom-tc-lib-pdf-encrypt (<< 3.0.0), php-tecnickcom-tc-lib-pdf-encrypt (>= 2.1.26), php-tecnickcom-tc-lib-unicode-data (<< 3.0.0), php-tecnickcom-tc-lib-unicode-data (>= 2.0.34), php-tecnickcom-tc-lib-unicode (<< 3.0.0), php-tecnickcom-tc-lib-unicode (>= 2.0.35), php-tecnickcom-tc-lib-pdf-page (<< 5.0.0), php-tecnickcom-tc-lib-pdf-page (>= 4.3.3), php-tecnickcom-tc-lib-pdf-graph (<< 3.0.0), php-tecnickcom-tc-lib-pdf-graph (>= 2.4.2), ${misc:Depends}
1414
Description: PHP Barcode library
1515
This library includes PHP classes to generate PDF documents.

resources/rpm/rpm.spec

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,25 @@ Requires: php(language) >= 8.1.0
2020
Requires: php-date
2121
Requires: php-pcre
2222
Requires: php-composer(%{c_vendor}/tc-lib-barcode) < 3.0.0
23-
Requires: php-composer(%{c_vendor}/tc-lib-barcode) >= 2.4.17
23+
Requires: php-composer(%{c_vendor}/tc-lib-barcode) >= 2.4.18
2424
Requires: php-composer(%{c_vendor}/tc-lib-color) < 3.0.0
25-
Requires: php-composer(%{c_vendor}/tc-lib-color) >= 2.3.3
25+
Requires: php-composer(%{c_vendor}/tc-lib-color) >= 2.3.2
2626
Requires: php-composer(%{c_vendor}/tc-lib-pdf-image) < 3.0.0
27-
Requires: php-composer(%{c_vendor}/tc-lib-pdf-image) >= 2.1.23
27+
Requires: php-composer(%{c_vendor}/tc-lib-pdf-image) >= 2.1.24
2828
Requires: php-composer(%{c_vendor}/tc-lib-pdf-font) < 3.0.0
29-
Requires: php-composer(%{c_vendor}/tc-lib-pdf-font) >= 2.6.21
29+
Requires: php-composer(%{c_vendor}/tc-lib-pdf-font) >= 2.6.22
3030
Requires: php-composer(%{c_vendor}/tc-lib-file) < 3.0.0
31-
Requires: php-composer(%{c_vendor}/tc-lib-file) >= 2.2.11
31+
Requires: php-composer(%{c_vendor}/tc-lib-file) >= 2.2.12
3232
Requires: php-composer(%{c_vendor}/tc-lib-pdf-encrypt) < 3.0.0
33-
Requires: php-composer(%{c_vendor}/tc-lib-pdf-encrypt) >= 2.1.25
33+
Requires: php-composer(%{c_vendor}/tc-lib-pdf-encrypt) >= 2.1.26
3434
Requires: php-composer(%{c_vendor}/tc-lib-unicode-data) < 3.0.0
35-
Requires: php-composer(%{c_vendor}/tc-lib-unicode-data) >= 2.0.33
35+
Requires: php-composer(%{c_vendor}/tc-lib-unicode-data) >= 2.0.34
3636
Requires: php-composer(%{c_vendor}/tc-lib-unicode) < 3.0.0
37-
Requires: php-composer(%{c_vendor}/tc-lib-unicode) >= 2.0.34
37+
Requires: php-composer(%{c_vendor}/tc-lib-unicode) >= 2.0.35
3838
Requires: php-composer(%{c_vendor}/tc-lib-pdf-page) < 5.0.0
39-
Requires: php-composer(%{c_vendor}/tc-lib-pdf-page) >= 4.3.2
39+
Requires: php-composer(%{c_vendor}/tc-lib-pdf-page) >= 4.3.3
4040
Requires: php-composer(%{c_vendor}/tc-lib-pdf-graph) < 3.0.0
41-
Requires: php-composer(%{c_vendor}/tc-lib-pdf-graph) >= 2.4.1
41+
Requires: php-composer(%{c_vendor}/tc-lib-pdf-graph) >= 2.4.2
4242

4343
Provides: php-composer(%{c_vendor}/%{gh_project}) = %{version}
4444
Provides: php-%{gh_project} = %{version}

src/Base.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ abstract class Base
180180
/**
181181
* TCPDF version.
182182
*/
183-
protected string $version = '8.2.8';
183+
protected string $version = '8.3.1';
184184

185185
/**
186186
* Time is seconds since EPOCH when the document was created.

src/HTML.php

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,34 @@
3535
*/
3636
abstract class HTML extends \Com\Tecnick\Pdf\JavaScript
3737
{
38-
//@TODO: add missing methods
38+
//@TODO: to be completed
39+
40+
/**
41+
* Valid bullet types for list-items
42+
*
43+
* @var array<string>
44+
*/
45+
protected const LIST_SYMBOL = [
46+
'!',
47+
'#',
48+
'1',
49+
'A',
50+
'I',
51+
'a',
52+
'circle',
53+
'decimal',
54+
'decimal-leading-zero',
55+
'disc',
56+
'i',
57+
'lower-alpha',
58+
'lower-greek',
59+
'lower-latin',
60+
'lower-roman',
61+
'square',
62+
'upper-alpha',
63+
'upper-latin',
64+
'upper-roman',
65+
];
3966

4067
/**
4168
* Cleanup HTML code (requires HTML Tidy library).

src/MetaInfo.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ private function setNonEmptyFieldValue(string $field, string $value): static
7979
private function setNonEmptyArrayFieldValue(string $field, string $key, string $value): static
8080
{
8181
if (
82-
isset($this->$field)
83-
&& \is_array($this->$field)
82+
isset($this->{$field})
83+
&& \is_array($this->{$field})
8484
&& ($key !== '')
85-
&& isset($this->$field[$key])
85+
&& isset($this->{$field}[$key])
8686
&& ($value !== '')
8787
) {
88-
$this->$field[$key] = $value;
88+
$this->{$field}[$key] = $value;
8989
}
9090

9191
return $this;
@@ -459,10 +459,10 @@ protected function getPageBoxName(string $name): string
459459
if (isset($this->viewerpref[$name])) {
460460
$val = $this->viewerpref[$name];
461461
if (
462-
isset($this->page->$box[$val]) // @phpstan-ignore offsetAccess.nonOffsetAccessible
463-
&& \is_string($this->page->$box[$val])
462+
isset($this->page->{$box}[$val]) // @phpstan-ignore offsetAccess.nonOffsetAccessible
463+
&& \is_string($this->page->{$box}[$val])
464464
) {
465-
$box = $this->page->$box[$val];
465+
$box = $this->page->{$box}[$val];
466466
}
467467
}
468468

0 commit comments

Comments
 (0)