Skip to content

Commit

Permalink
test: add typehints for php 7.3 language level
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris8934 authored and karser committed Feb 25, 2022
1 parent b6e787c commit fc9c9f5
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 51 deletions.
2 changes: 1 addition & 1 deletion Action/Api/CaptureTransactionAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

class CaptureTransactionAction extends BaseApiAwareAction
{
public function execute($request)
public function execute($request): void
{
RequestNotSupportedException::assertSupports($this, $request);
$model = ArrayObject::ensureArrayObject($request->getModel());
Expand Down
4 changes: 2 additions & 2 deletions Action/AuthorizeAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AuthorizeAction implements ActionInterface, GatewayAwareInterface
*
* @param Authorize $request
*/
public function execute($request)
public function execute($request): void
{
RequestNotSupportedException::assertSupports($this, $request);

Expand All @@ -30,7 +30,7 @@ public function execute($request)
/**
* {@inheritDoc}
*/
public function supports($request)
public function supports($request): bool
{
return
$request instanceof Authorize &&
Expand Down
4 changes: 2 additions & 2 deletions Action/CancelAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class CancelAction implements ActionInterface
*
* @param Cancel $request
*/
public function execute($request)
public function execute($request): void
{
RequestNotSupportedException::assertSupports($this, $request);

Expand All @@ -29,7 +29,7 @@ public function execute($request)
/**
* {@inheritDoc}
*/
public function supports($request)
public function supports($request): bool
{
return
$request instanceof Cancel &&
Expand Down
6 changes: 3 additions & 3 deletions Action/CaptureAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct()
/**
* @param Capture $request
*/
public function execute($request)
public function execute($request): void
{
RequestNotSupportedException::assertSupports($this, $request);

Expand All @@ -65,7 +65,7 @@ public function execute($request)
}
}

private function handlePaymentPageInterface(Capture $request)
private function handlePaymentPageInterface(Capture $request): void
{
$model = ArrayObject::ensureArrayObject($request->getModel());

Expand Down Expand Up @@ -102,7 +102,7 @@ private function handlePaymentPageInterface(Capture $request)
}
}

private function handleTransactionInterface(Capture $request)
private function handleTransactionInterface(Capture $request): void
{
$model = ArrayObject::ensureArrayObject($request->getModel());

Expand Down
8 changes: 3 additions & 5 deletions Action/CaptureReferencedAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ class CaptureReferencedAction implements ActionInterface, GatewayAwareInterface
/**
* @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($request): void
{
RequestNotSupportedException::assertSupports($this, $request);

Expand All @@ -49,10 +49,8 @@ public function execute($request)

/**
* @param mixed $request
*
* @return boolean
*/
public function supports($request)
public function supports($request): bool
{
return
$request instanceof CaptureReferenced &&
Expand Down
4 changes: 2 additions & 2 deletions Action/ConvertPaymentAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ConvertPaymentAction implements ActionInterface
*
* @param Convert $request
*/
public function execute($request)
public function execute($request): void
{
RequestNotSupportedException::assertSupports($this, $request);

Expand Down Expand Up @@ -50,7 +50,7 @@ public function execute($request)
/**
* {@inheritDoc}
*/
public function supports($request)
public function supports($request): bool
{
return
$request instanceof Convert &&
Expand Down
5 changes: 2 additions & 3 deletions Action/InsertCardAliasAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class InsertCardAliasAction implements ActionInterface, GatewayAwareInterface
*/
public function execute($request): void
{

RequestNotSupportedException::assertSupports($this, $request);

/** @var $cardAlias CardAliasInterface */
Expand All @@ -39,7 +38,7 @@ public function execute($request): void
}
}

private function doExecute(InsertCardAlias $request, ArrayObject $details)
private function doExecute(InsertCardAlias $request, ArrayObject $details): void
{
if (empty($details['Token'])) {
$this->insertAliasAction($request, $details);
Expand All @@ -48,7 +47,7 @@ private function doExecute(InsertCardAlias $request, ArrayObject $details)
$this->gateway->execute(new AssertInsertAlias($details));
}

private function insertAliasAction(InsertCardAlias $request, ArrayObject $model)
private function insertAliasAction(InsertCardAlias $request, ArrayObject $model): void
{
if (empty($model['ReturnUrls'])) {
$token = $request->getToken();
Expand Down
4 changes: 2 additions & 2 deletions Action/RefundAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class RefundAction implements ActionInterface, GatewayAwareInterface
*
* @param Refund $request
*/
public function execute($request)
public function execute($request): void
{
RequestNotSupportedException::assertSupports($this, $request);

Expand All @@ -33,7 +33,7 @@ public function execute($request)
/**
* {@inheritDoc}
*/
public function supports($request)
public function supports($request): bool
{
return
$request instanceof Refund &&
Expand Down
2 changes: 1 addition & 1 deletion Action/StatusAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class StatusAction implements ActionInterface
/**
* @param GetStatusInterface $request
*/
public function execute($request)
public function execute($request): void
{
RequestNotSupportedException::assertSupports($this, $request);

Expand Down
30 changes: 4 additions & 26 deletions Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ class Api
'optionalParameters' => null,
);

/**
* @param array $options
* @param HttpClientInterface $client
* @param MessageFactory $messageFactory
*/
public function __construct(array $options, HttpClientInterface $client, MessageFactory $messageFactory)
{
$options = ArrayObject::ensureArrayObject($options);
Expand All @@ -66,13 +61,7 @@ public function __construct(array $options, HttpClientInterface $client, Message
$this->messageFactory = $messageFactory;
}

/**
* @param string $path
* @param array $fields
*
* @return array
*/
protected function doRequest($path, array $fields)
protected function doRequest(string $path, array $fields): array
{
$headers = [
'Authorization' => 'Basic ' . base64_encode($this->options['username'] . ':' . $this->options['password']),
Expand Down Expand Up @@ -235,18 +224,12 @@ public function deleteAlias(string $id): array
return $this->doRequest(self::ALIAS_DELETE_PATH, $payload);
}

/**
* @return string
*/
public function getApiEndpoint()
public function getApiEndpoint(): string
{
return $this->options['sandbox'] ? 'https://test.saferpay.com/api' : 'https://www.saferpay.com/api';
}

/**
* @return string
*/
public function getCaptureStrategy()
public function getCaptureStrategy(): string
{
if (isset($this->options['interface']) && is_string($this->options['interface'])) {
return $this->options['interface'];
Expand Down Expand Up @@ -329,12 +312,7 @@ protected function addOptionalInterfaceParams(string $interface, array $payload)

return $payload;
}

/**
* @param string $data
* @param string $delimiter
* @return array
*/

protected function trimExplode(string $data, string $delimiter = ','): array {
return array_map('trim', explode($delimiter, $data));
}
Expand Down
3 changes: 0 additions & 3 deletions Model/CardAlias.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ public function __construct()
$this->details = [];
}

/**
* @return array
*/
public function getDetails(): array
{
return $this->details;
Expand Down
2 changes: 1 addition & 1 deletion SaferpayGatewayFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class SaferpayGatewayFactory extends GatewayFactory
/**
* {@inheritDoc}
*/
protected function populateConfig(ArrayObject $config)
protected function populateConfig(ArrayObject $config): void
{
$config->defaults([
'payum.factory_name' => 'saferpay',
Expand Down

0 comments on commit fc9c9f5

Please sign in to comment.