Skip to content

Commit c88208a

Browse files
authored
Merge pull request #190 from phpcr/php-8
php 8
2 parents 2166818 + b54210d commit c88208a

31 files changed

+183
-167
lines changed

.styleci.yml

+2
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ preset: recommended
22

33
enabled:
44
- no_useless_else
5+
disabled:
6+
- align_double_arrow

.travis.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
language: php
22

33
php:
4-
- 5.6
5-
- 7.0
64
- 7.1
75
- 7.2
86
- 7.3
97
- 7.4
8+
- nightly
109

1110
env:
1211
- PACKAGE_VERSION=high
@@ -15,7 +14,7 @@ sudo: false
1514

1615
matrix:
1716
include:
18-
- php: 5.6
17+
- php: 7.1
1918
env: PACKAGE_VERSION=low
2019
- php: 7.4
2120
env:

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Changelog
22
=========
33

4+
1.5.0
5+
-----
6+
7+
* Support PHP 8
8+
* Drop support for PHP 5.6 and 7.0
9+
410
1.4.1
511
-----
612

composer.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727
}
2828
],
2929
"require": {
30-
"php": "^5.6 || ^7.0",
30+
"php": "^7.1 || ^8.0",
3131
"phpcr/phpcr": "~2.1.0",
32-
"symfony/console": "^2.3|^3.0|^4.0|^5.0"
32+
"symfony/console": "^2.3 || ^3.0 || ^4.0 || ^5.0"
3333
},
3434
"require-dev": {
3535
"ramsey/uuid": "^3.5",
36-
"phpunit/phpunit": "^5.7 || ^6.0 || ^7.0"
36+
"phpunit/phpunit": "^7.5 || ^8.0 || ^9.0"
3737
},
3838
"suggest": {
3939
"ramsey/uuid": "A library for generating RFC 4122 version 1, 3, 4, and 5 universally unique identifiers (UUID)."

tests/PHPCR/Tests/Util/CND/Reader/BufferReaderTest.php

+21-9
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,21 @@
77

88
class BufferReaderTest extends TestCase
99
{
10-
public function test__construct()
10+
public function test__construct(): void
1111
{
1212
$buffer = "Some random\nor\r\nstring";
1313
$reader = new BufferReader($buffer);
1414

15-
$this->assertInstanceOf(BufferReader::class, $reader);
16-
$this->assertAttributeEquals(str_replace("\r\n", "\n", $buffer).$reader->getEofMarker(), 'buffer', $reader);
17-
$this->assertAttributeEquals(0, 'startPos', $reader);
18-
$this->assertAttributeEquals(0, 'forwardPos', $reader);
15+
$reflection = new \ReflectionClass($reader);
16+
$bufferProperty = $reflection->getProperty('buffer');
17+
$bufferProperty->setAccessible(true);
18+
$this->assertSame(str_replace("\r\n", "\n", $buffer).$reader->getEofMarker(), $bufferProperty->getValue($reader));
19+
$startPos = $reflection->getProperty('startPos');
20+
$startPos->setAccessible(true);
21+
$this->assertSame(0, $startPos->getValue($reader));
22+
$forwardPos = $reflection->getProperty('forwardPos');
23+
$forwardPos->setAccessible(true);
24+
$this->assertSame(0, $forwardPos->getValue($reader));
1925

2026
$this->assertEquals(1, $reader->getCurrentLine());
2127
$this->assertEquals(1, $reader->getCurrentColumn());
@@ -90,10 +96,16 @@ public function test__constructEmptyString()
9096
{
9197
$reader = new BufferReader('');
9298

93-
$this->assertInstanceOf(BufferReader::class, $reader);
94-
$this->assertAttributeEquals($reader->getEofMarker(), 'buffer', $reader);
95-
$this->assertAttributeEquals(0, 'startPos', $reader);
96-
$this->assertAttributeEquals(0, 'forwardPos', $reader);
99+
$reflection = new \ReflectionClass($reader);
100+
$buffer = $reflection->getProperty('buffer');
101+
$buffer->setAccessible(true);
102+
$this->assertSame($reader->getEofMarker(), $buffer->getValue($reader));
103+
$startPos = $reflection->getProperty('startPos');
104+
$startPos->setAccessible(true);
105+
$this->assertSame(0, $startPos->getValue($reader));
106+
$forwardPos = $reflection->getProperty('forwardPos');
107+
$forwardPos->setAccessible(true);
108+
$this->assertSame(0, $forwardPos->getValue($reader));
97109

98110
$this->assertEquals(1, $reader->getCurrentLine());
99111
$this->assertEquals(1, $reader->getCurrentColumn());

tests/PHPCR/Tests/Util/CND/Reader/FileReaderTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class FileReaderTest extends TestCase
2323
*/
2424
private $lines;
2525

26-
public function setUp()
26+
public function setUp(): void
2727
{
2828
$this->filepath = __DIR__.'/../Fixtures/files/TestFile.txt';
2929
$this->reader = new FileReader($this->filepath);

tests/PHPCR/Tests/Util/CND/Scanner/GenericScannerTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class GenericScannerTest extends TestCase
108108

109109
protected $expectedTokensNoEmptyToken;
110110

111-
public function setUp()
111+
public function setUp(): void
112112
{
113113
$this->expectedTokensNoEmptyToken = [];
114114
foreach ($this->expectedTokens as $token) {

tests/PHPCR/Tests/Util/CND/Scanner/TokenQueueTest.php

+7-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class TokenQueueTest extends TestCase
3333
*/
3434
private $queue;
3535

36-
public function setUp()
36+
public function setUp(): void
3737
{
3838
$this->token0 = new Token(0, 'token 0');
3939
$this->token1 = new Token(1, 'token 1');
@@ -50,13 +50,16 @@ public function setUp()
5050
public function testAdd()
5151
{
5252
$queue = new TokenQueue();
53-
$this->assertAttributeEquals([], 'tokens', $queue);
53+
$reflection = new \ReflectionClass($queue);
54+
$tokens = $reflection->getProperty('tokens');
55+
$tokens->setAccessible(true);
56+
$this->assertSame([], $tokens->getValue($queue));
5457

5558
$queue->add($this->token0);
56-
$this->assertAttributeEquals([$this->token0], 'tokens', $queue);
59+
$this->assertSame([$this->token0], $tokens->getValue($queue));
5760

5861
$queue->add($this->token1);
59-
$this->assertAttributeEquals([$this->token0, $this->token1], 'tokens', $queue);
62+
$this->assertSame([$this->token0, $this->token1], $tokens->getValue($queue));
6063
}
6164

6265
public function testResetAndPeek()

tests/PHPCR/Tests/Util/CND/Scanner/TokenTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ class TokenTest extends TestCase
1212
*/
1313
private $token;
1414

15-
public function setUp()
15+
public function setUp(): void
1616
{
1717
$this->token = new Token(123, 'foobar');
1818
}
1919

2020
public function test__construct()
2121
{
22-
$this->assertAttributeEquals(123, 'type', $this->token);
23-
$this->assertAttributeEquals('foobar', 'data', $this->token);
22+
$this->assertSame(123, $this->token->type);
23+
$this->assertSame('foobar', $this->token->data);
2424
}
2525

2626
public function testGetData()

tests/PHPCR/Tests/Util/Console/Command/BaseCommandTest.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ abstract class BaseCommandTest extends TestCase
6969
*/
7070
public $application;
7171

72-
public function setUp()
72+
public function setUp(): void
7373
{
7474
$this->session = $this->createMock(SessionInterface::class);
7575
$this->workspace = $this->createMock(WorkspaceInterface::class);
@@ -88,21 +88,21 @@ public function setUp()
8888
'phpcr_console_dumper' => $this->dumperHelper,
8989
]);
9090

91-
$this->session->expects($this->any())
91+
$this->session
9292
->method('getWorkspace')
93-
->will($this->returnValue($this->workspace));
93+
->willReturn($this->workspace);
9494

95-
$this->workspace->expects($this->any())
95+
$this->workspace
9696
->method('getName')
97-
->will($this->returnValue('test'));
97+
->willReturn('test');
9898

99-
$this->workspace->expects($this->any())
99+
$this->workspace
100100
->method('getQueryManager')
101-
->will($this->returnValue($this->queryManager));
101+
->willReturn($this->queryManager);
102102

103-
$this->queryManager->expects($this->any())
103+
$this->queryManager
104104
->method('getSupportedQueryLanguages')
105-
->will($this->returnValue(['JCR-SQL2']));
105+
->willReturn(['JCR-SQL2']);
106106

107107
$this->application = new Application();
108108
$this->application->setHelperSet($this->helperSet);

tests/PHPCR/Tests/Util/Console/Command/NodeDumpCommandTest.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class NodeDumpCommandTest extends BaseCommandTest
1414
/** @var TreeWalker|MockObject */
1515
protected $treeWalker;
1616

17-
public function setUp()
17+
public function setUp(): void
1818
{
1919
parent::setUp();
2020
$this->treeWalker = $this->getMockBuilder(TreeWalker::class)
@@ -30,13 +30,13 @@ public function testCommand()
3030
$this->dumperHelper
3131
->expects($this->once())
3232
->method('getTreeWalker')
33-
->will($this->returnValue($this->treeWalker));
33+
->willReturn($this->treeWalker);
3434

3535
$this->session
3636
->expects($this->once())
3737
->method('getNode')
3838
->with('/')
39-
->will($this->returnValue($this->node1));
39+
->willReturn($this->node1);
4040

4141
$this->treeWalker
4242
->expects($this->once())
@@ -53,13 +53,13 @@ public function testCommandIdentifier()
5353
$this->dumperHelper
5454
->expects($this->once())
5555
->method('getTreeWalker')
56-
->will($this->returnValue($this->treeWalker));
56+
->willReturn($this->treeWalker);
5757

5858
$this->session
5959
->expects($this->once())
6060
->method('getNodeByIdentifier')
6161
->with($uuid)
62-
->will($this->returnValue($this->node1));
62+
->willReturn($this->node1);
6363

6464
$this->treeWalker
6565
->expects($this->once())
@@ -86,6 +86,6 @@ public function testNotFound()
8686
->will($this->throwException(new ItemNotFoundException()));
8787

8888
$ct = $this->executeCommand('phpcr:node:dump', [], 1);
89-
$this->assertContains('does not exist', $ct->getDisplay());
89+
$this->assertStringContainsString('does not exist', $ct->getDisplay());
9090
}
9191
}

tests/PHPCR/Tests/Util/Console/Command/NodeRemoveCommandTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
class NodeRemoveCommandTest extends BaseCommandTest
99
{
10-
public function setUp()
10+
public function setUp(): void
1111
{
1212
parent::setUp();
1313

tests/PHPCR/Tests/Util/Console/Command/NodeTouchCommandTest.php

+17-17
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class NodeTouchCommandTest extends BaseCommandTest
2020
*/
2121
public $phpcrHelper;
2222

23-
public function setUp()
23+
public function setUp(): void
2424
{
2525
parent::setUp();
2626

@@ -32,13 +32,13 @@ public function setUp()
3232
->disableOriginalConstructor()
3333
->getMock();
3434

35-
$this->phpcrHelper->expects($this->any())
35+
$this->phpcrHelper
3636
->method('getSession')
37-
->will($this->returnValue($this->session));
37+
->willReturn($this->session);
3838

39-
$this->phpcrHelper->expects($this->any())
39+
$this->phpcrHelper
4040
->method('getName')
41-
->will($this->returnValue('phpcr'));
41+
->willReturn('phpcr');
4242

4343
$this->helperSet->set($this->phpcrHelper);
4444
}
@@ -50,7 +50,7 @@ public function testTouch()
5050

5151
$this->session->expects($this->exactly(2))
5252
->method('getNode')
53-
->will($this->returnCallback(function ($path) use ($node) {
53+
->willReturnCallback(function ($path) use ($node) {
5454
switch ($path) {
5555
case '/':
5656
return $node;
@@ -59,12 +59,12 @@ public function testTouch()
5959
}
6060

6161
throw new Exception('Unexpected '.$path);
62-
}));
62+
});
6363

6464
$this->node1->expects($this->once())
6565
->method('addNode')
6666
->with('cms')
67-
->will($this->returnValue($child));
67+
->willReturn($child);
6868

6969
$this->session->expects($this->once())
7070
->method('save');
@@ -77,31 +77,31 @@ public function testUpdate()
7777
$nodeType = $this->createMock(NodeTypeInterface::class);
7878
$nodeType->expects($this->once())
7979
->method('getName')
80-
->will($this->returnValue('nt:unstructured'));
80+
->willReturn('nt:unstructured');
8181

8282
$this->session->expects($this->exactly(1))
8383
->method('getNode')
8484
->with('/cms')
85-
->will($this->returnValue($this->node1));
85+
->willReturn($this->node1);
8686

8787
$this->node1->expects($this->once())
8888
->method('getPrimaryNodeType')
89-
->will($this->returnValue($nodeType));
89+
->willReturn($nodeType);
9090

9191
$me = $this;
9292

9393
$this->phpcrHelper->expects($this->once())
9494
->method('processNode')
95-
->will($this->returnCallback(function ($output, $node, $options) use ($me) {
95+
->willReturnCallback(function ($output, $node, $options) use ($me) {
9696
$me->assertEquals($me->node1, $node);
9797
$me->assertEquals([
98-
'setProp' => ['foo=bar'],
99-
'removeProp' => ['bar'],
100-
'addMixins' => ['foo:bar'],
98+
'setProp' => ['foo=bar'],
99+
'removeProp' => ['bar'],
100+
'addMixins' => ['foo:bar'],
101101
'removeMixins' => ['bar:foo'],
102-
'dump' => true,
102+
'dump' => true,
103103
], $options);
104-
}));
104+
});
105105

106106
$this->executeCommand('phpcr:node:touch', [
107107
'path' => '/cms',

tests/PHPCR/Tests/Util/Console/Command/NodeTypeListCommandTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class NodeTypeListCommandTest extends BaseCommandTest
1313
*/
1414
private $nodeTypeManager;
1515

16-
public function setUp()
16+
public function setUp(): void
1717
{
1818
parent::setUp();
1919

@@ -27,15 +27,15 @@ public function testNodeTypeList()
2727
{
2828
$this->session->expects($this->once())
2929
->method('getWorkspace')
30-
->will($this->returnValue($this->workspace));
30+
->willReturn($this->workspace);
3131

3232
$this->workspace->expects($this->once())
3333
->method('getNodeTypeManager')
34-
->will($this->returnValue($this->nodeTypeManager));
34+
->willReturn($this->nodeTypeManager);
3535

3636
$this->nodeTypeManager->expects($this->once())
3737
->method('getAllNodeTypes')
38-
->will($this->returnValue([]));
38+
->willReturn([]);
3939

4040
$this->executeCommand('phpcr:node-type:list', []);
4141
}

0 commit comments

Comments
 (0)