Skip to content

Commit

Permalink
Add declare(strict_types=1);
Browse files Browse the repository at this point in the history
  • Loading branch information
trejjam committed Oct 29, 2017
1 parent aae048f commit 72f2e72
Show file tree
Hide file tree
Showing 15 changed files with 59 additions and 71 deletions.
7 changes: 2 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
],
"require": {
"php": ">=7.1",
"trejjam/thepay-lib": "dev-namespaces#8bfc44f",
"trejjam/thepay-lib": "dev-namespaces#aef9b4c",
"trejjam/base-extension": "~0.7",
"nette/di": "~2.3",
"nette/application": "~2.3",
Expand All @@ -27,10 +27,7 @@
"autoload": {
"psr-4": {
"Trejjam\\ThePay\\": "src/"
},
"classmap": [
"src/exceptions.php"
]
}
},
"extra": {
"branch-alias": {
Expand Down
3 changes: 2 additions & 1 deletion src/DI/ThePayExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public function beforeCompile()
$merchantConfig['dataApiPassword'],
$merchantConfig['webServicesWsdl'],
$merchantConfig['dataWebServicesWsdl'],
]);
]
);
}
}
72 changes: 26 additions & 46 deletions src/Helper/DataApi.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
<?php
/**
* Created by PhpStorm.
* User: jam
* Date: 24.9.15
* Time: 11:08
*/
declare(strict_types=1);

namespace Trejjam\ThePay\Helper;

Expand All @@ -25,20 +20,12 @@ function __construct(Trejjam\ThePay\MerchantConfig $config)
$this->config = $config;
}

/**
* @return Trejjam\ThePay\MerchantConfig
*/
public function getMerchantConfig()
public function getMerchantConfig() : Trejjam\ThePay\MerchantConfig
{
return $this->config;
}

/**
* @param bool $onlyActive
*
* @return Tp\DataApi\Responses\GetPaymentMethodsResponse
*/
public function getPaymentMethods($onlyActive = TRUE)
public function getPaymentMethods(bool $onlyActive = TRUE) : Tp\DataApi\Responses\GetPaymentMethodsResponse
{
return Tp\Helper\DataApi::getPaymentMethods($this->config, $onlyActive);
}
Expand All @@ -49,55 +36,48 @@ public function getPaymentMethods($onlyActive = TRUE)
*
* @return null|string
*/
public function getPaymentMethodIcon(Parameters\MerchantAccountMethod $method, $type = 'tight')
public function getPaymentMethodIcon(Parameters\MerchantAccountMethod $method, string $type = 'tight') : string
{
return Nette\Utils\Strings::replace($this->config->gateUrl, [
'~/demo-~' => '/',
]) . 'images/logos/public/' . $type . '/' . $method->getId() . '.png';
'~/demo-~' => '/',
]) . 'images/logos/public/' . $type . '/' . $method->getId() . '.png';
}

/**
* @param string $paymentId
*
* @return Tp\DataApi\Responses\GetPaymentResponse
*/
public function getPayment($paymentId)
public function getPayment(string $paymentId) : Tp\DataApi\Responses\GetPaymentResponse
{
return Tp\Helper\DataApi::getPayment($this->config, $paymentId);
}

/**
* @param string $paymentId
*
* @return Tp\DataApi\Responses\GetPaymentInstructionsResponse
*/
public function getPaymentInstructions($paymentId)
public function getPaymentInstructions(string $paymentId) : Tp\DataApi\Responses\GetPaymentInstructionsResponse
{
return Tp\Helper\DataApi::getPaymentInstructions($this->config, $paymentId);
}

/**
* @param string $paymentId
*
* @return Tp\DataApi\Responses\GetPaymentStateResponse
*/
public function getPaymentState($paymentId)
public function getPaymentState(string $paymentId) : Tp\DataApi\Responses\GetPaymentStateResponse
{
return Tp\Helper\DataApi::getPaymentState($this->config, $paymentId);
}

/**
* @param Parameters\GetPaymentsSearchParams|NULL $searchParams
* @param Parameters\PaginationRequest|NULL $pagination
* @param Parameters\Ordering|NULL $ordering
*
* @return Tp\DataApi\Responses\GetPaymentsResponse
*/
public function getPayments(
Parameters\GetPaymentsSearchParams $searchParams = NULL,
Parameters\PaginationRequest $pagination = NULL,
Parameters\Ordering $ordering = NULL)
{
Parameters\Ordering $ordering = NULL
) : Tp\DataApi\Responses\GetPaymentsResponse {
return Tp\Helper\DataApi::getPayments($this->config, $searchParams, $pagination, $ordering);
}

/**
* @param $type
* @param array $paymentMethods
*
* @return Tp\DataApi\Responses\SetPaymentMethodsResponse
* @throws Tp\InvalidSignatureException
* @throws Tp\SoapException
*/
public function setPaymentMethods(
$type,
array $paymentMethods = NULL
) : Tp\DataApi\Responses\SetPaymentMethodsResponse {
return Tp\Helper\DataApi::setPaymentMethods($this->config, $type, $paymentMethods);
}
}
5 changes: 3 additions & 2 deletions src/Helper/IRadioMerchant.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?php
declare(strict_types=1);

namespace Trejjam\ThePay\Helper;

use Tp;
use Tp\Helper\RadioMerchant;

interface IRadioMerchant
{
/**
* @return Tp\Helper\RadioMerchant
* @return RadioMerchant
*/
function create();
}
1 change: 1 addition & 0 deletions src/IPayment.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);

namespace Trejjam\ThePay;

Expand Down
1 change: 1 addition & 0 deletions src/IPermanentPayment.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);

namespace Trejjam\ThePay;

Expand Down
1 change: 1 addition & 0 deletions src/IReturnedPayment.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);

namespace Trejjam\ThePay;

Expand Down
3 changes: 2 additions & 1 deletion src/MerchantConfig.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);

namespace Trejjam\ThePay;

Expand All @@ -13,7 +14,7 @@ class MerchantConfig extends Tp\MerchantConfig
{
public $isDemo = FALSE;

public function isDemo()
public function isDemo() : bool
{
return $this->isDemo;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Payment.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php
declare(strict_types=1);

namespace Trejjam\ThePay;

use Nette;
use Tp;
use Trejjam;

class Payment extends Tp\Payment
{
Expand All @@ -20,7 +20,7 @@ public function __construct(MerchantConfig $config = NULL, Nette\Application\Lin
$this->linkGenerator = $linkGenerator;
}

public function setReturnUrl($returnUrl, $params = [])
public function setReturnUrl($returnUrl, array $params = [])
{
if (preg_match('~^([\w:]+):(\w*+)(#.*)?()\z~', $returnUrl)) {
$returnUrl = $this->linkGenerator->link($returnUrl, $params);
Expand All @@ -44,7 +44,7 @@ public function setBackToEshopUrl($backToEshopUrl = NULL, $params = [])
parent::setBackToEshopUrl($backToEshopUrl);
}

public function getRedirectUrl()
public function getRedirectUrl() : string
{
$queryArgs = $this->getArgs();
$queryArgs['signature'] = $this->getSignature();
Expand Down
12 changes: 6 additions & 6 deletions src/PermanentPayment.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php
declare(strict_types=1);

namespace Trejjam\ThePay;

use Nette;
use Tp;
use Trejjam;

class PermanentPayment extends Tp\PermanentPayment
{
Expand All @@ -20,7 +20,7 @@ public function __construct(MerchantConfig $config, Nette\Application\LinkGenera
$this->linkGenerator = $linkGenerator;
}

public function getMerchantData()
public function getMerchantData() : string
{
if (is_null($this->merchantData)) {
throw new PermanentPaymentException('Property merchantData was not set', PermanentPaymentException::UNDEFINED_PROPERTY);
Expand All @@ -29,7 +29,7 @@ public function getMerchantData()
return parent::getMerchantData();
}

public function getDescription()
public function getDescription() : string
{
if (is_null($this->description)) {
throw new PermanentPaymentException('Property description was not set', PermanentPaymentException::UNDEFINED_PROPERTY);
Expand All @@ -38,7 +38,7 @@ public function getDescription()
return parent::getDescription();
}

public function getReturnUrl()
public function getReturnUrl() : string
{
if (is_null($this->returnUrl)) {
throw new PermanentPaymentException('Property returnUrl was not set', PermanentPaymentException::UNDEFINED_PROPERTY);
Expand All @@ -56,7 +56,7 @@ public function setReturnUrl($returnUrl, $params = [])
parent::setReturnUrl($returnUrl);
}

public function getSignature()
public function getSignature() : string
{
$this->getMerchantData();
$this->getDescription();
Expand All @@ -65,7 +65,7 @@ public function getSignature()
return parent::getSignature();
}

public function getSignatureLite()
public function getSignatureLite() : string
{
$this->getMerchantData();

Expand Down
1 change: 1 addition & 0 deletions src/exceptions.php → src/PermanentPaymentException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);

namespace Trejjam\ThePay;

Expand Down
7 changes: 4 additions & 3 deletions src/ReturnedPayment.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php
declare(strict_types=1);

namespace Trejjam\ThePay;

use Nette;
use Tp;
use Trejjam;

class ReturnedPayment extends Tp\ReturnedPayment
{
Expand Down Expand Up @@ -50,8 +50,9 @@ public function setBackToEshopUrl($backToEshopUrl = NULL, $params = [])
parent::setBackToEshopUrl($backToEshopUrl);
}

public function __debugInfo(){
$out=[];
public function __debugInfo()
{
$out = [];

foreach ($this->__sleep() as $v) {
$out[$v] = $this->$v;
Expand Down
1 change: 1 addition & 0 deletions tests/TpPayment.phpt → tests/TpPaymentTest.phpt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);

namespace Test;

Expand Down
7 changes: 4 additions & 3 deletions tests/app/router/RouterFactory.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php
declare(strict_types=1);

namespace Test\App;

use Nette,
Nette\Application\Routers\RouteList,
Nette\Application\Routers\Route;
use Nette;
use Nette\Application\Routers\RouteList;
use Nette\Application\Routers\Route;


/**
Expand Down
3 changes: 2 additions & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
declare(strict_types=1);

require __DIR__ . '/../vendor/autoload.php';
require dirname(__DIR__) . '/vendor/autoload.php';

if (!class_exists('Tester\Assert')) {
echo "Install Nette Tester using `composer update --dev`\n";
Expand Down

0 comments on commit 72f2e72

Please sign in to comment.