@@ -263,7 +263,14 @@ public function testFormatContent(): void
263263 $ expected = str_replace (["\r\n" , "\n" ], ["\n" , "\r\n" ], $ expected );
264264
265265 $ formatContent = new \ReflectionMethod ('Smalot\PdfParser\PDFObject ' , 'formatContent ' );
266- $ formatContent ->setAccessible (true );
266+
267+ // TODO: remove this if-clause when dropping 8.0.x support
268+ // From documentation > http://php.net/manual/en/reflectionproperty.setaccessible.php:
269+ // As of PHP 8.1.0, calling this method has no effect; all properties are accessible by default.
270+ if (version_compare (PHP_VERSION , '8.1.0 ' , '< ' )) {
271+ $ formatContent ->setAccessible (true );
272+ }
273+
267274 $ cleaned = $ formatContent ->invoke ($ this ->getPdfObjectInstance (new Document ()), $ content );
268275
269276 $ this ->assertEquals ($ expected , $ cleaned );
@@ -303,7 +310,13 @@ public function testFormatContent(): void
303310 public function testFormatContentIssue709 ()
304311 {
305312 $ formatContent = new \ReflectionMethod ('Smalot\PdfParser\PDFObject ' , 'formatContent ' );
306- $ formatContent ->setAccessible (true );
313+
314+ // TODO: remove this if-clause when dropping 8.0.x support
315+ // From documentation > http://php.net/manual/en/reflectionproperty.setaccessible.php:
316+ // As of PHP 8.1.0, calling this method has no effect; all properties are accessible by default.
317+ if (version_compare (PHP_VERSION , '8.1.0 ' , '< ' )) {
318+ $ formatContent ->setAccessible (true );
319+ }
307320
308321 $ content = '(String \\\\\\(string)Tj ' .str_repeat ('(Test)Tj ' , 4500 );
309322 $ cleaned = $ formatContent ->invoke ($ this ->getPdfObjectInstance (new Document ()), $ content );
@@ -319,7 +332,13 @@ public function testFormatContentIssue709()
319332 public function testFormatContentInlineImages (): void
320333 {
321334 $ formatContent = new \ReflectionMethod ('Smalot\PdfParser\PDFObject ' , 'formatContent ' );
322- $ formatContent ->setAccessible (true );
335+
336+ // TODO: remove this if-clause when dropping 8.0.x support
337+ // From documentation > http://php.net/manual/en/reflectionproperty.setaccessible.php:
338+ // As of PHP 8.1.0, calling this method has no effect; all properties are accessible by default.
339+ if (version_compare (PHP_VERSION , '8.1.0 ' , '< ' )) {
340+ $ formatContent ->setAccessible (true );
341+ }
323342
324343 $ cleaned = $ formatContent ->invoke (
325344 $ this ->getPdfObjectInstance (new Document ()),
0 commit comments