Skip to content

Commit 88a3aff

Browse files
authored
Merge pull request #157 from Setasign/development
2 parents 273ab15 + 8ac4642 commit 88a3aff

File tree

10 files changed

+212
-172
lines changed

10 files changed

+212
-172
lines changed

.github/workflows/code-style.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- name: Install php
3333
uses: shivammathur/setup-php@v2
3434
with:
35-
php-version: "7.1"
35+
php-version: "7.4"
3636

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

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
runs-on: ubuntu-20.04
3232
strategy:
3333
matrix:
34-
php: ['8.0', '8.1']
34+
php: ['8.0', '8.1', '8.2']
3535
steps:
3636
- name: Checkout
3737
uses: actions/checkout@v2

composer.lock

Lines changed: 176 additions & 134 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpstan.neon

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ parameters:
66

77
ignoreErrors:
88
-
9-
message: "#^Return typehint of method setasign\\\\Fpdi\\\\Fpdi\\:\\:getPdfParserInstance\\(\\) has invalid type setasign\\\\FpdiPdfParser\\\\PdfParser\\\\PdfParser\\.$#"
9+
message: "#^Method setasign\\\\Fpdi\\\\Fpdi\\:\\:getPdfParserInstance\\(\\) has invalid return type setasign\\\\FpdiPdfParser\\\\PdfParser\\\\PdfParser\\.$#"
1010
count: 1
1111
path: src/Fpdi.php
1212
-
13-
message: "#^Return typehint of method setasign\\\\Fpdi\\\\Tcpdf\\\\Fpdi\\:\\:getPdfParserInstance\\(\\) has invalid type setasign\\\\FpdiPdfParser\\\\PdfParser\\\\PdfParser\\.$#"
13+
message: "#^Method setasign\\\\Fpdi\\\\Tcpdf\\\\Fpdi\\:\\:getPdfParserInstance\\(\\) has invalid return type setasign\\\\FpdiPdfParser\\\\PdfParser\\\\PdfParser\\.$#"
1414
count: 1
1515
path: src/Tcpdf/Fpdi.php
1616
-
17-
message: "#^Return typehint of method setasign\\\\Fpdi\\\\Tfpdf\\\\Fpdi\\:\\:getPdfParserInstance\\(\\) has invalid type setasign\\\\FpdiPdfParser\\\\PdfParser\\\\PdfParser\\.$#"
17+
message: "#^Method setasign\\\\Fpdi\\\\Tfpdf\\\\Fpdi\\:\\:getPdfParserInstance\\(\\) has invalid return type setasign\\\\FpdiPdfParser\\\\PdfParser\\\\PdfParser\\.$#"
1818
count: 1
1919
path: src/Tfpdf/Fpdi.php

src/PdfParser/CrossReference/FixedReader.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public function getSubSections()
5858

5959
/**
6060
* @inheritdoc
61+
* @return int|false
6162
*/
6263
public function getOffsetFor($objectNumber)
6364
{

src/PdfParser/CrossReference/LineReader.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public function __construct(PdfParser $parser)
4242

4343
/**
4444
* @inheritdoc
45+
* @return int|false
4546
*/
4647
public function getOffsetFor($objectNumber)
4748
{

src/PdfParser/Filter/Lzw.php

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -87,37 +87,28 @@ public function decode($data)
8787
$this->nextData = 0;
8888
$this->nextBits = 0;
8989

90-
$oldCode = 0;
90+
$prevCode = 0;
9191

9292
$uncompData = '';
9393

9494
while (($code = $this->getNextCode()) !== 257) {
9595
if ($code === 256) {
9696
$this->initsTable();
97-
$code = $this->getNextCode();
98-
99-
if ($code === 257) {
100-
break;
101-
}
102-
97+
} elseif ($prevCode === 256) {
10398
$uncompData .= $this->sTable[$code];
104-
$oldCode = $code;
99+
} elseif ($code < $this->tIdx) {
100+
$string = $this->sTable[$code];
101+
$uncompData .= $string;
102+
103+
$this->addStringToTable($this->sTable[$prevCode], $string[0]);
105104
} else {
106-
if ($code < $this->tIdx) {
107-
$string = $this->sTable[$code];
108-
$uncompData .= $string;
109-
110-
$this->addStringToTable($this->sTable[$oldCode], $string[0]);
111-
$oldCode = $code;
112-
} else {
113-
$string = $this->sTable[$oldCode];
114-
$string .= $string[0];
115-
$uncompData .= $string;
116-
117-
$this->addStringToTable($string);
118-
$oldCode = $code;
119-
}
105+
$string = $this->sTable[$prevCode];
106+
$string .= $string[0];
107+
$uncompData .= $string;
108+
109+
$this->addStringToTable($string);
120110
}
111+
$prevCode = $code;
121112
}
122113

123114
return $uncompData;
@@ -163,7 +154,7 @@ protected function addStringToTable($oldString, $newString = '')
163154
/**
164155
* Returns the next 9, 10, 11 or 12 bits.
165156
*
166-
* @return integer
157+
* @return int
167158
*/
168159
protected function getNextCode()
169160
{

src/Tcpdf/Fpdi.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ public function getTemplateSize($tpl, $width = null, $height = null)
140140

141141
/**
142142
* @inheritdoc
143+
* @return string
143144
*/
144145
protected function _getxobjectdict()
145146
{

tests/functional/PdfParser/Filter/LzwTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ public function decodeProvider()
1919
"\x80\x0D\x47\x23\x91\x00\xC2\x0A\x20\x1C\x0D\x06\x30\x78\x31\x8C\xDA\x0A\x17\x92"
2020
. "\x4D\xA6\x78\x59\x10\xDF\x01",
2121
"599 0 0 841 0 0 cm\n/Img1 Do"
22-
]
22+
],
23+
[
24+
"\x80\x40\x05\xB0\x28\x11\x06\x06\x42\x80\x80",
25+
"-----A---B"
26+
],
2327
];
2428
}
2529

tests/visual/Alpha/AlphaPdf.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,24 @@ protected function _putextgstates()
4545
for ($i = 1; $i <= $count; $i++) {
4646
$this->_newobj();
4747
$this->extgstates[$i]['n'] = $this->n;
48-
$this->_out('<</Type /ExtGState');
48+
$this->_put('<</Type /ExtGState');
4949
$parms = $this->extgstates[$i]['parms'];
50-
$this->_out(sprintf('/ca %.3F', $parms['ca']));
51-
$this->_out(sprintf('/CA %.3F', $parms['CA']));
52-
$this->_out('/BM '.$parms['BM']);
53-
$this->_out('>>');
54-
$this->_out('endobj');
50+
$this->_put(sprintf('/ca %.3F', $parms['ca']));
51+
$this->_put(sprintf('/CA %.3F', $parms['CA']));
52+
$this->_put('/BM '.$parms['BM']);
53+
$this->_put('>>');
54+
$this->_put('endobj');
5555
}
5656
}
5757

5858
protected function _putresourcedict()
5959
{
6060
parent::_putresourcedict();
61-
$this->_out('/ExtGState <<');
61+
$this->_put('/ExtGState <<');
6262
foreach ($this->extgstates as $k => $extgstate) {
63-
$this->_out('/GS'.$k.' '.$extgstate['n'].' 0 R');
63+
$this->_put('/GS'.$k.' '.$extgstate['n'].' 0 R');
6464
}
65-
$this->_out('>>');
65+
$this->_put('>>');
6666
}
6767

6868
protected function _putresources()

0 commit comments

Comments
 (0)