Skip to content

Commit 41c8080

Browse files
committed
added a fix to solve chr deprecation
deprecation warning was: > chr(): Providing a value not in-between 0 and 255 is deprecated, this is because a byte value must be in the [0, 255] interval. The value used will be constrained using % 256 Also removed --display-deprecations in Windows tests
1 parent bc946ec commit 41c8080

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,4 +201,4 @@ jobs:
201201
run: composer update --working-dir=dev-tools
202202

203203
- name: Tests
204-
run: dev-tools/vendor/bin/phpunit -c phpunit-windows.xml --display-deprecations --exclude-group linux-only
204+
run: dev-tools/vendor/bin/phpunit -c phpunit-windows.xml --exclude-group linux-only

src/Smalot/PdfParser/RawData/FilterHelper.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,17 @@ protected function decodeFilterASCII85Decode(string $data): string
190190
// the value represented by a group of 5 characters should never be greater than 2^32 - 1
191191
$tuple += (($char - 33) * $pow85[$group_pos]);
192192
if (4 == $group_pos) {
193+
// The following if-clause is an attempt to fix/suppress the following deprecation warning:
194+
// chr(): Providing a value not in-between 0 and 255 is deprecated, this is because a byte value
195+
// must be in the [0, 255] interval. The value used will be constrained using % 256
196+
if (
197+
255 < $tuple >> 24
198+
|| 255 < $tuple >> 16
199+
|| 255 < $tuple >> 8
200+
) {
201+
$tuple = $tuple % 256;
202+
}
203+
193204
$decoded .= \chr($tuple >> 24)
194205
.\chr($tuple >> 16)
195206
.\chr($tuple >> 8)

0 commit comments

Comments
 (0)