Skip to content

Commit

Permalink
Requires PHP 8.1+ ; Updated all dependencies + fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaasuni committed Dec 26, 2024
1 parent 5fef3eb commit ed6f7b9
Show file tree
Hide file tree
Showing 14 changed files with 109 additions and 76 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 All @@ -50,7 +50,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 }}
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,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.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

# Generate source code documentation
Expand Down Expand Up @@ -212,8 +212,8 @@ endif
.PHONY: lint
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 src text codesize,unusedcode,naming,design --exclude */vendor/*
./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 @@ -261,7 +261,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 @@
3.0.14
3.0.15
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
}
],
"require": {
"php": ">=8.0",
"php": ">=8.1",
"ext-pcre": "*",
"tecnickcom/tc-lib-pdf-filter": "^2.0"
},
"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-parser 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-tecnickcom-tc-lib-pdf-filter (<< 2.0.0), php-tecnickcom-tc-lib-pdf-filter (>= 2.0.17), ${misc:Depends}
Depends: php (>= 8.1.0), php-tecnickcom-tc-lib-pdf-filter (<< 2.0.0), php-tecnickcom-tc-lib-pdf-filter (>= 2.0.18), ${misc:Depends}
Description: PHP PDF Parser Library
PHP library to parse PDF documents.
4 changes: 2 additions & 2 deletions resources/rpm/rpm.spec
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ 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-composer(%{c_vendor}/tc-lib-pdf-filter) < 2.0.0
Requires: php-composer(%{c_vendor}/tc-lib-pdf-filter) >= 2.0.17
Requires: php-composer(%{c_vendor}/tc-lib-pdf-filter) >= 2.0.18
Requires: php-pcre

Provides: php-composer(%{c_vendor}/%{gh_project}) = %{version}
Expand Down
4 changes: 2 additions & 2 deletions src/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-pdf-parser
*
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
* @SuppressWarnings("PHPMD.ExcessiveClassComplexity")
*
* @phpstan-import-type RawObjectArray from \Com\Tecnick\Pdf\Parser\Process\RawObject
*/
Expand Down Expand Up @@ -230,7 +230,7 @@ protected function getObjectVal(array $obj): array
* 1: array<string>,
* } Decoded stream data and remaining filters.
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings("PHPMD.CyclomaticComplexity")
*/
protected function decodeStream(array $sdic, string $stream): array
{
Expand Down
6 changes: 3 additions & 3 deletions src/Process/RawObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ protected function processParenthesis(string $char, int &$offset, string &$objty
* @param string $char Symbol to process
* @param int $offset Offset
* @param string $objtype Object type
* @param array<int, array{
* @param string|array<int, array{
* 0: string,
* 1: string|array<int, array{
* 0: string,
Expand All @@ -253,7 +253,7 @@ protected function processBracket(string $char, int &$offset, string &$objtype,
do {
$element = $this->getRawObject($offset);
$offset = $element[2];
$objval[] = $element;
$objval[] = $element; // @phpstan-ignore parameterByRef.type
} while ($element[0] != ']');

// remove closing delimiter
Expand Down Expand Up @@ -289,7 +289,7 @@ protected function processAngular(string $char, int &$offset, string &$objtype,
do {
$element = $this->getRawObject($offset);
$offset = $element[2];
$objval[] = $element;
$objval[] = $element; // @phpstan-ignore parameterByRef.type
} while ($element[0] != '>>');

// remove closing delimiter
Expand Down
47 changes: 30 additions & 17 deletions src/Process/Xref.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
abstract class Xref extends \Com\Tecnick\Pdf\Parser\Process\XrefStream
{
/**
* XREF data.
* Default empty XREF data.
*
* @var array{
* 'trailer': array{
Expand All @@ -47,7 +47,7 @@ abstract class Xref extends \Com\Tecnick\Pdf\Parser\Process\XrefStream
* 'xref': array<string, int>,
* }
*/
protected array $xref = [
protected const XREF_EMPTY = [
'trailer' => [
'encrypt' => '',
'id' => [],
Expand All @@ -58,6 +58,22 @@ abstract class Xref extends \Com\Tecnick\Pdf\Parser\Process\XrefStream
'xref' => [],
];

/**
* XREF data.
*
* @var array{
* 'trailer': array{
* 'encrypt'?: string,
* 'id': array<int, string>,
* 'info': string,
* 'root': string,
* 'size': int,
* },
* 'xref': array<string, int>,
* }
*/
protected array $xref = self::XREF_EMPTY;

/**
* Store the processed offsets
*
Expand Down Expand Up @@ -107,7 +123,7 @@ abstract protected function getIndirectObject(string $obj_ref, int $offset = 0,
* 'xref': array<string, int>,
* } Xref and trailer data.
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings("PHPMD.CyclomaticComplexity")
*/
protected function getXrefData(int $offset = 0, array $xref = []): array
{
Expand Down Expand Up @@ -355,7 +371,7 @@ protected function getTrailerData(array $xref, array $matches): array
* 'xref': array<string, int>,
* } Xref and trailer data.
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings("PHPMD.CyclomaticComplexity")
*/
protected function decodeXrefStream(int $startxref, array $xref): array
{
Expand All @@ -366,16 +382,13 @@ protected function decodeXrefStream(int $startxref, array $xref): array
}

$xrefcrs = $this->getIndirectObject($xrefobj[1], $startxref, true);
if (! isset($xref['trailer']) || empty($xref['trailer'])) {
// get only the last updated version
$xref['trailer'] = [];
$filltrailer = true;
} else {
$filltrailer = false;
}

$filltrailer = empty($xref['trailer']);
if ($filltrailer) {
$xref['trailer'] = self::XREF_EMPTY['trailer'];
}
if (! isset($xref['xref'])) {
$xref['xref'] = [];
$xref['xref'] = self::XREF_EMPTY['xref'];
}

$valid_crs = false;
Expand Down Expand Up @@ -405,7 +418,7 @@ protected function decodeXrefStream(int $startxref, array $xref): array
$ddata = [];
// initialize first row with zeros
$prev_row = array_fill(0, $rowlen, 0);
$this->pngUnpredictor($sdata, $ddata, $columns, $prev_row);
$this->pngUnpredictor($sdata, $ddata, $columns, $prev_row); //@phpstan-ignore argument.type
// complete decoding
$sdata = [];
$this->processDdata($sdata, $ddata, $wbt);
Expand All @@ -417,12 +430,12 @@ protected function decodeXrefStream(int $startxref, array $xref): array
}

// end decoding data
if ($prevxref !== []) {
// get previous xref
return $this->getXrefData($prevxref, $xref);
if (is_null($prevxref)) {
return $xref;
}

return $xref;
// get previous xref
return $this->getXrefData($prevxref, $xref);
}

/**
Expand Down
Loading

0 comments on commit ed6f7b9

Please sign in to comment.