Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions .github/workflows/code-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ jobs:
- name: Install php
uses: shivammathur/setup-php@v2
with:
php-version: "7.2"
php-version: "8.5"

- name: Install dependencies
run: composer update --dev --no-interaction --prefer-dist --no-progress --no-suggest --ansi

- name: Run phpcs
run: ./vendor/bin/phpcs -q --report=checkstyle src
run: ./vendor-bin/phpcs/vendor/bin/phpcs -q --report=checkstyle src

phpstan:
name: phpstan
Expand All @@ -39,11 +39,10 @@ jobs:
- name: Install php
uses: shivammathur/setup-php@v2
with:
php-version: "7.4"
tools: phpstan
php-version: "8.5"

- name: Install dependencies
run: composer update --dev --no-interaction --prefer-dist --no-progress --no-suggest --ansi

- name: Run phpstan
run: phpstan analyse --no-progress
run: ./vendor-bin/phpstan/vendor/bin/phpstan analyse --no-progress
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
php: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5', '8.6']
steps:
- name: Checkout
uses: actions/checkout@v6
Expand Down
19 changes: 15 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}
},
"require": {
"php": ">=7.2 <=8.5.99999",
"php": ">=7.2 <=8.6.99999",
"ext-zlib": "*"
},
"conflict": {
Expand All @@ -40,8 +40,7 @@
"phpunit/phpunit": "^8.5.52",
"setasign/fpdf": "^1.9.0",
"tecnickcom/tcpdf": "^6.8",
"setasign/tfpdf": "~1.33",
"squizlabs/php_codesniffer": "^3.5"
"setasign/tfpdf": "~1.33"
},
"autoload-dev": {
"psr-4": {
Expand All @@ -50,6 +49,18 @@
},
"scripts": {
"all-tests": "@php vendor/bin/phpunit",
"cs": "@php vendor/bin/phpcs"
"cs": "@php vendor-bin/phpcs/vendor/bin/phpcs",
"phpstan": "@php vendor-bin/phpstan/vendor/bin/phpstan analyse",

"post-install-cmd": [
"@composer --working-dir=vendor-bin/phpcs install",
"@composer --working-dir=vendor-bin/phpstan install"
],
"post-update-cmd": [
"@composer --working-dir=vendor-bin/phpcs update",
"@composer --working-dir=vendor-bin/phpstan update"
],

"cbf": "@php vendor-bin/phpcs/vendor/bin/phpcbf"
}
}
101 changes: 11 additions & 90 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 19 additions & 1 deletion phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="PHP_CodeSniffer"
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd"
xsi:noNamespaceSchemaLocation="vendor-bin/phpcs/vendor/squizlabs/php_codesniffer/phpcs.xsd"
>
<file>src</file>
<!-- <file>tests</file>-->
Expand All @@ -14,4 +14,22 @@
<exclude name="PSR2.Methods.MethodDeclaration.Underscore"/>
<exclude name="PSR12.Properties.ConstantVisibility.NotFound"/>
</rule>

<!-- relative path from PHPCS source location -->
<config name="installed_paths" value="../../slevomat/coding-standard"/>

<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalConstants"/>
<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalFunctions"/>
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
<properties>
<property name="searchAnnotations" value="true"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowYodaComparison"/>
<rule ref="SlevomatCodingStandard.PHP.OptimizedFunctionsWithoutUnpacking"/>
<rule ref="SlevomatCodingStandard.PHP.TypeCast"/>
<rule ref="SlevomatCodingStandard.PHP.ShortList"/>
<rule ref="SlevomatCodingStandard.PHP.UselessSemicolon"/>
<rule ref="SlevomatCodingStandard.Variables.DisallowSuperGlobalVariable"/>
<rule ref="SlevomatCodingStandard.Commenting.EmptyComment"/>
</ruleset>
2 changes: 2 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ parameters:
#- tests

ignoreErrors:
-
identifier: unset.possiblyHookedProperty
-
message: "#^Method setasign\\\\Fpdi\\\\Fpdi\\:\\:getPdfParserInstance\\(\\) has invalid return type setasign\\\\FpdiPdfParser\\\\PdfParser\\\\PdfParser\\.$#"
count: 1
Expand Down
4 changes: 2 additions & 2 deletions src/FpdfTplTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function useTemplate($tpl, $x = 0, $y = 0, $width = null, $height = null,

if (\is_array($x)) {
unset($x['tpl']);
\extract($x, EXTR_IF_EXISTS);
\extract($x, \EXTR_IF_EXISTS);
/** @noinspection NotOptimalIfConditionsInspection */
/** @phpstan-ignore function.alreadyNarrowedType */
if (\is_array($x)) {
Expand Down Expand Up @@ -408,7 +408,7 @@ public function SetFontSize($size)
{
parent::SetFontSize($size);
if ($this->page === 0 && $this->currentTemplateId !== null) {
$this->_out(sprintf('BT /F%d %.2F Tf ET', $this->CurrentFont['i'], $this->FontSizePt));
$this->_out(\sprintf('BT /F%d %.2F Tf ET', $this->CurrentFont['i'], $this->FontSizePt));
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/FpdfTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use setasign\Fpdi\PdfParser\PdfParserException;
use setasign\Fpdi\PdfParser\Type\PdfIndirectObject;
use setasign\Fpdi\PdfParser\Type\PdfNull;
use setasign\Fpdi\PdfParser\Type\PdfType;

/**
* This trait is used for the implementation of FPDI in FPDF and tFPDF.
Expand Down Expand Up @@ -139,7 +138,7 @@ protected function _putlinks($n)
$this->_newobj();
$rect = \sprintf('%.2F %.2F %.2F %.2F', $pl[0], $pl[1], $pl[0] + $pl[2], $pl[1] - $pl[3]);
$this->_put('<</Type /Annot /Subtype /Link /Rect [' . $rect . ']', false);
if (is_string($pl[4])) {
if (\is_string($pl[4])) {
if (isset($pl['importedLink'])) {
$this->_put('/A <</S /URI /URI (' . $this->_escape($pl[4]) . ')>>');
$values = $pl['importedLink']['pdfObject']->value;
Expand Down
5 changes: 0 additions & 5 deletions src/Fpdi.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@

namespace setasign\Fpdi;

use setasign\Fpdi\PdfParser\CrossReference\CrossReferenceException;
use setasign\Fpdi\PdfParser\PdfParserException;
use setasign\Fpdi\PdfParser\Type\PdfIndirectObject;
use setasign\Fpdi\PdfParser\Type\PdfNull;

/**
* Class Fpdi
*
Expand Down
8 changes: 4 additions & 4 deletions src/FpdiTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ trait FpdiTrait
*/
public function cleanUp($allReaders = false)
{
$readers = $allReaders ? array_keys($this->readers) : $this->createdReaders;
$readers = $allReaders ? \array_keys($this->readers) : $this->createdReaders;
foreach ($readers as $id) {
$this->readers[$id]->getParser()->getStreamReader()->cleanUp();
unset($this->readers[$id]);
Expand Down Expand Up @@ -335,7 +335,7 @@ public function importPage(

if ($rotation !== 0) {
$rotation *= -1;
$angle = $rotation * M_PI / 180;
$angle = $rotation * \M_PI / 180;
$a = \cos($angle);
$b = \sin($angle);
$c = -$b;
Expand Down Expand Up @@ -451,7 +451,7 @@ public function useImportedPage($pageId, $x = 0, $y = 0, $width = null, $height
if (\is_array($x)) {
/** @noinspection OffsetOperationsInspection */
unset($x['pageId']);
\extract($x, EXTR_IF_EXISTS);
\extract($x, \EXTR_IF_EXISTS);
/** @noinspection NotOptimalIfConditionsInspection */
/** @phpstan-ignore function.alreadyNarrowedType */
if (\is_array($x)) {
Expand Down Expand Up @@ -489,7 +489,7 @@ public function useImportedPage($pageId, $x = 0, $y = 0, $width = null, $height
)
);

if (count($importedPage['externalLinks']) > 0) {
if (\count($importedPage['externalLinks']) > 0) {
foreach ($importedPage['externalLinks'] as $externalLink) {
// mPDF uses also 'externalLinks' but doesn't come with a rect-value
if (!isset($externalLink['rect'])) {
Expand Down
2 changes: 1 addition & 1 deletion src/PdfParser/CrossReference/LineReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ protected function read($xrefContent)
// can be reverted for php7.2
$differentLineEndings = \count(\array_count_values($m[0]));
if ($differentLineEndings > 1) {
$lines = \preg_split("/(\r\n|\n|\r)/", $xrefContent, -1, PREG_SPLIT_NO_EMPTY);
$lines = \preg_split("/(\r\n|\n|\r)/", $xrefContent, -1, \PREG_SPLIT_NO_EMPTY);
} else {
$lines = \explode($m[0][0], $xrefContent);
}
Expand Down
14 changes: 7 additions & 7 deletions src/PdfParser/Filter/Flate.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,21 @@ public function decode($data)
$data = (($data !== '') ? @\gzuncompress($data) : '');
if ($data === false) {
// let's try if the checksum is CRC32
$fh = fopen('php://temp', 'w+b');
fwrite($fh, "\x1f\x8b\x08\x00\x00\x00\x00\x00" . $oData);
$fh = \fopen('php://temp', 'w+b');
\fwrite($fh, "\x1f\x8b\x08\x00\x00\x00\x00\x00" . $oData);
// "window" == 31 -> 16 + (8 to 15): Uses the low 4 bits of the value as the window size logarithm.
// The input must include a gzip header and trailer (via 16).
stream_filter_append($fh, 'zlib.inflate', STREAM_FILTER_READ, ['window' => 31]);
fseek($fh, 0);
$data = @stream_get_contents($fh);
fclose($fh);
\stream_filter_append($fh, 'zlib.inflate', \STREAM_FILTER_READ, ['window' => 31]);
\fseek($fh, 0);
$data = @\stream_get_contents($fh);
\fclose($fh);

if ($data) {
return $data;
}

// Try this fallback (remove the zlib stream header)
$data = @(gzinflate(substr($oData, 2)));
$data = @(\gzinflate(\substr($oData, 2)));

if ($data === false) {
throw new FlateException(
Expand Down
Loading