diff --git a/src/PHPCR/Util/CND/Scanner/GenericToken.php b/src/PHPCR/Util/CND/Scanner/GenericToken.php index 9f88af8..e47b65a 100644 --- a/src/PHPCR/Util/CND/Scanner/GenericToken.php +++ b/src/PHPCR/Util/CND/Scanner/GenericToken.php @@ -9,7 +9,7 @@ * @license http://opensource.org/licenses/MIT MIT License * @author Daniel Barsotti */ -class GenericToken extends Token +class GenericToken extends Token implements \Stringable { public const TK_WHITESPACE = 0; public const TK_NEWLINE = 1; diff --git a/src/PHPCR/Util/CND/Scanner/Token.php b/src/PHPCR/Util/CND/Scanner/Token.php index 6e4d146..d32fdde 100644 --- a/src/PHPCR/Util/CND/Scanner/Token.php +++ b/src/PHPCR/Util/CND/Scanner/Token.php @@ -13,7 +13,7 @@ * @license http://opensource.org/licenses/MIT MIT License * @author Daniel Barsotti */ -class Token +class Token implements \Stringable { public function __construct( private int $type = 0, diff --git a/tests/PHPCR/Tests/Util/CND/Reader/BufferReaderTest.php b/tests/PHPCR/Tests/Util/CND/Reader/BufferReaderTest.php index 2e4dc33..48b3e94 100644 --- a/tests/PHPCR/Tests/Util/CND/Reader/BufferReaderTest.php +++ b/tests/PHPCR/Tests/Util/CND/Reader/BufferReaderTest.php @@ -16,13 +16,22 @@ public function testConstruct(): void $reflection = new \ReflectionClass($reader); $bufferProperty = $reflection->getProperty('buffer'); - $bufferProperty->setAccessible(true); + // remove when we drop PHP 8.0 support + if (PHP_VERSION_ID < 80100) { + $bufferProperty->setAccessible(true); + } $this->assertSame(str_replace("\r\n", "\n", $buffer).$reader->getEofMarker(), $bufferProperty->getValue($reader)); $startPos = $reflection->getProperty('startPos'); - $startPos->setAccessible(true); + // remove when we drop PHP 8.0 support + if (PHP_VERSION_ID < 80100) { + $startPos->setAccessible(true); + } $this->assertSame(0, $startPos->getValue($reader)); $forwardPos = $reflection->getProperty('forwardPos'); - $forwardPos->setAccessible(true); + // remove when we drop PHP 8.0 support + if (PHP_VERSION_ID < 80100) { + $forwardPos->setAccessible(true); + } $this->assertSame(0, $forwardPos->getValue($reader)); $this->assertEquals(1, $reader->getCurrentLine()); @@ -100,13 +109,22 @@ public function testConstructEmptyString(): void $reflection = new \ReflectionClass($reader); $buffer = $reflection->getProperty('buffer'); - $buffer->setAccessible(true); + // remove when we drop PHP 8.0 support + if (PHP_VERSION_ID < 80100) { + $buffer->setAccessible(true); + } $this->assertSame($reader->getEofMarker(), $buffer->getValue($reader)); $startPos = $reflection->getProperty('startPos'); - $startPos->setAccessible(true); + // remove when we drop PHP 8.0 support + if (PHP_VERSION_ID < 80100) { + $startPos->setAccessible(true); + } $this->assertSame(0, $startPos->getValue($reader)); $forwardPos = $reflection->getProperty('forwardPos'); - $forwardPos->setAccessible(true); + // remove when we drop PHP 8.0 support + if (PHP_VERSION_ID < 80100) { + $forwardPos->setAccessible(true); + } $this->assertSame(0, $forwardPos->getValue($reader)); $this->assertEquals(1, $reader->getCurrentLine()); diff --git a/tests/PHPCR/Tests/Util/CND/Scanner/TokenQueueTest.php b/tests/PHPCR/Tests/Util/CND/Scanner/TokenQueueTest.php index 8b653c5..3020e62 100644 --- a/tests/PHPCR/Tests/Util/CND/Scanner/TokenQueueTest.php +++ b/tests/PHPCR/Tests/Util/CND/Scanner/TokenQueueTest.php @@ -54,7 +54,10 @@ public function testAdd(): void $queue = new TokenQueue(); $reflection = new \ReflectionClass($queue); $tokens = $reflection->getProperty('tokens'); - $tokens->setAccessible(true); + // remove when we drop PHP 8.0 support + if (PHP_VERSION_ID < 80100) { + $tokens->setAccessible(true); + } $this->assertSame([], $tokens->getValue($queue)); $queue->add($this->token0); diff --git a/tests/PHPCR/Tests/Util/Console/Helper/PhpcrConsoleDumperHelperTest.php b/tests/PHPCR/Tests/Util/Console/Helper/PhpcrConsoleDumperHelperTest.php index 748fb87..6588401 100644 --- a/tests/PHPCR/Tests/Util/Console/Helper/PhpcrConsoleDumperHelperTest.php +++ b/tests/PHPCR/Tests/Util/Console/Helper/PhpcrConsoleDumperHelperTest.php @@ -56,7 +56,10 @@ public function testGetTreeWalker(array $options): void $reflection = new \ReflectionClass($tw); $propVisitorProp = $reflection->getProperty('propertyVisitor'); - $propVisitorProp->setAccessible(true); + // remove when we drop PHP 8.0 support + if (PHP_VERSION_ID < 80100) { + $propVisitorProp->setAccessible(true); + } $propVisitor = $propVisitorProp->getValue($tw); if (true === $options['show_props']) {