From a71432ca3c0f0902189b612e54928dcecdbfa9a5 Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Tue, 3 May 2022 17:53:08 +0200 Subject: [PATCH] feat: WIP drop support of php < 8, update phpunit 5/8 => 9 --- src/Payum/Core/Action/ActionInterface.php | 13 +- .../Core/Action/AuthorizePaymentAction.php | 4 +- .../Core/Action/CapturePaymentAction.php | 5 +- ...ecuteSameRequestWithModelDetailsAction.php | 4 +- src/Payum/Core/Action/GetCurrencyAction.php | 11 +- src/Payum/Core/Action/GetTokenAction.php | 18 +- src/Payum/Core/Action/PayoutPayoutAction.php | 4 +- src/Payum/Core/ApiAwareInterface.php | 4 +- src/Payum/Core/ApiAwareTrait.php | 12 +- .../Bridge/Defuse/Security/DefuseCypher.php | 12 +- .../Doctrine/Storage/DoctrineStorage.php | 22 +- .../Core/Bridge/Doctrine/Types/ObjectType.php | 2 +- src/Payum/Core/Bridge/Guzzle/HttpClient.php | 17 +- .../Core/Bridge/Guzzle/HttpClientFactory.php | 13 +- .../Core/Bridge/Httplug/HttplugClient.php | 17 +- .../Laminas/Storage/TableGatewayStorage.php | 22 +- .../PlainPhp/Action/GetHttpRequestAction.php | 10 +- .../Psr/Log/LogExecutedActionsExtension.php | 12 +- .../Bridge/Symfony/ContainerAwareRegistry.php | 2 +- src/Payum/Core/CoreGatewayFactory.php | 39 +--- src/Payum/Core/Debug/Humanify.php | 14 +- .../Core/Exception/Http/HttpException.php | 27 +-- .../Exception/Http/HttpExceptionInterface.php | 24 +- .../RequestNotSupportedException.php | 45 +--- src/Payum/Core/Extension/Context.php | 80 +------ .../EndlessCycleDetectorExtension.php | 20 +- .../Core/Extension/ExtensionCollection.php | 16 +- .../Core/Extension/ExtensionInterface.php | 15 +- .../GenericTokenFactoryExtension.php | 20 +- src/Payum/Core/Extension/StorageExtension.php | 24 +- src/Payum/Core/Gateway.php | 45 +--- src/Payum/Core/GatewayAwareInterface.php | 2 +- src/Payum/Core/GatewayAwareTrait.php | 7 +- src/Payum/Core/GatewayFactory.php | 25 +- src/Payum/Core/GatewayFactoryInterface.php | 14 +- src/Payum/Core/GatewayInterface.php | 7 +- src/Payum/Core/HttpClientInterface.php | 7 +- src/Payum/Core/ISO4217/Currency.php | 36 +-- src/Payum/Core/Model/ArrayObject.php | 20 +- src/Payum/Core/Model/BankAccount.php | 83 ++----- src/Payum/Core/Model/BankAccountInterface.php | 60 +---- src/Payum/Core/Model/CreditCard.php | 50 ++-- src/Payum/Core/Model/CreditCardInterface.php | 65 ++---- .../Core/Model/CreditCardPaymentInterface.php | 5 +- .../Core/Model/DetailsAggregateInterface.php | 5 +- .../Core/Model/DetailsAwareInterface.php | 7 +- .../Model/DirectDebitPaymentInterface.php | 5 +- src/Payum/Core/Model/GatewayConfig.php | 33 +-- .../Core/Model/GatewayConfigInterface.php | 24 +- src/Payum/Core/Model/Identity.php | 30 +-- .../Core/Model/ModelAggregateInterface.php | 5 +- src/Payum/Core/Model/ModelAwareInterface.php | 7 +- src/Payum/Core/Model/Payment.php | 4 +- src/Payum/Core/Model/PaymentInterface.php | 30 +-- src/Payum/Core/Model/Payout.php | 4 +- src/Payum/Core/Model/PayoutInterface.php | 25 +- src/Payum/Core/Model/Token.php | 39 +--- src/Payum/Core/Payum.php | 65 ++---- src/Payum/Core/PayumBuilder.php | 218 ++++-------------- src/Payum/Core/Registry/AbstractRegistry.php | 45 +--- src/Payum/Core/Registry/DynamicRegistry.php | 40 +--- src/Payum/Core/Registry/FallbackRegistry.php | 2 +- .../GatewayFactoryRegistryInterface.php | 12 +- .../Registry/GatewayRegistryInterface.php | 8 +- src/Payum/Core/Registry/SimpleRegistry.php | 19 +- .../Registry/StorageRegistryInterface.php | 8 +- src/Payum/Core/Reply/BaseModelAware.php | 20 +- src/Payum/Core/Reply/HttpPostRedirect.php | 33 +-- src/Payum/Core/Reply/HttpRedirect.php | 21 +- src/Payum/Core/Reply/HttpResponse.php | 28 +-- src/Payum/Core/Request/BaseGetStatus.php | 5 +- src/Payum/Core/Request/Convert.php | 55 +---- src/Payum/Core/Request/Generic.php | 42 +--- src/Payum/Core/Request/GetBinaryStatus.php | 51 ++-- src/Payum/Core/Request/GetCreditCardToken.php | 7 +- src/Payum/Core/Request/GetCurrency.php | 32 +-- src/Payum/Core/Request/GetHttpRequest.php | 47 ++-- src/Payum/Core/Request/GetHumanStatus.php | 73 +++--- src/Payum/Core/Request/GetToken.php | 28 +-- src/Payum/Core/Request/ObtainCreditCard.php | 19 +- src/Payum/Core/Request/RenderTemplate.php | 53 +---- .../Core/Security/AbstractTokenFactory.php | 36 +-- src/Payum/Core/Security/CryptedInterface.php | 14 +- src/Payum/Core/Security/CypherInterface.php | 12 +- .../Core/Security/GenericTokenFactory.php | 32 +-- .../GenericTokenFactoryAwareInterface.php | 7 +- .../GenericTokenFactoryAwareTrait.php | 12 +- .../Security/GenericTokenFactoryInterface.php | 48 +--- .../Security/HttpRequestVerifierInterface.php | 10 +- src/Payum/Core/Security/SensitiveValue.php | 41 +--- .../Core/Security/TokenAggregateInterface.php | 5 +- .../Core/Security/TokenFactoryInterface.php | 18 +- src/Payum/Core/Security/TokenInterface.php | 54 ++--- src/Payum/Core/Security/Util/Mask.php | 9 +- src/Payum/Core/Security/Util/Random.php | 4 +- .../Security/Util/RequestTokenVerifier.php | 7 +- src/Payum/Core/Storage/AbstractStorage.php | 42 +--- .../Core/Storage/CryptoStorageDecorator.php | 18 +- src/Payum/Core/Storage/FilesystemStorage.php | 32 +-- src/Payum/Core/Storage/IdentityInterface.php | 10 +- src/Payum/Core/Storage/StorageInterface.php | 26 +-- .../Action/AuthorizePaymentActionTest.php | 10 +- .../Tests/Action/CapturePaymentActionTest.php | 42 ++-- ...eSameRequestWithModelDetailsActionTest.php | 8 +- .../Tests/Action/GatewayAwareActionTest.php | 4 +- .../Tests/Action/GetCurrencyActionTest.php | 10 +- .../Core/Tests/Action/GetTokenActionTest.php | 6 +- .../Tests/Action/PayoutPayoutActionTest.php | 48 ++-- .../Defuse/Security/DefuseCypherTest.php | 4 +- .../Doctrine/Storage/DoctrineStorageTest.php | 22 +- .../Bridge/Guzzle/HttpClientFactoryTest.php | 2 +- .../Action/GetHttpRequestActionTest.php | 2 +- .../Security/HttpRequestVerifierTest.php | 33 ++- .../PlainPhp/Security/TokenFactoryTest.php | 80 +++---- .../Propel/Storage/Propel1StorageTest.php | 10 +- .../Propel/Storage/Propel2StorageTest.php | 16 +- .../Log/LogExecutedActionsExtensionTest.php | 48 ++-- .../Bridge/Psr/Log/LoggerExtensionTest.php | 34 ++- .../Core/Tests/Bridge/Spl/ArrayObjectTest.php | 79 +++---- src/Payum/Core/Tests/Debug/HumanifyTest.php | 20 +- .../Http/HttpExceptionInterfaceTest.php | 2 +- .../Exception/Http/HttpExceptionTest.php | 14 +- .../InvalidArgumentExceptionExceptionTest.php | 4 +- .../Tests/Exception/LogicExceptionTest.php | 4 +- .../RequestNotSupportedExceptionTest.php | 16 +- .../Tests/Exception/RuntimeExceptionTest.php | 4 +- .../Exception/UnsupportedApiExceptionTest.php | 2 +- .../EndlessCycleDetectorExtensionTest.php | 8 +- .../Extension/ExtensionCollectionTest.php | 24 +- .../GenericTokenFactoryExtensionTest.php | 14 +- .../Tests/Extension/StorageExtensionTest.php | 44 ++-- .../Request/Api/CreateTokenForCreditCard.php | 2 +- 132 files changed, 869 insertions(+), 2287 deletions(-) diff --git a/src/Payum/Core/Action/ActionInterface.php b/src/Payum/Core/Action/ActionInterface.php index 20602d5e1..df594d36a 100644 --- a/src/Payum/Core/Action/ActionInterface.php +++ b/src/Payum/Core/Action/ActionInterface.php @@ -4,16 +4,9 @@ interface ActionInterface { /** - * @param mixed $request - * - * @throws \Payum\Core\Exception\RequestNotSupportedException if the action dose not support the request. + * @throws \Payum\Core\Exception\RequestNotSupportedException if the action does not support the request. */ - public function execute($request); + public function execute(mixed $request): void; - /** - * @param mixed $request - * - * @return boolean - */ - public function supports($request); + public function supports(mixed $request): bool; } diff --git a/src/Payum/Core/Action/AuthorizePaymentAction.php b/src/Payum/Core/Action/AuthorizePaymentAction.php index 77503e2e3..e659b7e4f 100644 --- a/src/Payum/Core/Action/AuthorizePaymentAction.php +++ b/src/Payum/Core/Action/AuthorizePaymentAction.php @@ -19,7 +19,7 @@ class AuthorizePaymentAction implements ActionInterface, GatewayAwareInterface * * @param Authorize $request */ - public function execute($request) + public function execute($request): void { RequestNotSupportedException::assertSupports($this, $request); @@ -46,7 +46,7 @@ public function execute($request) /** * {@inheritDoc} */ - public function supports($request) + public function supports($request): bool { return $request instanceof Authorize && diff --git a/src/Payum/Core/Action/CapturePaymentAction.php b/src/Payum/Core/Action/CapturePaymentAction.php index 00d044643..fe5aa6efa 100644 --- a/src/Payum/Core/Action/CapturePaymentAction.php +++ b/src/Payum/Core/Action/CapturePaymentAction.php @@ -16,10 +16,9 @@ class CapturePaymentAction implements ActionInterface, GatewayAwareInterface /** * {@inheritDoc} - * * @param Capture $request */ - public function execute($request) + public function execute($request): void { RequestNotSupportedException::assertSupports($this, $request); @@ -46,7 +45,7 @@ public function execute($request) /** * {@inheritDoc} */ - public function supports($request) + public function supports($request): bool { return $request instanceof Capture && diff --git a/src/Payum/Core/Action/ExecuteSameRequestWithModelDetailsAction.php b/src/Payum/Core/Action/ExecuteSameRequestWithModelDetailsAction.php index 992b18053..01c4ad9ba 100644 --- a/src/Payum/Core/Action/ExecuteSameRequestWithModelDetailsAction.php +++ b/src/Payum/Core/Action/ExecuteSameRequestWithModelDetailsAction.php @@ -19,7 +19,7 @@ class ExecuteSameRequestWithModelDetailsAction implements ActionInterface, Gatew * * @param ModelAggregateInterface|ModelAwareInterface $request */ - public function execute($request) + public function execute($request): void { RequestNotSupportedException::assertSupports($this, $request); @@ -44,7 +44,7 @@ public function execute($request) /** * {@inheritDoc} */ - public function supports($request) + public function supports($request): bool { return $request instanceof ModelAggregateInterface && diff --git a/src/Payum/Core/Action/GetCurrencyAction.php b/src/Payum/Core/Action/GetCurrencyAction.php index c5b2c6caa..cdcba8a10 100644 --- a/src/Payum/Core/Action/GetCurrencyAction.php +++ b/src/Payum/Core/Action/GetCurrencyAction.php @@ -12,13 +12,10 @@ class GetCurrencyAction implements ActionInterface * @var ISO4217 * @deprecated The iso4217 property is deprecated and will be removed in v2 */ - protected $iso4217; + protected mixed $iso4217; - private $usePayumIso4217 = false; + private bool $usePayumIso4217 = false; - /** - * @param ISO4217 $iso4217 - */ public function __construct(ISO4217 $iso4217 = null) { if ($iso4217 instanceof ISO4217) { @@ -34,7 +31,7 @@ public function __construct(ISO4217 $iso4217 = null) * * @param GetCurrency $request */ - public function execute($request) + public function execute($request): void { RequestNotSupportedException::assertSupports($this, $request); @@ -61,7 +58,7 @@ public function execute($request) /** * {@inheritDoc} */ - public function supports($request) + public function supports($request): bool { return $request instanceof GetCurrency && diff --git a/src/Payum/Core/Action/GetTokenAction.php b/src/Payum/Core/Action/GetTokenAction.php index 3b3a0f618..b27306729 100644 --- a/src/Payum/Core/Action/GetTokenAction.php +++ b/src/Payum/Core/Action/GetTokenAction.php @@ -8,25 +8,15 @@ class GetTokenAction implements ActionInterface { - /** - * @var StorageInterface - */ - private $tokenStorage; - - /** - * @param StorageInterface $tokenStorage - */ - public function __construct(StorageInterface $tokenStorage) - { - $this->tokenStorage = $tokenStorage; - } + public function __construct(private StorageInterface $tokenStorage) + {} /** * {@inheritDoc} * * @param $request GetToken */ - public function execute($request) + public function execute($request): void { RequestNotSupportedException::assertSupports($this, $request); @@ -40,7 +30,7 @@ public function execute($request) /** * {@inheritDoc} */ - public function supports($request) + public function supports($request): bool { return $request instanceof GetToken; } diff --git a/src/Payum/Core/Action/PayoutPayoutAction.php b/src/Payum/Core/Action/PayoutPayoutAction.php index b404eb573..6f28db8ff 100644 --- a/src/Payum/Core/Action/PayoutPayoutAction.php +++ b/src/Payum/Core/Action/PayoutPayoutAction.php @@ -19,7 +19,7 @@ class PayoutPayoutAction implements ActionInterface, GatewayAwareInterface * * @param Payout $request */ - public function execute($request) + public function execute($request): void { RequestNotSupportedException::assertSupports($this, $request); @@ -46,7 +46,7 @@ public function execute($request) /** * {@inheritDoc} */ - public function supports($request) + public function supports($request): bool { return $request instanceof Payout && diff --git a/src/Payum/Core/ApiAwareInterface.php b/src/Payum/Core/ApiAwareInterface.php index 16cf6f940..a00fa057e 100644 --- a/src/Payum/Core/ApiAwareInterface.php +++ b/src/Payum/Core/ApiAwareInterface.php @@ -6,9 +6,7 @@ interface ApiAwareInterface { /** - * @param mixed $api - * * @throws UnsupportedApiException if the given Api is not supported. */ - public function setApi($api); + public function setApi(mixed $api); } diff --git a/src/Payum/Core/ApiAwareTrait.php b/src/Payum/Core/ApiAwareTrait.php index b783b43e2..477c6684e 100644 --- a/src/Payum/Core/ApiAwareTrait.php +++ b/src/Payum/Core/ApiAwareTrait.php @@ -6,20 +6,14 @@ trait ApiAwareTrait { - /** - * @var mixed - */ - protected $api; + protected mixed $api; - /** - * @var string - */ - protected $apiClass; + protected string $apiClass; /** * {@inheritDoc} */ - public function setApi($api) + public function setApi($api): void { if (empty($this->apiClass)) { throw new LogicException(sprintf('You must configure apiClass in __constructor method of the class the trait is applied to.')); diff --git a/src/Payum/Core/Bridge/Defuse/Security/DefuseCypher.php b/src/Payum/Core/Bridge/Defuse/Security/DefuseCypher.php index 2f31d1598..ec6a4e371 100644 --- a/src/Payum/Core/Bridge/Defuse/Security/DefuseCypher.php +++ b/src/Payum/Core/Bridge/Defuse/Security/DefuseCypher.php @@ -7,14 +7,8 @@ class DefuseCypher implements CypherInterface { - /** - * @var string - */ - private $key; + private string|Key $key; - /** - * {@inheritdoc} - */ public function __construct($secret) { $this->key = Key::loadFromAsciiSafeString($secret); @@ -23,7 +17,7 @@ public function __construct($secret) /** * {@inheritdoc} */ - public function decrypt($value) + public function decrypt($value): string { return Crypto::decrypt($value, $this->key); } @@ -31,7 +25,7 @@ public function decrypt($value) /** * {@inheritdoc} */ - public function encrypt($value) + public function encrypt($value): string { return Crypto::encrypt($value, $this->key); } diff --git a/src/Payum/Core/Bridge/Doctrine/Storage/DoctrineStorage.php b/src/Payum/Core/Bridge/Doctrine/Storage/DoctrineStorage.php index fbde52aa8..a7ecb2448 100644 --- a/src/Payum/Core/Bridge/Doctrine/Storage/DoctrineStorage.php +++ b/src/Payum/Core/Bridge/Doctrine/Storage/DoctrineStorage.php @@ -4,29 +4,19 @@ use Doctrine\Persistence\ObjectManager; use Payum\Core\Model\Identity; use Payum\Core\Storage\AbstractStorage; +use Payum\Core\Storage\IdentityInterface; class DoctrineStorage extends AbstractStorage { - /** - * @var \Doctrine\Persistence\ObjectManager - */ - protected $objectManager; - - /** - * @param \Doctrine\Persistence\ObjectManager $objectManager - * @param string $modelClass - */ - public function __construct(ObjectManager $objectManager, $modelClass) + public function __construct(protected ObjectManager $objectManager, string $modelClass) { parent::__construct($modelClass); - - $this->objectManager = $objectManager; } /** * {@inheritDoc} */ - public function findBy(array $criteria) + public function findBy(array $criteria): array { return $this->objectManager->getRepository($this->modelClass)->findBy($criteria); } @@ -42,7 +32,7 @@ protected function doFind($id) /** * {@inheritDoc} */ - protected function doUpdateModel($model) + protected function doUpdateModel($model): void { $this->objectManager->persist($model); $this->objectManager->flush(); @@ -51,7 +41,7 @@ protected function doUpdateModel($model) /** * {@inheritDoc} */ - protected function doDeleteModel($model) + protected function doDeleteModel($model): void { $this->objectManager->remove($model); $this->objectManager->flush(); @@ -60,7 +50,7 @@ protected function doDeleteModel($model) /** * {@inheritDoc} */ - protected function doGetIdentity($model) + protected function doGetIdentity($model): IdentityInterface { $modelMetadata = $this->objectManager->getClassMetadata(get_class($model)); $id = $modelMetadata->getIdentifierValues($model); diff --git a/src/Payum/Core/Bridge/Doctrine/Types/ObjectType.php b/src/Payum/Core/Bridge/Doctrine/Types/ObjectType.php index 6de510738..25dc185fb 100644 --- a/src/Payum/Core/Bridge/Doctrine/Types/ObjectType.php +++ b/src/Payum/Core/Bridge/Doctrine/Types/ObjectType.php @@ -18,7 +18,7 @@ class ObjectType extends Type /** * {@inheritDoc} */ - public function convertToDatabaseValue($value) + public function convertToDatabaseValue($value): string { return serialize($value); } diff --git a/src/Payum/Core/Bridge/Guzzle/HttpClient.php b/src/Payum/Core/Bridge/Guzzle/HttpClient.php index 70222fdc3..9777846cc 100644 --- a/src/Payum/Core/Bridge/Guzzle/HttpClient.php +++ b/src/Payum/Core/Bridge/Guzzle/HttpClient.php @@ -4,6 +4,7 @@ use GuzzleHttp\ClientInterface; use Payum\Core\HttpClientInterface; use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; /** * This is a HttpClient that is using Guzzle. @@ -12,23 +13,13 @@ */ class HttpClient implements HttpClientInterface { - /** - * @var ClientInterface - */ - private $client; - - /** - * @param ClientInterface $client - */ - public function __construct(ClientInterface $client) - { - $this->client = $client; - } + public function __construct(private ClientInterface $client) + {} /** * {@inheritDoc} */ - public function send(RequestInterface $request) + public function send(RequestInterface $request): ResponseInterface { return $this->client->send($request); } diff --git a/src/Payum/Core/Bridge/Guzzle/HttpClientFactory.php b/src/Payum/Core/Bridge/Guzzle/HttpClientFactory.php index 7e368ffff..6329a6a5e 100644 --- a/src/Payum/Core/Bridge/Guzzle/HttpClientFactory.php +++ b/src/Payum/Core/Bridge/Guzzle/HttpClientFactory.php @@ -13,10 +13,8 @@ class HttpClientFactory { /** * Create a Guzzle client. - * - * @return \GuzzleHttp\Client */ - public static function createGuzzle() + public static function createGuzzle(): Client { $client = null; if (!class_exists(Client::class)) { @@ -25,14 +23,14 @@ public static function createGuzzle() } $version = \GuzzleHttp\ClientInterface::VERSION; - if (substr($version, 0, 1) !== '6') { + if ($version[0] !== '6') { throw new \LogicException('This version of Guzzle is not supported.'); } $curl = curl_version(); $curlOptions = [ - CURLOPT_USERAGENT => sprintf('Payum/1.x curl/%s PHP/%s', $curl['version'], phpversion()), + CURLOPT_USERAGENT => sprintf('Payum/1.x curl/%s PHP/%s', $curl['version'], PHP_VERSION), ]; return new \GuzzleHttp\Client([ @@ -40,10 +38,7 @@ public static function createGuzzle() ]); } - /** - * @return HttpClientInterface - */ - public static function create() + public static function create(): HttpClientInterface { return new HttpClient(static::createGuzzle()); } diff --git a/src/Payum/Core/Bridge/Httplug/HttplugClient.php b/src/Payum/Core/Bridge/Httplug/HttplugClient.php index ce27ae76a..a07c42464 100644 --- a/src/Payum/Core/Bridge/Httplug/HttplugClient.php +++ b/src/Payum/Core/Bridge/Httplug/HttplugClient.php @@ -4,6 +4,7 @@ use Payum\Core\HttpClientInterface; use Psr\Http\Message\RequestInterface; use Http\Client\HttpClient; +use Psr\Http\Message\ResponseInterface; /** * This is a HttpClient that support Httplug. This is an adapter class that make sure we can use Httplug without breaking @@ -13,23 +14,13 @@ */ class HttplugClient implements HttpClientInterface { - /** - * @var HttpClient - */ - private $client; - - /** - * @param HttpClient $client - */ - public function __construct(HttpClient $client) - { - $this->client = $client; - } + public function __construct(private HttpClient $client) + {} /** * {@inheritDoc} */ - public function send(RequestInterface $request) + public function send(RequestInterface $request): ResponseInterface { return $this->client->sendRequest($request); } diff --git a/src/Payum/Core/Bridge/Laminas/Storage/TableGatewayStorage.php b/src/Payum/Core/Bridge/Laminas/Storage/TableGatewayStorage.php index 215e420c8..e2e030227 100644 --- a/src/Payum/Core/Bridge/Laminas/Storage/TableGatewayStorage.php +++ b/src/Payum/Core/Bridge/Laminas/Storage/TableGatewayStorage.php @@ -50,10 +50,7 @@ class TableGatewayStorage extends AbstractStorage */ protected $tableGateway; - /** - * @var string - */ - protected $idField; + protected string $idField; /** * @param LaminasTableGateway|ZendTableGateway $tableGateway @@ -79,7 +76,7 @@ public function __construct($tableGateway, $modelClass, $idField = 'id') /** * {@inheritDoc} */ - public function findBy(array $criteria) + public function findBy(array $criteria): array { throw new LogicException('Method is not supported by the storage.'); } @@ -87,7 +84,7 @@ public function findBy(array $criteria) /** * {@inheritDoc} */ - protected function doFind($id) + protected function doFind($id): ?object { return $this->tableGateway->select(array("{$this->idField} = ?" => $id))->current(); } @@ -95,7 +92,7 @@ protected function doFind($id) /** * {@inheritDoc} */ - protected function doUpdateModel($model) + protected function doUpdateModel($model): void { if ($id = $this->getModelId($model)) { $this->tableGateway->update( @@ -110,7 +107,7 @@ protected function doUpdateModel($model) /** * {@inheritDoc} */ - protected function doDeleteModel($model) + protected function doDeleteModel($model): void { $this->tableGateway->delete(array("{$this->idField} = ?" => $this->getModelId($model))); } @@ -118,7 +115,7 @@ protected function doDeleteModel($model) /** * {@inheritDoc} */ - protected function doGetIdentity($model) + protected function doGetIdentity($model): IdentityInterface { $id = $this->getModelId($model); @@ -129,12 +126,7 @@ protected function doGetIdentity($model) return new Identity($id, $model); } - /** - * @param object $model - * - * @return mixed - */ - protected function getModelId($model) + protected function getModelId(object $model): mixed { $rp = new \ReflectionProperty($model, $this->idField); $rp->setAccessible(true); diff --git a/src/Payum/Core/Bridge/PlainPhp/Action/GetHttpRequestAction.php b/src/Payum/Core/Bridge/PlainPhp/Action/GetHttpRequestAction.php index 4930049b5..1f88289b9 100644 --- a/src/Payum/Core/Bridge/PlainPhp/Action/GetHttpRequestAction.php +++ b/src/Payum/Core/Bridge/PlainPhp/Action/GetHttpRequestAction.php @@ -16,19 +16,19 @@ public function execute($request) { RequestNotSupportedException::assertSupports($this, $request); - $request->method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET'; + $request->method = $_SERVER['REQUEST_METHOD'] ?? 'GET'; $request->query = $_GET; $request->request = $_REQUEST; - $request->clientIp = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''; - $request->uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''; - $request->userAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; + $request->clientIp = $_SERVER['REMOTE_ADDR'] ?? ''; + $request->uri = $_SERVER['REQUEST_URI'] ?? ''; + $request->userAgent = $_SERVER['HTTP_USER_AGENT'] ?? ''; $request->content = file_get_contents('php://input'); } /** * {@inheritDoc} */ - public function supports($request) + public function supports($request): bool { return $request instanceof GetHttpRequest; } diff --git a/src/Payum/Core/Bridge/Psr/Log/LogExecutedActionsExtension.php b/src/Payum/Core/Bridge/Psr/Log/LogExecutedActionsExtension.php index b8fc989c6..72c11f4b3 100644 --- a/src/Payum/Core/Bridge/Psr/Log/LogExecutedActionsExtension.php +++ b/src/Payum/Core/Bridge/Psr/Log/LogExecutedActionsExtension.php @@ -10,14 +10,8 @@ class LogExecutedActionsExtension implements ExtensionInterface, LoggerAwareInterface { - /** - * @var LoggerInterface - */ - protected $logger; + protected LoggerInterface $logger; - /** - * @param LoggerInterface $logger - */ public function __construct(LoggerInterface $logger = null) { $this->logger = $logger ?: new NullLogger(); @@ -34,14 +28,14 @@ public function setLogger(LoggerInterface $logger): void /** * {@inheritDoc} */ - public function onPreExecute(Context $context) + public function onPreExecute(Context $context): void { } /** * {@inheritDoc} */ - public function onExecute(Context $context) + public function onExecute(Context $context): void { $this->logger->debug(sprintf( '[Payum] %d# %s::execute(%s)', diff --git a/src/Payum/Core/Bridge/Symfony/ContainerAwareRegistry.php b/src/Payum/Core/Bridge/Symfony/ContainerAwareRegistry.php index 655cc8bdb..5605e8258 100644 --- a/src/Payum/Core/Bridge/Symfony/ContainerAwareRegistry.php +++ b/src/Payum/Core/Bridge/Symfony/ContainerAwareRegistry.php @@ -12,7 +12,7 @@ class ContainerAwareRegistry extends AbstractRegistry implements ContainerAwareI /** * {@inheritDoc} */ - protected function getService($id) + protected function getService(string $id) { return $this->container->get($id); } diff --git a/src/Payum/Core/CoreGatewayFactory.php b/src/Payum/Core/CoreGatewayFactory.php index a91ca96f4..5ad7aadee 100644 --- a/src/Payum/Core/CoreGatewayFactory.php +++ b/src/Payum/Core/CoreGatewayFactory.php @@ -33,23 +33,13 @@ class CoreGatewayFactory implements GatewayFactoryInterface { - /** - * @var array - */ - protected $defaultConfig; - - /** - * @param array $defaultConfig - */ - public function __construct(array $defaultConfig = []) - { - $this->defaultConfig = $defaultConfig; - } + public function __construct(protected array $defaultConfig = []) + {} /** * {@inheritDoc} */ - public function create(array $config = []) + public function create(array $config = []): GatewayInterface|Gateway { $config = ArrayObject::ensureArrayObject($config); $config->defaults($this->createConfig()); @@ -68,7 +58,7 @@ public function create(array $config = []) /** * {@inheritDoc} */ - public function createConfig(array $config = []) + public function createConfig(array $config = []): array { $config = ArrayObject::ensureArrayObject($config); $config->defaults($this->defaultConfig); @@ -206,9 +196,6 @@ public function createConfig(array $config = []) return (array) $config; } - /** - * @param ArrayObject $config - */ protected function buildClosures(ArrayObject $config) { // with higher priority @@ -226,11 +213,7 @@ protected function buildClosures(ArrayObject $config) } } - /** - * @param Gateway $gateway - * @param ArrayObject $config - */ - protected function buildActions(Gateway $gateway, ArrayObject $config) + protected function buildActions(Gateway $gateway, ArrayObject $config): void { foreach ($config as $name => $value) { if (0 === strpos($name, 'payum.action')) { @@ -241,11 +224,7 @@ protected function buildActions(Gateway $gateway, ArrayObject $config) } } - /** - * @param Gateway $gateway - * @param ArrayObject $config - */ - protected function buildApis(Gateway $gateway, ArrayObject $config) + protected function buildApis(Gateway $gateway, ArrayObject $config): void { foreach ($config as $name => $value) { if (0 === strpos($name, 'payum.api')) { @@ -256,11 +235,7 @@ protected function buildApis(Gateway $gateway, ArrayObject $config) } } - /** - * @param Gateway $gateway - * @param ArrayObject $config - */ - protected function buildExtensions(Gateway $gateway, ArrayObject $config) + protected function buildExtensions(Gateway $gateway, ArrayObject $config): void { foreach ($config as $name => $value) { if (0 === strpos($name, 'payum.extension')) { diff --git a/src/Payum/Core/Debug/Humanify.php b/src/Payum/Core/Debug/Humanify.php index 9e3570a20..50f87ff3b 100644 --- a/src/Payum/Core/Debug/Humanify.php +++ b/src/Payum/Core/Debug/Humanify.php @@ -6,11 +6,7 @@ abstract class Humanify { - /** - * @param mixed $request - * @return string - */ - public static function request($request) + public static function request(mixed $request): string { $return = self::value($request); @@ -30,13 +26,7 @@ public static function request($request) return $return; } - /** - * @param mixed $value - * @param bool $shortClass - * - * @return string - */ - public static function value($value, $shortClass = true) + public static function value(mixed $value, bool $shortClass = true): string { if (is_object($value)) { if ($shortClass) { diff --git a/src/Payum/Core/Exception/Http/HttpException.php b/src/Payum/Core/Exception/Http/HttpException.php index 51c4c5533..3c3ef9d69 100644 --- a/src/Payum/Core/Exception/Http/HttpException.php +++ b/src/Payum/Core/Exception/Http/HttpException.php @@ -7,20 +7,13 @@ class HttpException extends RuntimeException implements HttpExceptionInterface { - /** - * @var RequestInterface - */ - protected $request; - - /** - * @var ResponseInterface - */ - protected $response; + protected RequestInterface $request; + protected ResponseInterface $response; /** * {@inheritDoc} */ - public function setRequest(RequestInterface $request) + public function setRequest(RequestInterface $request): void { $this->request = $request; } @@ -28,7 +21,7 @@ public function setRequest(RequestInterface $request) /** * {@inheritDoc} */ - public function getRequest() + public function getRequest(): RequestInterface { return $this->request; } @@ -36,7 +29,7 @@ public function getRequest() /** * {@inheritDoc} */ - public function setResponse(ResponseInterface $response) + public function setResponse(ResponseInterface $response): void { $this->response = $response; } @@ -44,18 +37,12 @@ public function setResponse(ResponseInterface $response) /** * {@inheritDoc} */ - public function getResponse() + public function getResponse(): ResponseInterface { return $this->response; } - /** - * @param RequestInterface $request - * @param ResponseInterface $response - * - * @return HttpException - */ - public static function factory(RequestInterface $request, ResponseInterface $response) + public static function factory(RequestInterface $request, ResponseInterface $response): HttpException { if ($response->getStatusCode() >= 400 && $response->getStatusCode() < 500) { $label = 'Client error response'; diff --git a/src/Payum/Core/Exception/Http/HttpExceptionInterface.php b/src/Payum/Core/Exception/Http/HttpExceptionInterface.php index 07c28ac5b..c12894f9b 100644 --- a/src/Payum/Core/Exception/Http/HttpExceptionInterface.php +++ b/src/Payum/Core/Exception/Http/HttpExceptionInterface.php @@ -7,27 +7,11 @@ interface HttpExceptionInterface extends ExceptionInterface { - /** - * @param RequestInterface $request - * - * @return void - */ - public function setRequest(RequestInterface $request); + public function setRequest(RequestInterface $request): void; - /** - * @return RequestInterface - */ - public function getRequest(); + public function getRequest(): RequestInterface; - /** - * @param ResponseInterface $response - * - * @return void - */ - public function setResponse(ResponseInterface $response); + public function setResponse(ResponseInterface $response): void; - /** - * @return ResponseInterface - */ - public function getResponse(); + public function getResponse(): ResponseInterface; } diff --git a/src/Payum/Core/Exception/RequestNotSupportedException.php b/src/Payum/Core/Exception/RequestNotSupportedException.php index 7ac4d3bfa..790bb4b74 100644 --- a/src/Payum/Core/Exception/RequestNotSupportedException.php +++ b/src/Payum/Core/Exception/RequestNotSupportedException.php @@ -8,51 +8,30 @@ class RequestNotSupportedException extends InvalidArgumentException { - /** - * @var mixed - */ - protected $request; + protected mixed $request; + protected ?ActionInterface $action; - /** - * @var ActionInterface|null - */ - protected $action; - - /** - * @return mixed - */ - public function getRequest() + public function getRequest(): mixed { return $this->request; } - /** - * @return ActionInterface|null - */ - public function getAction() + public function getAction(): ?ActionInterface { return $this->action; } /** - * @param \Payum\Core\Action\ActionInterface $action - * @param mixed $request - * * @throws RequestNotSupportedException */ - public static function assertSupports(ActionInterface $action, $request) + public static function assertSupports(ActionInterface $action, mixed $request): void { if (false == $action->supports($request)) { throw static::createActionNotSupported($action, $request); } } - /** - * @param mixed $request - * - * @return RequestNotSupportedException - */ - public static function create($request) + public static function create(mixed $request): RequestNotSupportedException { $exception = new self(sprintf( 'Request %s is not supported. %s', @@ -65,13 +44,7 @@ public static function create($request) return $exception; } - /** - * @param \Payum\Core\Action\ActionInterface $action - * @param mixed $request - * - * @return RequestNotSupportedException - */ - public static function createActionNotSupported(ActionInterface $action, $request) + public static function createActionNotSupported(ActionInterface $action, mixed $request): RequestNotSupportedException { $exception = new self(sprintf("Action %s is not supported the request %s. %s", Humanify::value($action), @@ -86,11 +59,9 @@ public static function createActionNotSupported(ActionInterface $action, $reques } /** - * @param $request - * * @return string[] */ - protected static function suggestions($request) + protected static function suggestions($request): array { $suggestions = []; diff --git a/src/Payum/Core/Extension/Context.php b/src/Payum/Core/Extension/Context.php index 6ade53e50..38337ed6b 100644 --- a/src/Payum/Core/Extension/Context.php +++ b/src/Payum/Core/Extension/Context.php @@ -7,100 +7,47 @@ class Context { - /** - * @var GatewayInterface - */ - protected $gateway; - - /** - * @var mixed - */ - protected $request; - - /** - * @var ActionInterface - */ - protected $action; - - /** - * @var ReplyInterface|null - */ - protected $reply; - - /** - * @var \Exception|null - */ - protected $exception; - - /** - * @var Context[] - */ - protected $previous; + protected ActionInterface $action; + protected ?ReplyInterface $reply; /** - * @param GatewayInterface $gateway - * @param $request * @param Context[] $previous */ - public function __construct(GatewayInterface $gateway, $request, array $previous) + public function __construct(protected GatewayInterface $gateway, protected mixed $request, protected array $previous) { - $this->gateway = $gateway; - $this->request = $request; - $this->previous = $previous; } - /** - * @return ActionInterface - */ - public function getAction() + public function getAction(): ActionInterface { return $this->action; } - /** - * @param ActionInterface $action - */ - public function setAction(ActionInterface $action) + public function setAction(ActionInterface $action): void { $this->action = $action; } - /** - * @return null|ReplyInterface - */ - public function getReply() + public function getReply(): ?ReplyInterface { return $this->reply; } - /** - * @param null|ReplyInterface $reply - */ - public function setReply(ReplyInterface $reply = null) + public function setReply(ReplyInterface $reply = null): void { $this->reply = $reply; } - /** - * @return \Exception|null - */ - public function getException() + public function getException(): ?\Exception { return $this->exception; } - /** - * @param \Exception|null $exception - */ - public function setException(\Exception $exception = null) + public function setException(\Exception $exception = null): void { $this->exception = $exception; } - /** - * @return GatewayInterface - */ - public function getGateway() + public function getGateway(): GatewayInterface { return $this->gateway; } @@ -108,15 +55,12 @@ public function getGateway() /** * @return Context[] */ - public function getPrevious() + public function getPrevious(): array { return $this->previous; } - /** - * @return mixed - */ - public function getRequest() + public function getRequest(): mixed { return $this->request; } diff --git a/src/Payum/Core/Extension/EndlessCycleDetectorExtension.php b/src/Payum/Core/Extension/EndlessCycleDetectorExtension.php index bc2bdc5dc..a1d3095b8 100644 --- a/src/Payum/Core/Extension/EndlessCycleDetectorExtension.php +++ b/src/Payum/Core/Extension/EndlessCycleDetectorExtension.php @@ -5,23 +5,13 @@ class EndlessCycleDetectorExtension implements ExtensionInterface { - /** - * @var int - */ - protected $limit; - - /** - * @param int $limit - */ - public function __construct($limit = 100) - { - $this->limit = $limit; - } + public function __construct(protected int $limit = 100) + {} /** * {@inheritDoc} */ - public function onPreExecute(Context $context) + public function onPreExecute(Context $context): void { if (count($context->getPrevious()) >= $this->limit) { throw new LogicException(sprintf( @@ -34,14 +24,14 @@ public function onPreExecute(Context $context) /** * {@inheritDoc} */ - public function onExecute(Context $context) + public function onExecute(Context $context): void { } /** * {@inheritDoc} */ - public function onPostExecute(Context $context) + public function onPostExecute(Context $context): void { } } diff --git a/src/Payum/Core/Extension/ExtensionCollection.php b/src/Payum/Core/Extension/ExtensionCollection.php index 202dad325..fa812b343 100644 --- a/src/Payum/Core/Extension/ExtensionCollection.php +++ b/src/Payum/Core/Extension/ExtensionCollection.php @@ -6,15 +6,9 @@ class ExtensionCollection implements ExtensionInterface /** * @var ExtensionInterface[] */ - protected $extensions = array(); + protected array $extensions = []; - /** - * @param ExtensionInterface $extension - * @param bool $forcePrepend - * - * @return void - */ - public function addExtension(ExtensionInterface $extension, $forcePrepend = false) + public function addExtension(ExtensionInterface $extension, bool $forcePrepend = false): void { $forcePrepend ? array_unshift($this->extensions, $extension) : @@ -25,7 +19,7 @@ public function addExtension(ExtensionInterface $extension, $forcePrepend = fals /** * {@inheritDoc} */ - public function onPreExecute(Context $context) + public function onPreExecute(Context $context): void { foreach ($this->extensions as $extension) { $extension->onPreExecute($context); @@ -35,7 +29,7 @@ public function onPreExecute(Context $context) /** * {@inheritDoc} */ - public function onExecute(Context $context) + public function onExecute(Context $context): void { foreach ($this->extensions as $extension) { $extension->onExecute($context); @@ -45,7 +39,7 @@ public function onExecute(Context $context) /** * {@inheritDoc} */ - public function onPostExecute(Context $context) + public function onPostExecute(Context $context): void { foreach ($this->extensions as $extension) { $extension->onPostExecute($context); diff --git a/src/Payum/Core/Extension/ExtensionInterface.php b/src/Payum/Core/Extension/ExtensionInterface.php index e526fc84e..650273d82 100644 --- a/src/Payum/Core/Extension/ExtensionInterface.php +++ b/src/Payum/Core/Extension/ExtensionInterface.php @@ -3,18 +3,9 @@ interface ExtensionInterface { - /** - * @var Context $context - */ - public function onPreExecute(Context $context); + public function onPreExecute(Context $context): void; - /** - * @var Context $context - */ - public function onExecute(Context $context); + public function onExecute(Context $context): void; - /** - * @var Context $context - */ - public function onPostExecute(Context $context); + public function onPostExecute(Context $context): void; } diff --git a/src/Payum/Core/Extension/GenericTokenFactoryExtension.php b/src/Payum/Core/Extension/GenericTokenFactoryExtension.php index 1fb5df2da..2da77dd3b 100644 --- a/src/Payum/Core/Extension/GenericTokenFactoryExtension.php +++ b/src/Payum/Core/Extension/GenericTokenFactoryExtension.php @@ -8,30 +8,20 @@ class GenericTokenFactoryExtension implements ExtensionInterface { - /** - * @var GenericTokenFactoryInterface - */ - protected $genericTokenFactory; - - /** - * @param GenericTokenFactoryInterface $genericTokenFactory - */ - public function __construct(GenericTokenFactoryInterface $genericTokenFactory) - { - $this->genericTokenFactory = $genericTokenFactory; - } + public function __construct(protected GenericTokenFactoryInterface $genericTokenFactory) + {} /** * {@inheritDoc} */ - public function onPreExecute(Context $context) + public function onPreExecute(Context $context): void { } /** * {@inheritDoc} */ - public function onExecute(Context $context) + public function onExecute(Context $context): void { $action = $context->getAction(); if ($action instanceof GenericTokenFactoryAwareInterface) { @@ -42,7 +32,7 @@ public function onExecute(Context $context) /** * {@inheritDoc} */ - public function onPostExecute(Context $context) + public function onPostExecute(Context $context): void { $action = $context->getAction(); if ($action instanceof GenericTokenFactoryAwareInterface) { diff --git a/src/Payum/Core/Extension/StorageExtension.php b/src/Payum/Core/Extension/StorageExtension.php index 87e881dd5..a4f7a792f 100644 --- a/src/Payum/Core/Extension/StorageExtension.php +++ b/src/Payum/Core/Extension/StorageExtension.php @@ -7,28 +7,19 @@ class StorageExtension implements ExtensionInterface { - /** - * @var \Payum\Core\Storage\StorageInterface - */ - protected $storage; - /** * @var object[] */ - protected $scheduledForUpdateModels = array(); + protected array $scheduledForUpdateModels = []; - /** - * @param \Payum\Core\Storage\StorageInterface $storage - */ - public function __construct(StorageInterface $storage) + public function __construct(protected StorageInterface $storage) { - $this->storage = $storage; } /** * {@inheritDoc} */ - public function onPreExecute(Context $context) + public function onPreExecute(Context $context): void { $request = $context->getRequest(); @@ -52,14 +43,14 @@ public function onPreExecute(Context $context) /** * {@inheritDoc} */ - public function onExecute(Context $context) + public function onExecute(Context $context): void { } /** * {@inheritDoc} */ - public function onPostExecute(Context $context) + public function onPostExecute(Context $context): void { $request = $context->getRequest(); @@ -75,10 +66,7 @@ public function onPostExecute(Context $context) } } - /** - * @param mixed $model - */ - protected function scheduleForUpdateIfSupported($model) + protected function scheduleForUpdateIfSupported(mixed $model): void { if ($this->storage->support($model)) { $modelHash = spl_object_hash($model); diff --git a/src/Payum/Core/Gateway.php b/src/Payum/Core/Gateway.php index db4d9abc1..73df05801 100644 --- a/src/Payum/Core/Gateway.php +++ b/src/Payum/Core/Gateway.php @@ -15,25 +15,20 @@ class Gateway implements GatewayInterface /** * @var Action\ActionInterface[] */ - protected $actions; + protected array $actions; /** * @var mixed[] */ - protected $apis; + protected array $apis; - /** - * @var \Payum\Core\Extension\ExtensionCollection - */ - protected $extensions; + protected ExtensionCollection $extensions; /** * @var Context[] */ - protected $stack; + protected array $stack; - /** - */ public function __construct() { $this->stack = []; @@ -43,13 +38,7 @@ public function __construct() $this->extensions = new ExtensionCollection(); } - /** - * @param mixed $api - * @param bool $forcePrepend - * - * @return void - */ - public function addApi($api, $forcePrepend = false) + public function addApi(mixed $api, bool $forcePrepend = false): void { $forcePrepend ? array_unshift($this->apis, $api) : @@ -57,13 +46,7 @@ public function addApi($api, $forcePrepend = false) ; } - /** - * @param Action\ActionInterface $action - * @param bool $forcePrepend - * - * @return void - */ - public function addAction(ActionInterface $action, $forcePrepend = false) + public function addAction(ActionInterface $action, bool $forcePrepend = false): void { $forcePrepend ? array_unshift($this->actions, $action) : @@ -71,13 +54,7 @@ public function addAction(ActionInterface $action, $forcePrepend = false) ; } - /** - * @param \Payum\Core\Extension\ExtensionInterface $extension - * @param bool $forcePrepend - * - * @return void - */ - public function addExtension(ExtensionInterface $extension, $forcePrepend = false) + public function addExtension(ExtensionInterface $extension, bool $forcePrepend = false): void { $this->extensions->addExtension($extension, $forcePrepend); } @@ -89,7 +66,7 @@ public function execute($request, $catchReply = false) { $context = new Context($this, $request, $this->stack); - array_push($this->stack, $context); + $this->stack[] = $context; try { $this->extensions->onPreExecute($context); @@ -132,7 +109,7 @@ public function execute($request, $catchReply = false) return; } - protected function onPostExecuteWithException(Context $context) + protected function onPostExecuteWithException(Context $context): void { array_pop($this->stack); @@ -162,11 +139,9 @@ protected function onPostExecuteWithException(Context $context) } /** - * @param mixed $request - * * @return ActionInterface|false */ - protected function findActionSupported($request) + protected function findActionSupported(mixed $request): bool|ActionInterface { foreach ($this->actions as $action) { if ($action instanceof GatewayAwareInterface) { diff --git a/src/Payum/Core/GatewayAwareInterface.php b/src/Payum/Core/GatewayAwareInterface.php index 1a796bbba..9ad69696e 100644 --- a/src/Payum/Core/GatewayAwareInterface.php +++ b/src/Payum/Core/GatewayAwareInterface.php @@ -6,5 +6,5 @@ interface GatewayAwareInterface /** * @param \Payum\Core\GatewayInterface $gateway */ - public function setGateway(GatewayInterface $gateway); + public function setGateway(GatewayInterface $gateway): void; } diff --git a/src/Payum/Core/GatewayAwareTrait.php b/src/Payum/Core/GatewayAwareTrait.php index 54108b731..c2a45fccb 100644 --- a/src/Payum/Core/GatewayAwareTrait.php +++ b/src/Payum/Core/GatewayAwareTrait.php @@ -3,15 +3,12 @@ trait GatewayAwareTrait { - /** - * @var GatewayInterface - */ - protected $gateway; + protected GatewayInterface $gateway; /** * {@inheritDoc} */ - public function setGateway(GatewayInterface $gateway) + public function setGateway(GatewayInterface $gateway): void { $this->gateway = $gateway; } diff --git a/src/Payum/Core/GatewayFactory.php b/src/Payum/Core/GatewayFactory.php index 05c10f050..2c8c69435 100644 --- a/src/Payum/Core/GatewayFactory.php +++ b/src/Payum/Core/GatewayFactory.php @@ -5,21 +5,11 @@ class GatewayFactory implements GatewayFactoryInterface { - /** - * @var GatewayFactoryInterface - */ - protected $coreGatewayFactory; + protected GatewayFactoryInterface $coreGatewayFactory; - /** - * @var array - */ - protected $defaultConfig; + protected array $defaultConfig; - /** - * @param array $defaultConfig - * @param GatewayFactoryInterface $coreGatewayFactory - */ - public function __construct(array $defaultConfig = array(), GatewayFactoryInterface $coreGatewayFactory = null) + public function __construct(array $defaultConfig = [], GatewayFactoryInterface $coreGatewayFactory = null) { $this->coreGatewayFactory = $coreGatewayFactory ?: new CoreGatewayFactory(); $this->defaultConfig = $defaultConfig; @@ -28,7 +18,7 @@ public function __construct(array $defaultConfig = array(), GatewayFactoryInterf /** * {@inheritDoc} */ - public function create(array $config = array()) + public function create(array $config = []): GatewayInterface { return $this->coreGatewayFactory->create($this->createConfig($config)); } @@ -36,7 +26,7 @@ public function create(array $config = array()) /** * {@inheritDoc} */ - public function createConfig(array $config = array()) + public function createConfig(array $config = []): array { $config = ArrayObject::ensureArrayObject($config); $config->defaults($this->defaultConfig); @@ -47,10 +37,7 @@ public function createConfig(array $config = array()) return (array) $config; } - /** - * {@inheritDoc} - */ - protected function populateConfig(ArrayObject $config) + protected function populateConfig(ArrayObject $config): void { } } diff --git a/src/Payum/Core/GatewayFactoryInterface.php b/src/Payum/Core/GatewayFactoryInterface.php index 1afa5a6dc..5897165d4 100644 --- a/src/Payum/Core/GatewayFactoryInterface.php +++ b/src/Payum/Core/GatewayFactoryInterface.php @@ -3,17 +3,7 @@ interface GatewayFactoryInterface { - /** - * @param array $config - * - * @return array - */ - public function createConfig(array $config = array()); + public function createConfig(array $config = []): array; - /** - * @param array $config - * - * @return GatewayInterface - */ - public function create(array $config = array()); + public function create(array $config = []): GatewayInterface; } diff --git a/src/Payum/Core/GatewayInterface.php b/src/Payum/Core/GatewayInterface.php index 34004291c..31d2fa008 100644 --- a/src/Payum/Core/GatewayInterface.php +++ b/src/Payum/Core/GatewayInterface.php @@ -4,13 +4,10 @@ interface GatewayInterface { /** - * @param mixed $request - * @param boolean $catchReply If false the reply behave like an exception. If true the reply will be caught internally and returned. + * @param bool $catchReply If false the reply behave like an exception. If true the reply will be caught internally and returned. * * @throws \Payum\Core\Exception\RequestNotSupportedException If there is not an action which able to process the request. * @throws \Payum\Core\Reply\ReplyInterface Gateway throws reply if some external tasks have to be done. For example show a credit card form, an iframe or perform a redirect. - * - * @return \Payum\Core\Reply\ReplyInterface|null */ - public function execute($request, $catchReply = false); + public function execute(mixed $request, bool $catchReply = false): ?Reply\ReplyInterface; } diff --git a/src/Payum/Core/HttpClientInterface.php b/src/Payum/Core/HttpClientInterface.php index 7aac493ea..202905d50 100644 --- a/src/Payum/Core/HttpClientInterface.php +++ b/src/Payum/Core/HttpClientInterface.php @@ -6,10 +6,5 @@ interface HttpClientInterface { - /** - * @param RequestInterface $request - * - * @return ResponseInterface - */ - public function send(RequestInterface $request); + public function send(RequestInterface $request): ResponseInterface; } diff --git a/src/Payum/Core/ISO4217/Currency.php b/src/Payum/Core/ISO4217/Currency.php index d1e32d13c..66768f505 100644 --- a/src/Payum/Core/ISO4217/Currency.php +++ b/src/Payum/Core/ISO4217/Currency.php @@ -7,44 +7,12 @@ use Alcohol\ISO4217; final class Currency { - /** - * @var string - */ - private $name; - - /** - * @var string - */ - private $alpha3; - - /** - * @var string - */ - private $numeric; - - /** - * @var int - */ - private $exp; - - /** - * @var string|string[] - */ - private $country; /** - * @param string $name - * @param string $alpha3 - * @param string $numeric - * @param int $exp * @param string|string[] $country */ - public function __construct(string $name, string $alpha3, string $numeric, int $exp, $country) + public function __construct(private string $name, private string $alpha3, private string $numeric, private int $exp, private string|array $country) { - $this->name = $name; - $this->alpha3 = $alpha3; - $this->numeric = $numeric; - $this->exp = $exp; $this->country = $country; } @@ -71,7 +39,7 @@ public function getExp(): int /** * @return string|\string[] */ - public function getCountry() + public function getCountry(): array|string { return $this->country; } diff --git a/src/Payum/Core/Model/ArrayObject.php b/src/Payum/Core/Model/ArrayObject.php index 9740a992f..b3a8012b9 100644 --- a/src/Payum/Core/Model/ArrayObject.php +++ b/src/Payum/Core/Model/ArrayObject.php @@ -3,16 +3,12 @@ class ArrayObject implements \ArrayAccess, \IteratorAggregate { - /** - * @var array - */ - protected $details = array(); + protected array $details = []; /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists(mixed $offset): bool { return array_key_exists($offset, $this->details); } @@ -20,8 +16,7 @@ public function offsetExists($offset) /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset): mixed { return $this->details[$offset]; } @@ -29,8 +24,7 @@ public function offsetGet($offset) /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet(mixed $offset, mixed $value): void { $this->details[$offset] = $value; } @@ -38,8 +32,7 @@ public function offsetSet($offset, $value) /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset(mixed $offset): void { unset($this->details[$offset]); } @@ -47,8 +40,7 @@ public function offsetUnset($offset) /** * {@inheritDoc} */ - #[\ReturnTypeWillChange] - public function getIterator() + public function getIterator(): \Traversable|array|\ArrayIterator { return new \ArrayIterator($this->details); } diff --git a/src/Payum/Core/Model/BankAccount.php b/src/Payum/Core/Model/BankAccount.php index b8bbcb73c..58b2e2d7d 100644 --- a/src/Payum/Core/Model/BankAccount.php +++ b/src/Payum/Core/Model/BankAccount.php @@ -9,138 +9,91 @@ class BankAccount implements BankAccountInterface { /** * Name of the account holder - * - * @var string */ - private $holder; + private string $holder; /** * The account number (BBAN) - * - * @var string */ - private $number; + private string $number; /** * Code that identifies the bank where the account is held - * - * @var string */ - private $bankCode; + private string $bankCode; /** * The bank's country code (ISO 3166-1 ALPHA-2) * * @link https://en.wikipedia.org/wiki/ISO_3166-1 - * @var string */ - private $bankCountryCode; + private string $bankCountryCode; - /** - * @var string - */ - private $iban; + private string $iban; /** * The bank's BIC code * * @link https://en.wikipedia.org/wiki/ISO_9362 - * @var string */ - private $bic; + private string $bic; - /** - * @return string - */ - public function getHolder() + public function getHolder(): string { return $this->holder; } - /** - * @param string $holder - */ - public function setHolder($holder) + public function setHolder(string $holder): void { $this->holder = $holder; } - /** - * @return string - */ - public function getNumber() + public function getNumber(): string { return $this->number; } - /** - * @param string $number - */ - public function setNumber($number) + public function setNumber(string $number): void { $this->number = $number; } - /** - * @return string - */ - public function getBankCode() + public function getBankCode(): string { return $this->bankCode; } - /** - * @param string $bankCode - */ - public function setBankCode($bankCode) + public function setBankCode(string $bankCode): void { $this->bankCode = $bankCode; } - /** - * @return string - */ - public function getBankCountryCode() + public function getBankCountryCode(): string { return $this->bankCountryCode; } - /** - * @param string $bankCountryCode - */ - public function setBankCountryCode($bankCountryCode) + public function setBankCountryCode(string $bankCountryCode): void { $this->bankCountryCode = $bankCountryCode; } - /** - * @return string - */ - public function getIban() + public function getIban(): string { return $this->iban; } - /** - * @param string $iban - */ - public function setIban($iban) + public function setIban(string $iban): void { $this->iban = $iban; } - /** - * @return string - */ - public function getBic() + public function getBic(): string { return $this->bic; } - /** - * @param string $bic - */ - public function setBic($bic) + public function setBic(string $bic): void { $this->bic = $bic; } diff --git a/src/Payum/Core/Model/BankAccountInterface.php b/src/Payum/Core/Model/BankAccountInterface.php index 2bffa4883..172fb4d87 100644 --- a/src/Payum/Core/Model/BankAccountInterface.php +++ b/src/Payum/Core/Model/BankAccountInterface.php @@ -7,63 +7,27 @@ */ interface BankAccountInterface { - /** - * @return string - */ - public function getHolder(); + public function getHolder(): string; - /** - * @param string $holder - */ - public function setHolder($holder); + public function setHolder(string $holder); - /** - * @return string - */ - public function getNumber(); + public function getNumber(): string; - /** - * @param string $number - */ - public function setNumber($number); + public function setNumber(string $number); - /** - * @return string - */ - public function getBankCode(); + public function getBankCode(): string; - /** - * @param string $bankCode - */ - public function setBankCode($bankCode); + public function setBankCode(string $bankCode); - /** - * @return string - */ - public function getBankCountryCode(); + public function getBankCountryCode(): string; - /** - * @param string $bankCountryCode - */ - public function setBankCountryCode($bankCountryCode); + public function setBankCountryCode(string $bankCountryCode); - /** - * @return string - */ - public function getIban(); + public function getIban(): string; - /** - * @param string $iban - */ - public function setIban($iban); + public function setIban(string $iban); - /** - * @return string - */ - public function getBic(); + public function getBic(): string; - /** - * @param string $bic - */ - public function setBic($bic); + public function setBic(string $bic); } diff --git a/src/Payum/Core/Model/CreditCard.php b/src/Payum/Core/Model/CreditCard.php index f2e70e67d..c18b79158 100644 --- a/src/Payum/Core/Model/CreditCard.php +++ b/src/Payum/Core/Model/CreditCard.php @@ -7,20 +7,11 @@ class CreditCard implements CreditCardInterface { - /** - * @var string - */ - protected $token; + protected string $token; - /** - * @var string - */ - protected $brand; + protected string $brand; - /** - * @var string - */ - protected $holder; + protected string $holder; /** * @var SensitiveValue @@ -29,15 +20,9 @@ class CreditCard implements CreditCardInterface */ protected $securedHolder; - /** - * @var string - */ - protected $maskedHolder; + protected string $maskedHolder; - /** - * @var string - */ - protected $number; + protected string $number; /** * @var SensitiveValue @@ -46,15 +31,9 @@ class CreditCard implements CreditCardInterface */ protected $securedNumber; - /** - * @var string - */ - protected $maskedNumber; + protected string $maskedNumber; - /** - * @var string - */ - protected $securityCode; + protected string $securityCode; /** * @var SensitiveValue @@ -63,10 +42,7 @@ class CreditCard implements CreditCardInterface */ protected $securedSecurityCode; - /** - * @var \DateTime - */ - protected $expireAt; + protected \DateTime $expireAt; /** * @var SensitiveValue @@ -86,7 +62,7 @@ public function __construct() /** * {@inheritDoc} */ - public function setToken($token) + public function setToken(string $token) { $this->token = $token; } @@ -102,7 +78,7 @@ public function getToken() /** * {@inheritDoc} */ - public function setBrand($brand) + public function setBrand(string $brand) { $this->brand = $brand; } @@ -118,7 +94,7 @@ public function getBrand() /** * {@inheritDoc} */ - public function setHolder($holder) + public function setHolder(SensitiveValue|string $holder) { $this->securedHolder = SensitiveValue::ensureSensitive($holder); $this->maskedHolder = Mask::mask($this->securedHolder->peek()); @@ -138,7 +114,7 @@ public function getHolder() /** * {@inheritDoc} */ - public function setMaskedHolder($maskedHolder) + public function setMaskedHolder(string $maskedHolder) { $this->maskedHolder = $maskedHolder; } @@ -174,7 +150,7 @@ public function getNumber() /** * {@inheritDoc} */ - public function setMaskedNumber($maskedNumber) + public function setMaskedNumber(string $maskedNumber) { return $this->maskedNumber = $maskedNumber; } diff --git a/src/Payum/Core/Model/CreditCardInterface.php b/src/Payum/Core/Model/CreditCardInterface.php index 9beeefccc..7d3d82ca3 100644 --- a/src/Payum/Core/Model/CreditCardInterface.php +++ b/src/Payum/Core/Model/CreditCardInterface.php @@ -5,80 +5,41 @@ interface CreditCardInterface { - /** - * @return string - */ - public function getToken(); + public function getToken(): string; - /** - * @param string $token - */ - public function setToken($token); + public function setToken(string $token); - /** - * @return string - */ - public function getBrand(); + public function getBrand(): string; - /** - * @param string $brand - */ - public function setBrand($brand); + public function setBrand(string $brand); - /** - * @return string - */ - public function getHolder(); + public function getHolder(): string; - /** - * @param string|SensitiveValue $holder - */ - public function setHolder($holder); + public function setHolder(SensitiveValue|string $holder); - /** - * @param string $maskedHolder - */ - public function setMaskedHolder($maskedHolder); + public function setMaskedHolder(string $maskedHolder); - /** - * @return string - */ - public function getMaskedHolder(); + public function getMaskedHolder(): string; - /** - * @return string - */ - public function getNumber(); + public function getNumber(): string; /** * @param string|SensitiveValue $number */ public function setNumber($number); - /** - * @param string $maskedNumber - */ - public function setMaskedNumber($maskedNumber); + public function setMaskedNumber(string $maskedNumber); - /** - * @return string - */ - public function getMaskedNumber(); + public function getMaskedNumber(): string; - /** - * @return string - */ - public function getSecurityCode(); + public function getSecurityCode(): string; /** * @param string|SensitiveValue $securityCode */ public function setSecurityCode($securityCode); - /** - * @return \DateTime - */ - public function getExpireAt(); + public function getExpireAt(): \DateTime; /** * @param \DateTime|SensitiveValue $date diff --git a/src/Payum/Core/Model/CreditCardPaymentInterface.php b/src/Payum/Core/Model/CreditCardPaymentInterface.php index 67cc7415f..77d21fd16 100644 --- a/src/Payum/Core/Model/CreditCardPaymentInterface.php +++ b/src/Payum/Core/Model/CreditCardPaymentInterface.php @@ -6,8 +6,5 @@ */ interface CreditCardPaymentInterface { - /** - * @return CreditCardInterface|null - */ - public function getCreditCard(); + public function getCreditCard(): ?CreditCardInterface; } diff --git a/src/Payum/Core/Model/DetailsAggregateInterface.php b/src/Payum/Core/Model/DetailsAggregateInterface.php index 79b218def..ff5a64c0b 100644 --- a/src/Payum/Core/Model/DetailsAggregateInterface.php +++ b/src/Payum/Core/Model/DetailsAggregateInterface.php @@ -3,8 +3,5 @@ interface DetailsAggregateInterface { - /** - * @return object|null - */ - public function getDetails(); + public function getDetails(): ?object; } diff --git a/src/Payum/Core/Model/DetailsAwareInterface.php b/src/Payum/Core/Model/DetailsAwareInterface.php index b4142176c..f1031f477 100644 --- a/src/Payum/Core/Model/DetailsAwareInterface.php +++ b/src/Payum/Core/Model/DetailsAwareInterface.php @@ -3,10 +3,5 @@ interface DetailsAwareInterface { - /** - * @param object $details - * - * @return void - */ - public function setDetails($details); + public function setDetails(object $details): void; } diff --git a/src/Payum/Core/Model/DirectDebitPaymentInterface.php b/src/Payum/Core/Model/DirectDebitPaymentInterface.php index 9a6513067..68c203110 100644 --- a/src/Payum/Core/Model/DirectDebitPaymentInterface.php +++ b/src/Payum/Core/Model/DirectDebitPaymentInterface.php @@ -3,8 +3,5 @@ interface DirectDebitPaymentInterface { - /** - * @return BankAccountInterface|null - */ - public function getBankAccount(); + public function getBankAccount(): ?BankAccountInterface; } diff --git a/src/Payum/Core/Model/GatewayConfig.php b/src/Payum/Core/Model/GatewayConfig.php index 7814f0b49..aba277558 100644 --- a/src/Payum/Core/Model/GatewayConfig.php +++ b/src/Payum/Core/Model/GatewayConfig.php @@ -6,27 +6,18 @@ class GatewayConfig implements GatewayConfigInterface, CryptedInterface { - /** - * @var string - */ - protected $factoryName; + protected string $factoryName; - /** - * @var string - */ - protected $gatewayName; + protected string $gatewayName; - /** - * @var array - */ - protected $config; + protected array $config; /** * Note: This should not be persisted to database * * @var array */ - protected $decryptedConfig; + protected array $decryptedConfig; public function __construct() { @@ -37,7 +28,7 @@ public function __construct() /** * {@inheritDoc} */ - public function getFactoryName() + public function getFactoryName(): string { return $this->factoryName; } @@ -45,23 +36,17 @@ public function getFactoryName() /** * {@inheritDoc} */ - public function setFactoryName($factoryName) + public function setFactoryName($factoryName): void { $this->factoryName = $factoryName; } - /** - * @return string - */ - public function getGatewayName() + public function getGatewayName(): string { return $this->gatewayName; } - - /** - * @param string $gatewayName - */ - public function setGatewayName($gatewayName) + + public function setGatewayName(string $gatewayName): void { $this->gatewayName = $gatewayName; } diff --git a/src/Payum/Core/Model/GatewayConfigInterface.php b/src/Payum/Core/Model/GatewayConfigInterface.php index 05057a9c6..635663d3d 100644 --- a/src/Payum/Core/Model/GatewayConfigInterface.php +++ b/src/Payum/Core/Model/GatewayConfigInterface.php @@ -3,37 +3,23 @@ interface GatewayConfigInterface { - /** - * @return string - */ - public function getGatewayName(); + public function getGatewayName(): string ; - /** - * @param string $gatewayName - */ - public function setGatewayName($gatewayName); + public function setGatewayName(string $gatewayName); /** * @deprecated since 1.3.3 will be removed in 2.0. set factory option inside the config - * - * @return string */ - public function getFactoryName(); + public function getFactoryName(): string; /** * @deprecated since 1.3.3 will be removed in 2.0. set factory option inside the config * * @param string $name */ - public function setFactoryName($name); + public function setFactoryName(string $name); - /** - * @param array $config - */ public function setConfig(array $config); - /** - * @return array - */ - public function getConfig(); + public function getConfig(): array; } diff --git a/src/Payum/Core/Model/Identity.php b/src/Payum/Core/Model/Identity.php index d800b018f..5f63bda92 100644 --- a/src/Payum/Core/Model/Identity.php +++ b/src/Payum/Core/Model/Identity.php @@ -5,30 +5,17 @@ class Identity implements IdentityInterface { - /** - * @var string - */ - protected $class; - - /** - * @var mixed - */ - protected $id; + protected string $class; - /** - * @param mixed $id - * @param string|object $class - */ - public function __construct($id, $class) + public function __construct(protected mixed $id, string|object $class) { - $this->id = $id; $this->class = is_object($class) ? get_class($class) : $class; } /** * {@inheritDoc} */ - public function getClass() + public function getClass(): object|string { return $this->class; } @@ -44,7 +31,7 @@ public function getId() /** * {@inheritDoc} */ - public function serialize() + public function serialize(): ?string { return serialize(array($this->id, $this->class)); } @@ -52,7 +39,7 @@ public function serialize() /** * {@inheritDoc} */ - public function unserialize($serialized) + public function unserialize($serialized): void { list($this->id, $this->class) = unserialize($serialized); } @@ -62,15 +49,12 @@ public function __serialize(): array return array($this->id, $this->class); } - public function __unserialize(array $data) + public function __unserialize(array $data): void { list($this->id, $this->class) = $data; } - /** - * @return string - */ - public function __toString() + public function __toString(): string { return $this->class.'#'.$this->id; } diff --git a/src/Payum/Core/Model/ModelAggregateInterface.php b/src/Payum/Core/Model/ModelAggregateInterface.php index cbc9b61c7..249a22e7d 100644 --- a/src/Payum/Core/Model/ModelAggregateInterface.php +++ b/src/Payum/Core/Model/ModelAggregateInterface.php @@ -3,8 +3,5 @@ interface ModelAggregateInterface { - /** - * @return mixed - */ - public function getModel(); + public function getModel(): mixed; } diff --git a/src/Payum/Core/Model/ModelAwareInterface.php b/src/Payum/Core/Model/ModelAwareInterface.php index e19ebd7b8..78939f073 100644 --- a/src/Payum/Core/Model/ModelAwareInterface.php +++ b/src/Payum/Core/Model/ModelAwareInterface.php @@ -3,10 +3,5 @@ interface ModelAwareInterface { - /** - * @param mixed $model - * - * @return void - */ - public function setModel($model); + public function setModel(mixed $model): void; } diff --git a/src/Payum/Core/Model/Payment.php b/src/Payum/Core/Model/Payment.php index 4805bc917..4e0bc1681 100644 --- a/src/Payum/Core/Model/Payment.php +++ b/src/Payum/Core/Model/Payment.php @@ -160,9 +160,9 @@ public function getDetails() /** * {@inheritDoc} * - * @param array|\Traversable $details + * @param object $details */ - public function setDetails($details) + public function setDetails(object $details) { if ($details instanceof \Traversable) { $details = iterator_to_array($details); diff --git a/src/Payum/Core/Model/PaymentInterface.php b/src/Payum/Core/Model/PaymentInterface.php index df8ecda7f..fb5566a0f 100644 --- a/src/Payum/Core/Model/PaymentInterface.php +++ b/src/Payum/Core/Model/PaymentInterface.php @@ -6,33 +6,15 @@ */ interface PaymentInterface extends CreditCardPaymentInterface, DetailsAggregateInterface, DetailsAwareInterface { - /** - * @return string - */ - public function getNumber(); + public function getNumber(): string; - /** - * @return string - */ - public function getDescription(); + public function getDescription(): string; - /** - * @return string - */ - public function getClientEmail(); + public function getClientEmail(): string; - /** - * @return string - */ - public function getClientId(); + public function getClientId(): string; - /** - * @return int - */ - public function getTotalAmount(); + public function getTotalAmount(): int; - /** - * @return string - */ - public function getCurrencyCode(); + public function getCurrencyCode(): string; } diff --git a/src/Payum/Core/Model/Payout.php b/src/Payum/Core/Model/Payout.php index f602a087a..c78c6c9d0 100644 --- a/src/Payum/Core/Model/Payout.php +++ b/src/Payum/Core/Model/Payout.php @@ -132,9 +132,9 @@ public function getDetails() /** * {@inheritDoc} * - * @param array|\Traversable $details + * @param object $details */ - public function setDetails($details) + public function setDetails(object $details) { if ($details instanceof \Traversable) { $details = iterator_to_array($details); diff --git a/src/Payum/Core/Model/PayoutInterface.php b/src/Payum/Core/Model/PayoutInterface.php index 676852058..7b57b1587 100644 --- a/src/Payum/Core/Model/PayoutInterface.php +++ b/src/Payum/Core/Model/PayoutInterface.php @@ -6,28 +6,13 @@ */ interface PayoutInterface extends DetailsAggregateInterface, DetailsAwareInterface { - /** - * @return string - */ - public function getRecipientId(); + public function getRecipientId(): string; - /** - * @return string - */ - public function getRecipientEmail(); + public function getRecipientEmail(): string; - /** - * @return string - */ - public function getDescription(); + public function getDescription(): string; - /** - * @return int - */ - public function getTotalAmount(); + public function getTotalAmount(): int; - /** - * @return string - */ - public function getCurrencyCode(); + public function getCurrencyCode(): string; } diff --git a/src/Payum/Core/Model/Token.php b/src/Payum/Core/Model/Token.php index 1f1889c2e..4a07b7132 100644 --- a/src/Payum/Core/Model/Token.php +++ b/src/Payum/Core/Model/Token.php @@ -7,30 +7,15 @@ class Token implements TokenInterface { - /** - * @var IdentityInterface - */ - protected $details; + protected IdentityInterface $details; - /** - * @var string - */ - protected $hash; + protected string $hash; - /** - * @var string - */ - protected $afterUrl; + protected string $afterUrl; - /** - * @var string - */ - protected $targetUrl; + protected string $targetUrl; - /** - * @var string - */ - protected $gatewayName; + protected string $gatewayName; public function __construct() { @@ -39,10 +24,8 @@ public function __construct() /** * {@inheritDoc} - * - * @return Identity */ - public function getDetails() + public function getDetails(): Identity { return $this->details; } @@ -50,7 +33,7 @@ public function getDetails() /** * {@inheritDoc} */ - public function setDetails($details) + public function setDetails(object $details) { $this->details = $details; } @@ -66,7 +49,7 @@ public function getHash() /** * {@inheritDoc} */ - public function setHash($hash) + public function setHash(string $hash) { $this->hash = $hash; } @@ -82,7 +65,7 @@ public function getTargetUrl() /** * {@inheritDoc} */ - public function setTargetUrl($targetUrl) + public function setTargetUrl(string $targetUrl) { $this->targetUrl = $targetUrl; } @@ -98,7 +81,7 @@ public function getAfterUrl() /** * {@inheritDoc} */ - public function setAfterUrl($afterUrl) + public function setAfterUrl(string $afterUrl) { $this->afterUrl = $afterUrl; } @@ -114,7 +97,7 @@ public function getGatewayName() /** * {@inheritDoc} */ - public function setGatewayName($gatewayName) + public function setGatewayName(string $gatewayName) { $this->gatewayName = $gatewayName; } diff --git a/src/Payum/Core/Payum.php b/src/Payum/Core/Payum.php index 974bb05a6..460ab2ff9 100644 --- a/src/Payum/Core/Payum.php +++ b/src/Payum/Core/Payum.php @@ -8,48 +8,18 @@ class Payum implements RegistryInterface { - /** - * @var RegistryInterface - */ - protected $registry; - - /** - * @var HttpRequestVerifierInterface - */ - protected $httpRequestVerifier; - - /** - * @var GenericTokenFactoryInterface - */ - protected $tokenFactory; - - /** - * @var StorageInterface - */ - protected $tokenStorage; - - /** - * @param RegistryInterface $registry - * @param HttpRequestVerifierInterface $httpRequestVerifier - * @param GenericTokenFactoryInterface $tokenFactory - * @param StorageInterface $tokenStorage - */ public function __construct( - RegistryInterface $registry, - HttpRequestVerifierInterface $httpRequestVerifier, - GenericTokenFactoryInterface $tokenFactory, - StorageInterface $tokenStorage + protected RegistryInterface $registry, + protected HttpRequestVerifierInterface $httpRequestVerifier, + protected GenericTokenFactoryInterface $tokenFactory, + protected StorageInterface $tokenStorage ) { - $this->registry = $registry; - $this->httpRequestVerifier = $httpRequestVerifier; - $this->tokenFactory = $tokenFactory; - $this->tokenStorage = $tokenStorage; } /** * {@inheritDoc} */ - public function getGatewayFactory($name) + public function getGatewayFactory($name): GatewayFactoryInterface { return $this->registry->getGatewayFactory($name); } @@ -57,7 +27,7 @@ public function getGatewayFactory($name) /** * {@inheritDoc} */ - public function getGatewayFactories() + public function getGatewayFactories(): array { return $this->registry->getGatewayFactories(); } @@ -65,7 +35,7 @@ public function getGatewayFactories() /** * {@inheritDoc} */ - public function getGateway($name) + public function getGateway(string $name): GatewayInterface { return $this->registry->getGateway($name); } @@ -73,7 +43,7 @@ public function getGateway($name) /** * {@inheritDoc} */ - public function getGateways() + public function getGateways(): array { return $this->registry->getGateways(); } @@ -81,7 +51,7 @@ public function getGateways() /** * {@inheritDoc} */ - public function getStorage($class) + public function getStorage($class): StorageInterface { return $this->registry->getStorage($class); } @@ -89,31 +59,22 @@ public function getStorage($class) /** * {@inheritDoc} */ - public function getStorages() + public function getStorages(): array { return $this->registry->getStorages(); } - /** - * @return HttpRequestVerifierInterface - */ - public function getHttpRequestVerifier() + public function getHttpRequestVerifier(): HttpRequestVerifierInterface { return $this->httpRequestVerifier; } - /** - * @return GenericTokenFactoryInterface - */ - public function getTokenFactory() + public function getTokenFactory(): GenericTokenFactoryInterface { return $this->tokenFactory; } - /** - * @return StorageInterface - */ - public function getTokenStorage() + public function getTokenStorage(): StorageInterface { return $this->tokenStorage; } diff --git a/src/Payum/Core/PayumBuilder.php b/src/Payum/Core/PayumBuilder.php index 5d3c5fab1..2cd42a6e3 100644 --- a/src/Payum/Core/PayumBuilder.php +++ b/src/Payum/Core/PayumBuilder.php @@ -59,69 +59,44 @@ class PayumBuilder /** * @var string[] */ - protected $genericTokenFactoryPaths = []; + protected array $genericTokenFactoryPaths = []; - /** - * @var StorageInterface - */ - protected $tokenStorage; + protected StorageInterface $tokenStorage; /** * @var GatewayFactoryInterface|callable|null */ protected $coreGatewayFactory; - /** - * @var array - */ - protected $coreGatewayFactoryConfig = []; + protected array $coreGatewayFactoryConfig = []; - /** - * @var StorageInterface - */ - protected $gatewayConfigStorage; + protected StorageInterface $gatewayConfigStorage; - /** - * @var GatewayInterface[] - */ - protected $gateways = []; + protected array $gateways = []; - /** - * @var array - */ - protected $gatewayConfigs = []; + protected array $gatewayConfigs = []; /** * @var GatewayFactoryInterface[]|callable[] */ - protected $gatewayFactories = []; + protected array $gatewayFactories = []; - /** - * @var array - */ - protected $gatewayFactoryConfigs = []; + protected array $gatewayFactoryConfigs = []; /** * @var StorageInterface[] */ - protected $storages = []; + protected array $storages = []; - /** - * @var RegistryInterface - */ - protected $mainRegistry; + protected RegistryInterface $mainRegistry; /** * @deprecated will be removed in 2.0 - * - * @var HttpClientInterface */ - protected $httpClient; + protected HttpClientInterface $httpClient; - /** - * @return static - */ - public function addDefaultStorages() + + public function addDefaultStorages(): static { $this ->setTokenStorage(new FilesystemStorage(sys_get_temp_dir(), Token::class, 'hash')) @@ -134,13 +109,7 @@ public function addDefaultStorages() return $this; } - /** - * @param string $modelClass - * @param StorageInterface $storage - * - * @return static - */ - public function addStorage($modelClass, StorageInterface $storage) + public function addStorage(string $modelClass, StorageInterface $storage): static { // TODO add checks @@ -149,13 +118,7 @@ public function addStorage($modelClass, StorageInterface $storage) return $this; } - /** - * @param string $name - * @param GatewayInterface|array $gateway - * - * @return static - */ - public function addGateway($name, $gateway) + public function addGateway(string $name, GatewayInterface|array $gateway): static { // TODO add checks if ($gateway instanceof GatewayInterface) { @@ -175,13 +138,7 @@ public function addGateway($name, $gateway) return $this; } - /** - * @param string $name - * @param GatewayFactoryInterface|callable $gatewayFactory - * - * @return static - */ - public function addGatewayFactory($name, $gatewayFactory) + public function addGatewayFactory(string $name, callable|GatewayFactoryInterface $gatewayFactory): static { if ( $gatewayFactory instanceof GatewayFactoryInterface || @@ -194,26 +151,15 @@ public function addGatewayFactory($name, $gatewayFactory) throw new InvalidArgumentException('Invalid argument'); } - /** - * @param string $name - * @param array $config - * - * @return static - */ - public function addGatewayFactoryConfig($name, array $config) + public function addGatewayFactoryConfig(string $name, array $config): static { - $currentConfig = isset($this->gatewayFactoryConfigs[$name]) ? $this->gatewayFactoryConfigs[$name] : []; + $currentConfig = $this->gatewayFactoryConfigs[$name] ?? []; $this->gatewayFactoryConfigs[$name] = array_replace_recursive($currentConfig, $config); return $this; } - /** - * @param HttpRequestVerifierInterface|callable|null $httpRequestVerifier - * - * @return static - */ - public function setHttpRequestVerifier($httpRequestVerifier = null) + public function setHttpRequestVerifier(callable|HttpRequestVerifierInterface $httpRequestVerifier = null): static { if ( null === $httpRequestVerifier || @@ -227,12 +173,7 @@ public function setHttpRequestVerifier($httpRequestVerifier = null) throw new InvalidArgumentException('Invalid argument'); } - /** - * @param TokenFactoryInterface|callable|null $tokenFactory - * - * @return static - */ - public function setTokenFactory($tokenFactory = null) + public function setTokenFactory(callable|TokenFactoryInterface $tokenFactory = null): static { if ( null === $tokenFactory || @@ -246,12 +187,7 @@ public function setTokenFactory($tokenFactory = null) throw new InvalidArgumentException('Invalid argument'); } - /** - * @param GenericTokenFactoryInterface|callable|null $tokenFactory - * - * @return static - */ - public function setGenericTokenFactory($tokenFactory = null) + public function setGenericTokenFactory(callable|GenericTokenFactoryInterface $tokenFactory = null): static { if ( null === $tokenFactory || @@ -267,34 +203,22 @@ public function setGenericTokenFactory($tokenFactory = null) /** * @param \string[] $paths - * - * @return static */ - public function setGenericTokenFactoryPaths(array $paths = []) + public function setGenericTokenFactoryPaths(array $paths = []): static { $this->genericTokenFactoryPaths = $paths; return $this; } - /** - * @param StorageInterface $tokenStorage - * - * @return static - */ - public function setTokenStorage(StorageInterface $tokenStorage = null) + public function setTokenStorage(StorageInterface $tokenStorage = null): static { $this->tokenStorage = $tokenStorage; return $this; } - /** - * @param GatewayFactoryInterface|callable|null $coreGatewayFactory - * - * @return static - */ - public function setCoreGatewayFactory($coreGatewayFactory = null) + public function setCoreGatewayFactory(callable|GatewayFactoryInterface $coreGatewayFactory = null): static { if ( null === $coreGatewayFactory || @@ -308,24 +232,14 @@ public function setCoreGatewayFactory($coreGatewayFactory = null) throw new InvalidArgumentException('Invalid argument'); } - /** - * @param array $config - * - * @return static - */ - public function setCoreGatewayFactoryConfig(array $config = null) + public function setCoreGatewayFactoryConfig(array $config = null): static { $this->coreGatewayFactoryConfig = $config; return $this; } - /** - * @param array $config - * - * @return static - */ - public function addCoreGatewayFactoryConfig(array $config) + public function addCoreGatewayFactoryConfig(array $config): static { $currentConfig = $this->coreGatewayFactoryConfig ?: []; $this->coreGatewayFactoryConfig = array_replace_recursive($currentConfig, $config); @@ -333,24 +247,14 @@ public function addCoreGatewayFactoryConfig(array $config) return $this; } - /** - * @param StorageInterface $gatewayConfigStorage - * - * @return static - */ - public function setGatewayConfigStorage(StorageInterface $gatewayConfigStorage = null) + public function setGatewayConfigStorage(StorageInterface $gatewayConfigStorage = null): static { $this->gatewayConfigStorage = $gatewayConfigStorage; return $this; } - /** - * @param RegistryInterface $mainRegistry - * - * @return static - */ - public function setMainRegistry(RegistryInterface $mainRegistry = null) + public function setMainRegistry(RegistryInterface $mainRegistry = null): static { $this->mainRegistry = $mainRegistry; @@ -358,23 +262,16 @@ public function setMainRegistry(RegistryInterface $mainRegistry = null) } /** - * @param HttpClientInterface $httpClient - * * @deprecated this method will be removed in 2.0 Use self::addCoreGatewayFactoryConfig to overwrite http client. - * - * @return static */ - public function setHttpClient(HttpClientInterface $httpClient = null) + public function setHttpClient(HttpClientInterface $httpClient = null): static { $this->httpClient = $httpClient; return $this; } - /** - * @return Payum - */ - public function getPayum() + public function getPayum(): Payum { if (false == $tokenStorage = $this->tokenStorage) { throw new \LogicException('Token storage must be configured.'); @@ -424,13 +321,7 @@ public function getPayum() return new Payum($registry, $httpRequestVerifier, $genericTokenFactory, $tokenStorage); } - /** - * @param StorageInterface $tokenStorage - * @param StorageRegistryInterface $storageRegistry - * - * @return TokenFactoryInterface - */ - protected function buildTokenFactory(StorageInterface $tokenStorage, StorageRegistryInterface $storageRegistry) + protected function buildTokenFactory(StorageInterface $tokenStorage, StorageRegistryInterface $storageRegistry): TokenFactoryInterface { $tokenFactory = $this->tokenFactory; @@ -445,14 +336,7 @@ protected function buildTokenFactory(StorageInterface $tokenStorage, StorageRegi return $tokenFactory ?: new TokenFactory($tokenStorage, $storageRegistry); } - /** - * @param TokenFactoryInterface $tokenFactory - * @param string[] $paths - * - * @return GenericTokenFactoryInterface - * - */ - protected function buildGenericTokenFactory(TokenFactoryInterface $tokenFactory, array $paths) + protected function buildGenericTokenFactory(TokenFactoryInterface $tokenFactory, array $paths): GenericTokenFactoryInterface { $genericTokenFactory = $this->genericTokenFactory; @@ -467,12 +351,7 @@ protected function buildGenericTokenFactory(TokenFactoryInterface $tokenFactory, return $genericTokenFactory ?: new GenericTokenFactory($tokenFactory, $paths); } - /** - * @param StorageInterface $tokenStorage - * - * @return HttpRequestVerifierInterface - */ - private function buildHttpRequestVerifier(StorageInterface $tokenStorage) + private function buildHttpRequestVerifier(StorageInterface $tokenStorage): HttpRequestVerifierInterface { $httpRequestVerifier = $this->httpRequestVerifier; @@ -487,11 +366,7 @@ private function buildHttpRequestVerifier(StorageInterface $tokenStorage) return $httpRequestVerifier ?: new HttpRequestVerifier($tokenStorage); } - /** - * @param array $config - * @return GatewayFactoryInterface - */ - private function buildCoreGatewayFactory(array $config) + private function buildCoreGatewayFactory(array $config): GatewayFactoryInterface { $coreGatewayFactory = $this->coreGatewayFactory; @@ -513,14 +388,7 @@ private function buildCoreGatewayFactory(array $config) return $coreGatewayFactory ?: new CoreGatewayFactory($config); } - /** - * @param array $gateways - * @param array $storages - * @param array $gatewayFactories - * - * @return RegistryInterface - */ - protected function buildRegistry(array $gateways = [], array $storages = [], array $gatewayFactories = []) + protected function buildRegistry(array $gateways = [], array $storages = [], array $gatewayFactories = []): RegistryInterface { $registry = new SimpleRegistry($gateways, $storages, $gatewayFactories); $registry->setAddStorageExtensions(false); @@ -540,11 +408,9 @@ protected function buildRegistry(array $gateways = [], array $storages = [], arr } /** - * @param GatewayFactoryInterface $coreGatewayFactory - * * @return GatewayFactoryInterface[] */ - protected function buildGatewayFactories(GatewayFactoryInterface $coreGatewayFactory) + protected function buildGatewayFactories(GatewayFactoryInterface $coreGatewayFactory): array { $map = [ 'paypal_express_checkout' => PaypalExpressCheckoutGatewayFactory::class, @@ -569,7 +435,7 @@ protected function buildGatewayFactories(GatewayFactoryInterface $coreGatewayFac foreach ($map as $name => $factoryClass) { if (class_exists($factoryClass)) { $gatewayFactories[$name] = new $factoryClass( - isset($this->gatewayFactoryConfigs[$name]) ? $this->gatewayFactoryConfigs[$name] : [], + $this->gatewayFactoryConfigs[$name] ?? [], $coreGatewayFactory ); } @@ -579,11 +445,9 @@ protected function buildGatewayFactories(GatewayFactoryInterface $coreGatewayFac } /** - * @param GatewayFactoryInterface $coreGatewayFactory - * * @return GatewayFactoryInterface[] */ - protected function buildAddedGatewayFactories(GatewayFactoryInterface $coreGatewayFactory) + protected function buildAddedGatewayFactories(GatewayFactoryInterface $coreGatewayFactory): array { $gatewayFactories = []; foreach ($this->gatewayFactories as $name => $factory) { @@ -606,7 +470,7 @@ protected function buildAddedGatewayFactories(GatewayFactoryInterface $coreGatew * * @return GatewayFactoryInterface[] */ - protected function buildOmnipayGatewayFactories(GatewayFactoryInterface $coreGatewayFactory) + protected function buildOmnipayGatewayFactories(GatewayFactoryInterface $coreGatewayFactory): array { $gatewayFactories = []; if (false == class_exists(\Omnipay\Omnipay::class) || false == class_exists(OmnipayGatewayFactory::class)) { @@ -633,11 +497,9 @@ protected function buildOmnipayGatewayFactories(GatewayFactoryInterface $coreGat } /** - * @param GatewayFactoryInterface $coreGatewayFactory - * * @return GatewayFactoryInterface[] */ - protected function buildOmnipayV3GatewayFactories(GatewayFactoryInterface $coreGatewayFactory) + protected function buildOmnipayV3GatewayFactories(GatewayFactoryInterface $coreGatewayFactory): array { $gatewayFactories = []; if (false == class_exists(\Omnipay\Omnipay::class) || false == class_exists(OmnipayV3GatewayFactory::class)) { diff --git a/src/Payum/Core/Registry/AbstractRegistry.php b/src/Payum/Core/Registry/AbstractRegistry.php index cb8d747ed..c8c9b1fdd 100644 --- a/src/Payum/Core/Registry/AbstractRegistry.php +++ b/src/Payum/Core/Registry/AbstractRegistry.php @@ -2,35 +2,14 @@ namespace Payum\Core\Registry; use Payum\Core\Exception\InvalidArgumentException; +use Payum\Core\GatewayFactoryInterface; +use Payum\Core\GatewayInterface; +use Payum\Core\Storage\StorageInterface; abstract class AbstractRegistry implements RegistryInterface { - /** - * @var array - */ - protected $gateways; - - /** - * @var array - */ - protected $storages; - - /** - * @var array - */ - protected $gatewayFactories; - - /** - * @param array $gateways - * @param array $storages - * @param array $gatewayFactories - */ - public function __construct(array $gateways = array(), array $storages = array(), array $gatewayFactories = array()) - { - $this->gateways = $gateways; - $this->storages = $storages; - $this->gatewayFactories = $gatewayFactories; - } + public function __construct(protected array $gateways = [], protected array $storages = [], protected array $gatewayFactories = []) + {} /** * Fetches/creates the given services @@ -41,12 +20,12 @@ public function __construct(array $gateways = array(), array $storages = array() * * @return object instance of the given service */ - abstract protected function getService($id); + abstract protected function getService(string $id): object; /** * {@inheritDoc} */ - public function getStorage($class) + public function getStorage($class): StorageInterface { $class = is_object($class) ? get_class($class) : $class; @@ -79,7 +58,7 @@ public function getStorage($class) /** * {@inheritDoc} */ - public function getStorages() + public function getStorages(): array { $storages = array(); foreach ($this->storages as $modelClass => $storageId) { @@ -92,7 +71,7 @@ public function getStorages() /** * {@inheritDoc} */ - public function getGateway($name) + public function getGateway(string $name): GatewayInterface { if (!isset($this->gateways[$name])) { throw new InvalidArgumentException(sprintf('Gateway "%s" does not exist.', $name)); @@ -104,7 +83,7 @@ public function getGateway($name) /** * {@inheritDoc} */ - public function getGateways() + public function getGateways(): array { $gateways = array(); foreach ($this->gateways as $name => $id) { @@ -117,7 +96,7 @@ public function getGateways() /** * {@inheritDoc} */ - public function getGatewayFactory($name) + public function getGatewayFactory(string $name): GatewayFactoryInterface { if (!isset($this->gatewayFactories[$name])) { throw new InvalidArgumentException(sprintf('Gateway factory "%s" does not exist.', $name)); @@ -129,7 +108,7 @@ public function getGatewayFactory($name) /** * {@inheritDoc} */ - public function getGatewayFactories() + public function getGatewayFactories(): array { $gatewayFactories = array(); foreach ($this->gatewayFactories as $name => $id) { diff --git a/src/Payum/Core/Registry/DynamicRegistry.php b/src/Payum/Core/Registry/DynamicRegistry.php index eedd0902d..202c2c028 100644 --- a/src/Payum/Core/Registry/DynamicRegistry.php +++ b/src/Payum/Core/Registry/DynamicRegistry.php @@ -2,6 +2,7 @@ namespace Payum\Core\Registry; use Payum\Core\Exception\InvalidArgumentException; +use Payum\Core\GatewayFactoryInterface; use Payum\Core\GatewayInterface; use Payum\Core\Model\GatewayConfigInterface; use Payum\Core\Storage\StorageInterface; @@ -11,39 +12,27 @@ class DynamicRegistry implements RegistryInterface /** * @var GatewayInterface[] */ - private $gateways = []; + private array $gateways = []; - /** - * @var StorageInterface - */ - private $gatewayConfigStore; - - /** - * @var GatewayFactoryRegistryInterface|null - */ - private $gatewayFactoryRegistry; + private ?GatewayFactoryRegistryInterface $gatewayFactoryRegistry; /** * @deprecated since 1.3.3 will be removed in 2.0 - * - * @var bool */ - private $backwardCompatibility = true; + private bool $backwardCompatibility = true; /** - * @param StorageInterface $gatewayConfigStore * @param GatewayFactoryRegistryInterface $gatewayFactoryRegistry */ - public function __construct(StorageInterface $gatewayConfigStore, GatewayFactoryRegistryInterface $gatewayFactoryRegistry) + public function __construct(private StorageInterface $gatewayConfigStore, GatewayFactoryRegistryInterface $gatewayFactoryRegistry) { - $this->gatewayConfigStore = $gatewayConfigStore; $this->gatewayFactoryRegistry = $gatewayFactoryRegistry; } /** * {@inheritDoc} */ - public function getGatewayFactory($name) + public function getGatewayFactory($name): GatewayFactoryInterface { // @deprecated It will throw invalid argument exception in 2.x if ($this->backwardCompatibility && $this->gatewayFactoryRegistry instanceof RegistryInterface) { @@ -56,7 +45,7 @@ public function getGatewayFactory($name) /** * {@inheritDoc} */ - public function getGatewayFactories() + public function getGatewayFactories(): array { // @deprecated It will return empty array here if ($this->backwardCompatibility && $this->gatewayFactoryRegistry instanceof RegistryInterface) { @@ -69,7 +58,7 @@ public function getGatewayFactories() /** * {@inheritDoc} */ - public function getGateway($name) + public function getGateway(string $name): GatewayInterface { if (array_key_exists($name, $this->gateways)) { return $this->gateways[$name]; @@ -93,7 +82,7 @@ public function getGateway($name) /** * {@inheritDoc} */ - public function getGateways() + public function getGateways(): array { // @deprecated It will return empty array here if ($this->backwardCompatibility && $this->gatewayFactoryRegistry instanceof RegistryInterface) { @@ -113,7 +102,7 @@ public function getGateways() /** * {@inheritDoc} */ - public function getStorage($class) + public function getStorage($class): StorageInterface { // @deprecated It will throw invalid argument exception in 2.x if ($this->backwardCompatibility && $this->gatewayFactoryRegistry instanceof RegistryInterface) { @@ -129,7 +118,7 @@ public function getStorage($class) /** * {@inheritDoc} */ - public function getStorages() + public function getStorages(): array { // @deprecated It will return empty array here if ($this->backwardCompatibility && $this->gatewayFactoryRegistry instanceof RegistryInterface) { @@ -149,12 +138,7 @@ public function setBackwardCompatibility($backwardCompatibility) $this->backwardCompatibility = $backwardCompatibility; } - /** - * @param GatewayConfigInterface $gatewayConfig - * - * @return GatewayInterface - */ - protected function createGateway(GatewayConfigInterface $gatewayConfig) + protected function createGateway(GatewayConfigInterface $gatewayConfig): GatewayInterface { $config = $gatewayConfig->getConfig(); diff --git a/src/Payum/Core/Registry/FallbackRegistry.php b/src/Payum/Core/Registry/FallbackRegistry.php index 3d303f58d..d2ce7e60a 100644 --- a/src/Payum/Core/Registry/FallbackRegistry.php +++ b/src/Payum/Core/Registry/FallbackRegistry.php @@ -48,7 +48,7 @@ public function getGatewayFactories() /** * {@inheritDoc} */ - public function getGateway($name) + public function getGateway(string $name) { try { return $this->registry->getGateway($name); diff --git a/src/Payum/Core/Registry/GatewayFactoryRegistryInterface.php b/src/Payum/Core/Registry/GatewayFactoryRegistryInterface.php index b233b7a9c..4616b6d9d 100644 --- a/src/Payum/Core/Registry/GatewayFactoryRegistryInterface.php +++ b/src/Payum/Core/Registry/GatewayFactoryRegistryInterface.php @@ -1,21 +1,19 @@ addStorageExtensions = $bool; } @@ -32,7 +28,7 @@ public function setAddStorageExtensions($bool) /** * {@inheritDoc} */ - public function getGateway($name) + public function getGateway(string $name): GatewayInterface { $gateway = parent::getGateway($name); @@ -46,18 +42,15 @@ public function getGateway($name) /** * {@inheritDoc} */ - protected function getService($id) + protected function getService(string $id): object|string { return $id; } /** * @deprecated since 1.3.3 and will be removed in 2.x. - * - * @param string $name - * @param GatewayInterface $gateway */ - protected function addStorageToGateway($name, GatewayInterface $gateway) + protected function addStorageToGateway(string $name, GatewayInterface $gateway): void { /** @var Gateway $gateway */ if (false == $gateway instanceof Gateway) { diff --git a/src/Payum/Core/Registry/StorageRegistryInterface.php b/src/Payum/Core/Registry/StorageRegistryInterface.php index e001ac595..025cb4785 100644 --- a/src/Payum/Core/Registry/StorageRegistryInterface.php +++ b/src/Payum/Core/Registry/StorageRegistryInterface.php @@ -7,18 +7,14 @@ interface StorageRegistryInterface { /** - * @param object|string $class - * * @throws InvalidArgumentException if storage with such name not exists - * - * @return StorageInterface */ - public function getStorage($class); + public function getStorage(object|string $class): StorageInterface; /** * The key must be a model class * * @return StorageInterface[] */ - public function getStorages(); + public function getStorages(): array; } diff --git a/src/Payum/Core/Reply/BaseModelAware.php b/src/Payum/Core/Reply/BaseModelAware.php index c40290aec..c0779916b 100644 --- a/src/Payum/Core/Reply/BaseModelAware.php +++ b/src/Payum/Core/Reply/BaseModelAware.php @@ -7,31 +7,19 @@ abstract class BaseModelAware extends LogicException implements ReplyInterface, ModelAwareInterface, ModelAggregateInterface { - /** - * @var mixed - */ - protected $model; + protected mixed $model; - /** - * @param mixed $model - */ - public function __construct($model) + public function __construct(mixed $model) { $this->setModel($model); } - /** - * @return mixed - */ - public function getModel() + public function getModel(): mixed { return $this->model; } - /** - * @param mixed $model - */ - public function setModel($model) + public function setModel($model): void { if (is_array($model)) { $model = new \ArrayObject($model); diff --git a/src/Payum/Core/Reply/HttpPostRedirect.php b/src/Payum/Core/Reply/HttpPostRedirect.php index 00ce33400..a1de0d68f 100644 --- a/src/Payum/Core/Reply/HttpPostRedirect.php +++ b/src/Payum/Core/Reply/HttpPostRedirect.php @@ -3,23 +3,14 @@ class HttpPostRedirect extends HttpResponse { - /** - * @var string - */ - protected $url; + protected string $url; - /** - * @var array - */ - protected $fields; + protected array $fields; /** - * @param string $url - * @param array $fields - * @param int $statusCode * @param string[] $headers */ - public function __construct($url, array $fields = array(), $statusCode = 200, array $headers = array()) + public function __construct(string $url, array $fields = [], $statusCode = 200, array $headers = []) { $this->url = $url; $this->fields = $fields; @@ -27,29 +18,17 @@ public function __construct($url, array $fields = array(), $statusCode = 200, ar parent::__construct($this->prepareContent($url, $fields), $statusCode, $headers); } - /** - * @return string - */ - public function getUrl() + public function getUrl(): string { return $this->url; } - /** - * @return array - */ - public function getFields() + public function getFields(): array { return $this->fields; } - /** - * @param string $url - * @param array $fields - * - * @return string - */ - protected function prepareContent($url, array $fields) + protected function prepareContent(string $url, array $fields): string { $formInputs = ''; foreach ($fields as $name => $value) { diff --git a/src/Payum/Core/Reply/HttpRedirect.php b/src/Payum/Core/Reply/HttpRedirect.php index 6ba865cab..c3b43de0d 100644 --- a/src/Payum/Core/Reply/HttpRedirect.php +++ b/src/Payum/Core/Reply/HttpRedirect.php @@ -3,17 +3,12 @@ class HttpRedirect extends HttpResponse { - /** - * @var string - */ - protected $url; + protected string $url; /** - * @param string $url - * @param int $statusCode * @param string[] $headers */ - public function __construct($url, $statusCode = 302, array $headers = array()) + public function __construct($url, $statusCode = 302, array $headers = []) { $this->url = $url; @@ -22,20 +17,12 @@ public function __construct($url, $statusCode = 302, array $headers = array()) parent::__construct($this->prepareContent($url), $statusCode, $headers); } - /** - * @return string - */ - public function getUrl() + public function getUrl(): string { return $this->url; } - /** - * @param $url - * - * @return string - */ - protected function prepareContent($url) + protected function prepareContent(string $url): string { if (empty($url)) { throw new \InvalidArgumentException('Cannot redirect to an empty URL.'); diff --git a/src/Payum/Core/Reply/HttpResponse.php b/src/Payum/Core/Reply/HttpResponse.php index c3c658442..23118c8ae 100644 --- a/src/Payum/Core/Reply/HttpResponse.php +++ b/src/Payum/Core/Reply/HttpResponse.php @@ -3,45 +3,31 @@ class HttpResponse extends Base { - /** - * @var string - */ - protected $content; + protected string $content; - /** - * @var int - */ - protected $statusCode; + protected int $statusCode; /** * @var string[] */ - protected $headers; + protected array $headers; /** - * @param string $content - * @param int $statusCode * @param string[] $headers */ - public function __construct($content, $statusCode = 200, array $headers = array()) + public function __construct(string $content, int $statusCode = 200, array $headers = []) { $this->content = $content; $this->statusCode = $statusCode; $this->headers = $headers; } - /** - * @return string - */ - public function getContent() + public function getContent(): string { return $this->content; } - /** - * @return int - */ - public function getStatusCode() + public function getStatusCode(): int { return $this->statusCode; } @@ -49,7 +35,7 @@ public function getStatusCode() /** * @return string[] */ - public function getHeaders() + public function getHeaders(): array { return $this->headers; } diff --git a/src/Payum/Core/Request/BaseGetStatus.php b/src/Payum/Core/Request/BaseGetStatus.php index d522999ee..e0e2dd761 100644 --- a/src/Payum/Core/Request/BaseGetStatus.php +++ b/src/Payum/Core/Request/BaseGetStatus.php @@ -3,10 +3,7 @@ abstract class BaseGetStatus extends Generic implements GetStatusInterface { - /** - * @var int - */ - protected $status; + protected int $status; /** * {@inheritDoc} diff --git a/src/Payum/Core/Request/Convert.php b/src/Payum/Core/Request/Convert.php index f4065bda6..eca3a83f1 100644 --- a/src/Payum/Core/Request/Convert.php +++ b/src/Payum/Core/Request/Convert.php @@ -5,74 +5,33 @@ class Convert { - /** - * @var mixed - */ - protected $source; + protected mixed $result; - /** - * @var mixed - */ - protected $result; - - /** - * @var string - */ - protected $to; - - /** - * @var TokenInterface - */ - private $token; - - /** - * @param mixed $source - * @param string $to - * @param TokenInterface $token - */ - public function __construct($source, $to, TokenInterface $token = null) + public function __construct(protected mixed $source, protected string $to, private ?TokenInterface $token = null) { - $this->source = $source; - $this->to = $to; - $this->token = $token; } - /** - * @return mixed - */ - public function getSource() + public function getSource(): mixed { return $this->source; } - /** - * @return string - */ - public function getTo() + public function getTo(): string { return $this->to; } - /** - * @return TokenInterface - */ - public function getToken() + public function getToken(): ?TokenInterface { return $this->token; } - /** - * @return mixed - */ - public function getResult() + public function getResult(): mixed { return $this->result; } - /** - * @param mixed $result - */ - public function setResult($result) + public function setResult(mixed $result): void { $this->result = $result; } diff --git a/src/Payum/Core/Request/Generic.php b/src/Payum/Core/Request/Generic.php index ac01dc89f..ee683e95b 100644 --- a/src/Payum/Core/Request/Generic.php +++ b/src/Payum/Core/Request/Generic.php @@ -9,25 +9,13 @@ abstract class Generic implements ModelAwareInterface, ModelAggregateInterface, TokenAggregateInterface { - /** - * @var mixed - */ - protected $model; + protected mixed $model; - /** - * @var mixed - */ - protected $firstModel; + protected mixed $firstModel; - /** - * @var TokenInterface - */ - protected $token; + protected TokenInterface $token; - /** - * @param mixed $model - */ - public function __construct($model) + public function __construct(mixed $model) { $this->setModel($model); @@ -36,18 +24,12 @@ public function __construct($model) } } - /** - * @return mixed - */ - public function getModel() + public function getModel(): mixed { return $this->model; } - /** - * @param mixed $model - */ - public function setModel($model) + public function setModel(mixed $model): void { if (is_array($model)) { $model = new \ArrayObject($model); @@ -61,23 +43,17 @@ public function setModel($model) /** * {@inheritDoc} */ - public function getToken() + public function getToken(): ?TokenInterface { return $this->token; } - /** - * @return mixed - */ - public function getFirstModel() + public function getFirstModel(): mixed { return $this->firstModel; } - /** - * @param mixed $model - */ - protected function setFirstModel($model) + protected function setFirstModel(mixed $model): void { if ($this->firstModel) { return; diff --git a/src/Payum/Core/Request/GetBinaryStatus.php b/src/Payum/Core/Request/GetBinaryStatus.php index bc23ef54e..b3e95d59a 100644 --- a/src/Payum/Core/Request/GetBinaryStatus.php +++ b/src/Payum/Core/Request/GetBinaryStatus.php @@ -28,7 +28,7 @@ class GetBinaryStatus extends BaseGetStatus /** * {@inheritDoc} */ - public function markCaptured() + public function markCaptured(): void { $this->status = static::STATUS_CAPTURED; } @@ -36,7 +36,7 @@ public function markCaptured() /** * {@inheritDoc} */ - public function isCaptured() + public function isCaptured(): bool { return $this->isCurrentStatusEqualTo(static::STATUS_CAPTURED); } @@ -44,7 +44,7 @@ public function isCaptured() /** * {@inheritDoc} */ - public function markAuthorized() + public function markAuthorized(): void { $this->status = static::STATUS_AUTHORIZED; } @@ -52,7 +52,7 @@ public function markAuthorized() /** * {@inheritDoc} */ - public function isAuthorized() + public function isAuthorized(): bool { return $this->isCurrentStatusEqualTo(static::STATUS_AUTHORIZED); } @@ -60,7 +60,7 @@ public function isAuthorized() /** * {@inheritDoc} */ - public function markPayedout() + public function markPayedout(): void { $this->status = static::STATUS_PAYEDOUT; } @@ -68,7 +68,7 @@ public function markPayedout() /** * {@inheritDoc} */ - public function isPayedout() + public function isPayedout(): bool { return $this->isCurrentStatusEqualTo(static::STATUS_PAYEDOUT); } @@ -76,7 +76,7 @@ public function isPayedout() /** * {@inheritDoc} */ - public function markRefunded() + public function markRefunded(): void { $this->status = static::STATUS_REFUNDED; } @@ -84,7 +84,7 @@ public function markRefunded() /** * {@inheritDoc} */ - public function isRefunded() + public function isRefunded(): bool { return $this->isCurrentStatusEqualTo(static::STATUS_REFUNDED); } @@ -92,7 +92,7 @@ public function isRefunded() /** * {@inheritDoc} */ - public function markSuspended() + public function markSuspended(): void { $this->status = static::STATUS_SUSPENDED; } @@ -100,7 +100,7 @@ public function markSuspended() /** * {@inheritDoc} */ - public function isSuspended() + public function isSuspended(): bool { return $this->isCurrentStatusEqualTo(static::STATUS_SUSPENDED); } @@ -108,7 +108,7 @@ public function isSuspended() /** * {@inheritDoc} */ - public function markExpired() + public function markExpired(): void { $this->status = static::STATUS_EXPIRED; } @@ -116,7 +116,7 @@ public function markExpired() /** * {@inheritDoc} */ - public function isExpired() + public function isExpired(): bool { return $this->isCurrentStatusEqualTo(static::STATUS_EXPIRED); } @@ -124,7 +124,7 @@ public function isExpired() /** * {@inheritDoc} */ - public function markCanceled() + public function markCanceled(): void { $this->status = static::STATUS_CANCELED; } @@ -132,7 +132,7 @@ public function markCanceled() /** * {@inheritDoc} */ - public function isCanceled() + public function isCanceled(): bool { return $this->isCurrentStatusEqualTo(static::STATUS_CANCELED); } @@ -140,7 +140,7 @@ public function isCanceled() /** * {@inheritDoc} */ - public function markPending() + public function markPending(): void { $this->status = static::STATUS_PENDING; } @@ -148,7 +148,7 @@ public function markPending() /** * {@inheritDoc} */ - public function isPending() + public function isPending(): bool { return $this->isCurrentStatusEqualTo(static::STATUS_PENDING); } @@ -156,7 +156,7 @@ public function isPending() /** * {@inheritDoc} */ - public function markFailed() + public function markFailed(): void { $this->status = static::STATUS_FAILED; } @@ -164,7 +164,7 @@ public function markFailed() /** * {@inheritDoc} */ - public function isFailed() + public function isFailed(): bool { return $this->isCurrentStatusEqualTo(static::STATUS_FAILED); } @@ -172,7 +172,7 @@ public function isFailed() /** * {@inheritDoc} */ - public function markNew() + public function markNew(): void { $this->status = static::STATUS_NEW; } @@ -180,7 +180,7 @@ public function markNew() /** * {@inheritDoc} */ - public function isNew() + public function isNew(): bool { return $this->isCurrentStatusEqualTo(static::STATUS_NEW); } @@ -188,7 +188,7 @@ public function isNew() /** * {@inheritDoc} */ - public function markUnknown() + public function markUnknown(): void { $this->status = static::STATUS_UNKNOWN; } @@ -196,17 +196,12 @@ public function markUnknown() /** * {@inheritDoc} */ - public function isUnknown() + public function isUnknown(): bool { return $this->isCurrentStatusEqualTo(static::STATUS_UNKNOWN); } - /** - * @param int $expectedStatus - * - * @return boolean - */ - protected function isCurrentStatusEqualTo($expectedStatus) + protected function isCurrentStatusEqualTo(int $expectedStatus): bool { return ($expectedStatus | $this->getValue()) == $expectedStatus; } diff --git a/src/Payum/Core/Request/GetCreditCardToken.php b/src/Payum/Core/Request/GetCreditCardToken.php index 40146bd39..80e4e3544 100644 --- a/src/Payum/Core/Request/GetCreditCardToken.php +++ b/src/Payum/Core/Request/GetCreditCardToken.php @@ -1,10 +1,9 @@ code = $code; } diff --git a/src/Payum/Core/Request/GetHttpRequest.php b/src/Payum/Core/Request/GetHttpRequest.php index e48e365f3..d367d94e4 100644 --- a/src/Payum/Core/Request/GetHttpRequest.php +++ b/src/Payum/Core/Request/GetHttpRequest.php @@ -3,40 +3,19 @@ class GetHttpRequest { - /** - * @var array - */ - public $query; - - /** - * @var array - */ - public $request; - - /** - * @var string - */ - public $method; - - /** - * @var string - */ - public $uri; - - /** - * @var string - */ - public $clientIp; - - /** - * @var string - */ - public $userAgent; - - /** - * @var string - */ - public $content; + public array $query; + + public array $request; + + public string $method; + + public string $uri; + + public string $clientIp; + + public string $userAgent; + + public string $content; public function __construct() { diff --git a/src/Payum/Core/Request/GetHumanStatus.php b/src/Payum/Core/Request/GetHumanStatus.php index b44afa8f4..b6db39e44 100644 --- a/src/Payum/Core/Request/GetHumanStatus.php +++ b/src/Payum/Core/Request/GetHumanStatus.php @@ -3,32 +3,32 @@ class GetHumanStatus extends BaseGetStatus { - const STATUS_CAPTURED = 'captured'; + public const STATUS_CAPTURED = 'captured'; - const STATUS_AUTHORIZED = 'authorized'; + public const STATUS_AUTHORIZED = 'authorized'; - const STATUS_PAYEDOUT = 'payedout'; + public const STATUS_PAYEDOUT = 'payedout'; - const STATUS_REFUNDED = 'refunded'; + public const STATUS_REFUNDED = 'refunded'; - const STATUS_UNKNOWN = 'unknown'; + public const STATUS_UNKNOWN = 'unknown'; - const STATUS_FAILED = 'failed'; + public const STATUS_FAILED = 'failed'; - const STATUS_SUSPENDED = 'suspended'; + public const STATUS_SUSPENDED = 'suspended'; - const STATUS_EXPIRED = 'expired'; + public const STATUS_EXPIRED = 'expired'; - const STATUS_PENDING = 'pending'; + public const STATUS_PENDING = 'pending'; - const STATUS_CANCELED = 'canceled'; + public const STATUS_CANCELED = 'canceled'; - const STATUS_NEW = 'new'; + public const STATUS_NEW = 'new'; /** * {@inheritDoc} */ - public function markCaptured() + public function markCaptured(): void { $this->status = static::STATUS_CAPTURED; } @@ -36,7 +36,7 @@ public function markCaptured() /** * {@inheritDoc} */ - public function isCaptured() + public function isCaptured(): bool { return $this->isCurrentStatusEqualTo(static::STATUS_CAPTURED); } @@ -44,7 +44,7 @@ public function isCaptured() /** * {@inheritDoc} */ - public function markAuthorized() + public function markAuthorized(): void { $this->status = static::STATUS_AUTHORIZED; } @@ -52,7 +52,7 @@ public function markAuthorized() /** * {@inheritDoc} */ - public function isAuthorized() + public function isAuthorized(): bool { return $this->isCurrentStatusEqualTo(static::STATUS_AUTHORIZED); } @@ -60,7 +60,7 @@ public function isAuthorized() /** * {@inheritDoc} */ - public function markPayedout() + public function markPayedout(): void { $this->status = static::STATUS_PAYEDOUT; } @@ -68,7 +68,7 @@ public function markPayedout() /** * {@inheritDoc} */ - public function isPayedout() + public function isPayedout(): bool { return $this->isCurrentStatusEqualTo(static::STATUS_PAYEDOUT); } @@ -76,7 +76,7 @@ public function isPayedout() /** * {@inheritDoc} */ - public function markRefunded() + public function markRefunded(): void { $this->status = static::STATUS_REFUNDED; } @@ -84,7 +84,7 @@ public function markRefunded() /** * {@inheritDoc} */ - public function isRefunded() + public function isRefunded(): bool { return $this->isCurrentStatusEqualTo(static::STATUS_REFUNDED); } @@ -92,7 +92,7 @@ public function isRefunded() /** * {@inheritDoc} */ - public function markSuspended() + public function markSuspended(): void { $this->status = static::STATUS_SUSPENDED; } @@ -100,7 +100,7 @@ public function markSuspended() /** * {@inheritDoc} */ - public function isSuspended() + public function isSuspended(): bool { return $this->isCurrentStatusEqualTo(static::STATUS_SUSPENDED); } @@ -108,7 +108,7 @@ public function isSuspended() /** * {@inheritDoc} */ - public function markExpired() + public function markExpired(): void { $this->status = static::STATUS_EXPIRED; } @@ -116,7 +116,7 @@ public function markExpired() /** * {@inheritDoc} */ - public function isExpired() + public function isExpired(): bool { return $this->isCurrentStatusEqualTo(static::STATUS_EXPIRED); } @@ -124,7 +124,7 @@ public function isExpired() /** * {@inheritDoc} */ - public function markCanceled() + public function markCanceled(): void { $this->status = static::STATUS_CANCELED; } @@ -132,7 +132,7 @@ public function markCanceled() /** * {@inheritDoc} */ - public function isCanceled() + public function isCanceled(): bool { return $this->isCurrentStatusEqualTo(static::STATUS_CANCELED); } @@ -140,7 +140,7 @@ public function isCanceled() /** * {@inheritDoc} */ - public function markPending() + public function markPending(): void { $this->status = static::STATUS_PENDING; } @@ -148,7 +148,7 @@ public function markPending() /** * {@inheritDoc} */ - public function isPending() + public function isPending(): bool { return $this->isCurrentStatusEqualTo(static::STATUS_PENDING); } @@ -156,7 +156,7 @@ public function isPending() /** * {@inheritDoc} */ - public function markFailed() + public function markFailed(): void { $this->status = static::STATUS_FAILED; } @@ -164,7 +164,7 @@ public function markFailed() /** * {@inheritDoc} */ - public function isFailed() + public function isFailed(): bool { return $this->isCurrentStatusEqualTo(static::STATUS_FAILED); } @@ -172,7 +172,7 @@ public function isFailed() /** * {@inheritDoc} */ - public function markNew() + public function markNew(): void { $this->status = static::STATUS_NEW; } @@ -180,7 +180,7 @@ public function markNew() /** * {@inheritDoc} */ - public function isNew() + public function isNew(): bool { return $this->isCurrentStatusEqualTo(static::STATUS_NEW); } @@ -188,7 +188,7 @@ public function isNew() /** * {@inheritDoc} */ - public function markUnknown() + public function markUnknown(): void { $this->status = static::STATUS_UNKNOWN; } @@ -196,17 +196,12 @@ public function markUnknown() /** * {@inheritDoc} */ - public function isUnknown() + public function isUnknown(): bool { return $this->isCurrentStatusEqualTo(static::STATUS_UNKNOWN); } - /** - * @param string $expectedStatus - * - * @return boolean - */ - protected function isCurrentStatusEqualTo($expectedStatus) + protected function isCurrentStatusEqualTo(string $expectedStatus): bool { return $this->getValue() === $expectedStatus; } diff --git a/src/Payum/Core/Request/GetToken.php b/src/Payum/Core/Request/GetToken.php index 4942599c3..bd58dbbcf 100644 --- a/src/Payum/Core/Request/GetToken.php +++ b/src/Payum/Core/Request/GetToken.php @@ -5,43 +5,25 @@ class GetToken { - /** - * @var string - */ - private $hash; + private string $hash; - /** - * @var TokenInterface - */ - private $token; + private TokenInterface $token; - /** - * @param string $hash - */ - public function __construct($hash) + public function __construct(string $hash) { $this->hash = $hash; } - /** - * @return string - */ - public function getHash() + public function getHash(): string { return $this->hash; } - /** - * @return TokenInterface - */ - public function getToken() + public function getToken(): TokenInterface { return $this->token; } - /** - * @param TokenInterface $token - */ public function setToken(TokenInterface $token) { $this->token = $token; diff --git a/src/Payum/Core/Request/ObtainCreditCard.php b/src/Payum/Core/Request/ObtainCreditCard.php index 6b39275f7..70db90a8d 100644 --- a/src/Payum/Core/Request/ObtainCreditCard.php +++ b/src/Payum/Core/Request/ObtainCreditCard.php @@ -6,34 +6,21 @@ class ObtainCreditCard extends Generic { - /** - * @var CreditCardInterface - */ - protected $creditCard; + protected CreditCardInterface $creditCard; - /** - * @param object|null $firstModel - * @param object|null $currentModel - */ - public function __construct($firstModel = null, $currentModel = null) + public function __construct(?object $firstModel = null, ?object $currentModel = null) { parent::__construct($firstModel); $this->setModel($currentModel); } - /** - * @param CreditCardInterface $creditCard - */ public function set(CreditCardInterface $creditCard) { $this->creditCard = $creditCard; } - /** - * @return CreditCardInterface - */ - public function obtain() + public function obtain(): CreditCardInterface { if (false == $this->creditCard) { throw new LogicException('Credit card could not be obtained. It has to be set before obtain.'); diff --git a/src/Payum/Core/Request/RenderTemplate.php b/src/Payum/Core/Request/RenderTemplate.php index 334795dd7..d498e3bfe 100644 --- a/src/Payum/Core/Request/RenderTemplate.php +++ b/src/Payum/Core/Request/RenderTemplate.php @@ -3,78 +3,45 @@ class RenderTemplate { - /** - * @var string - */ - protected $templateName; + protected string $templateName; - /** - * @var array - */ - protected $parameters; + protected array $parameters; - /** - * @var string - */ - protected $result; + protected string $result; - /** - * @param string $templateName - * @param array $parameters - */ - public function __construct($templateName, array $parameters = array()) + public function __construct(string $templateName, array $parameters = []) { $this->templateName = $templateName; $this->parameters = $parameters; $this->result = ''; } - /** - * @return string - */ - public function getTemplateName() + public function getTemplateName(): string { return $this->templateName; } - /** - * @return array - */ - public function getParameters() + public function getParameters(): array { return $this->parameters; } - /** - * @return string - */ - public function getResult() + public function getResult(): string { return $this->result; } - /** - * @param string $result - */ - public function setResult($result) + public function setResult(string $result) { $this->result = $result; } - /** - * @param string $name - * @param mixed $value - */ - public function setParameter($name, $value) + public function setParameter(string $name, mixed$value) { $this->parameters[$name] = $value; } - /** - * @param string $name - * @param mixed $value - */ - public function addParameter($name, $value) + public function addParameter(string $name, mixed $value) { if (array_key_exists($name, $this->parameters)) { throw new \InvalidArgumentException(sprintf('Parameter with given name "%s" already exists', $name)); diff --git a/src/Payum/Core/Security/AbstractTokenFactory.php b/src/Payum/Core/Security/AbstractTokenFactory.php index 29cef1a56..688da017e 100644 --- a/src/Payum/Core/Security/AbstractTokenFactory.php +++ b/src/Payum/Core/Security/AbstractTokenFactory.php @@ -11,30 +11,14 @@ abstract class AbstractTokenFactory implements TokenFactoryInterface { - /** - * @var StorageInterface - */ - protected $tokenStorage; - - /** - * @var StorageRegistryInterface - */ - protected $storageRegistry; - - /** - * @param StorageInterface $tokenStorage - * @param StorageRegistryInterface $storageRegistry - */ - public function __construct(StorageInterface $tokenStorage, StorageRegistryInterface $storageRegistry) + public function __construct(protected StorageInterface $tokenStorage, protected StorageRegistryInterface $storageRegistry) { - $this->tokenStorage = $tokenStorage; - $this->storageRegistry = $storageRegistry; } /** * {@inheritDoc} */ - public function createToken($gatewayName, $model, $targetPath, array $targetParameters = [], $afterPath = null, array $afterParameters = []) + public function createToken(string $gatewayName, $model, $targetPath, array $targetParameters = [], $afterPath = null, array $afterParameters = []): TokenInterface { /** @var TokenInterface $token */ $token = $this->tokenStorage->create(); @@ -73,13 +57,7 @@ public function createToken($gatewayName, $model, $targetPath, array $targetPara return $token; } - /** - * @param HttpUri $uri - * @param array $query - * - * @return HttpUri - */ - protected function addQueryToUri(HttpUri $uri, array $query) + protected function addQueryToUri(HttpUri $uri, array $query): HttpUri { $uriQuery = Query::createFromUri($uri)->withoutEmptyPairs(); @@ -88,11 +66,5 @@ protected function addQueryToUri(HttpUri $uri, array $query) return $uri->withQuery((string) Query::createFromParams($query)); } - /** - * @param string $path - * @param array $parameters - * - * @return string - */ - abstract protected function generateUrl($path, array $parameters = array()); + abstract protected function generateUrl(string $path, array $parameters = []): string; } diff --git a/src/Payum/Core/Security/CryptedInterface.php b/src/Payum/Core/Security/CryptedInterface.php index bad3b4243..03e1ea888 100644 --- a/src/Payum/Core/Security/CryptedInterface.php +++ b/src/Payum/Core/Security/CryptedInterface.php @@ -3,17 +3,7 @@ interface CryptedInterface { - /** - * @param CypherInterface $cypher - * - * @return void - */ - public function decrypt(CypherInterface $cypher); + public function decrypt(CypherInterface $cypher): void; - /** - * @param CypherInterface $cypher - * - * @return void - */ - public function encrypt(CypherInterface $cypher); + public function encrypt(CypherInterface $cypher): void; } diff --git a/src/Payum/Core/Security/CypherInterface.php b/src/Payum/Core/Security/CypherInterface.php index 4df0ae361..8e84149ea 100644 --- a/src/Payum/Core/Security/CypherInterface.php +++ b/src/Payum/Core/Security/CypherInterface.php @@ -5,21 +5,13 @@ interface CypherInterface { /** * This method decrypts the passed value. - * - * @param string $value - * - * @return string */ - public function decrypt($value); + public function decrypt(string $value): string; /** * This method encrypts the passed value. * * Binary data may be base64-encoded. - * - * @param string $value - * - * @return string */ - public function encrypt($value); + public function encrypt(string $value): string; } diff --git a/src/Payum/Core/Security/GenericTokenFactory.php b/src/Payum/Core/Security/GenericTokenFactory.php index 407fa44a8..dfefa4805 100644 --- a/src/Payum/Core/Security/GenericTokenFactory.php +++ b/src/Payum/Core/Security/GenericTokenFactory.php @@ -5,18 +5,14 @@ class GenericTokenFactory implements GenericTokenFactoryInterface { - /** - * @var TokenFactoryInterface - */ - protected $tokenFactory; + protected TokenFactoryInterface $tokenFactory; /** * @var string[] */ - protected $paths; + protected array $paths; /** - * @param TokenFactoryInterface $tokenFactory * @param string[] $paths */ public function __construct(TokenFactoryInterface $tokenFactory, array $paths) @@ -28,7 +24,7 @@ public function __construct(TokenFactoryInterface $tokenFactory, array $paths) /** * {@inheritDoc} */ - public function createToken($gatewayName, $model, $targetPath, array $targetParameters = [], $afterPath = null, array $afterParameters = []) + public function createToken($gatewayName, $model, $targetPath, array $targetParameters = [], $afterPath = null, array $afterParameters = []): TokenInterface { return $this->tokenFactory->createToken( $gatewayName, @@ -43,7 +39,7 @@ public function createToken($gatewayName, $model, $targetPath, array $targetPara /** * {@inheritDoc} */ - public function createCaptureToken($gatewayName, $model, $afterPath, array $afterParameters = []) + public function createCaptureToken(string $gatewayName, object $model, string $afterPath, array $afterParameters = []): TokenInterface { $capturePath = $this->getPath('capture'); @@ -61,7 +57,7 @@ public function createCaptureToken($gatewayName, $model, $afterPath, array $afte /** * {@inheritDoc} */ - public function createAuthorizeToken($gatewayName, $model, $afterPath, array $afterParameters = []) + public function createAuthorizeToken(string $gatewayName, object $model, string $afterPath, array $afterParameters = []): TokenInterface { $authorizePath = $this->getPath('authorize'); @@ -73,7 +69,7 @@ public function createAuthorizeToken($gatewayName, $model, $afterPath, array $af /** * {@inheritDoc} */ - public function createRefundToken($gatewayName, $model, $afterPath = null, array $afterParameters = []) + public function createRefundToken(string $gatewayName, object $model, string $afterPath = null, array $afterParameters = []): TokenInterface { $refundPath = $this->getPath('refund'); @@ -85,10 +81,7 @@ public function createRefundToken($gatewayName, $model, $afterPath = null, array return $this->createToken($gatewayName, $model, $refundPath, [], $afterUrl); } - /** - * {@inheritDoc} - */ - public function createCancelToken($gatewayName, $model, $afterPath = null, array $afterParameters = []) + public function createCancelToken($gatewayName, $model, $afterPath = null, array $afterParameters = []): TokenInterface { $cancelPath = $this->getPath('cancel'); @@ -103,7 +96,7 @@ public function createCancelToken($gatewayName, $model, $afterPath = null, array /** * {@inheritDoc} */ - public function createPayoutToken($gatewayName, $model, $afterPath, array $afterParameters = []) + public function createPayoutToken(string $gatewayName, object $model, string $afterPath, array $afterParameters = []): TokenInterface { $capturePath = $this->getPath('payout'); @@ -121,17 +114,12 @@ public function createPayoutToken($gatewayName, $model, $afterPath, array $after /** * {@inheritDoc} */ - public function createNotifyToken($gatewayName, $model = null) + public function createNotifyToken(string $gatewayName, object $model = null): TokenInterface { return $this->createToken($gatewayName, $model, $this->getPath('notify')); } - /** - * @param string $name - * - * @return string - */ - protected function getPath($name) + protected function getPath(string $name): string { if (empty($this->paths[$name])) { throw new LogicException(sprintf( diff --git a/src/Payum/Core/Security/GenericTokenFactoryAwareInterface.php b/src/Payum/Core/Security/GenericTokenFactoryAwareInterface.php index 4dc600111..23dad4681 100644 --- a/src/Payum/Core/Security/GenericTokenFactoryAwareInterface.php +++ b/src/Payum/Core/Security/GenericTokenFactoryAwareInterface.php @@ -3,10 +3,5 @@ interface GenericTokenFactoryAwareInterface { - /** - * @param GenericTokenFactoryInterface $genericTokenFactory - * - * @return void - */ - public function setGenericTokenFactory(GenericTokenFactoryInterface $genericTokenFactory = null); + public function setGenericTokenFactory(GenericTokenFactoryInterface $genericTokenFactory = null): void; } diff --git a/src/Payum/Core/Security/GenericTokenFactoryAwareTrait.php b/src/Payum/Core/Security/GenericTokenFactoryAwareTrait.php index e2cafd6f0..c229e517a 100644 --- a/src/Payum/Core/Security/GenericTokenFactoryAwareTrait.php +++ b/src/Payum/Core/Security/GenericTokenFactoryAwareTrait.php @@ -3,17 +3,9 @@ trait GenericTokenFactoryAwareTrait { - /** - * @var GenericTokenFactoryInterface - */ - protected $tokenFactory; + protected GenericTokenFactoryInterface $tokenFactory; - /** - * @param GenericTokenFactoryInterface $genericTokenFactory - * - * @return void - */ - public function setGenericTokenFactory(GenericTokenFactoryInterface $genericTokenFactory = null) + public function setGenericTokenFactory(GenericTokenFactoryInterface $genericTokenFactory = null): void { $this->tokenFactory = $genericTokenFactory; } diff --git a/src/Payum/Core/Security/GenericTokenFactoryInterface.php b/src/Payum/Core/Security/GenericTokenFactoryInterface.php index 2e90b70dd..92e33f8d3 100644 --- a/src/Payum/Core/Security/GenericTokenFactoryInterface.php +++ b/src/Payum/Core/Security/GenericTokenFactoryInterface.php @@ -6,51 +6,13 @@ */ interface GenericTokenFactoryInterface extends TokenFactoryInterface { - /** - * @param string $gatewayName - * @param object $model - * @param string $afterPath - * @param array $afterParameters - * - * @return TokenInterface - */ - public function createAuthorizeToken($gatewayName, $model, $afterPath, array $afterParameters = []); + public function createAuthorizeToken(string $gatewayName, object $model, string $afterPath, array $afterParameters = []): TokenInterface; - /** - * @param string $gatewayName - * @param object $model - * @param string $afterPath - * @param array $afterParameters - * - * @return TokenInterface - */ - public function createCaptureToken($gatewayName, $model, $afterPath, array $afterParameters = []); + function createCaptureToken(string $gatewayName, object $model, string $afterPath, array $afterParameters = []): TokenInterface; - /** - * @param string $gatewayName - * @param object $model - * @param string $afterPath - * @param array $afterParameters - * - * @return TokenInterface - */ - public function createRefundToken($gatewayName, $model, $afterPath = null, array $afterParameters = []); + public function createRefundToken(string $gatewayName, object $model, string $afterPath = null, array $afterParameters = []): TokenInterface; - /** - * @param string $gatewayName - * @param object $model - * @param string $afterPath - * @param array $afterParameters - * - * @return TokenInterface - */ - public function createPayoutToken($gatewayName, $model, $afterPath, array $afterParameters = []); + public function createPayoutToken(string $gatewayName, object $model, string $afterPath, array $afterParameters = []): TokenInterface; - /** - * @param string $gatewayName - * @param object|null $model - * - * @return TokenInterface - */ - public function createNotifyToken($gatewayName, $model = null); + public function createNotifyToken(string $gatewayName, object $model = null): TokenInterface; } diff --git a/src/Payum/Core/Security/HttpRequestVerifierInterface.php b/src/Payum/Core/Security/HttpRequestVerifierInterface.php index e73159162..4ba4fae3d 100644 --- a/src/Payum/Core/Security/HttpRequestVerifierInterface.php +++ b/src/Payum/Core/Security/HttpRequestVerifierInterface.php @@ -8,17 +8,11 @@ interface HttpRequestVerifierInterface * * @throws \InvalidArgumentException if request not supported * @throws \Exception if token verification failed. - * - * @return TokenInterface */ - public function verify($httpRequest); + public function verify(mixed $httpRequest): TokenInterface; /** * This method invalidate token so it could not be used in future. - * - * @param TokenInterface $token - * - * @return void */ - public function invalidate(TokenInterface $token); + public function invalidate(TokenInterface $token): void; } diff --git a/src/Payum/Core/Security/SensitiveValue.php b/src/Payum/Core/Security/SensitiveValue.php index a0e311ce1..2c815d43a 100644 --- a/src/Payum/Core/Security/SensitiveValue.php +++ b/src/Payum/Core/Security/SensitiveValue.php @@ -6,28 +6,19 @@ final class SensitiveValue implements \Serializable, \JsonSerializable { - private $value; + private mixed $value; - /** - * @param mixed $value - */ - final public function __construct($value) + public function __construct(mixed $value) { $this->value = $value; } - /** - * @return mixed - */ - public function peek() + public function peek(): mixed { return $this->value; } - /** - * @return mixed - */ - public function get() + public function get(): mixed { $value = $this->value; @@ -36,7 +27,7 @@ public function get() return $value; } - public function erase() + public function erase(): void { $this->value = null; } @@ -52,7 +43,7 @@ public function serialize() /** * {@inheritDoc} */ - public function unserialize($serialized) + public function unserialize($serialized): void { } @@ -61,7 +52,7 @@ public function __serialize(): array return []; } - public function __unserialize(array $data) + public function __unserialize(array $data): void { } @@ -73,36 +64,22 @@ public function jsonSerialize() { } - /** - * {@inheritDoc} - */ public function __toString() { return ''; } - /** - * {@inheritDoc} - */ public function __clone() { throw new LogicException('It is not permitted to close this object.'); } - /** - * {@inheritDoc} - */ - public function __debugInfo() + public function __debugInfo(): array { return ['value' => is_scalar($this->value) ? Mask::mask($this->value) : '[FILTERED OUT]']; } - /** - * @param mixed $value - * - * @return SensitiveValue - */ - public static function ensureSensitive($value) + public static function ensureSensitive(mixed $value): SensitiveValue { return $value instanceof self ? $value : new self($value); } diff --git a/src/Payum/Core/Security/TokenAggregateInterface.php b/src/Payum/Core/Security/TokenAggregateInterface.php index 93f2fc8a8..dfed5c0d8 100644 --- a/src/Payum/Core/Security/TokenAggregateInterface.php +++ b/src/Payum/Core/Security/TokenAggregateInterface.php @@ -3,8 +3,5 @@ interface TokenAggregateInterface { - /** - * @return TokenInterface|null - */ - public function getToken(); + public function getToken(): ?TokenInterface; } diff --git a/src/Payum/Core/Security/TokenFactoryInterface.php b/src/Payum/Core/Security/TokenFactoryInterface.php index ca5b37a5b..554b58750 100644 --- a/src/Payum/Core/Security/TokenFactoryInterface.php +++ b/src/Payum/Core/Security/TokenFactoryInterface.php @@ -3,15 +3,11 @@ interface TokenFactoryInterface { - /** - * @param string $gatewayName - * @param object|null $model - * @param string $targetPath - * @param array $targetParameters - * @param string $afterPath - * @param array $afterParameters - * - * @return TokenInterface - */ - public function createToken($gatewayName, $model, $targetPath, array $targetParameters = array(), $afterPath = null, array $afterParameters = array()); + public function createToken(string $gatewayName, + ?object $model, + string $targetPath, + array $targetParameters = [], + string $afterPath = null, + array $afterParameters = [] + ): TokenInterface; } diff --git a/src/Payum/Core/Security/TokenInterface.php b/src/Payum/Core/Security/TokenInterface.php index ee6442830..6677fd0d0 100644 --- a/src/Payum/Core/Security/TokenInterface.php +++ b/src/Payum/Core/Security/TokenInterface.php @@ -10,43 +10,19 @@ */ interface TokenInterface extends DetailsAggregateInterface, DetailsAwareInterface { - /** - * @return string - */ - public function getHash(); - - /** - * @param string $hash - */ - public function setHash($hash); - - /** - * @return string - */ - public function getTargetUrl(); - - /** - * @param string $targetUrl - */ - public function setTargetUrl($targetUrl); - - /** - * @return string - */ - public function getAfterUrl(); - - /** - * @param string $afterUrl - */ - public function setAfterUrl($afterUrl); - - /** - * @return string - */ - public function getGatewayName(); - - /** - * @param string $gatewayName - */ - public function setGatewayName($gatewayName); + public function getHash(): string; + + public function setHash(string $hash); + + public function getTargetUrl(): string; + + public function setTargetUrl(string $targetUrl); + + public function getAfterUrl(): string; + + public function setAfterUrl(string $afterUrl); + + public function getGatewayName(): string; + + public function setGatewayName(string $gatewayName); } diff --git a/src/Payum/Core/Security/Util/Mask.php b/src/Payum/Core/Security/Util/Mask.php index 1615a3695..32308b654 100644 --- a/src/Payum/Core/Security/Util/Mask.php +++ b/src/Payum/Core/Security/Util/Mask.php @@ -3,14 +3,7 @@ class Mask { - /** - * @param string $value - * @param string $maskSymbol - * @param int $showLast - * - * @return string - */ - public static function mask($value, $maskSymbol = null, $showLast = 3) + public static function mask(string $value, string $maskSymbol = null, int $showLast = 3): string { $maskSymbol = $maskSymbol ?: 'X'; $showLast = max(0, $showLast); diff --git a/src/Payum/Core/Security/Util/Random.php b/src/Payum/Core/Security/Util/Random.php index 6e10e0aff..6141d86b9 100644 --- a/src/Payum/Core/Security/Util/Random.php +++ b/src/Payum/Core/Security/Util/Random.php @@ -18,12 +18,12 @@ */ class Random { - public static function generateToken() + public static function generateToken(): string { return rtrim(strtr(base64_encode(self::getRandomNumber()), '+/', '-_'), '='); } - private static function getRandomNumber() + private static function getRandomNumber(): string { return random_bytes(32); } diff --git a/src/Payum/Core/Security/Util/RequestTokenVerifier.php b/src/Payum/Core/Security/Util/RequestTokenVerifier.php index 03f642043..a9986461e 100644 --- a/src/Payum/Core/Security/Util/RequestTokenVerifier.php +++ b/src/Payum/Core/Security/Util/RequestTokenVerifier.php @@ -7,12 +7,7 @@ class RequestTokenVerifier { - /** - * @param string $requestUri - * @param string $tokenUri - * @return bool - */ - public static function isValid($requestUri, $tokenUri) + public static function isValid(string $requestUri, string $tokenUri): bool { $uri = Http::createFromString($requestUri); $altUri = Http::createFromString($tokenUri); diff --git a/src/Payum/Core/Storage/AbstractStorage.php b/src/Payum/Core/Storage/AbstractStorage.php index ba93b7acd..205ac8ae1 100644 --- a/src/Payum/Core/Storage/AbstractStorage.php +++ b/src/Payum/Core/Storage/AbstractStorage.php @@ -5,18 +5,8 @@ abstract class AbstractStorage implements StorageInterface { - /** - * @var string - */ - protected $modelClass; - - /** - * @param $modelClass - */ - public function __construct($modelClass) - { - $this->modelClass = $modelClass; - } + public function __construct(protected string $modelClass) + {} /** * {@inheritDoc} @@ -29,7 +19,7 @@ public function create() /** * {@inheritDoc} */ - public function support($model) + public function support($model): bool { return $model instanceof $this->modelClass; } @@ -37,7 +27,7 @@ public function support($model) /** * {@inheritDoc} */ - public function update($model) + public function update($model): void { $this->assertModelSupported($model); @@ -63,7 +53,7 @@ public function find($id) /** * {@inheritDoc} */ - public function delete($model) + public function delete($model): void { $this->assertModelSupported($model); @@ -73,7 +63,7 @@ public function delete($model) /** * {@inheritDoc} */ - public function identify($model) + public function identify($model): IdentityInterface { $this->assertModelSupported($model); @@ -82,38 +72,28 @@ public function identify($model) /** * @param object $model - * - * @return void */ - abstract protected function doUpdateModel($model); + abstract protected function doUpdateModel(object $model): void; /** * @param object $model - * - * @return void */ - abstract protected function doDeleteModel($model); + abstract protected function doDeleteModel($model): void; /** * @param object $model - * - * @return IdentityInterface */ - abstract protected function doGetIdentity($model); + abstract protected function doGetIdentity($model): IdentityInterface; /** * @param mixed $id - * - * @return object|null */ - abstract protected function doFind($id); + abstract protected function doFind($id): ?object; /** - * @param object $model - * * @throws \Payum\Core\Exception\InvalidArgumentException */ - protected function assertModelSupported($model) + protected function assertModelSupported(object $model): void { if (false == $this->support($model)) { throw new InvalidArgumentException(sprintf( diff --git a/src/Payum/Core/Storage/CryptoStorageDecorator.php b/src/Payum/Core/Storage/CryptoStorageDecorator.php index cc442a47c..e006eef6e 100644 --- a/src/Payum/Core/Storage/CryptoStorageDecorator.php +++ b/src/Payum/Core/Storage/CryptoStorageDecorator.php @@ -7,24 +7,8 @@ final class CryptoStorageDecorator implements StorageInterface { - /** - * @var StorageInterface - */ - private $decoratedStorage; - - /** - * @var CypherInterface - */ - private $crypto; - - /** - * @param StorageInterface $decoratedStorage - * @param CypherInterface $crypto - */ - public function __construct(StorageInterface $decoratedStorage, CypherInterface $crypto) + public function __construct(private StorageInterface $decoratedStorage, private CypherInterface $crypto) { - $this->decoratedStorage = $decoratedStorage; - $this->crypto = $crypto; } /** diff --git a/src/Payum/Core/Storage/FilesystemStorage.php b/src/Payum/Core/Storage/FilesystemStorage.php index e6e46be4a..149f3cd94 100644 --- a/src/Payum/Core/Storage/FilesystemStorage.php +++ b/src/Payum/Core/Storage/FilesystemStorage.php @@ -6,38 +6,18 @@ class FilesystemStorage extends AbstractStorage { - /** - * @var string - */ - protected $storageDir; - - /** - * @var string - */ - protected $idProperty; + protected array $identityMap; - /** - * @var array - */ - protected $identityMap; - - /** - * @param string $storageDir - * @param string $modelClass - * @param string $idProperty - */ - public function __construct($storageDir, $modelClass, $idProperty = 'payum_id') + public function __construct(protected string $storageDir, string $modelClass, protected string $idProperty = 'payum_id') { parent::__construct($modelClass); - $this->storageDir = $storageDir; - $this->idProperty = $idProperty; } /** * {@inheritDoc} */ - public function findBy(array $criteria) + public function findBy(array $criteria): array { throw new LogicException('Method is not supported by the storage.'); } @@ -59,7 +39,7 @@ protected function doFind($id) /** * {@inheritDoc} */ - protected function doUpdateModel($model) + protected function doUpdateModel($model): void { $ro = new \ReflectionObject($model); @@ -84,7 +64,7 @@ protected function doUpdateModel($model) /** * {@inheritDoc} */ - protected function doDeleteModel($model) + protected function doDeleteModel($model): void { $rp = new \ReflectionProperty($model, $this->idProperty); $rp->setAccessible(true); @@ -98,7 +78,7 @@ protected function doDeleteModel($model) /** * {@inheritDoc} */ - protected function doGetIdentity($model) + protected function doGetIdentity($model): IdentityInterface { $rp = new \ReflectionProperty($model, $this->idProperty); $rp->setAccessible(true); diff --git a/src/Payum/Core/Storage/IdentityInterface.php b/src/Payum/Core/Storage/IdentityInterface.php index a517092b8..e8d34b9c9 100644 --- a/src/Payum/Core/Storage/IdentityInterface.php +++ b/src/Payum/Core/Storage/IdentityInterface.php @@ -3,13 +3,7 @@ interface IdentityInterface extends \Serializable { - /** - * @return string - */ - public function getClass(); + public function getClass(): string; - /** - * @return mixed - */ - public function getId(); + public function getId(): mixed; } diff --git a/src/Payum/Core/Storage/StorageInterface.php b/src/Payum/Core/Storage/StorageInterface.php index fcb76f0ff..7957bb77f 100644 --- a/src/Payum/Core/Storage/StorageInterface.php +++ b/src/Payum/Core/Storage/StorageInterface.php @@ -3,42 +3,26 @@ interface StorageInterface { - /** - * @return object - */ - public function create(); + public function create(): object; - /** - * @param object $model - * - * @return boolean - */ - public function support($model); + public function support(object $model): bool; /** - * @param object $model - * * @throws \Payum\Core\Exception\InvalidArgumentException if not supported model given. - * - * @return void */ - public function update($model); + public function update(object $model): void; /** * @param object $model * * @throws \Payum\Core\Exception\InvalidArgumentException if not supported model given. - * - * @return void */ - public function delete($model); + public function delete(object $model): void; /** * @param mixed|IdentityInterface $id - * - * @return object|null */ - public function find($id); + public function find($id): ?object; /** * @param array $criteria diff --git a/src/Payum/Core/Tests/Action/AuthorizePaymentActionTest.php b/src/Payum/Core/Tests/Action/AuthorizePaymentActionTest.php index bd87fa260..1d6ca1c67 100644 --- a/src/Payum/Core/Tests/Action/AuthorizePaymentActionTest.php +++ b/src/Payum/Core/Tests/Action/AuthorizePaymentActionTest.php @@ -214,7 +214,7 @@ public function shouldSetDetailsBackToPaymentAfterAuthorizeDetailsExecution() /** * @test */ - public function shouldSetDetailsBackToPaymentEvenIfExceptionThrown() + public function shouldSetDetailsBackToPaymentEvenIfExceptionThrown(): void { $expectedDetails = array('foo' => 'fooVal'); @@ -226,20 +226,20 @@ public function shouldSetDetailsBackToPaymentEvenIfExceptionThrown() ->expects($this->at(0)) ->method('execute') ->with($this->isInstanceOf(GetHumanStatus::class)) - ->will($this->returnCallback(function (GetHumanStatus $request) { + ->willReturnCallback(function (GetHumanStatus $request) { $request->markPending(); - })) + }) ; $gatewayMock ->expects($this->at(1)) ->method('execute') ->with($this->isInstanceOf(Authorize::class)) - ->will($this->returnCallback(function (Authorize $request) { + ->willReturnCallback(function (Authorize $request) { $details = $request->getModel(); $details['bar'] = 'barVal'; throw new \Exception(); - })) + }) ; $action = new AuthorizePaymentAction(); diff --git a/src/Payum/Core/Tests/Action/CapturePaymentActionTest.php b/src/Payum/Core/Tests/Action/CapturePaymentActionTest.php index 1e0bb9d43..6c5b3d20c 100644 --- a/src/Payum/Core/Tests/Action/CapturePaymentActionTest.php +++ b/src/Payum/Core/Tests/Action/CapturePaymentActionTest.php @@ -27,7 +27,7 @@ public function provideSupportedRequests(): \Iterator /** * @test */ - public function shouldImplementGatewayAwareInterface() + public function shouldImplementGatewayAwareInterface(): void { $rc = new \ReflectionClass($this->actionClass); @@ -37,7 +37,7 @@ public function shouldImplementGatewayAwareInterface() /** * @test */ - public function shouldExecuteConvertRequestIfStatusNew() + public function shouldExecuteConvertRequestIfStatusNew(): void { $payment = new Payment(); @@ -48,21 +48,21 @@ public function shouldExecuteConvertRequestIfStatusNew() ->expects($this->at(0)) ->method('execute') ->with($this->isInstanceOf('Payum\Core\Request\GetHumanStatus')) - ->will($this->returnCallback(function (GetHumanStatus $request) { + ->willReturnCallback(function (GetHumanStatus $request) { $request->markNew(); - })) + }) ; $gatewayMock ->expects($this->at(1)) ->method('execute') ->with($this->isInstanceOf('Payum\Core\Request\Convert')) - ->will($this->returnCallback(function (Convert $request) use ($testCase, $payment) { + ->willReturnCallback(function (Convert $request) use ($testCase, $payment) { $testCase->assertSame($payment, $request->getSource()); $testCase->assertSame('array', $request->getTo()); $testCase->assertNull($request->getToken()); $request->setResult(array()); - })) + }) ; $action = new CapturePaymentAction(); @@ -78,7 +78,7 @@ public function shouldExecuteConvertRequestIfStatusNew() /** * @test */ - public function shouldSetConvertedResultToPaymentAsDetails() + public function shouldSetConvertedResultToPaymentAsDetails(): void { $payment = new Payment(); @@ -89,21 +89,21 @@ public function shouldSetConvertedResultToPaymentAsDetails() ->expects($this->at(0)) ->method('execute') ->with($this->isInstanceOf('Payum\Core\Request\GetHumanStatus')) - ->will($this->returnCallback(function (GetHumanStatus $request) { + ->willReturnCallback(function (GetHumanStatus $request) { $request->markNew(); - })) + }) ; $gatewayMock ->expects($this->at(1)) ->method('execute') ->with($this->isInstanceOf('Payum\Core\Request\Convert')) - ->will($this->returnCallback(function (Convert $request) use ($testCase, $payment) { + ->willReturnCallback(function (Convert $request) use ($testCase, $payment) { $details['foo'] = 'fooVal'; $request->setResult(array( 'foo' => 'fooVal', )); - })) + }) ; $action = new CapturePaymentAction(); @@ -124,7 +124,7 @@ public function shouldSetConvertedResultToPaymentAsDetails() /** * @test */ - public function shouldExecuteConvertRequestWithTokenIfOnePresent() + public function shouldExecuteConvertRequestWithTokenIfOnePresent(): void { $payment = new Payment(); $token = $this->createTokenMock(); @@ -136,20 +136,20 @@ public function shouldExecuteConvertRequestWithTokenIfOnePresent() ->expects($this->at(0)) ->method('execute') ->with($this->isInstanceOf('Payum\Core\Request\GetHumanStatus')) - ->will($this->returnCallback(function (GetHumanStatus $request) { + ->willReturnCallback(function (GetHumanStatus $request) { $request->markNew(); - })) + }) ; $gatewayMock ->expects($this->at(1)) ->method('execute') ->with($this->isInstanceOf('Payum\Core\Request\Convert')) - ->will($this->returnCallback(function (Convert $request) use ($testCase, $payment, $token) { + ->willReturnCallback(function (Convert $request) use ($testCase, $payment, $token) { $testCase->assertSame($payment, $request->getSource()); $testCase->assertSame($token, $request->getToken()); $request->setResult(array()); - })) + }) ; $action = new CapturePaymentAction(); @@ -168,7 +168,7 @@ public function shouldExecuteConvertRequestWithTokenIfOnePresent() /** * @test */ - public function shouldSetDetailsBackToPaymentAfterCaptureDetailsExecution() + public function shouldSetDetailsBackToPaymentAfterCaptureDetailsExecution(): void { $expectedDetails = array('foo' => 'fooVal'); @@ -182,22 +182,22 @@ public function shouldSetDetailsBackToPaymentAfterCaptureDetailsExecution() ->expects($this->at(0)) ->method('execute') ->with($this->isInstanceOf('Payum\Core\Request\GetHumanStatus')) - ->will($this->returnCallback(function (GetHumanStatus $request) { + ->willReturnCallback(function (GetHumanStatus $request) { $request->markPending(); - })) + }) ; $gatewayMock ->expects($this->at(1)) ->method('execute') ->with($this->isInstanceOf('Payum\Core\Request\Capture')) - ->will($this->returnCallback(function (Capture $request) use ($testCase, $expectedDetails) { + ->willReturnCallback(function (Capture $request) use ($testCase, $expectedDetails) { $details = $request->getModel(); $testCase->assertInstanceOf('ArrayAccess', $details); $testCase->assertEquals($expectedDetails, iterator_to_array($details)); $details['bar'] = 'barVal'; - })) + }) ; $action = new CapturePaymentAction(); diff --git a/src/Payum/Core/Tests/Action/ExecuteSameRequestWithModelDetailsActionTest.php b/src/Payum/Core/Tests/Action/ExecuteSameRequestWithModelDetailsActionTest.php index 26cacab84..87f24fa02 100644 --- a/src/Payum/Core/Tests/Action/ExecuteSameRequestWithModelDetailsActionTest.php +++ b/src/Payum/Core/Tests/Action/ExecuteSameRequestWithModelDetailsActionTest.php @@ -24,7 +24,7 @@ public function provideSupportedRequests(): \Iterator /** * @test */ - public function shouldImplementGatewayAwareInterface() + public function shouldImplementGatewayAwareInterface(): void { $rc = new \ReflectionClass($this->actionClass); @@ -104,7 +104,7 @@ public function shouldWrapArrayDetailsToArrayObjectAndExecute() /** * @test */ - public function shouldWrapArrayDetailsToArrayObjectAndSetDetailsBackAfterExecution() + public function shouldWrapArrayDetailsToArrayObjectAndSetDetailsBackAfterExecution(): void { $expectedDetails = array('foo' => 'fooVal', 'bar' => 'barVal'); @@ -146,7 +146,7 @@ public function shouldWrapArrayDetailsToArrayObjectAndSetDetailsBackAfterExecuti /** * @test */ - public function shouldWrapArrayDetailsToArrayObjectAndSetDetailsBackEvenOnException() + public function shouldWrapArrayDetailsToArrayObjectAndSetDetailsBackEvenOnException(): void { $expectedDetails = array('foo' => 'fooVal', 'bar' => 'barVal'); @@ -233,7 +233,7 @@ public function getDetails() return $this->details; } - public function setDetails($details) + public function setDetails(object $details) { $this->details = $details; } diff --git a/src/Payum/Core/Tests/Action/GatewayAwareActionTest.php b/src/Payum/Core/Tests/Action/GatewayAwareActionTest.php index 6f69e8981..c9b73dcd3 100644 --- a/src/Payum/Core/Tests/Action/GatewayAwareActionTest.php +++ b/src/Payum/Core/Tests/Action/GatewayAwareActionTest.php @@ -12,7 +12,7 @@ class GatewayAwareActionTest extends TestCase /** * @test */ - public function shouldImplementActionInterface() + public function shouldImplementActionInterface(): void { $rc = new \ReflectionClass(GatewayAwareAction::class); @@ -22,7 +22,7 @@ public function shouldImplementActionInterface() /** * @test */ - public function shouldImplementGatewayAwareInterface() + public function shouldImplementGatewayAwareInterface(): void { $rc = new \ReflectionClass(GatewayAwareAction::class); diff --git a/src/Payum/Core/Tests/Action/GetCurrencyActionTest.php b/src/Payum/Core/Tests/Action/GetCurrencyActionTest.php index b2c160db7..9cae54522 100644 --- a/src/Payum/Core/Tests/Action/GetCurrencyActionTest.php +++ b/src/Payum/Core/Tests/Action/GetCurrencyActionTest.php @@ -30,7 +30,7 @@ public function provideNotSupportedRequests(): \Iterator /** * @test */ - public function shouldSetCurrencyByAlpha3() + public function shouldSetCurrencyByAlpha3(): void { $action = new GetCurrencyAction(); @@ -42,7 +42,7 @@ public function shouldSetCurrencyByAlpha3() /** * @test */ - public function shouldSetCurrencyByNumeric() + public function shouldSetCurrencyByNumeric(): void { $action = new GetCurrencyAction(); @@ -54,7 +54,7 @@ public function shouldSetCurrencyByNumeric() /** * @test */ - public function throwsIfCurrencyNotSupported() + public function throwsIfCurrencyNotSupported(): void { $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('ISO 4217 does not contain: 000'); @@ -66,7 +66,7 @@ public function throwsIfCurrencyNotSupported() /** * @legacy */ - public function testPassingPayumIso4217IsDeprecated() + public function testPassingPayumIso4217IsDeprecated(): void { set_error_handler(function ($errorCode, $errorString) { $this->assertSame(E_USER_DEPRECATED, $errorCode); @@ -81,7 +81,7 @@ public function testPassingPayumIso4217IsDeprecated() /** * @group legacy */ - public function testItUsesPayumIso4217WhenItIsPassedThrough() + public function testItUsesPayumIso4217WhenItIsPassedThrough(): void { $mock = $this->createMock(ISO4217::class); $mock->expects($this->once()) diff --git a/src/Payum/Core/Tests/Action/GetTokenActionTest.php b/src/Payum/Core/Tests/Action/GetTokenActionTest.php index 51e77e84d..d10437e69 100644 --- a/src/Payum/Core/Tests/Action/GetTokenActionTest.php +++ b/src/Payum/Core/Tests/Action/GetTokenActionTest.php @@ -18,7 +18,7 @@ class GetTokenActionTest extends GenericActionTest /** * @var ActionInterface */ - protected $action; + protected ActionInterface $action; protected function setUp(): void { @@ -41,7 +41,7 @@ public function provideNotSupportedRequests(): \Iterator /** * @test */ - public function shouldSetFoundToken() + public function shouldSetFoundToken(): void { $hash = 'theHash'; $token = $this->createMock(TokenInterface::class); @@ -66,7 +66,7 @@ public function shouldSetFoundToken() /** * @test */ - public function throwIfTokenNotFound() + public function throwIfTokenNotFound(): void { $this->expectException(\Payum\Core\Exception\LogicException::class); $this->expectExceptionMessage('The token theHash could not be found'); diff --git a/src/Payum/Core/Tests/Action/PayoutPayoutActionTest.php b/src/Payum/Core/Tests/Action/PayoutPayoutActionTest.php index f8944d3e5..185dc08b4 100644 --- a/src/Payum/Core/Tests/Action/PayoutPayoutActionTest.php +++ b/src/Payum/Core/Tests/Action/PayoutPayoutActionTest.php @@ -28,7 +28,7 @@ public function provideSupportedRequests(): \Iterator /** * @test */ - public function shouldImplementGatewayAwareInterface() + public function shouldImplementGatewayAwareInterface(): void { $rc = new \ReflectionClass($this->actionClass); @@ -49,21 +49,21 @@ public function shouldExecuteConvertRequestIfStatusNew() ->expects($this->at(0)) ->method('execute') ->with($this->isInstanceOf(GetHumanStatus::class)) - ->will($this->returnCallback(function (GetHumanStatus $request) { + ->willReturnCallback(function (GetHumanStatus $request) { $request->markNew(); - })) + }) ; $gatewayMock ->expects($this->at(1)) ->method('execute') ->with($this->isInstanceOf(Convert::class)) - ->will($this->returnCallback(function (Convert $request) use ($testCase, $payoutModel) { + ->willReturnCallback(function (Convert $request) use ($testCase, $payoutModel) { $testCase->assertSame($payoutModel, $request->getSource()); $testCase->assertSame('array', $request->getTo()); $testCase->assertNull($request->getToken()); $request->setResult(array()); - })) + }) ; $action = new PayoutPayoutAction(); @@ -90,21 +90,21 @@ public function shouldSetConvertedResultToPayoutAsDetails() ->expects($this->at(0)) ->method('execute') ->with($this->isInstanceOf(GetHumanStatus::class)) - ->will($this->returnCallback(function (GetHumanStatus $request) { + ->willReturnCallback(function (GetHumanStatus $request) { $request->markNew(); - })) + }) ; $gatewayMock ->expects($this->at(1)) ->method('execute') ->with($this->isInstanceOf(Convert::class)) - ->will($this->returnCallback(function (Convert $request) use ($testCase, $payoutModel) { + ->willReturnCallback(function (Convert $request) use ($testCase, $payoutModel) { $details['foo'] = 'fooVal'; $request->setResult(array( 'foo' => 'fooVal', )); - })) + }) ; $action = new PayoutPayoutAction(); @@ -125,7 +125,7 @@ public function shouldSetConvertedResultToPayoutAsDetails() /** * @test */ - public function shouldExecuteConvertRequestWithTokenIfOnePresent() + public function shouldExecuteConvertRequestWithTokenIfOnePresent(): void { $payoutModel = new PayoutModel(); $token = $this->createTokenMock(); @@ -137,20 +137,20 @@ public function shouldExecuteConvertRequestWithTokenIfOnePresent() ->expects($this->at(0)) ->method('execute') ->with($this->isInstanceOf(GetHumanStatus::class)) - ->will($this->returnCallback(function (GetHumanStatus $request) { + ->willReturnCallback(function (GetHumanStatus $request) { $request->markNew(); - })) + }) ; $gatewayMock ->expects($this->at(1)) ->method('execute') ->with($this->isInstanceOf(Convert::class)) - ->will($this->returnCallback(function (Convert $request) use ($testCase, $payoutModel, $token) { + ->willReturnCallback(function (Convert $request) use ($testCase, $payoutModel, $token) { $testCase->assertSame($payoutModel, $request->getSource()); $testCase->assertSame($token, $request->getToken()); $request->setResult(array()); - })) + }) ; $action = new PayoutPayoutAction(); @@ -169,7 +169,7 @@ public function shouldExecuteConvertRequestWithTokenIfOnePresent() /** * @test */ - public function shouldSetDetailsBackToPayoutAfterPayoutDetailsExecution() + public function shouldSetDetailsBackToPayoutAfterPayoutDetailsExecution(): void { $expectedDetails = array('foo' => 'fooVal'); @@ -183,22 +183,22 @@ public function shouldSetDetailsBackToPayoutAfterPayoutDetailsExecution() ->expects($this->at(0)) ->method('execute') ->with($this->isInstanceOf(GetHumanStatus::class)) - ->will($this->returnCallback(function (GetHumanStatus $request) { + ->willReturnCallback(function (GetHumanStatus $request) { $request->markPending(); - })) + }) ; $gatewayMock ->expects($this->at(1)) ->method('execute') ->with($this->isInstanceOf(Payout::class)) - ->will($this->returnCallback(function (Payout $request) use ($testCase, $expectedDetails) { + ->willReturnCallback(function (Payout $request) use ($testCase, $expectedDetails) { $details = $request->getModel(); $testCase->assertInstanceOf('ArrayAccess', $details); $testCase->assertEquals($expectedDetails, iterator_to_array($details)); $details['bar'] = 'barVal'; - })) + }) ; $action = new PayoutPayoutAction(); @@ -214,7 +214,7 @@ public function shouldSetDetailsBackToPayoutAfterPayoutDetailsExecution() /** * @test */ - public function shouldSetDetailsBackToPayoutEvenIfExceptionThrown() + public function shouldSetDetailsBackToPayoutEvenIfExceptionThrown(): void { $expectedDetails = array('foo' => 'fooVal'); @@ -226,20 +226,20 @@ public function shouldSetDetailsBackToPayoutEvenIfExceptionThrown() ->expects($this->at(0)) ->method('execute') ->with($this->isInstanceOf(GetHumanStatus::class)) - ->will($this->returnCallback(function (GetHumanStatus $request) { + ->willReturnCallback(function (GetHumanStatus $request) { $request->markPending(); - })) + }) ; $gatewayMock ->expects($this->at(1)) ->method('execute') ->with($this->isInstanceOf(Payout::class)) - ->will($this->returnCallback(function (Payout $request) { + ->willReturnCallback(function (Payout $request) { $details = $request->getModel(); $details['bar'] = 'barVal'; throw new \Exception(); - })) + }) ; $action = new PayoutPayoutAction(); diff --git a/src/Payum/Core/Tests/Bridge/Defuse/Security/DefuseCypherTest.php b/src/Payum/Core/Tests/Bridge/Defuse/Security/DefuseCypherTest.php index 9b03ad106..2a86c699b 100644 --- a/src/Payum/Core/Tests/Bridge/Defuse/Security/DefuseCypherTest.php +++ b/src/Payum/Core/Tests/Bridge/Defuse/Security/DefuseCypherTest.php @@ -8,14 +8,14 @@ class DefuseCypherTest extends TestCase { - public function testShouldImplementCypherInterface() + public function testShouldImplementCypherInterface(): void { $rc = new \ReflectionClass(DefuseCypher::class); $this->assertTrue($rc->implementsInterface(CypherInterface::class)); } - public function testShouldEncryptAndDecryptValue() + public function testShouldEncryptAndDecryptValue(): void { $secret = Key::createNewRandomKey()->saveToAsciiSafeString(); diff --git a/src/Payum/Core/Tests/Bridge/Doctrine/Storage/DoctrineStorageTest.php b/src/Payum/Core/Tests/Bridge/Doctrine/Storage/DoctrineStorageTest.php index 3b378be0a..2362ca0cd 100644 --- a/src/Payum/Core/Tests/Bridge/Doctrine/Storage/DoctrineStorageTest.php +++ b/src/Payum/Core/Tests/Bridge/Doctrine/Storage/DoctrineStorageTest.php @@ -13,7 +13,7 @@ class DoctrineStorageTest extends TestCase /** * @test */ - public function shouldBeSubClassOfAbstractStorage() + public function shouldBeSubClassOfAbstractStorage(): void { $rc = new \ReflectionClass('Payum\Core\Bridge\Doctrine\Storage\DoctrineStorage'); @@ -23,7 +23,7 @@ public function shouldBeSubClassOfAbstractStorage() /** * @test */ - public function shouldCreateInstanceOfModelClassGivenInConstructor() + public function shouldCreateInstanceOfModelClassGivenInConstructor(): void { $expectedModelClass = 'Payum\Core\Tests\Mocks\Model\TestModel'; @@ -41,7 +41,7 @@ public function shouldCreateInstanceOfModelClassGivenInConstructor() /** * @test */ - public function shouldCallObjectManagerPersistAndFlushOnUpdateModel() + public function shouldCallObjectManagerPersistAndFlushOnUpdateModel(): void { $objectManagerMock = $this->createObjectManagerMock(); $objectManagerMock @@ -67,7 +67,7 @@ public function shouldCallObjectManagerPersistAndFlushOnUpdateModel() /** * @test */ - public function shouldProxyCriteriaToRepositoryFindByMethodOnFindByCall() + public function shouldProxyCriteriaToRepositoryFindByMethodOnFindByCall(): void { $modelClass = 'Payum\Core\Tests\Mocks\Model\TestModel'; $model = new TestModel(); @@ -101,7 +101,7 @@ public function shouldProxyCriteriaToRepositoryFindByMethodOnFindByCall() /** * @test */ - public function shouldFindModelById() + public function shouldFindModelById(): void { $expectedModelClass = 'Payum\Core\Tests\Mocks\Model\TestModel'; $expectedModelId = 123; @@ -112,7 +112,7 @@ public function shouldFindModelById() ->expects($this->once()) ->method('find') ->with($expectedModelClass, $expectedModelId) - ->will($this->returnValue($expectedFoundModel)) + ->willReturn($expectedFoundModel) ; $storage = new DoctrineStorage( @@ -125,18 +125,12 @@ public function shouldFindModelById() $this->assertSame($expectedFoundModel, $actualModel); } - /** - * @return MockObject|ObjectManager - */ - protected function createObjectManagerMock() + protected function createObjectManagerMock(): MockObject|ObjectRepository { return $this->createMock(ObjectManager::class); } - /** - * @return MockObject|ObjectRepository - */ - protected function createObjectRepositoryMock() + protected function createObjectRepositoryMock(): MockObject|ObjectRepository { return $this->createMock(ObjectRepository::class); } diff --git a/src/Payum/Core/Tests/Bridge/Guzzle/HttpClientFactoryTest.php b/src/Payum/Core/Tests/Bridge/Guzzle/HttpClientFactoryTest.php index cd5250aad..a682f7c30 100644 --- a/src/Payum/Core/Tests/Bridge/Guzzle/HttpClientFactoryTest.php +++ b/src/Payum/Core/Tests/Bridge/Guzzle/HttpClientFactoryTest.php @@ -11,7 +11,7 @@ class HttpClientFactoryTest extends TestCase /** * @test */ - public function shouldReturnHttpClient() + public function shouldReturnHttpClient(): void { $client = HttpClientFactory::create(); diff --git a/src/Payum/Core/Tests/Bridge/PlainPhp/Action/GetHttpRequestActionTest.php b/src/Payum/Core/Tests/Bridge/PlainPhp/Action/GetHttpRequestActionTest.php index 34c10af1d..d63e019ca 100644 --- a/src/Payum/Core/Tests/Bridge/PlainPhp/Action/GetHttpRequestActionTest.php +++ b/src/Payum/Core/Tests/Bridge/PlainPhp/Action/GetHttpRequestActionTest.php @@ -27,7 +27,7 @@ public function provideNotSupportedRequests(): \Iterator /** * @test */ - public function shouldFillRequestDetails() + public function shouldFillRequestDetails(): void { $action = new GetHttpRequestAction(); diff --git a/src/Payum/Core/Tests/Bridge/PlainPhp/Security/HttpRequestVerifierTest.php b/src/Payum/Core/Tests/Bridge/PlainPhp/Security/HttpRequestVerifierTest.php index 97a7c946c..6b78a28c6 100644 --- a/src/Payum/Core/Tests/Bridge/PlainPhp/Security/HttpRequestVerifierTest.php +++ b/src/Payum/Core/Tests/Bridge/PlainPhp/Security/HttpRequestVerifierTest.php @@ -11,7 +11,7 @@ class HttpRequestVerifierTest extends TestCase /** * @test */ - public function shouldImplementHttpRequestVerifierInterface() + public function shouldImplementHttpRequestVerifierInterface(): void { $rc = new \ReflectionClass('Payum\Core\Bridge\PlainPhp\Security\HttpRequestVerifier'); @@ -21,7 +21,7 @@ public function shouldImplementHttpRequestVerifierInterface() /** * @test */ - public function throwIfRequestIsNotArrayOnVerify() + public function throwIfRequestIsNotArrayOnVerify(): void { $this->expectException(\Payum\Core\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Invalid request given. In most cases you have to pass $_REQUEST array.'); @@ -33,7 +33,7 @@ public function throwIfRequestIsNotArrayOnVerify() /** * @test */ - public function throwIfRequestNotContainTokenParameterOnVerify() + public function throwIfRequestNotContainTokenParameterOnVerify(): void { $this->expectException(\Payum\Core\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Token parameter `payum_token` was not found in in the http request.'); @@ -45,7 +45,7 @@ public function throwIfRequestNotContainTokenParameterOnVerify() /** * @test */ - public function throwIfStorageCouldNotFindTokenByGivenHashOnVerify() + public function throwIfStorageCouldNotFindTokenByGivenHashOnVerify(): void { $this->expectException(\Payum\Core\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('A token with hash `invalidHash` could not be found.'); @@ -56,7 +56,7 @@ public function throwIfStorageCouldNotFindTokenByGivenHashOnVerify() ->expects($this->once()) ->method('find') ->with($invalidHash) - ->will($this->returnValue(null)) + ->willReturn(null) ; $verifier = new HttpRequestVerifier($storageMock); @@ -67,7 +67,7 @@ public function throwIfStorageCouldNotFindTokenByGivenHashOnVerify() /** * @test */ - public function throwIfTargetUrlPathNotMatchServerRequestUriPathOnVerify() + public function throwIfTargetUrlPathNotMatchServerRequestUriPathOnVerify(): void { $this->expectException(\Payum\Core\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('The current url http://target.com/bar not match target url http://target.com/foo set in the token.'); @@ -82,7 +82,7 @@ public function throwIfTargetUrlPathNotMatchServerRequestUriPathOnVerify() ->expects($this->once()) ->method('find') ->with('theHash') - ->will($this->returnValue($token)) + ->willReturn($token) ; $verifier = new HttpRequestVerifier($storageMock); @@ -93,7 +93,7 @@ public function throwIfTargetUrlPathNotMatchServerRequestUriPathOnVerify() /** * @test */ - public function shouldReturnExpectedTokenIfAllCheckPassedOnVerify() + public function shouldReturnExpectedTokenIfAllCheckPassedOnVerify(): void { $_SERVER['REQUEST_URI'] = 'http://target.com/foo'; @@ -106,7 +106,7 @@ public function shouldReturnExpectedTokenIfAllCheckPassedOnVerify() ->expects($this->once()) ->method('find') ->with('theHash') - ->will($this->returnValue($expectedToken)) + ->willReturn($expectedToken) ; $verifier = new HttpRequestVerifier($storageMock); @@ -119,7 +119,7 @@ public function shouldReturnExpectedTokenIfAllCheckPassedOnVerify() /** * @test */ - public function shouldReturnExpectedTokenIfAllEncodedCheckPassedOnVerify() + public function shouldReturnExpectedTokenIfAllEncodedCheckPassedOnVerify(): void { $_SERVER['REQUEST_URI'] = 'http://target.com/%5FSsYp0j9YWCZfC0qpxCK58s0kaSBXVTYVDecuCqo6%5Fw'; @@ -132,7 +132,7 @@ public function shouldReturnExpectedTokenIfAllEncodedCheckPassedOnVerify() ->expects($this->once()) ->method('find') ->with('theHash') - ->will($this->returnValue($expectedToken)) + ->willReturn($expectedToken) ; $verifier = new HttpRequestVerifier($storageMock); @@ -145,7 +145,7 @@ public function shouldReturnExpectedTokenIfAllEncodedCheckPassedOnVerify() /** * @test */ - public function shouldReturnTokenObjectSetToRequestGlobalArrayWithoutChecks() + public function shouldReturnTokenObjectSetToRequestGlobalArrayWithoutChecks(): void { $expectedToken = new Token(); @@ -159,7 +159,7 @@ public function shouldReturnTokenObjectSetToRequestGlobalArrayWithoutChecks() /** * @test */ - public function shouldAllowCustomizeTokenParameterInConstructor() + public function shouldAllowCustomizeTokenParameterInConstructor(): void { $expectedToken = new Token(); @@ -173,7 +173,7 @@ public function shouldAllowCustomizeTokenParameterInConstructor() /** * @test */ - public function shouldCallStorageDeleteModelMethodOnInvalidate() + public function shouldCallStorageDeleteModelMethodOnInvalidate(): void { $token = new Token(); @@ -189,10 +189,7 @@ public function shouldCallStorageDeleteModelMethodOnInvalidate() $verifier->invalidate($token); } - /** - * @return MockObject|\Payum\Core\Storage\StorageInterface - */ - protected function createStorageMock() + protected function createStorageMock(): \Payum\Core\Storage\StorageInterface|MockObject { return $this->createMock('Payum\Core\Storage\StorageInterface'); } diff --git a/src/Payum/Core/Tests/Bridge/PlainPhp/Security/TokenFactoryTest.php b/src/Payum/Core/Tests/Bridge/PlainPhp/Security/TokenFactoryTest.php index 88593844f..57e557589 100644 --- a/src/Payum/Core/Tests/Bridge/PlainPhp/Security/TokenFactoryTest.php +++ b/src/Payum/Core/Tests/Bridge/PlainPhp/Security/TokenFactoryTest.php @@ -16,7 +16,7 @@ class TokenFactoryTest extends TestCase /** * @test */ - public function shouldImplementsTokenFactoryInterface() + public function shouldImplementsTokenFactoryInterface(): void { $rc = new \ReflectionClass(TokenFactory::class); @@ -26,7 +26,7 @@ public function shouldImplementsTokenFactoryInterface() /** * @test */ - public function shouldBeSubClassOfAbtractTokenFactory() + public function shouldBeSubClassOfAbtractTokenFactory(): void { $rc = new \ReflectionClass(TokenFactory::class); @@ -44,7 +44,7 @@ public function shouldCreateTokenWithoutAfterPath() $tokenStorageMock ->expects($this->once()) ->method('create') - ->will($this->returnValue($token)) + ->willReturn($token) ; $tokenStorageMock ->expects($this->once()) @@ -61,7 +61,7 @@ public function shouldCreateTokenWithoutAfterPath() ->expects($this->once()) ->method('identify') ->with($this->identicalTo($model)) - ->will($this->returnValue($identity)) + ->willReturn($identity) ; $storageRegistryMock = $this->createStorageRegistryMock(); @@ -69,7 +69,7 @@ public function shouldCreateTokenWithoutAfterPath() ->expects($this->once()) ->method('getStorage') ->with($this->identicalTo($model)) - ->will($this->returnValue($modelStorage)) + ->willReturn($modelStorage) ; $factory = new TokenFactory($tokenStorageMock, $storageRegistryMock, 'http://example.com'); @@ -94,7 +94,7 @@ public function shouldCreateTokenWithoutAfterPath() /** * @test */ - public function shouldCreateTokenWithAfterUrl() + public function shouldCreateTokenWithAfterUrl(): void { $token = new Token(); @@ -102,7 +102,7 @@ public function shouldCreateTokenWithAfterUrl() $tokenStorageMock ->expects($this->once()) ->method('create') - ->will($this->returnValue($token)) + ->willReturn($token) ; $tokenStorageMock ->expects($this->once()) @@ -119,7 +119,7 @@ public function shouldCreateTokenWithAfterUrl() ->expects($this->once()) ->method('identify') ->with($this->identicalTo($model)) - ->will($this->returnValue($identity)) + ->willReturn($identity) ; $storageRegistryMock = $this->createStorageRegistryMock(); @@ -127,7 +127,7 @@ public function shouldCreateTokenWithAfterUrl() ->expects($this->once()) ->method('getStorage') ->with($this->identicalTo($model)) - ->will($this->returnValue($modelStorage)) + ->willReturn($modelStorage) ; $factory = new TokenFactory($tokenStorageMock, $storageRegistryMock, 'http://example.com'); @@ -154,7 +154,7 @@ public function shouldCreateTokenWithAfterUrl() /** * @test */ - public function shouldCreateTokenForSecuredBaseUrl() + public function shouldCreateTokenForSecuredBaseUrl(): void { $token = new Token(); $token->setHash('aHash'); @@ -163,7 +163,7 @@ public function shouldCreateTokenForSecuredBaseUrl() $tokenStorageMock ->expects($this->once()) ->method('create') - ->will($this->returnValue($token)) + ->willReturn($token) ; $tokenStorageMock ->expects($this->once()) @@ -198,7 +198,7 @@ public function shouldCreateTokenForSecuredBaseUrl() /** * @test */ - public function shouldCreateTokenForBaseUrlWithPath() + public function shouldCreateTokenForBaseUrlWithPath(): void { $token = new Token(); $token->setHash('aHash'); @@ -207,7 +207,7 @@ public function shouldCreateTokenForBaseUrlWithPath() $tokenStorageMock ->expects($this->once()) ->method('create') - ->will($this->returnValue($token)) + ->willReturn($token) ; $tokenStorageMock ->expects($this->once()) @@ -243,7 +243,7 @@ public function shouldCreateTokenForBaseUrlWithPath() * @test * @dataProvider pathDataProvider */ - public function shouldCreateTokenForBaseUrlWithPathAndScriptFile($hostname, $target, $result) + public function shouldCreateTokenForBaseUrlWithPathAndScriptFile($hostname, $target, $result): void { $token = new Token(); $token->setHash('aHash'); @@ -252,7 +252,7 @@ public function shouldCreateTokenForBaseUrlWithPathAndScriptFile($hostname, $tar $tokenStorageMock ->expects($this->once()) ->method('create') - ->will($this->returnValue($token)) + ->willReturn($token) ; $tokenStorageMock ->expects($this->once()) @@ -287,7 +287,7 @@ public function shouldCreateTokenForBaseUrlWithPathAndScriptFile($hostname, $tar /** * @test */ - public function shouldCreateTokenWithIdentityAsModel() + public function shouldCreateTokenWithIdentityAsModel(): void { $token = new Token(); @@ -295,7 +295,7 @@ public function shouldCreateTokenWithIdentityAsModel() $tokenStorageMock ->expects($this->once()) ->method('create') - ->will($this->returnValue($token)) + ->willReturn($token) ; $tokenStorageMock ->expects($this->once()) @@ -330,7 +330,7 @@ public function shouldCreateTokenWithIdentityAsModel() /** * @test */ - public function shouldCreateTokenWithoutModel() + public function shouldCreateTokenWithoutModel(): void { $token = new Token(); @@ -338,7 +338,7 @@ public function shouldCreateTokenWithoutModel() $tokenStorageMock ->expects($this->once()) ->method('create') - ->will($this->returnValue($token)) + ->willReturn($token) ; $tokenStorageMock ->expects($this->once()) @@ -372,7 +372,7 @@ public function shouldCreateTokenWithoutModel() /** * @test */ - public function shouldCreateTokenWithTargetPathAlreadyUrl() + public function shouldCreateTokenWithTargetPathAlreadyUrl(): void { $token = new Token(); @@ -380,7 +380,7 @@ public function shouldCreateTokenWithTargetPathAlreadyUrl() $tokenStorageMock ->expects($this->once()) ->method('create') - ->will($this->returnValue($token)) + ->willReturn($token) ; $tokenStorageMock ->expects($this->once()) @@ -397,7 +397,7 @@ public function shouldCreateTokenWithTargetPathAlreadyUrl() ->expects($this->once()) ->method('identify') ->with($this->identicalTo($model)) - ->will($this->returnValue($identity)) + ->willReturn($identity) ; $storageRegistryMock = $this->createStorageRegistryMock(); @@ -405,7 +405,7 @@ public function shouldCreateTokenWithTargetPathAlreadyUrl() ->expects($this->once()) ->method('getStorage') ->with($this->identicalTo($model)) - ->will($this->returnValue($modelStorage)) + ->willReturn($modelStorage) ; $factory = new TokenFactory($tokenStorageMock, $storageRegistryMock, 'http://example.com'); @@ -432,7 +432,7 @@ public function shouldCreateTokenWithTargetPathAlreadyUrl() /** * @test */ - public function shouldNotOverwritePayumTokenHashInAfterUrl() + public function shouldNotOverwritePayumTokenHashInAfterUrl(): void { $authorizeToken = new Token(); @@ -440,7 +440,7 @@ public function shouldNotOverwritePayumTokenHashInAfterUrl() $tokenStorageMock ->expects($this->at(0)) ->method('create') - ->will($this->returnValue($authorizeToken)) + ->willReturn($authorizeToken) ; $tokenStorageMock ->expects($this->at(1)) @@ -457,7 +457,7 @@ public function shouldNotOverwritePayumTokenHashInAfterUrl() ->expects($this->once()) ->method('identify') ->with($this->identicalTo($model)) - ->will($this->returnValue($identity)) + ->willReturn($identity) ; $storageRegistryMock = $this->createStorageRegistryMock(); @@ -465,7 +465,7 @@ public function shouldNotOverwritePayumTokenHashInAfterUrl() ->expects($this->once()) ->method('getStorage') ->with($this->identicalTo($model)) - ->will($this->returnValue($modelStorage)) + ->willReturn($modelStorage) ; $factory = new TokenFactory($tokenStorageMock, $storageRegistryMock, 'http://example.com'); @@ -495,7 +495,7 @@ public function shouldNotOverwritePayumTokenHashInAfterUrl() /** * @test */ - public function shouldAllowCreateAfterUrlWithoutPayumToken() + public function shouldAllowCreateAfterUrlWithoutPayumToken(): void { $authorizeToken = new Token(); @@ -503,7 +503,7 @@ public function shouldAllowCreateAfterUrlWithoutPayumToken() $tokenStorageMock ->expects($this->at(0)) ->method('create') - ->will($this->returnValue($authorizeToken)) + ->willReturn($authorizeToken) ; $tokenStorageMock ->expects($this->at(1)) @@ -520,7 +520,7 @@ public function shouldAllowCreateAfterUrlWithoutPayumToken() ->expects($this->once()) ->method('identify') ->with($this->identicalTo($model)) - ->will($this->returnValue($identity)) + ->willReturn($identity) ; $storageRegistryMock = $this->createStorageRegistryMock(); @@ -528,7 +528,7 @@ public function shouldAllowCreateAfterUrlWithoutPayumToken() ->expects($this->once()) ->method('getStorage') ->with($this->identicalTo($model)) - ->will($this->returnValue($modelStorage)) + ->willReturn($modelStorage) ; $factory = new TokenFactory($tokenStorageMock, $storageRegistryMock, 'http://example.com'); @@ -558,7 +558,7 @@ public function shouldAllowCreateAfterUrlWithoutPayumToken() /** * @test */ - public function shouldAllowCreateAfterUrlWithFragment() + public function shouldAllowCreateAfterUrlWithFragment(): void { $authorizeToken = new Token(); @@ -566,7 +566,7 @@ public function shouldAllowCreateAfterUrlWithFragment() $tokenStorageMock ->expects($this->at(0)) ->method('create') - ->will($this->returnValue($authorizeToken)) + ->willReturn($authorizeToken) ; $tokenStorageMock ->expects($this->at(1)) @@ -583,7 +583,7 @@ public function shouldAllowCreateAfterUrlWithFragment() ->expects($this->once()) ->method('identify') ->with($this->identicalTo($model)) - ->will($this->returnValue($identity)) + ->willReturn($identity) ; $storageRegistryMock = $this->createStorageRegistryMock(); @@ -591,7 +591,7 @@ public function shouldAllowCreateAfterUrlWithFragment() ->expects($this->once()) ->method('getStorage') ->with($this->identicalTo($model)) - ->will($this->returnValue($modelStorage)) + ->willReturn($modelStorage) ; $factory = new TokenFactory($tokenStorageMock, $storageRegistryMock, 'http://example.com'); @@ -639,18 +639,12 @@ public function pathDataProvider(): array ]; } - /** - * @return MockObject|StorageInterface - */ - protected function createStorageMock() + protected function createStorageMock(): StorageInterface|MockObject { return $this->createMock('Payum\Core\Storage\StorageInterface'); } - /** - * @return MockObject|StorageRegistryInterface - */ - protected function createStorageRegistryMock() + protected function createStorageRegistryMock(): MockObject|StorageRegistryInterface { return $this->createMock('Payum\Core\Registry\StorageRegistryInterface'); } diff --git a/src/Payum/Core/Tests/Bridge/Propel/Storage/Propel1StorageTest.php b/src/Payum/Core/Tests/Bridge/Propel/Storage/Propel1StorageTest.php index c91a7410a..540f9d783 100644 --- a/src/Payum/Core/Tests/Bridge/Propel/Storage/Propel1StorageTest.php +++ b/src/Payum/Core/Tests/Bridge/Propel/Storage/Propel1StorageTest.php @@ -11,7 +11,7 @@ class Propel1StorageTest extends TestCase /** * @test */ - public function shouldBeSubClassOfAbstractStorage() + public function shouldBeSubClassOfAbstractStorage(): void { $rc = new \ReflectionClass('Payum\Core\Bridge\Propel\Storage\Propel1Storage'); @@ -21,7 +21,7 @@ public function shouldBeSubClassOfAbstractStorage() /** * @test */ - public function shouldCreateInstanceOfModelClassGivenInConstructor() + public function shouldCreateInstanceOfModelClassGivenInConstructor(): void { $expectedModelClass = 'Payum\Core\Tests\Mocks\Model\PropelModel'; @@ -33,7 +33,7 @@ public function shouldCreateInstanceOfModelClassGivenInConstructor() $this->assertNull($model->getId()); } - public function throwForModelClassSaveOnUpdateModel() + public function throwForModelClassSaveOnUpdateModel(): void { $this->expectException(\Payum\Core\Exception\LogicException::class); $this->expectExceptionMessage('Save method was triggered.'); @@ -47,7 +47,7 @@ public function throwForModelClassSaveOnUpdateModel() /** * @test */ - public function shouldFindModelById() + public function shouldFindModelById(): void { $expectedModelId = 123; $expectedFoundModel = new PropelModel(); @@ -63,7 +63,7 @@ public function shouldFindModelById() /** * @test */ - public function shouldFindModelByCriteria() + public function shouldFindModelByCriteria(): void { $expectedModelId = 123; $expectedFoundModel = new PropelModel(); diff --git a/src/Payum/Core/Tests/Bridge/Propel/Storage/Propel2StorageTest.php b/src/Payum/Core/Tests/Bridge/Propel/Storage/Propel2StorageTest.php index 31012e0fd..bed4ba1e4 100644 --- a/src/Payum/Core/Tests/Bridge/Propel/Storage/Propel2StorageTest.php +++ b/src/Payum/Core/Tests/Bridge/Propel/Storage/Propel2StorageTest.php @@ -10,7 +10,7 @@ class Propel2StorageTest extends TestCase /** * @test */ - public function shouldBeSubClassOfAbstractStorage() + public function shouldBeSubClassOfAbstractStorage(): void { $rc = new \ReflectionClass('Payum\Core\Bridge\Propel2\Storage\Propel2Storage'); @@ -20,7 +20,7 @@ public function shouldBeSubClassOfAbstractStorage() /** * @test */ - public function shouldCreateInstanceOfModelClassGivenInConstructor() + public function shouldCreateInstanceOfModelClassGivenInConstructor(): void { $expectedModelClass = 'Payum\Core\Tests\Mocks\Model\Propel2Model'; @@ -32,7 +32,7 @@ public function shouldCreateInstanceOfModelClassGivenInConstructor() $this->assertNull($model->getId()); } - public function throwForModelClassSaveOnUpdateModel() + public function throwForModelClassSaveOnUpdateModel(): void { $this->expectException(\Payum\Core\Exception\LogicException::class); $this->expectExceptionMessage('Save method was triggered.'); @@ -46,7 +46,7 @@ public function throwForModelClassSaveOnUpdateModel() /** * @test */ - public function shouldFindModelById() + public function shouldFindModelById(): void { $expectedModelId = 123; $expectedModelQuery = new Propel2ModelQuery(); @@ -62,7 +62,7 @@ public function shouldFindModelById() /** * @test */ - public function shouldFindModelByCriterion() + public function shouldFindModelByCriterion(): void { $expectedModelId = 123; $expectedModelQuery = new Propel2ModelQuery(); @@ -78,7 +78,7 @@ public function shouldFindModelByCriterion() /** * @test */ - public function shouldFindModelByCriteria() + public function shouldFindModelByCriteria(): void { $expectedModelId = 123; $expectedModelCurrency = "USD"; @@ -92,10 +92,10 @@ public function shouldFindModelByCriteria() $storage = new PropelStorage('Payum\Core\Tests\Mocks\Model\Propel2Model'); - $actualModel = $storage->findBy(array( + $actualModel = $storage->findBy([ 'id' => $expectedModelId, 'currency' => $expectedModelCurrency - )); + ]); $this->assertEquals($expectedFoundModel, $actualModel); } diff --git a/src/Payum/Core/Tests/Bridge/Psr/Log/LogExecutedActionsExtensionTest.php b/src/Payum/Core/Tests/Bridge/Psr/Log/LogExecutedActionsExtensionTest.php index be4cc7127..22fc71d44 100644 --- a/src/Payum/Core/Tests/Bridge/Psr/Log/LogExecutedActionsExtensionTest.php +++ b/src/Payum/Core/Tests/Bridge/Psr/Log/LogExecutedActionsExtensionTest.php @@ -18,7 +18,7 @@ class LogExecutedActionsExtensionTest extends TestCase /** * @test */ - public function shouldImplementExtensionInterface() + public function shouldImplementExtensionInterface(): void { $rc = new \ReflectionClass('Payum\Core\Bridge\Psr\Log\LogExecutedActionsExtension'); @@ -28,7 +28,7 @@ public function shouldImplementExtensionInterface() /** * @test */ - public function shouldImplementLoggerAwareInterface() + public function shouldImplementLoggerAwareInterface(): void { $rc = new \ReflectionClass('Payum\Core\Bridge\Psr\Log\LogExecutedActionsExtension'); @@ -38,7 +38,7 @@ public function shouldImplementLoggerAwareInterface() /** * @test */ - public function shouldAllowSetLogger() + public function shouldAllowSetLogger(): void { $extension = new LogExecutedActionsExtension(); @@ -48,7 +48,7 @@ public function shouldAllowSetLogger() /** * @test */ - public function shouldNotLogAnythingOnPreExecute() + public function shouldNotLogAnythingOnPreExecute(): void { $logger = $this->createLoggerMock(); $logger @@ -66,7 +66,7 @@ public function shouldNotLogAnythingOnPreExecute() /** * @test */ - public function shouldNotLogAnythingOnPostExecute() + public function shouldNotLogAnythingOnPostExecute(): void { $logger = $this->createLoggerMock(); $logger @@ -85,7 +85,7 @@ public function shouldNotLogAnythingOnPostExecute() /** * @test */ - public function shouldUsePreviousToGetPreviousRequestNumberOnExecute() + public function shouldUsePreviousToGetPreviousRequestNumberOnExecute(): void { $logger = $this->createLoggerMock(); $logger @@ -107,7 +107,7 @@ public function shouldUsePreviousToGetPreviousRequestNumberOnExecute() /** * @test */ - public function shouldLogNotObjectActionAndRequestOnExecute() + public function shouldLogNotObjectActionAndRequestOnExecute(): void { $stringRequest = 'a string'; $arrayRequest = array(); @@ -141,7 +141,7 @@ public function shouldLogNotObjectActionAndRequestOnExecute() /** * @test */ - public function shouldLogActionAndObjectRequestOnExecute() + public function shouldLogActionAndObjectRequestOnExecute(): void { $action = new FooAction(); $stdRequest = new \stdClass(); @@ -175,7 +175,7 @@ public function shouldLogActionAndObjectRequestOnExecute() /** * @test */ - public function shouldLogActionAndModelRequestWithModelNoObjectOnExecute() + public function shouldLogActionAndModelRequestWithModelNoObjectOnExecute(): void { $action = new FooAction(); $model = array(); @@ -199,7 +199,7 @@ public function shouldLogActionAndModelRequestWithModelNoObjectOnExecute() /** * @test */ - public function shouldLogActionAndModelRequestWithObjectModelOnExecute() + public function shouldLogActionAndModelRequestWithObjectModelOnExecute(): void { $action = new FooAction(); $stdModel = new \stdClass(); @@ -223,7 +223,7 @@ public function shouldLogActionAndModelRequestWithObjectModelOnExecute() /** * @test */ - public function shouldLogReplyWhenSetOnPostExecute() + public function shouldLogReplyWhenSetOnPostExecute(): void { $action = new FooAction(); $replyMock = $this->createReplyMock(); @@ -249,7 +249,7 @@ public function shouldLogReplyWhenSetOnPostExecute() /** * @test */ - public function shouldLogHttpRedirectReplyWithUrlIncludedOnPostExecute() + public function shouldLogHttpRedirectReplyWithUrlIncludedOnPostExecute(): void { $action = new FooAction(); $reply = new HttpRedirect('http://example.com'); @@ -273,7 +273,7 @@ public function shouldLogHttpRedirectReplyWithUrlIncludedOnPostExecute() /** * @test */ - public function shouldLogExceptionWhenSetOnPostExecute() + public function shouldLogExceptionWhenSetOnPostExecute(): void { $action = new FooAction(); @@ -296,7 +296,7 @@ public function shouldLogExceptionWhenSetOnPostExecute() /** * @test */ - public function shouldLogExceptionWhenSetButActionNotSetOnPostExecute() + public function shouldLogExceptionWhenSetButActionNotSetOnPostExecute(): void { $logger = $this->createLoggerMock(); $logger @@ -313,34 +313,22 @@ public function shouldLogExceptionWhenSetButActionNotSetOnPostExecute() $extension->onPostExecute($context); } - /** - * @return MockObject|LoggerInterface - */ - protected function createLoggerMock() + protected function createLoggerMock(): MockObject|LoggerInterface { return $this->createMock('Psr\Log\LoggerInterface'); } - /** - * @return MockObject|ReplyInterface - */ - protected function createReplyMock() + protected function createReplyMock(): MockObject|ReplyInterface { return $this->createMock('Payum\Core\Reply\ReplyInterface'); } - /** - * @return MockObject|\Payum\Core\Action\ActionInterface - */ - protected function createActionMock() + protected function createActionMock(): MockObject|ActionInterface { return $this->createMock('Payum\Core\Action\ActionInterface'); } - /** - * @return MockObject|GatewayInterface - */ - protected function createGatewayMock() + protected function createGatewayMock(): GatewayInterface|MockObject { return $this->createMock('Payum\Core\GatewayInterface'); } diff --git a/src/Payum/Core/Tests/Bridge/Psr/Log/LoggerExtensionTest.php b/src/Payum/Core/Tests/Bridge/Psr/Log/LoggerExtensionTest.php index 45410dcca..348f4f5f8 100644 --- a/src/Payum/Core/Tests/Bridge/Psr/Log/LoggerExtensionTest.php +++ b/src/Payum/Core/Tests/Bridge/Psr/Log/LoggerExtensionTest.php @@ -10,20 +10,21 @@ use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; +use PHPUnit\Framework\SkippedTestError; class LoggerExtensionTest extends TestCase { public static function setUpBeforeClass(): void { if (false == interface_exists('Psr\Log\LoggerInterface')) { - throw new \PHPUnit_Framework_SkippedTestError('To run these tests install psr log lib.'); + throw new SkippedTestError('To run these tests install psr log lib.'); } } /** * @test */ - public function shouldImplementExtensionInterface() + public function shouldImplementExtensionInterface(): void { $rc = new \ReflectionClass('Payum\Core\Bridge\Psr\Log\LoggerExtension'); @@ -33,7 +34,7 @@ public function shouldImplementExtensionInterface() /** * @test */ - public function shouldImplementLoggerAwareInterface() + public function shouldImplementLoggerAwareInterface(): void { $rc = new \ReflectionClass('Payum\Core\Bridge\Psr\Log\LoggerExtension'); @@ -43,7 +44,7 @@ public function shouldImplementLoggerAwareInterface() /** * @test */ - public function shouldAllowSetLogger() + public function shouldAllowSetLogger(): void { $extension = new LoggerExtension(); $this->assertInstanceOf(LoggerAwareInterface::class, $extension); @@ -52,7 +53,7 @@ public function shouldAllowSetLogger() /** * @test */ - public function shouldInjectLoggerToLoggerAwareActionOnExecute() + public function shouldInjectLoggerToLoggerAwareActionOnExecute(): void { $logger = $this->createLoggerMock(); @@ -71,7 +72,7 @@ public function shouldInjectLoggerToLoggerAwareActionOnExecute() /** * @test */ - public function shouldNotInjectLoggerToNotLoggerAwareActionOnExecute() + public function shouldNotInjectLoggerToNotLoggerAwareActionOnExecute(): void { $logger = $this->createLoggerMock(); @@ -91,7 +92,7 @@ public function shouldNotInjectLoggerToNotLoggerAwareActionOnExecute() /** * @test */ - public function shouldInjectNullLoggerToLoggerAwareActionOnPostExecute() + public function shouldInjectNullLoggerToLoggerAwareActionOnPostExecute(): void { $logger = $this->createLoggerMock(); @@ -110,7 +111,7 @@ public function shouldInjectNullLoggerToLoggerAwareActionOnPostExecute() /** * @test */ - public function shouldNotInjectNullLoggerToNotLoggerAwareActionOnPostExecute() + public function shouldNotInjectNullLoggerToNotLoggerAwareActionOnPostExecute(): void { $logger = $this->createLoggerMock(); @@ -131,7 +132,7 @@ public function shouldNotInjectNullLoggerToNotLoggerAwareActionOnPostExecute() /** * @test */ - public function shouldDoNothingOnPreExecute() + public function shouldDoNothingOnPreExecute(): void { $logger = $this->createLoggerMock(); @@ -147,26 +148,17 @@ public function shouldDoNothingOnPreExecute() $this->assertNull($action->logger); } - /** - * @return MockObject|LoggerInterface - */ - protected function createLoggerMock() + protected function createLoggerMock(): MockObject|LoggerInterface { return $this->createMock('Psr\Log\LoggerInterface'); } - /** - * @return MockObject|ActionInterface - */ - protected function createActionMock() + protected function createActionMock(): MockObject|ActionInterface { return $this->createMock('Payum\Core\Action\ActionInterface'); } - /** - * @return MockObject|GatewayInterface - */ - protected function createGatewayMock() + protected function createGatewayMock(): GatewayInterface|MockObject { return $this->createMock('Payum\Core\GatewayInterface'); } diff --git a/src/Payum/Core/Tests/Bridge/Spl/ArrayObjectTest.php b/src/Payum/Core/Tests/Bridge/Spl/ArrayObjectTest.php index af2fc4508..8bcb902e9 100644 --- a/src/Payum/Core/Tests/Bridge/Spl/ArrayObjectTest.php +++ b/src/Payum/Core/Tests/Bridge/Spl/ArrayObjectTest.php @@ -10,7 +10,7 @@ class ArrayObjectTest extends TestCase /** * @test */ - public function shouldBeSubClassOfArrayObject() + public function shouldBeSubClassOfArrayObject(): void { $rc = new \ReflectionClass(ArrayObject::class); @@ -20,7 +20,7 @@ public function shouldBeSubClassOfArrayObject() /** * @test */ - public function shouldAllowGetPreviouslySetValueByIndex() + public function shouldAllowGetPreviouslySetValueByIndex(): void { $array = new ArrayObject(); $array['foo'] = 'bar'; @@ -32,7 +32,7 @@ public function shouldAllowGetPreviouslySetValueByIndex() /** * @test */ - public function shouldAllowGetValueSetInInternalArrayObject() + public function shouldAllowGetValueSetInInternalArrayObject(): void { $internalArray = new \ArrayObject(); $internalArray['foo'] = 'bar'; @@ -46,7 +46,7 @@ public function shouldAllowGetValueSetInInternalArrayObject() /** * @test */ - public function shouldAllowGetNullIfValueWithIndexNotSet() + public function shouldAllowGetNullIfValueWithIndexNotSet(): void { $array = new ArrayObject(); @@ -57,7 +57,7 @@ public function shouldAllowGetNullIfValueWithIndexNotSet() /** * @test */ - public function shouldReplaceFromArray() + public function shouldReplaceFromArray(): void { $expectedArray = array( 'foo' => 'valNew', @@ -78,7 +78,7 @@ public function shouldReplaceFromArray() /** * @test */ - public function shouldReplaceFromTraversable() + public function shouldReplaceFromTraversable(): void { $traversable = new \ArrayIterator(array( 'foo' => 'valNew', @@ -104,7 +104,7 @@ public function shouldReplaceFromTraversable() /** * @test */ - public function throwIfInvalidArgumentGivenForReplace() + public function throwIfInvalidArgumentGivenForReplace(): void { $this->expectException(\Payum\Core\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Invalid input given. Should be an array or instance of \Traversable'); @@ -116,7 +116,7 @@ public function throwIfInvalidArgumentGivenForReplace() /** * @test */ - public function shouldAllowCastToArrayFromCustomArrayObject() + public function shouldAllowCastToArrayFromCustomArrayObject(): void { $input = new CustomArrayObject(); $input['foo'] = 'barbaz'; @@ -132,7 +132,7 @@ public function shouldAllowCastToArrayFromCustomArrayObject() /** * @test */ - public function shouldAllowSetToCustomArrayObject() + public function shouldAllowSetToCustomArrayObject(): void { $input = new CustomArrayObject(); $input['foo'] = 'barbaz'; @@ -146,7 +146,7 @@ public function shouldAllowSetToCustomArrayObject() /** * @test */ - public function shouldAllowUnsetToCustomArrayObject() + public function shouldAllowUnsetToCustomArrayObject(): void { $input = new CustomArrayObject(); $input['foo'] = 'barbaz'; @@ -160,7 +160,7 @@ public function shouldAllowUnsetToCustomArrayObject() /** * @test */ - public function shouldAllowGetValueFromCustomArrayObject() + public function shouldAllowGetValueFromCustomArrayObject(): void { $input = new CustomArrayObject(); $input['foo'] = 'barbaz'; @@ -173,7 +173,7 @@ public function shouldAllowGetValueFromCustomArrayObject() /** * @test */ - public function shouldAllowIssetValueFromCustomArrayObject() + public function shouldAllowIssetValueFromCustomArrayObject(): void { $input = new CustomArrayObject(); $input['foo'] = 'barbaz'; @@ -187,7 +187,7 @@ public function shouldAllowIssetValueFromCustomArrayObject() /** * @test */ - public function shouldAllowIterateOverCustomArrayObject() + public function shouldAllowIterateOverCustomArrayObject(): void { $input = new CustomArrayObject(); $input['foo'] = 'barbaz'; @@ -203,7 +203,7 @@ public function shouldAllowIterateOverCustomArrayObject() /** * @test */ - public function throwIfRequiredFieldEmptyAndThrowOnInvalidTrue() + public function throwIfRequiredFieldEmptyAndThrowOnInvalidTrue(): void { $this->expectException(\Payum\Core\Exception\LogicException::class); $this->expectExceptionMessage('The aRequiredField fields are required.'); @@ -215,7 +215,7 @@ public function throwIfRequiredFieldEmptyAndThrowOnInvalidTrue() /** * @test */ - public function throwIfSecondRequiredFieldEmptyAndThrowOnInvalidTrue() + public function throwIfSecondRequiredFieldEmptyAndThrowOnInvalidTrue(): void { $this->expectException(\Payum\Core\Exception\LogicException::class); $this->expectExceptionMessage('The otherRequiredField fields are required.'); @@ -228,7 +228,7 @@ public function throwIfSecondRequiredFieldEmptyAndThrowOnInvalidTrue() /** * @test */ - public function throwByDefaultIfRequiredFieldEmpty() + public function throwByDefaultIfRequiredFieldEmpty(): void { $this->expectException(\Payum\Core\Exception\LogicException::class); $this->expectExceptionMessage('The aRequiredField fields are required.'); @@ -240,7 +240,7 @@ public function throwByDefaultIfRequiredFieldEmpty() /** * @test */ - public function shouldReturnFalseIfRequiredFieldEmptyAndThrowOnInvalidFalse() + public function shouldReturnFalseIfRequiredFieldEmptyAndThrowOnInvalidFalse(): void { $arrayObject = new ArrayObject(); @@ -250,7 +250,7 @@ public function shouldReturnFalseIfRequiredFieldEmptyAndThrowOnInvalidFalse() /** * @test */ - public function shouldAllowValidateScalarWhetherItNotEmpty() + public function shouldAllowValidateScalarWhetherItNotEmpty(): void { $arrayObject = new ArrayObject(); @@ -260,7 +260,7 @@ public function shouldAllowValidateScalarWhetherItNotEmpty() /** * @test */ - public function shouldReturnTrueIfRequiredFieldsNotEmpty() + public function shouldReturnTrueIfRequiredFieldsNotEmpty(): void { $arrayObject = new ArrayObject(); $arrayObject['aRequiredField'] = 'foo'; @@ -272,7 +272,7 @@ public function shouldReturnTrueIfRequiredFieldsNotEmpty() /** * @test */ - public function throwIfRequiredFieldNotSetAndThrowOnInvalidTrue() + public function throwIfRequiredFieldNotSetAndThrowOnInvalidTrue(): void { $this->expectException(\Payum\Core\Exception\LogicException::class); $this->expectExceptionMessage('The aRequiredField fields is not set.'); @@ -284,7 +284,7 @@ public function throwIfRequiredFieldNotSetAndThrowOnInvalidTrue() /** * @test */ - public function throwIfSecondRequiredFieldNotSetAndThrowOnInvalidTrue() + public function throwIfSecondRequiredFieldNotSetAndThrowOnInvalidTrue(): void { $this->expectException(\Payum\Core\Exception\LogicException::class); $this->expectExceptionMessage('The otherRequiredField fields is not set.'); @@ -297,7 +297,7 @@ public function throwIfSecondRequiredFieldNotSetAndThrowOnInvalidTrue() /** * @test */ - public function throwByDefaultIfRequiredFieldNotSet() + public function throwByDefaultIfRequiredFieldNotSet(): void { $this->expectException(\Payum\Core\Exception\LogicException::class); $this->expectExceptionMessage('The aRequiredField fields is not set.'); @@ -309,7 +309,7 @@ public function throwByDefaultIfRequiredFieldNotSet() /** * @test */ - public function shouldReturnFalseIfRequiredFieldNotSetAndThrowOnInvalidFalse() + public function shouldReturnFalseIfRequiredFieldNotSetAndThrowOnInvalidFalse(): void { $arrayObject = new ArrayObject(); @@ -319,7 +319,7 @@ public function shouldReturnFalseIfRequiredFieldNotSetAndThrowOnInvalidFalse() /** * @test */ - public function shouldAllowValidateScalarNotSet() + public function shouldAllowValidateScalarNotSet(): void { $arrayObject = new ArrayObject(); @@ -329,7 +329,7 @@ public function shouldAllowValidateScalarNotSet() /** * @test */ - public function shouldReturnTrueIfRequiredFieldsSet() + public function shouldReturnTrueIfRequiredFieldsSet(): void { $arrayObject = new ArrayObject(); $arrayObject['aRequiredField'] = 'foo'; @@ -341,7 +341,7 @@ public function shouldReturnTrueIfRequiredFieldsSet() /** * @test */ - public function shouldConvertArrayObjectToPrimitiveArrayMakingSensitiveValueUnsafeAndEraseIt() + public function shouldConvertArrayObjectToPrimitiveArrayMakingSensitiveValueUnsafeAndEraseIt(): void { $sensitiveValue = new SensitiveValue('theCreditCard'); @@ -365,7 +365,7 @@ public function shouldConvertArrayObjectToPrimitiveArrayMakingSensitiveValueUnsa /** * @test */ - public function shouldAllowSetDefaultValues() + public function shouldAllowSetDefaultValues(): void { $arrayObject = new ArrayObject(); $arrayObject['foo'] = 'fooVal'; @@ -379,7 +379,7 @@ public function shouldAllowSetDefaultValues() $this->assertEquals('barDefVal', $arrayObject['bar']); } - public function shouldAllowGetArrayAsArrayObjectIfSet() + public function shouldAllowGetArrayAsArrayObjectIfSet(): void { $array = new ArrayObject(); $array['foo'] = ['foo' => 'fooVal']; @@ -390,7 +390,7 @@ public function shouldAllowGetArrayAsArrayObjectIfSet() $this->assertEquals(['foo' => 'fooVal'], (array) $subArray); } - public function shouldAllowGetArrayAsArrayObjectIfNotSet() + public function shouldAllowGetArrayAsArrayObjectIfNotSet(): void { $array = new ArrayObject(); @@ -400,7 +400,7 @@ public function shouldAllowGetArrayAsArrayObjectIfNotSet() $this->assertEquals([], (array) $subArray); } - public function shouldAllowToArrayWithoutSensitiveValuesAdnLocal() + public function shouldAllowToArrayWithoutSensitiveValuesAdnLocal(): void { $array = new ArrayObject([ 'local' => 'theLocal', @@ -416,35 +416,30 @@ class CustomArrayObject implements \ArrayAccess, \IteratorAggregate { private $foo; - #[\ReturnTypeWillChange] - public function offsetExists($offset) + public function offsetExists(mixed $offset): bool { return 'foo' === $offset; } - #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset): mixed { return $this->{$offset}; } - #[\ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet(mixed $offset, mixed $value): void { $this->{$offset} = $value; } - #[\ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset(mixed $offset): void { $this->{$offset} = null; } - #[\ReturnTypeWillChange] - public function getIterator() + public function getIterator(): \ArrayIterator { - return new \ArrayIterator(array( + return new \ArrayIterator([ 'foo' => $this->foo, - )); + ]); } } diff --git a/src/Payum/Core/Tests/Debug/HumanifyTest.php b/src/Payum/Core/Tests/Debug/HumanifyTest.php index 0c137f4c5..89e06e7c8 100644 --- a/src/Payum/Core/Tests/Debug/HumanifyTest.php +++ b/src/Payum/Core/Tests/Debug/HumanifyTest.php @@ -11,7 +11,7 @@ class HumanifyTest extends TestCase /** * @test */ - public function shouldBeAbstract() + public function shouldBeAbstract(): void { $rc = new \ReflectionClass('Payum\Core\Debug\Humanify'); @@ -21,7 +21,7 @@ public function shouldBeAbstract() /** * @test */ - public function couldNotBeInstantiable() + public function couldNotBeInstantiable(): void { $rc = new \ReflectionClass('Payum\Core\Debug\Humanify'); @@ -31,7 +31,7 @@ public function couldNotBeInstantiable() /** * @test */ - public function shouldReturnObjectClassOnValueIfObjectPassed() + public function shouldReturnObjectClassOnValueIfObjectPassed(): void { $this->assertEquals('HumanifyTest', Humanify::value($this)); } @@ -39,7 +39,7 @@ public function shouldReturnObjectClassOnValueIfObjectPassed() /** * @test */ - public function shouldReturnObjectShortClassOnValueIfObjectPassedAndShortClassFlagSetTrue() + public function shouldReturnObjectShortClassOnValueIfObjectPassedAndShortClassFlagSetTrue(): void { $this->assertEquals('HumanifyTest', Humanify::value($this, true)); } @@ -47,7 +47,7 @@ public function shouldReturnObjectShortClassOnValueIfObjectPassedAndShortClassFl /** * @test */ - public function shouldReturnObjectClassOnValueIfObjectPassedAndShortClassFlagSetFalse() + public function shouldReturnObjectClassOnValueIfObjectPassedAndShortClassFlagSetFalse(): void { $this->assertEquals(__CLASS__, Humanify::value($this, false)); } @@ -55,7 +55,7 @@ public function shouldReturnObjectClassOnValueIfObjectPassedAndShortClassFlagSet /** * @test */ - public function shouldReturnValueTypeIfNotObjectValueGivenOnValue() + public function shouldReturnValueTypeIfNotObjectValueGivenOnValue(): void { $this->assertEquals('string', Humanify::value('foo')); } @@ -63,7 +63,7 @@ public function shouldReturnValueTypeIfNotObjectValueGivenOnValue() /** * @test */ - public function shouldReturnRequestTypeIfRequestNotObjectOnRequest() + public function shouldReturnRequestTypeIfRequestNotObjectOnRequest(): void { $this->assertEquals('string', Humanify::request('foo')); } @@ -71,7 +71,7 @@ public function shouldReturnRequestTypeIfRequestNotObjectOnRequest() /** * @test */ - public function shouldReturnRequestShortClassIfRequestObjectOnRequest() + public function shouldReturnRequestShortClassIfRequestObjectOnRequest(): void { $this->assertEquals('HumanifyTest', Humanify::request($this)); } @@ -79,7 +79,7 @@ public function shouldReturnRequestShortClassIfRequestObjectOnRequest() /** * @test */ - public function shouldReturnRequestShortClassAndModelIfRequestImplementsModelRequestInterfaceOnRequest() + public function shouldReturnRequestShortClassAndModelIfRequestImplementsModelRequestInterfaceOnRequest(): void { $request = new Capture($this); @@ -89,7 +89,7 @@ public function shouldReturnRequestShortClassAndModelIfRequestImplementsModelReq /** * @test */ - public function shouldReturnReplyShortClassAndUrlIfHttpRedirectReplyOnRequest() + public function shouldReturnReplyShortClassAndUrlIfHttpRedirectReplyOnRequest(): void { $request = new HttpRedirect('http://example.com/foo'); diff --git a/src/Payum/Core/Tests/Exception/Http/HttpExceptionInterfaceTest.php b/src/Payum/Core/Tests/Exception/Http/HttpExceptionInterfaceTest.php index 852035ff9..6c712261c 100644 --- a/src/Payum/Core/Tests/Exception/Http/HttpExceptionInterfaceTest.php +++ b/src/Payum/Core/Tests/Exception/Http/HttpExceptionInterfaceTest.php @@ -8,7 +8,7 @@ class HttpExceptionInterfaceTest extends TestCase /** * @test */ - public function shouldImplementPayumExceptionInterface() + public function shouldImplementPayumExceptionInterface(): void { $rc = new \ReflectionClass('Payum\Core\Exception\Http\HttpExceptionInterface'); diff --git a/src/Payum/Core/Tests/Exception/Http/HttpExceptionTest.php b/src/Payum/Core/Tests/Exception/Http/HttpExceptionTest.php index 2380dabb3..e364a8594 100644 --- a/src/Payum/Core/Tests/Exception/Http/HttpExceptionTest.php +++ b/src/Payum/Core/Tests/Exception/Http/HttpExceptionTest.php @@ -11,7 +11,7 @@ class HttpExceptionTest extends TestCase /** * @test */ - public function shouldBeSubClassOfRuntimeException() + public function shouldBeSubClassOfRuntimeException(): void { $rc = new \ReflectionClass('Payum\Core\Exception\Http\HttpException'); @@ -21,7 +21,7 @@ public function shouldBeSubClassOfRuntimeException() /** * @test */ - public function shouldImplementHttpExceptionInterface() + public function shouldImplementHttpExceptionInterface(): void { $rc = new \ReflectionClass('Payum\Core\Exception\Http\HttpException'); @@ -31,7 +31,7 @@ public function shouldImplementHttpExceptionInterface() /** * @test */ - public function shouldAllowSetRequest() + public function shouldAllowSetRequest(): void { $exception = new HttpException(); @@ -43,7 +43,7 @@ public function shouldAllowSetRequest() /** * @test */ - public function shouldAllowGetPreviouslySetRequest() + public function shouldAllowGetPreviouslySetRequest(): void { $exception = new HttpException(); @@ -55,7 +55,7 @@ public function shouldAllowGetPreviouslySetRequest() /** * @test */ - public function shouldAllowSetResponse() + public function shouldAllowSetResponse(): void { $exception = new HttpException(); @@ -67,7 +67,7 @@ public function shouldAllowSetResponse() /** * @test */ - public function shouldAllowGetPreviouslySetResponse() + public function shouldAllowGetPreviouslySetResponse(): void { $exception = new HttpException(); @@ -79,7 +79,7 @@ public function shouldAllowGetPreviouslySetResponse() /** * @test */ - public function shouldAllowCreateHttpExceptionFromRequestAndResponse() + public function shouldAllowCreateHttpExceptionFromRequestAndResponse(): void { $request = new Request('GET', 'http://example.com/foobar'); diff --git a/src/Payum/Core/Tests/Exception/InvalidArgumentExceptionExceptionTest.php b/src/Payum/Core/Tests/Exception/InvalidArgumentExceptionExceptionTest.php index f697d8a2e..3f10a5791 100644 --- a/src/Payum/Core/Tests/Exception/InvalidArgumentExceptionExceptionTest.php +++ b/src/Payum/Core/Tests/Exception/InvalidArgumentExceptionExceptionTest.php @@ -9,7 +9,7 @@ class InvalidArgumentExceptionExceptionTest extends TestCase /** * @test */ - public function shouldImplementExceptionInterface() + public function shouldImplementExceptionInterface(): void { $rc = new \ReflectionClass('Payum\Core\Exception\InvalidArgumentException'); @@ -19,7 +19,7 @@ public function shouldImplementExceptionInterface() /** * @test */ - public function shouldBeSubClassOfRuntimeException() + public function shouldBeSubClassOfRuntimeException(): void { $rc = new \ReflectionClass('Payum\Core\Exception\InvalidArgumentException'); diff --git a/src/Payum/Core/Tests/Exception/LogicExceptionTest.php b/src/Payum/Core/Tests/Exception/LogicExceptionTest.php index 44d4f101b..a5e2609b7 100644 --- a/src/Payum/Core/Tests/Exception/LogicExceptionTest.php +++ b/src/Payum/Core/Tests/Exception/LogicExceptionTest.php @@ -9,7 +9,7 @@ class LogicExceptionTest extends TestCase /** * @test */ - public function shouldImplementExceptionInterface() + public function shouldImplementExceptionInterface(): void { $rc = new \ReflectionClass('Payum\Core\Exception\LogicException'); @@ -19,7 +19,7 @@ public function shouldImplementExceptionInterface() /** * @test */ - public function shouldBeSubClassOfRuntimeException() + public function shouldBeSubClassOfRuntimeException(): void { $rc = new \ReflectionClass('Payum\Core\Exception\LogicException'); diff --git a/src/Payum/Core/Tests/Exception/RequestNotSupportedExceptionTest.php b/src/Payum/Core/Tests/Exception/RequestNotSupportedExceptionTest.php index fbcb966d2..aea531443 100644 --- a/src/Payum/Core/Tests/Exception/RequestNotSupportedExceptionTest.php +++ b/src/Payum/Core/Tests/Exception/RequestNotSupportedExceptionTest.php @@ -14,7 +14,7 @@ class RequestNotSupportedExceptionTest extends TestCase /** * @test */ - public function shouldBeSubClassOfInvalidArgumentException() + public function shouldBeSubClassOfInvalidArgumentException(): void { $rc = new \ReflectionClass(RequestNotSupportedException::class); @@ -24,7 +24,7 @@ public function shouldBeSubClassOfInvalidArgumentException() /** * @test */ - public function shouldCreateWithNoneObjectRequest() + public function shouldCreateWithNoneObjectRequest(): void { $exception = RequestNotSupportedException::create('anRequest'); @@ -38,7 +38,7 @@ public function shouldCreateWithNoneObjectRequest() /** * @test */ - public function shouldCreateWithObjectRequest() + public function shouldCreateWithObjectRequest(): void { $request = new \stdClass(); @@ -54,7 +54,7 @@ public function shouldCreateWithObjectRequest() /** * @test */ - public function shouldCreateWithActionAndStringRequest() + public function shouldCreateWithActionAndStringRequest(): void { $action = $this->createMock(ActionInterface::class); $actionClass = get_class($action); @@ -75,7 +75,7 @@ public function shouldCreateWithActionAndStringRequest() /** * @test */ - public function shouldCreateWithActionAndObjectRequest() + public function shouldCreateWithActionAndObjectRequest(): void { $request = new \stdClass(); @@ -97,7 +97,7 @@ public function shouldCreateWithActionAndObjectRequest() /** * @test */ - public function shouldCreateWithSuggestions() + public function shouldCreateWithSuggestions(): void { $request = new \stdClass(); @@ -113,7 +113,7 @@ public function shouldCreateWithSuggestions() /** * @test */ - public function shouldCreateWithSuggestionsOnIdentityAsModel() + public function shouldCreateWithSuggestionsOnIdentityAsModel(): void { $request = new Capture(new Identity('theId', \stdClass::class)); @@ -129,7 +129,7 @@ public function shouldCreateWithSuggestionsOnIdentityAsModel() /** * @return MockObject|\Payum\Core\Action\ActionInterface */ - protected function createActionMock() + protected function createActionMock(): MockObject|ActionInterface { return $this->createMock(ActionInterface::class); } diff --git a/src/Payum/Core/Tests/Exception/RuntimeExceptionTest.php b/src/Payum/Core/Tests/Exception/RuntimeExceptionTest.php index 01c0c5099..8dbf65a9b 100644 --- a/src/Payum/Core/Tests/Exception/RuntimeExceptionTest.php +++ b/src/Payum/Core/Tests/Exception/RuntimeExceptionTest.php @@ -9,7 +9,7 @@ class RuntimeExceptionTest extends TestCase /** * @test */ - public function shouldImplementExceptionInterface() + public function shouldImplementExceptionInterface(): void { $rc = new \ReflectionClass('Payum\Core\Exception\RuntimeException'); @@ -19,7 +19,7 @@ public function shouldImplementExceptionInterface() /** * @test */ - public function shouldBeSubClassOfRuntimeException() + public function shouldBeSubClassOfRuntimeException(): void { $rc = new \ReflectionClass('Payum\Core\Exception\RuntimeException'); diff --git a/src/Payum/Core/Tests/Exception/UnsupportedApiExceptionTest.php b/src/Payum/Core/Tests/Exception/UnsupportedApiExceptionTest.php index 0bce34865..d1a549e1f 100644 --- a/src/Payum/Core/Tests/Exception/UnsupportedApiExceptionTest.php +++ b/src/Payum/Core/Tests/Exception/UnsupportedApiExceptionTest.php @@ -9,7 +9,7 @@ class UnsupportedApiExceptionTest extends TestCase /** * @test */ - public function shouldBeSubClassOfInvalidArgumentException() + public function shouldBeSubClassOfInvalidArgumentException(): void { $rc = new \ReflectionClass('Payum\Core\Exception\UnsupportedApiException'); diff --git a/src/Payum/Core/Tests/Extension/EndlessCycleDetectorExtensionTest.php b/src/Payum/Core/Tests/Extension/EndlessCycleDetectorExtensionTest.php index 89f82e113..27bd443ea 100644 --- a/src/Payum/Core/Tests/Extension/EndlessCycleDetectorExtensionTest.php +++ b/src/Payum/Core/Tests/Extension/EndlessCycleDetectorExtensionTest.php @@ -13,7 +13,7 @@ class EndlessCycleDetectorExtensionTest extends TestCase /** * @test */ - public function shouldImplementExtensionInterface() + public function shouldImplementExtensionInterface(): void { $rc = new \ReflectionClass('Payum\Core\Extension\EndlessCycleDetectorExtension'); @@ -23,7 +23,7 @@ public function shouldImplementExtensionInterface() /** * @test */ - public function throwIfCycleCounterMoreOrEqualsToNumberOfPreviousRequest() + public function throwIfCycleCounterMoreOrEqualsToNumberOfPreviousRequest(): void { $this->expectException(\Payum\Core\Exception\LogicException::class); $this->expectExceptionMessage('Possible endless cycle detected. ::onPreExecute was called 2 times before reach the limit.'); @@ -43,7 +43,7 @@ public function throwIfCycleCounterMoreOrEqualsToNumberOfPreviousRequest() /** * @test */ - public function shouldNotThrowIfNumberOfPreviousRequestNotReachLimit() + public function shouldNotThrowIfNumberOfPreviousRequestNotReachLimit(): void { $this->expectNotToPerformAssertions(); @@ -67,7 +67,7 @@ public function shouldNotThrowIfNumberOfPreviousRequestNotReachLimit() /** * @return MockObject|GatewayInterface */ - protected function createGatewayMock() + protected function createGatewayMock(): GatewayInterface|MockObject { return $this->createMock('Payum\Core\GatewayInterface'); } diff --git a/src/Payum/Core/Tests/Extension/ExtensionCollectionTest.php b/src/Payum/Core/Tests/Extension/ExtensionCollectionTest.php index 9ce3bcdaa..be80d9a11 100644 --- a/src/Payum/Core/Tests/Extension/ExtensionCollectionTest.php +++ b/src/Payum/Core/Tests/Extension/ExtensionCollectionTest.php @@ -12,7 +12,7 @@ class ExtensionCollectionTest extends TestCase /** * @test */ - public function shouldImplementExtensionInterface() + public function shouldImplementExtensionInterface(): void { $rc = new \ReflectionClass('Payum\Core\Extension\ExtensionCollection'); @@ -22,7 +22,7 @@ public function shouldImplementExtensionInterface() /** * @test */ - public function shouldAllowAddExtensionAppendByDefault() + public function shouldAllowAddExtensionAppendByDefault(): void { $extensionFirst = $this->createExtensionMock(); $extensionSecond = $this->createExtensionMock(); @@ -44,7 +44,7 @@ public function shouldAllowAddExtensionAppendByDefault() /** * @test */ - public function shouldAllowAddExtensionWithForcedPrepend() + public function shouldAllowAddExtensionWithForcedPrepend(): void { $extensionFirst = $this->createExtensionMock(); $extensionSecond = $this->createExtensionMock(); @@ -66,7 +66,7 @@ public function shouldAllowAddExtensionWithForcedPrepend() /** * @test */ - public function shouldCallOnPreExecuteForAllExtensionsInCollection() + public function shouldCallOnPreExecuteForAllExtensionsInCollection(): void { $expectedContext = $this->createContextMock(); @@ -96,7 +96,7 @@ public function shouldCallOnPreExecuteForAllExtensionsInCollection() /** * @test */ - public function shouldCallOnExecuteForAllExtensionsInCollection() + public function shouldCallOnExecuteForAllExtensionsInCollection(): void { $expectedContext = $this->createContextMock(); @@ -126,7 +126,7 @@ public function shouldCallOnExecuteForAllExtensionsInCollection() /** * @test */ - public function shouldCallOnPostExecuteForAllExtensionsInCollection() + public function shouldCallOnPostExecuteForAllExtensionsInCollection(): void { $expectedContext = $this->createContextMock(); @@ -153,18 +153,12 @@ public function shouldCallOnPostExecuteForAllExtensionsInCollection() $this->assertNull($result); } - /** - * @return MockObject|Context - */ - protected function createContextMock() + protected function createContextMock(): Context|MockObject { - return $this->createMock('Payum\Core\Extension\Context', array(), array(), '', false); + return $this->createMock('Payum\Core\Extension\Context'); } - /** - * @return MockObject|ExtensionInterface - */ - protected function createExtensionMock() + protected function createExtensionMock(): ExtensionInterface|MockObject { return $this->createMock('Payum\Core\Extension\ExtensionInterface'); } diff --git a/src/Payum/Core/Tests/Extension/GenericTokenFactoryExtensionTest.php b/src/Payum/Core/Tests/Extension/GenericTokenFactoryExtensionTest.php index ed99d2677..95e15ba84 100644 --- a/src/Payum/Core/Tests/Extension/GenericTokenFactoryExtensionTest.php +++ b/src/Payum/Core/Tests/Extension/GenericTokenFactoryExtensionTest.php @@ -15,7 +15,7 @@ class GenericTokenFactoryExtensionTest extends TestCase /** * @test */ - public function shouldImplementExtensionInterface() + public function shouldImplementExtensionInterface(): void { $rc = new \ReflectionClass('Payum\Core\Extension\GenericTokenFactoryExtension'); @@ -25,7 +25,7 @@ public function shouldImplementExtensionInterface() /** * @test */ - public function shouldSetTokenFactoryToActionImplementsGenericTokenFactoryAwareInterface() + public function shouldSetTokenFactoryToActionImplementsGenericTokenFactoryAwareInterface(): void { $tokenFactory = $this->createGenericTokenFactoryMock(); @@ -44,7 +44,7 @@ public function shouldSetTokenFactoryToActionImplementsGenericTokenFactoryAwareI /** * @test */ - public function shouldUnsetGenericTokenFactoryOnPostExecute() + public function shouldUnsetGenericTokenFactoryOnPostExecute(): void { $tokenFactory = $this->createGenericTokenFactoryMock(); @@ -64,7 +64,7 @@ public function shouldUnsetGenericTokenFactoryOnPostExecute() /** * @test */ - public function shouldDoNothingIfActionNotImplementsGenericTokenFactoryAwareInterfaceOnPostExecute() + public function shouldDoNothingIfActionNotImplementsGenericTokenFactoryAwareInterfaceOnPostExecute(): void { $this->expectNotToPerformAssertions(); @@ -83,7 +83,7 @@ public function shouldDoNothingIfActionNotImplementsGenericTokenFactoryAwareInte /** * @return MockObject|ActionInterface */ - protected function createActionMock() + protected function createActionMock(): MockObject|ActionInterface { return $this->createMock('Payum\Core\Action\ActionInterface'); } @@ -91,7 +91,7 @@ protected function createActionMock() /** * @return MockObject|GenericTokenFactoryInterface */ - protected function createGenericTokenFactoryMock() + protected function createGenericTokenFactoryMock(): MockObject|GenericTokenFactoryInterface { return $this->createMock('Payum\Core\Security\GenericTokenFactoryInterface'); } @@ -99,7 +99,7 @@ protected function createGenericTokenFactoryMock() /** * @return MockObject|GatewayInterface */ - protected function createGatewayMock() + protected function createGatewayMock(): GatewayInterface|MockObject { return $this->createMock('Payum\Core\GatewayInterface'); } diff --git a/src/Payum/Core/Tests/Extension/StorageExtensionTest.php b/src/Payum/Core/Tests/Extension/StorageExtensionTest.php index f71778787..dac4b4e9d 100644 --- a/src/Payum/Core/Tests/Extension/StorageExtensionTest.php +++ b/src/Payum/Core/Tests/Extension/StorageExtensionTest.php @@ -17,7 +17,7 @@ class StorageExtensionTest extends TestCase /** * @test */ - public function shouldImplementExtensionInterface() + public function shouldImplementExtensionInterface(): void { $rc = new \ReflectionClass('Payum\Core\Extension\StorageExtension'); @@ -27,13 +27,13 @@ public function shouldImplementExtensionInterface() /** * @test */ - public function shouldDoNothingOnPreExecuteIfNoModelRequest() + public function shouldDoNothingOnPreExecuteIfNoModelRequest(): void { $neverUsedStorageMock = $this->createStorageMock(); $neverUsedStorageMock ->expects($this->never()) ->method('support') - ->will($this->returnValue(false)) + ->willReturn(false) ; $neverUsedStorageMock ->expects($this->never()) @@ -50,7 +50,7 @@ public function shouldDoNothingOnPreExecuteIfNoModelRequest() /** * @test */ - public function shouldDoNothingOnPreExecuteIfFindModelByIdentityReturnNull() + public function shouldDoNothingOnPreExecuteIfFindModelByIdentityReturnNull(): void { $expectedModel = new \stdClass(); $expectedId = 123; @@ -61,7 +61,7 @@ public function shouldDoNothingOnPreExecuteIfFindModelByIdentityReturnNull() ->expects($this->atLeastOnce()) ->method('find') ->with($identity) - ->will($this->returnValue(null)) + ->willReturn(null) ; $requestMock = $this->createMock(ModelAggregateAndAwareInterface::class); @@ -84,13 +84,13 @@ public function shouldDoNothingOnPreExecuteIfFindModelByIdentityReturnNull() /** * @test */ - public function shouldDoNothingOnPreExecuteIfModelNotIdentityAndNotSupported() + public function shouldDoNothingOnPreExecuteIfModelNotIdentityAndNotSupported(): void { $storageMock = $this->createStorageMock(); $storageMock ->expects($this->atLeastOnce()) ->method('support') - ->will($this->returnValue(true)) + ->willReturn(true) ; $storageMock ->expects($this->never()) @@ -117,7 +117,7 @@ public function shouldDoNothingOnPreExecuteIfModelNotIdentityAndNotSupported() /** * @test */ - public function shouldDoNothingOnPreExecuteIfRequestNotModelRequest() + public function shouldDoNothingOnPreExecuteIfRequestNotModelRequest(): void { $storageMock = $this->createStorageMock(); $storageMock @@ -141,7 +141,7 @@ public function shouldDoNothingOnPreExecuteIfRequestNotModelRequest() /** * @test */ - public function shouldSetFoundModelOnRequestIfIdentifierGivenAsModelAndStorageSupportsIt() + public function shouldSetFoundModelOnRequestIfIdentifierGivenAsModelAndStorageSupportsIt(): void { $expectedModel = new \stdClass(); $expectedId = 123; @@ -152,7 +152,7 @@ public function shouldSetFoundModelOnRequestIfIdentifierGivenAsModelAndStorageSu ->expects($this->once()) ->method('find') ->with($identity) - ->will($this->returnValue($expectedModel)) + ->willReturn($expectedModel) ; $requestMock = $this->createMock(ModelAggregateAndAwareInterface::class); @@ -175,7 +175,7 @@ public function shouldSetFoundModelOnRequestIfIdentifierGivenAsModelAndStorageSu /** * @test */ - public function shouldScheduleForUpdateRequestModelIfStorageSupportItOnPreExecute() + public function shouldScheduleForUpdateRequestModelIfStorageSupportItOnPreExecute(): void { $model = new \stdClass(); @@ -188,7 +188,7 @@ public function shouldScheduleForUpdateRequestModelIfStorageSupportItOnPreExecut ->expects($this->once()) ->method('support') ->with($this->identicalTo($model)) - ->will($this->returnValue(true)) + ->willReturn(true) ; $requestMock = $this->createMock(ModelAggregateInterface::class); @@ -207,7 +207,7 @@ public function shouldScheduleForUpdateRequestModelIfStorageSupportItOnPreExecut /** * @test */ - public function shouldScheduleForUpdateRequestModelIfStorageSupportItOnPostExecute() + public function shouldScheduleForUpdateRequestModelIfStorageSupportItOnPostExecute(): void { $model = new \stdClass(); @@ -220,7 +220,7 @@ public function shouldScheduleForUpdateRequestModelIfStorageSupportItOnPostExecu ->expects($this->once()) ->method('support') ->with($this->identicalTo($model)) - ->will($this->returnValue(true)) + ->willReturn(true) ; $requestMock = $this->createMock(ModelAggregateInterface::class); @@ -246,7 +246,7 @@ public function shouldScheduleForUpdateRequestModelIfStorageSupportItOnPostExecu /** * @test */ - public function shouldUpdateModelOneTimeOnLatestOnPostExecute() + public function shouldUpdateModelOneTimeOnLatestOnPostExecute(): void { //when previous is empty @@ -257,7 +257,7 @@ public function shouldUpdateModelOneTimeOnLatestOnPostExecute() ->expects($this->atLeastOnce()) ->method('support') ->with($this->identicalTo($expectedModel)) - ->will($this->returnValue(true)) + ->willReturn(true) ; $storageMock ->expects($this->once()) @@ -283,7 +283,7 @@ public function shouldUpdateModelOneTimeOnLatestOnPostExecute() /** * @test */ - public function shouldNotUpdateModelIfNotLatestOnPostExecute() + public function shouldNotUpdateModelIfNotLatestOnPostExecute(): void { //when previous is NOT empty @@ -294,7 +294,7 @@ public function shouldNotUpdateModelIfNotLatestOnPostExecute() ->expects($this->atLeastOnce()) ->method('support') ->with($this->identicalTo($expectedModel)) - ->will($this->returnValue(true)) + ->willReturn(true) ; $storageMock ->expects($this->never()) @@ -319,7 +319,7 @@ public function shouldNotUpdateModelIfNotLatestOnPostExecute() $extension->onPostExecute($context); } - protected function createModelRequestWithModel($model) + protected function createModelRequestWithModel($model): ModelAggregateAndAwareInterface|MockObject { $modelRequestMock = $this->createMock(ModelAggregateAndAwareInterface::class); $modelRequestMock @@ -333,7 +333,7 @@ protected function createModelRequestWithModel($model) /** * @return MockObject|StorageInterface */ - protected function createStorageMock() + protected function createStorageMock(): StorageInterface|MockObject { return $this->createMock('Payum\Core\Storage\StorageInterface'); } @@ -341,7 +341,7 @@ protected function createStorageMock() /** * @return MockObject|ActionInterface */ - protected function createActionMock() + protected function createActionMock(): MockObject|ActionInterface { return $this->createMock('Payum\Core\Action\ActionInterface'); } @@ -349,7 +349,7 @@ protected function createActionMock() /** * @return MockObject|GatewayInterface */ - protected function createGatewayMock() + protected function createGatewayMock(): GatewayInterface|MockObject { return $this->createMock('Payum\Core\GatewayInterface'); } diff --git a/src/Payum/Stripe/Request/Api/CreateTokenForCreditCard.php b/src/Payum/Stripe/Request/Api/CreateTokenForCreditCard.php index 5e60c141e..dcb7dba5a 100644 --- a/src/Payum/Stripe/Request/Api/CreateTokenForCreditCard.php +++ b/src/Payum/Stripe/Request/Api/CreateTokenForCreditCard.php @@ -8,7 +8,7 @@ class CreateTokenForCreditCard extends Generic /** * @var array|\ArrayAccess */ - protected $token = []; + protected \Payum\Core\Security\TokenInterface $token = []; /** * @return array|\ArrayAccess