Skip to content

Commit 943c5bf

Browse files
committed
Upgrade to php 8.1
1 parent a9ec8b2 commit 943c5bf

39 files changed

+193
-158
lines changed

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
}
1919
},
2020
"require": {
21-
"php": ">=5.5",
21+
"php": ">=7.3",
2222
"guzzlehttp/psr7": "^1.4",
23-
"psr/log": "^1.0"
23+
"psr/log": "^1.0|^2.0|^3.0"
2424
},
2525
"require-dev": {
26-
"phpunit/phpunit": "^4.8 || ^5.7",
26+
"phpunit/phpunit": "^9.5",
2727
"php-mock/php-mock": "^1.0 || ^2.0",
28-
"humbug/humbug": "~1.0@dev"
28+
"phpspec/prophecy-phpunit": "^2.0"
2929
}
3030
}

phpunit.xml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
convertWarningsToExceptions="true"
1010
processIsolation="false"
1111
stopOnFailure="false"
12-
syntaxCheck="false"
1312
bootstrap="./tests/bootstrap.php"
1413
>
1514

@@ -19,9 +18,9 @@
1918
</testsuite>
2019
</testsuites>
2120

22-
<filter>
23-
<whitelist processUncoveredFilesFromWhitelist="false">
21+
<coverage processUncoveredFiles="false">
22+
<include>
2423
<directory suffix=".php">src/</directory>
25-
</whitelist>
26-
</filter>
24+
</include>
25+
</coverage>
2726
</phpunit>

src/Debugger/DebugLogger.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function __construct(DataCollector $dataCollector)
3030
/**
3131
* @inheritDoc
3232
*/
33-
public function debug($message, array $context = [])
33+
public function debug($message, array $context = []): void
3434
{
3535
if (isset($context['request']) && !isset($context['response'])) {
3636
$this->dataCollector->collectRequest($context['request']);
@@ -45,7 +45,7 @@ public function debug($message, array $context = [])
4545
/**
4646
* @inheritDoc
4747
*/
48-
public function log($level, $message, array $context = [])
48+
public function log($level, $message, array $context = []): void
4949
{
5050
if (LogLevel::DEBUG) {
5151
$this->debug($message, $context);

src/Handler/Call/CallRegistry.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Getresponse\Sdk\Client\Handler\Call;
44

55
use Psr\Http\Message\RequestInterface;
6+
use Traversable;
67

78
/**
89
* Class CallRegistry
@@ -42,7 +43,7 @@ public function registerCall($identifier, Call $call)
4243
/**
4344
* @return \ArrayIterator | Call[]
4445
*/
45-
public function getIterator()
46+
public function getIterator(): Traversable
4647
{
4748
return new \ArrayIterator($this->calls);
4849
}
@@ -80,12 +81,8 @@ public function has($requestIdentifier)
8081
{
8182
return !empty($this->calls[$requestIdentifier]);
8283
}
83-
84-
/**
85-
* Count elements of an object
86-
* @return int
87-
*/
88-
public function count()
84+
85+
public function count(): int
8986
{
9087
return count($this->calls);
9188
}

src/Operation/BaseModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class BaseModel implements \JsonSerializable
1212
/**
1313
* @return array
1414
*/
15-
function jsonSerialize()
15+
public function jsonSerialize(): array
1616
{
1717
return [];
1818
}

src/Operation/DateRangeSearch.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,11 @@ public function __construct($from = null, $to = null)
2929
$this->to = $to;
3030
}
3131

32-
/**
33-
* @return array
34-
*/
35-
public function toArray()
32+
public function toArray(): array
3633
{
3734
return array_filter([
38-
'from' => $this->from,
39-
'to' => $this->to
35+
'from' => $this->from ?? '',
36+
'to' => $this->to ?? ''
4037
], 'strlen');
4138
}
4239
}

src/Operation/OperationResponseCollection.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php
22
namespace Getresponse\Sdk\Client\Operation;
33

4+
use Traversable;
5+
46
/**
57
* Class OperationResponseCollection
68
* @package Getresponse\Sdk\Client\Operation
@@ -32,7 +34,7 @@ public function __construct(array $operations, array $succeeded, array $failed)
3234
/**
3335
* @return \ArrayIterator | OperationResponse[]
3436
*/
35-
public function getIterator()
37+
public function getIterator(): Traversable
3638
{
3739
return new \ArrayIterator($this->operations);
3840
}

src/Version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
*/
99
class Version
1010
{
11-
const VERSION = '1.1.1';
11+
const VERSION = '2.0.0';
1212
}

tests/FunctionMock/FunctionMockFactory.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
namespace Getresponse\Sdk\Client\Test\FunctionMock;
33

44
use phpmock\MockBuilder;
5+
use SebastianBergmann\Template\Template;
56

67
/**
78
* Class FunctionMock
@@ -27,7 +28,7 @@ public static function create($namespace, $name, callable $callback = null)
2728
'invokeSignatureParameters' => $parameterBuilder->getSignatureParameters(),
2829
'bodyParameters' => $parameterBuilder->getBodyParameters(),
2930
];
30-
$template = new \Text_Template(__DIR__ . '/functionMockClassTemplate.tpl');
31+
$template = new Template(__DIR__ . '/functionMockClassTemplate.tpl');
3132
$template->setVar($data, false);
3233
$definition = $template->render();
3334
eval($definition);
@@ -66,7 +67,7 @@ private static function createDefaultCallbackDefinition($namespace, $name, Param
6667
'signatureParameters' => $parameterBuilder->getSignatureParameters(),
6768
'bodyParameters' => $parameterBuilder->getBodyParameters(),
6869
];
69-
$template = new \Text_Template(__DIR__ . '/function.tpl');
70+
$template = new Template(__DIR__ . '/function.tpl');
7071
$template->setVar($data, false);
7172
return $template->render();
7273
}

tests/FunctionMock/ParameterBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ private function buildParameterSignature(\ReflectionParameter $reflectionParamet
6161
if ($reflectionParameter->isDefaultValueAvailable()) {
6262
$defaultValue = $reflectionParameter->getDefaultValue();
6363
}
64-
return sprintf('%s = %s', $parameter, $defaultValue);
64+
return sprintf('%s = "%s"', $parameter, $defaultValue);
6565
}
6666

6767
/**

tests/Unit/Debugger/DataCollectorTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,20 @@
66
use GuzzleHttp\Psr7\Request;
77
use GuzzleHttp\Psr7\Response;
88
use GuzzleHttp\Psr7\Uri;
9+
use PHPUnit\Framework\TestCase;
910

1011
/**
1112
* Class DataCollectorTest
1213
* @package Getresponse\Sdk\Client\Test\Unit\Debugger
1314
*/
14-
class DataCollectorTest extends \PHPUnit_Framework_TestCase
15+
class DataCollectorTest extends TestCase
1516
{
1617
/**
1718
* @var DataCollector
1819
*/
1920
private $systemUnderTest;
2021

21-
protected function setUp()
22+
protected function setUp(): void
2223
{
2324
$this->systemUnderTest = new DataCollector();
2425
}
@@ -408,4 +409,4 @@ private function assertRequest(array $call, Request $request, array $requestHead
408409
static::assertEmpty($call['request']['body']);
409410
}
410411
}
411-
}
412+
}

tests/Unit/Debugger/DebugLoggerTest.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,29 @@
77
use GuzzleHttp\Psr7\Request;
88
use GuzzleHttp\Psr7\Response;
99
use GuzzleHttp\Psr7\Uri;
10+
use PHPUnit\Framework\MockObject\MockObject;
11+
use PHPUnit\Framework\TestCase;
1012
use Psr\Log\LogLevel;
1113

1214
/**
1315
* Class DebugLoggerTest
1416
* @package Getresponse\Sdk\Client\Test\Unit\Debugger
1517
*/
16-
class DebugLoggerTest extends \PHPUnit_Framework_TestCase
18+
class DebugLoggerTest extends TestCase
1719
{
1820
/**
1921
* @var DebugLogger
2022
*/
2123
private $systemUnderTest;
2224

2325
/**
24-
* @var DataCollector | \PHPUnit_Framework_MockObject_MockObject
26+
* @var DataCollector|MockObject
2527
*/
2628
private $dataCollectorMock;
2729

28-
protected function setUp()
30+
protected function setUp(): void
2931
{
30-
$this->dataCollectorMock = $this
31-
->getMockBuilder(DataCollector::class)
32-
->disableOriginalConstructor()
33-
->getMock();
32+
$this->dataCollectorMock = $this->createMock(DataCollector::class);
3433
$this->systemUnderTest = new DebugLogger($this->dataCollectorMock);
3534
}
3635

@@ -44,7 +43,7 @@ public function shouldAddRequestToDataCollector()
4443
$this->dataCollectorMock
4544
->expects(static::once())
4645
->method('collectRequest')
47-
->withConsecutive($this->equalTo($request));
46+
->withConsecutive([$this->equalTo($request)]);
4847

4948
$this->systemUnderTest->debug('log message', [
5049
'request' => $request,
@@ -67,12 +66,12 @@ public function shouldAddContextToDataCollector()
6766
$this->dataCollectorMock
6867
->expects(static::once())
6968
->method('collectResponse')
70-
->withConsecutive($this->equalTo([$response, $request, $info]));
69+
->withConsecutive([$this->equalTo($response), $this->equalTo($request), $this->equalTo($info)]);
7170

7271
$this->systemUnderTest->log(LogLevel::DEBUG, 'log message', [
7372
'request' => $request,
7473
'response' => $response,
7574
'info' => $info,
7675
]);
7776
}
78-
}
77+
}

tests/Unit/Debugger/DebuggerTest.php

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,28 @@
55
use Getresponse\Sdk\Client\Debugger\DebugDumper;
66
use Getresponse\Sdk\Client\Debugger\Debugger;
77
use Getresponse\Sdk\Client\Debugger\Formatter;
8+
use PHPUnit\Framework\MockObject\MockObject;
9+
use PHPUnit\Framework\TestCase;
810

911
/**
1012
* Class DebuggerTest
1113
* @package Getresponse\Sdk\Client\Test\Unit\Debugger
1214
*/
13-
class DebuggerTest extends \PHPUnit_Framework_TestCase
15+
class DebuggerTest extends TestCase
1416
{
1517
/**
1618
* @var Debugger
1719
*/
1820
private $systemUnderTest;
1921

2022
/**
21-
* @var DataCollector | \PHPUnit_Framework_MockObject_MockObject
23+
* @var DataCollector|MockObject
2224
*/
2325
private $dataCollectorMock;
2426

25-
protected function setUp()
27+
protected function setUp(): void
2628
{
27-
$this->dataCollectorMock = $this
28-
->getMockBuilder(DataCollector::class)
29-
->disableOriginalConstructor()
30-
->getMock();
29+
$this->dataCollectorMock = $this->createMock(DataCollector::class);
3130
$this->systemUnderTest = new Debugger($this->dataCollectorMock);
3231
}
3332

@@ -43,19 +42,19 @@ public function shouldDebug()
4342
->willReturn($debugData);
4443

4544
$formattedDebugData = '{"data":[]}';
46-
$formatterMock = $this->getMockBuilder(Formatter::class)->getMock();
45+
$formatterMock = $this->createMock(Formatter::class);
4746
$formatterMock
4847
->expects(static::once())
4948
->method('format')
50-
->withConsecutive($this->equalTo($debugData))
49+
->withConsecutive([$this->equalTo($debugData)])
5150
->willReturn($formattedDebugData);
5251

53-
$debugDumperMock = $this->getMockBuilder(DebugDumper::class)->getMock();
52+
$debugDumperMock = $this->createMock(DebugDumper::class);
5453
$debugDumperMock
5554
->expects(static::once())
5655
->method('dump')
57-
->withConsecutive($this->equalTo($formattedDebugData));
56+
->withConsecutive([$this->equalTo($formattedDebugData)]);
5857

5958
$this->systemUnderTest->debug($formatterMock, $debugDumperMock);
6059
}
61-
}
60+
}

tests/Unit/Debugger/DisplayDebugDumperTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@
22
namespace Getresponse\Sdk\Client\Test\Unit\Debugger;
33

44
use Getresponse\Sdk\Client\Debugger\DisplayDebugDumper;
5+
use PHPUnit\Framework\TestCase;
56

67
/**
78
* Class DisplayDebugDumperTest
89
* @package Getresponse\Sdk\Client\Test\Unit\Debugger
910
*/
10-
class DisplayDebugDumperTest extends \PHPUnit_Framework_TestCase
11+
class DisplayDebugDumperTest extends TestCase
1112
{
1213
/**
1314
* @var DisplayDebugDumper
1415
*/
1516
private $systemUnderTest;
1617

17-
protected function setUp()
18+
protected function setUp(): void
1819
{
1920
$this->systemUnderTest = new DisplayDebugDumper();
2021
}

tests/Unit/Debugger/FileDebugDumperTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,28 @@
44
use Getresponse\Sdk\Client\Debugger\FileDebugDumper;
55
use Getresponse\Sdk\Client\Test\FunctionMock\FunctionMockRegistry;
66
use Getresponse\Sdk\Client\Test\FunctionMock\MockBuilder;
7+
use PHPUnit\Framework\TestCase;
78

89
/**
910
* Class FileDebugDumperTest
1011
* @package Getresponse\Sdk\Client\Test\Unit\Debugger
1112
*/
12-
class FileDebugDumperTest extends \PHPUnit_Framework_TestCase
13+
class FileDebugDumperTest extends TestCase
1314
{
1415
const DEBUG_DUMPER_NAMESPACE = 'Getresponse\Sdk\Client\Debugger';
1516

1617
/**
1718
* @inheritDoc
1819
*/
19-
protected function setUp()
20+
protected function setUp(): void
2021
{
2122
FunctionMockRegistry::resetAll();
2223
}
2324

2425
/**
2526
* @inheritDoc
2627
*/
27-
protected function tearDown()
28+
protected function tearDown(): void
2829
{
2930
FunctionMockRegistry::resetAll();
3031
}
@@ -47,10 +48,10 @@ public function shouldDisplay()
4748

4849
/**
4950
* @test
50-
* @expectedException \InvalidArgumentException
5151
*/
5252
public function shouldThrowExceptionWhenInvalidDir()
5353
{
54+
$this->expectException(\InvalidArgumentException::class);
5455
new FileDebugDumper('somename');
5556
}
5657
}

0 commit comments

Comments
 (0)