Skip to content

Commit

Permalink
Requires PHP 8.1+ ; Updated dependencies + fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaasuni committed Dec 26, 2024
1 parent b13ed8a commit b67b979
Show file tree
Hide file tree
Showing 24 changed files with 76 additions and 66 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-version: ["8.0", "8.1", "8.2", "8.3"]
php-version: ["8.1", "8.2", "8.3", "8.4"]
experimental: [false]
os: [ubuntu-latest]
coverage-extension: [pcov]
Expand Down Expand Up @@ -52,7 +52,7 @@ jobs:
- name: Run all tests
run: make qa
- name: Send coverage
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v5
with:
flags: php-${{ matrix.php-version }}-${{ matrix.os }}
name: php-${{ matrix.php-version }}-${{ matrix.os }}
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ endif
deps: ensuretarget
rm -rf ./vendor/* $(TARGETDIR)/fonts
($(COMPOSER) install -vvv --no-interaction)
curl --silent --show-error --fail --location --output ./vendor/phpstan.phar https://github.com/phpstan/phpstan/releases/download/1.10.41/phpstan.phar \
curl --silent --show-error --fail --location --output ./vendor/phpstan.phar https://github.com/phpstan/phpstan/releases/download/2.0.4/phpstan.phar \
&& chmod +x ./vendor/phpstan.phar
cd util && make deps

Expand Down Expand Up @@ -224,7 +224,7 @@ endif
lint:
./vendor/bin/phpcs --ignore="./vendor/" --standard=phpcs.xml src test
./vendor/bin/phpmd src text codesize,unusedcode,naming,design --exclude vendor
./vendor/bin/phpmd test text unusedcode,naming,design
./vendor/bin/phpmd test text unusedcode,naming,design --exclude vendor
php -r 'exit((int)version_compare(PHP_MAJOR_VERSION, "7", ">"));' || ./vendor/phpstan.phar analyse

# Run all tests and reports
Expand Down Expand Up @@ -272,7 +272,7 @@ tag:
.PHONY: test
test:
cp phpunit.xml.dist phpunit.xml
./vendor/bin/phpunit --migrate-configuration || true
#./vendor/bin/phpunit --migrate-configuration || true
XDEBUG_MODE=coverage ./vendor/bin/phpunit --stderr test

# Remove all installed files
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.6.4
2.6.5
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
}
],
"require": {
"php": ">=8.0",
"php": ">=8.1",
"ext-json": "*",
"ext-pcre": "*",
"ext-zlib": "*",
Expand All @@ -30,10 +30,10 @@
"tecnickcom/tc-lib-pdf-encrypt": "^2.1"
},
"require-dev": {
"pdepend/pdepend": "2.13.0",
"phpmd/phpmd": "2.13.0",
"phpunit/phpunit": "10.1.2 || 9.6.13",
"squizlabs/php_codesniffer": "3.7.2"
"pdepend/pdepend": "2.16.2",
"phpmd/phpmd": "2.15.0",
"phpunit/phpunit": "11.5.2 || 10.5.40",
"squizlabs/php_codesniffer": "3.11.2"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ parameters:
paths:
- src
- test
scanDirectories:
excludePaths:
- vendor
ignoreErrors:
reportUnmatchedIgnoredErrors: false
Expand Down
32 changes: 18 additions & 14 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnTestsThatTriggerErrors="true"
displayDetailsOnTestsThatTriggerNotices="true"
displayDetailsOnTestsThatTriggerWarnings="true"
displayDetailsOnPhpunitDeprecations="true"
processIsolation="false"
stopOnFailure="false"
verbose="true">
stopOnFailure="false">
<testsuites>
<testsuite name="tc-lib-pdf-font Test Suite">
<directory>./test</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix="php">src</directory>
</whitelist>
</filter>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</source>
<coverage>
<report>
<clover outputFile="target/coverage/coverage.xml"/>
<html outputDirectory="target/coverage" lowUpperBound="50" highLowerBound="90"/>
</report>
</coverage>
<logging>
<log type="coverage-html" target="target/coverage"/>
<log type="coverage-clover" target="target/coverage/coverage.xml"/>
<log type="junit" target="target/logs/junit.xml"/>
<junit outputFile="target/logs/junit.xml"/>
</logging>
</phpunit>
2 changes: 1 addition & 1 deletion resources/debian/compat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9
10
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-json, php-zip, php-tecnickcom-tc-lib-file (<< 3.0.0), php-tecnickcom-tc-lib-file (>= 2.1.1), php-tecnickcom-tc-lib-unicode-data (<< 3.0.0), php-tecnickcom-tc-lib-unicode-data (>= 2.0.17), php-tecnickcom-tc-lib-pdf-encrypt (<< 3.0.0), php-tecnickcom-tc-lib-pdf-encrypt (>= 2.1.9), php-tecnickcom-tc-lib-pdf-font-core (<< 2.0.0), php-tecnickcom-tc-lib-pdf-font-data-core (>= 1.8.7), ${misc:Depends}
Depends: php (>= 8.1.0), php-json, php-zip, php-tecnickcom-tc-lib-file (<< 3.0.0), php-tecnickcom-tc-lib-file (>= 2.1.2), php-tecnickcom-tc-lib-unicode-data (<< 3.0.0), php-tecnickcom-tc-lib-unicode-data (>= 2.0.18), php-tecnickcom-tc-lib-pdf-encrypt (<< 3.0.0), php-tecnickcom-tc-lib-pdf-encrypt (>= 2.1.10), php-tecnickcom-tc-lib-pdf-font-core (<< 2.0.0), php-tecnickcom-tc-lib-pdf-font-data-core (>= 1.8.7), ${misc:Depends}
Description: PHP PDF Fonts Library
PHP library containing PDF font methods and utilities.
2 changes: 1 addition & 1 deletion resources/fonts/debian/compat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9
10
8 changes: 4 additions & 4 deletions resources/rpm/rpm.spec
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ URL: https://github.com/%{gh_owner}/%{gh_project}
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id_u} -n)
BuildArch: noarch

Requires: php(language) >= 8.0.0
Requires: php(language) >= 8.1.0
Requires: php-json
Requires: php-pcre
Requires: php-zlib
Requires: php-composer(%{c_vendor}/tc-lib-file) < 3.0.0
Requires: php-composer(%{c_vendor}/tc-lib-file) >= 2.1.1
Requires: php-composer(%{c_vendor}/tc-lib-file) >= 2.1.2
Requires: php-composer(%{c_vendor}/tc-lib-unicode-data) < 3.0.0
Requires: php-composer(%{c_vendor}/tc-lib-unicode-data) >= 2.0.17
Requires: php-composer(%{c_vendor}/tc-lib-unicode-data) >= 2.0.18
Requires: php-composer(%{c_vendor}/tc-lib-pdf-encrypt) < 3.0.0
Requires: php-composer(%{c_vendor}/tc-lib-pdf-encrypt) >= 2.1.9
Requires: php-composer(%{c_vendor}/tc-lib-pdf-encrypt) >= 2.1.10
Requires: php-composer(%{c_vendor}/tc-lib-pdf-font-data-core) < 2.0.0
Requires: php-composer(%{c_vendor}/tc-lib-pdf-font-data-core) >= 1.8.7

Expand Down
2 changes: 0 additions & 2 deletions src/Buffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ abstract class Buffer
* @param bool $pdfa True if we are in PDF/A mode.
*
* @return string Font key
*
* @throws FontException in case of error
*/
public function __construct(
protected float $kunit,
Expand Down
8 changes: 4 additions & 4 deletions src/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
*
* @phpstan-import-type TFontData from Load
*
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
* @SuppressWarnings("PHPMD.ExcessiveClassComplexity")
*/
class Import
{
Expand Down Expand Up @@ -319,8 +319,8 @@ protected function initFlags(): void
/**
* Save the eported metadata font file
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings("PHPMD.CyclomaticComplexity")
* @SuppressWarnings("PHPMD.NPathComplexity")
*/
protected function saveFontData(): void
{
Expand Down Expand Up @@ -535,7 +535,7 @@ protected function getEncodingTable(string $encoding = ''): string
/**
* If required, get differences between the reference encoding (cp1252) and the current encoding
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings("PHPMD.CyclomaticComplexity")
*/
protected function getEncodingDiff(): string
{
Expand Down
2 changes: 1 addition & 1 deletion src/Import/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ protected function extractMetrics(): void
* @param array<int, string> $col Array containing row elements to process
* @param array<int, int> $cwd Array contianing cid widths
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings("PHPMD.CyclomaticComplexity")
*/
protected function processMetricRow(array $col, array &$cwd): void
{
Expand Down
14 changes: 7 additions & 7 deletions src/Import/TrueType.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
*
* @phpstan-import-type TFontData from \Com\Tecnick\Pdf\Font\Load
*
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
* @SuppressWarnings(PHPMD.ExcessiveClassLength)
* @SuppressWarnings("PHPMD.ExcessiveClassComplexity")
* @SuppressWarnings("PHPMD.ExcessiveClassLength")
*/
class TrueType
{
Expand Down Expand Up @@ -491,10 +491,10 @@ protected function getWidths(): void
$this->fdt['table']['glyf']['offset']
+ $this->fdt['indexToLoc'][$this->fdt['ctgdata'][$cid]]
);
$xMin = round($this->fbyte->getFWord($this->offset + 2) * $this->fdt['urk']);
$yMin = round($this->fbyte->getFWord($this->offset + 4) * $this->fdt['urk']);
$xMax = round($this->fbyte->getFWord($this->offset + 6) * $this->fdt['urk']);
$yMax = round($this->fbyte->getFWord($this->offset + 8) * $this->fdt['urk']);
$xMin = (int) round($this->fbyte->getFWord($this->offset + 2) * $this->fdt['urk']);
$yMin = (int) round($this->fbyte->getFWord($this->offset + 4) * $this->fdt['urk']);
$xMax = (int) round($this->fbyte->getFWord($this->offset + 6) * $this->fdt['urk']);
$yMax = (int) round($this->fbyte->getFWord($this->offset + 8) * $this->fdt['urk']);
$this->fdt['cbbox'][$cid] = [$xMin, $yMin, $xMax, $yMax];
}
}
Expand All @@ -515,7 +515,7 @@ protected function addCtgItem(int $cid, int $gid): void
/**
* Process the CID To GID Map.
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings("PHPMD.CyclomaticComplexity")
*/
protected function getCIDToGIDMap(): void
{
Expand Down
6 changes: 3 additions & 3 deletions src/Import/TypeOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-pdf-font
*
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
* @SuppressWarnings("PHPMD.ExcessiveClassComplexity")
*/
class TypeOne extends \Com\Tecnick\Pdf\Font\Import\Core
{
Expand Down Expand Up @@ -283,11 +283,11 @@ protected function decodeNumber(
if ($ccom[$idx] == 255) {
$sval = chr($ccom[($idx + 1)]) . chr($ccom[($idx + 2)]) . chr($ccom[($idx + 3)]) . chr($ccom[($idx + 4)]);
$vsval = unpack('li', $sval);
if ($vsval === false) {
if (($vsval === false) || (!is_numeric($vsval['i']))) {
throw new FontException('Unable to unpack number');
}

$cdec[$cck] = $vsval['i'];
$cdec[$cck] = (int) $vsval['i'];
return ($idx + 5);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Load.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ public function load(): void
*
* @throws FontException in case of error
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings("PHPMD.CyclomaticComplexity")
*/
protected function getFontInfo(): void
{
Expand Down
16 changes: 12 additions & 4 deletions src/OutFont.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,15 @@ protected function getCid0(array $font): string
* @param array{
* 'cidinfo': TFontDataCidInfo,
* 'cw': array<int, int>,
* } $font Font to process
* 'desc': TFontDataDesc,
* 'dw': int,
* 'enc': string,
* 'i': int,
* 'n': int,
* 'name': string,
* 'subset': bool,
* 'subsetchars': array<int, bool>,
* } $font Font to process
* @param int $cidoffset Offset for CID values
*/
protected function uniToCid(array &$font, int $cidoffset): void
Expand Down Expand Up @@ -169,9 +177,9 @@ protected function uniToCid(array &$font, int $cidoffset): void
*
* return string
*
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings("PHPMD.ExcessiveMethodLength")
* @SuppressWarnings("PHPMD.CyclomaticComplexity")
* @SuppressWarnings("PHPMD.NPathComplexity")
*/
protected function getTrueTypeUnicode(array $font): string
{
Expand Down
2 changes: 1 addition & 1 deletion src/Stack.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
* 'xheight': float,
* }
*
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
* @SuppressWarnings("PHPMD.ExcessiveClassComplexity")
*/
class Stack extends \Com\Tecnick\Pdf\Font\Buffer
{
Expand Down
4 changes: 2 additions & 2 deletions src/Subset.php
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,8 @@ protected function removeUnusedTables(): void
/**
* Add glyf and loca tables
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings("PHPMD.CyclomaticComplexity")
* @SuppressWarnings("PHPMD.NPathComplexity")
*/
protected function addProcessedTables(): void
{
Expand Down
2 changes: 1 addition & 1 deletion src/UniToCid.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-pdf-font
*
* @SuppressWarnings(PHPMD)
* @SuppressWarnings("PHPMD")
*/
class UniToCid
{
Expand Down
2 changes: 1 addition & 1 deletion test/BufferTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-pdf-font
*
* @SuppressWarnings(PHPMD.LongVariable)
* @SuppressWarnings("PHPMD.LongVariable")
*/
class BufferTest extends TestUtil
{
Expand Down
8 changes: 4 additions & 4 deletions test/ImportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

namespace Test;

use PHPUnit\Framework\Attributes\DataProvider;

/**
* Import Test
*
Expand All @@ -27,7 +29,7 @@
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-pdf-font
*
* @SuppressWarnings(PHPMD.LongVariable)
* @SuppressWarnings("PHPMD.LongVariable")
*/
class ImportTest extends TestUtil
{
Expand Down Expand Up @@ -77,9 +79,7 @@ public function testImportUnsupportedOpenType(): void
new \Com\Tecnick\Pdf\Font\Import($outdir . 'test.ttf', $outdir);
}

/**
* @dataProvider importDataProvider
*/
#[DataProvider('importDataProvider')]
public function testImport(
string $fontdir,
string $font,
Expand Down
2 changes: 1 addition & 1 deletion test/OutputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-pdf-font
*
* @SuppressWarnings(PHPMD.LongVariable)
* @SuppressWarnings("PHPMD.LongVariable")
*/
class OutputTest extends TestUtil
{
Expand Down
2 changes: 1 addition & 1 deletion test/StackTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-pdf-font
*
* @SuppressWarnings(PHPMD.LongVariable)
* @SuppressWarnings("PHPMD.LongVariable")
*/
class StackTest extends TestUtil
{
Expand Down

0 comments on commit b67b979

Please sign in to comment.