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
2 changes: 1 addition & 1 deletion src/PHPCR/Util/CND/Scanner/GenericToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @license http://opensource.org/licenses/MIT MIT License
* @author Daniel Barsotti <daniel.barsotti@liip.ch>
*/
class GenericToken extends Token
class GenericToken extends Token implements \Stringable
{
public const TK_WHITESPACE = 0;
public const TK_NEWLINE = 1;
Expand Down
2 changes: 1 addition & 1 deletion src/PHPCR/Util/CND/Scanner/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @license http://opensource.org/licenses/MIT MIT License
* @author Daniel Barsotti <daniel.barsotti@liip.ch>
*/
class Token
class Token implements \Stringable
{
public function __construct(
private int $type = 0,
Expand Down
30 changes: 24 additions & 6 deletions tests/PHPCR/Tests/Util/CND/Reader/BufferReaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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());
Expand Down
5 changes: 4 additions & 1 deletion tests/PHPCR/Tests/Util/CND/Scanner/TokenQueueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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']) {
Expand Down