Skip to content
Open
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
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,34 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## 2.9.0

### Added
- PHP 8.1, 8.2, 8.3 and PHP 9.0 compatibility
- PHPUnit 9.6 support for modern testing
- Explicit nullable parameter type declarations (PHP 8.1+ requirement)
- Array return type declarations for EventSubscriber implementations
- Null safety checks for `substr()` calls to prevent deprecation warnings

### Changed
- Updated minimum PHP version from >=5.5 to >=7.1 (required for nullable types)
- Updated PHPUnit from 4.8 to 9.6
- Updated all test files to PHPUnit 9 syntax
- Added `ext-mbstring` as dev dependency for PHPUnit 9

### Fixed
- Fixed implicit nullable parameter deprecation warnings in PHP 8.1+
- Fixed `EventDispatcher::dispatch()` nullable parameter
- Fixed `WalletClient::finalizePayment()` nullable parameter
- Fixed `WalletClient::getWalletStatements()` nullable parameter
- Fixed `WalletClient::getLocations()` nullable parameter
- Fixed `TokenRelatedWalletClient::getCurrentWalletStatements()` nullable parameter
- Fixed `LocationManager::isLocationOpen()` nullable parameter
- Fixed `Router::resolveEndpointPath()` to properly handle null path parameter
- Fixed `EndpointSetter::onBeforeRequest()` substr() null safety
- Fixed missing return type declarations in EventSubscriber interface and implementations
- Fixed all PHPUnit deprecations in test suite

## 2.8.0
- Added owner type to wallet account entity

Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
"psr-0": { "Paysera_WalletApi": "src/" }
},
"require-dev": {
"phpunit/phpunit": "^4.7"
"phpunit/phpunit": "^9.5",
"ext-mbstring": "*"
},
"require": {
"php": ">=5.5 || >=7.0",
"php": ">=7.1",
"ext-json": "*",
"paysera/lib-wallet-transfer-rest-client": "^0.2.0"
}
Expand Down
1 change: 0 additions & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
convertWarningsToExceptions = "true"
processIsolation = "false"
stopOnFailure = "false"
syntaxCheck = "false"
bootstrap = "./tests/bootstrap.php">
<testsuites>
<testsuite name="Project Test Suite">
Expand Down
2 changes: 1 addition & 1 deletion src/Paysera/WalletApi/Callback/EventSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ abstract class Paysera_WalletApi_Callback_EventSubscriber
implements Paysera_WalletApi_EventDispatcher_EventSubscriberInterface
{

public static function getSubscribedEvents()
public static function getSubscribedEvents(): array
{
return array(
'transaction.failed' => 'onTransactionFailed',
Expand Down
2 changes: 1 addition & 1 deletion src/Paysera/WalletApi/Client/TokenRelatedWalletClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function acceptTransactionUsingCurrentPin($transactionKey, $pin, $fundsSo
*
* @return Paysera_WalletApi_Entity_Search_Result|Paysera_WalletApi_Entity_Statement[]
*/
public function getCurrentWalletStatements(Paysera_WalletApi_Entity_Statement_SearchFilter $filter = null)
public function getCurrentWalletStatements(?Paysera_WalletApi_Entity_Statement_SearchFilter $filter = null)
{
return $this->getWalletStatements('me', $filter);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Paysera/WalletApi/Client/WalletClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public function changeFreezePeriod($paymentId, DateTime $freezeUntil)
*
* @throws Paysera_WalletApi_Exception_ApiException
*/
public function finalizePayment($paymentId, Paysera_WalletApi_Entity_Money $finalPrice = null)
public function finalizePayment($paymentId, ?Paysera_WalletApi_Entity_Money $finalPrice = null)
{
Paysera_WalletApi_Util_Assert::isInt($paymentId);

Expand Down Expand Up @@ -496,7 +496,7 @@ public function getWalletBalance($walletId)
*
* @throws Paysera_WalletApi_Exception_ApiException
*/
public function getWalletStatements($walletId, Paysera_WalletApi_Entity_Statement_SearchFilter $filter = null)
public function getWalletStatements($walletId, ?Paysera_WalletApi_Entity_Statement_SearchFilter $filter = null)
{
Paysera_WalletApi_Util_Assert::isId($walletId);
if ($filter !== null) {
Expand Down Expand Up @@ -798,7 +798,7 @@ public function getProjectLocations(
* @param Paysera_WalletApi_Entity_Location_SearchFilter $filter
* @return Paysera_WalletApi_Entity_Search_Result|Paysera_WalletApi_Entity_Location[]
*/
public function getLocations(Paysera_WalletApi_Entity_Location_SearchFilter $filter = null)
public function getLocations(?Paysera_WalletApi_Entity_Location_SearchFilter $filter = null)
{
if ($filter !== null) {
$query = '?' . http_build_query($this->mapper->encodeLocationFilter($filter), null, '&');
Expand Down
2 changes: 1 addition & 1 deletion src/Paysera/WalletApi/EventDispatcher/EventDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function __construct(array $listeners = array())
*
* @return boolean whether at least one listener was registered
*/
public function dispatch($eventName, Paysera_WalletApi_EventDispatcher_Event $event = null)
public function dispatch($eventName, ?Paysera_WalletApi_EventDispatcher_Event $event = null)
{
if (null === $event) {
$event = new Paysera_WalletApi_EventDispatcher_Event();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ interface Paysera_WalletApi_EventDispatcher_EventSubscriberInterface
*
* @return array
*/
public static function getSubscribedEvents();
public static function getSubscribedEvents(): array;
}
2 changes: 1 addition & 1 deletion src/Paysera/WalletApi/Listener/AppendHeadersListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function onBeforeRequest(Paysera_WalletApi_Event_RequestEvent $event)
}
}

public static function getSubscribedEvents()
public static function getSubscribedEvents(): array
{
return array(
Paysera_WalletApi_Events::BEFORE_REQUEST => array('onBeforeRequest', 100),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function onTokenRefresh(Paysera_WalletApi_Event_MacAccessTokenEvent $even
// implement in subclasses
}

public static function getSubscribedEvents()
public static function getSubscribedEvents(): array
{
return array(
Paysera_WalletApi_Events::AFTER_OAUTH_TOKEN_REFRESH => 'onTokenRefresh',
Expand Down
4 changes: 2 additions & 2 deletions src/Paysera/WalletApi/Listener/EndpointSetter.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ public function __construct($endpoint)
public function onBeforeRequest(Paysera_WalletApi_Event_RequestEvent $event)
{
$uri = $event->getRequest()->getFullUri();
if (substr($uri, 0, 7) !== 'http://' && substr($uri, 0, 8) !== 'https://') {
if ($uri !== null && substr($uri, 0, 7) !== 'http://' && substr($uri, 0, 8) !== 'https://') {
$event->getRequest()->setFullUri($this->endpoint . $uri);
}
}

public static function getSubscribedEvents()
public static function getSubscribedEvents(): array
{
return array(
Paysera_WalletApi_Events::BEFORE_REQUEST => array('onBeforeRequest', 100),
Expand Down
2 changes: 1 addition & 1 deletion src/Paysera/WalletApi/Listener/InvalidResponseListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function onResponseException(Paysera_WalletApi_Event_ResponseExceptionEve
}
}

public static function getSubscribedEvents()
public static function getSubscribedEvents(): array
{
return array(
Paysera_WalletApi_Events::ON_RESPONSE_EXCEPTION => 'onResponseException',
Expand Down
2 changes: 1 addition & 1 deletion src/Paysera/WalletApi/Listener/OAuthRequestSigner.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function getToken()
return $this->token;
}

public static function getSubscribedEvents()
public static function getSubscribedEvents(): array
{
return parent::getSubscribedEvents() + array(
Paysera_WalletApi_Events::ON_RESPONSE_EXCEPTION => 'onResponseException',
Expand Down
2 changes: 1 addition & 1 deletion src/Paysera/WalletApi/Listener/ParameterSetter.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function onBeforeRequest(Paysera_WalletApi_Event_RequestEvent $event)
$event->setOptions($options);
}

public static function getSubscribedEvents()
public static function getSubscribedEvents(): array
{
return array(
Paysera_WalletApi_Events::BEFORE_REQUEST => array('onBeforeRequest', 100),
Expand Down
2 changes: 1 addition & 1 deletion src/Paysera/WalletApi/Listener/RequestSigner.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function onBeforeRequest(Paysera_WalletApi_Event_RequestEvent $event)
$this->signer->signRequest($event->getRequest(), $parameters);
}

public static function getSubscribedEvents()
public static function getSubscribedEvents(): array
{
return array(
Paysera_WalletApi_Events::BEFORE_REQUEST => array('onBeforeRequest', -100),
Expand Down
2 changes: 1 addition & 1 deletion src/Paysera/WalletApi/Service/LocationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Paysera_WalletApi_Service_LocationManager
* @param DateTime $date
* @return bool
*/
public function isLocationOpen(Paysera_WalletApi_Entity_Location $location, DateTime $date = null)
public function isLocationOpen(Paysera_WalletApi_Entity_Location $location, ?DateTime $date = null)
{
if (count($location->getWorkingHours()) === 0) {
return false;
Expand Down
3 changes: 3 additions & 0 deletions src/Paysera/WalletApi/Util/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ protected function getLanguagePrefix($lang = null)
*/
private function resolveEndpointPath($endpoint, $path)
{
if ($path === null) {
return $endpoint;
}
if (substr($path, 0, 7) !== 'http://' && substr($path, 0, 8) !== 'https://') {
return $endpoint . $path;
} else {
Expand Down
15 changes: 7 additions & 8 deletions tests/Paysera/WalletApi/Auth/MacTest.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
<?php

class Paysera_WalletApi_Auth_MacTest extends PHPUnit_Framework_TestCase
class Paysera_WalletApi_Auth_MacTest extends PHPUnit\Framework\TestCase
{
protected $service;

/** @var Paysera_WalletApi_Auth_Mac|PHPUnit_Framework_MockObject_MockObject */
/** @var Paysera_WalletApi_Auth_Mac|PHPUnit\Framework\MockObject\MockObject */
protected $mock;

public function setUp()
public function setUp(): void
{
$this->service = new Paysera_WalletApi_Auth_Mac('wkVd93h2uS', 'IrdTc8uQodU7PRpLzzLTW6wqZAO6tAMU');

$this->mock = $this->getMock(
'Paysera_WalletApi_Auth_Mac',
array('getTimestamp', 'generateNonce'),
array('wkVd93h2uS', 'IrdTc8uQodU7PRpLzzLTW6wqZAO6tAMU')
);
$this->mock = $this->getMockBuilder('Paysera_WalletApi_Auth_Mac')
->setConstructorArgs(array('wkVd93h2uS', 'IrdTc8uQodU7PRpLzzLTW6wqZAO6tAMU'))
->onlyMethods(array('getTimestamp', 'generateNonce'))
->getMock();
$this->mock->expects($this->any())->method('getTimestamp')->will($this->returnValue('1343818800'));
$this->mock->expects($this->any())->method('generateNonce')->will($this->returnValue('nQnNaSNyubfPErjRO55yaaEYo9YZfKHN'));
}
Expand Down
8 changes: 4 additions & 4 deletions tests/Paysera/WalletApi/Callback/SignCheckerTest.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<?php

class Paysera_WalletApi_Callback_SignCheckerTest extends PHPUnit_Framework_TestCase
class Paysera_WalletApi_Callback_SignCheckerTest extends PHPUnit\Framework\TestCase
{
/**
* @var Paysera_WalletApi_Callback_SignChecker
*/
protected $service;

/**
* @var PHPUnit_Framework_MockObject_MockObject|Paysera_WalletApi_Http_ClientInterface
* @var PHPUnit\Framework\MockObject\MockObject|Paysera_WalletApi_Http_ClientInterface
*/
protected $webClient;

public function setUp()
public function setUp(): void
{
$this->webClient = $this->getMock('Paysera_WalletApi_Http_ClientInterface');
$this->webClient = $this->createMock('Paysera_WalletApi_Http_ClientInterface');
$this->service = new Paysera_WalletApi_Callback_SignChecker('http://publickey.abc', $this->webClient);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

class Paysera_WalletApi_Client_BasicClientTest extends PHPUnit_Framework_TestCase
class Paysera_WalletApi_Client_BasicClientTest extends PHPUnit\Framework\TestCase
{
/**
* @dataProvider test_makeRequest_correctly_handles_makeRequest_return_value_provider
Expand All @@ -14,16 +14,16 @@ public function test_makeRequest_correctly_handles_webClient_makeRequest_corrupt
$status,
$content
) {
$webClient = $this->getMock('\Paysera_WalletApi_Http_ClientInterface', array('makeRequest'));
$webClient = $this->createMock('\Paysera_WalletApi_Http_ClientInterface', array('makeRequest'));
$webClient->expects($this->any())->method('makeRequest')->will($this->returnValue(
new Paysera_WalletApi_Http_Response($status, array(), $content)
));
$basicClient = new Paysera_WalletApi_Client_BasicClient(
$webClient,
$this->getMock('\Paysera_WalletApi_EventDispatcher_EventDispatcher')
$this->createMock('\Paysera_WalletApi_EventDispatcher_EventDispatcher')
);

$this->setExpectedException('\Paysera_WalletApi_Exception_ApiException');
$this->expectException('\Paysera_WalletApi_Exception_ApiException');
$basicClient->makeRequest(
new Paysera_WalletApi_Http_Request(
'http://example.com/',
Expand Down
2 changes: 1 addition & 1 deletion tests/Paysera/WalletApi/Entity/HostTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php


class Paysera_WalletApi_Entity_HostTest extends PHPUnit_Framework_TestCase
class Paysera_WalletApi_Entity_HostTest extends PHPUnit\Framework\TestCase
{

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

class Paysera_WalletApi_Listener_AppendHeadersListenerTest extends PHPUnit_Framework_TestCase
class Paysera_WalletApi_Listener_AppendHeadersListenerTest extends PHPUnit\Framework\TestCase
{
public function testHeadersIsDefined()
{
Expand Down
10 changes: 5 additions & 5 deletions tests/Paysera/WalletApi/Listener/InvalidResponseListenerTest.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

class Paysera_WalletApi_Listener_InvalidResponseListenerTest extends PHPUnit_Framework_TestCase
class Paysera_WalletApi_Listener_InvalidResponseListenerTest extends PHPUnit\Framework\TestCase
{

/**
* @var PHPUnit_Framework_MockObject_MockObject|Paysera_WalletApi_Http_ClientInterface
* @var PHPUnit\Framework\MockObject\MockObject|Paysera_WalletApi_Http_ClientInterface
*/
protected $webClient;

Expand All @@ -16,9 +16,9 @@ class Paysera_WalletApi_Listener_InvalidResponseListenerTest extends PHPUnit_Fra
/**
* Set up
*/
public function setUp()
public function setUp(): void
{
$this->webClient = $this->getMock('Paysera_WalletApi_Http_ClientInterface');
$this->webClient = $this->createMock('Paysera_WalletApi_Http_ClientInterface');

$dispatcher = new Paysera_WalletApi_EventDispatcher_EventDispatcher();
$dispatcher->addSubscriber(new Paysera_WalletApi_Listener_InvalidResponseListener());
Expand Down Expand Up @@ -87,7 +87,7 @@ public function testDoubleInvalidResponse()
'
)));

$this->setExpectedException('Paysera_WalletApi_Exception_ResponseException');
$this->expectException('Paysera_WalletApi_Exception_ResponseException');
$this->service->makeRequest(new Paysera_WalletApi_Http_Request(''));
}

Expand Down
Loading