Skip to content

Commit 72f2e72

Browse files
committed
Add declare(strict_types=1);
1 parent aae048f commit 72f2e72

15 files changed

+59
-71
lines changed

composer.json

+2-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
],
1212
"require": {
1313
"php": ">=7.1",
14-
"trejjam/thepay-lib": "dev-namespaces#8bfc44f",
14+
"trejjam/thepay-lib": "dev-namespaces#aef9b4c",
1515
"trejjam/base-extension": "~0.7",
1616
"nette/di": "~2.3",
1717
"nette/application": "~2.3",
@@ -27,10 +27,7 @@
2727
"autoload": {
2828
"psr-4": {
2929
"Trejjam\\ThePay\\": "src/"
30-
},
31-
"classmap": [
32-
"src/exceptions.php"
33-
]
30+
}
3431
},
3532
"extra": {
3633
"branch-alias": {

src/DI/ThePayExtension.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ public function beforeCompile()
8080
$merchantConfig['dataApiPassword'],
8181
$merchantConfig['webServicesWsdl'],
8282
$merchantConfig['dataWebServicesWsdl'],
83-
]);
83+
]
84+
);
8485
}
8586
}

src/Helper/DataApi.php

+26-46
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
<?php
2-
/**
3-
* Created by PhpStorm.
4-
* User: jam
5-
* Date: 24.9.15
6-
* Time: 11:08
7-
*/
2+
declare(strict_types=1);
83

94
namespace Trejjam\ThePay\Helper;
105

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

28-
/**
29-
* @return Trejjam\ThePay\MerchantConfig
30-
*/
31-
public function getMerchantConfig()
23+
public function getMerchantConfig() : Trejjam\ThePay\MerchantConfig
3224
{
3325
return $this->config;
3426
}
3527

36-
/**
37-
* @param bool $onlyActive
38-
*
39-
* @return Tp\DataApi\Responses\GetPaymentMethodsResponse
40-
*/
41-
public function getPaymentMethods($onlyActive = TRUE)
28+
public function getPaymentMethods(bool $onlyActive = TRUE) : Tp\DataApi\Responses\GetPaymentMethodsResponse
4229
{
4330
return Tp\Helper\DataApi::getPaymentMethods($this->config, $onlyActive);
4431
}
@@ -49,55 +36,48 @@ public function getPaymentMethods($onlyActive = TRUE)
4936
*
5037
* @return null|string
5138
*/
52-
public function getPaymentMethodIcon(Parameters\MerchantAccountMethod $method, $type = 'tight')
39+
public function getPaymentMethodIcon(Parameters\MerchantAccountMethod $method, string $type = 'tight') : string
5340
{
5441
return Nette\Utils\Strings::replace($this->config->gateUrl, [
55-
'~/demo-~' => '/',
56-
]) . 'images/logos/public/' . $type . '/' . $method->getId() . '.png';
42+
'~/demo-~' => '/',
43+
]) . 'images/logos/public/' . $type . '/' . $method->getId() . '.png';
5744
}
5845

59-
/**
60-
* @param string $paymentId
61-
*
62-
* @return Tp\DataApi\Responses\GetPaymentResponse
63-
*/
64-
public function getPayment($paymentId)
46+
public function getPayment(string $paymentId) : Tp\DataApi\Responses\GetPaymentResponse
6547
{
6648
return Tp\Helper\DataApi::getPayment($this->config, $paymentId);
6749
}
6850

69-
/**
70-
* @param string $paymentId
71-
*
72-
* @return Tp\DataApi\Responses\GetPaymentInstructionsResponse
73-
*/
74-
public function getPaymentInstructions($paymentId)
51+
public function getPaymentInstructions(string $paymentId) : Tp\DataApi\Responses\GetPaymentInstructionsResponse
7552
{
7653
return Tp\Helper\DataApi::getPaymentInstructions($this->config, $paymentId);
7754
}
7855

79-
/**
80-
* @param string $paymentId
81-
*
82-
* @return Tp\DataApi\Responses\GetPaymentStateResponse
83-
*/
84-
public function getPaymentState($paymentId)
56+
public function getPaymentState(string $paymentId) : Tp\DataApi\Responses\GetPaymentStateResponse
8557
{
8658
return Tp\Helper\DataApi::getPaymentState($this->config, $paymentId);
8759
}
8860

89-
/**
90-
* @param Parameters\GetPaymentsSearchParams|NULL $searchParams
91-
* @param Parameters\PaginationRequest|NULL $pagination
92-
* @param Parameters\Ordering|NULL $ordering
93-
*
94-
* @return Tp\DataApi\Responses\GetPaymentsResponse
95-
*/
9661
public function getPayments(
9762
Parameters\GetPaymentsSearchParams $searchParams = NULL,
9863
Parameters\PaginationRequest $pagination = NULL,
99-
Parameters\Ordering $ordering = NULL)
100-
{
64+
Parameters\Ordering $ordering = NULL
65+
) : Tp\DataApi\Responses\GetPaymentsResponse {
10166
return Tp\Helper\DataApi::getPayments($this->config, $searchParams, $pagination, $ordering);
10267
}
68+
69+
/**
70+
* @param $type
71+
* @param array $paymentMethods
72+
*
73+
* @return Tp\DataApi\Responses\SetPaymentMethodsResponse
74+
* @throws Tp\InvalidSignatureException
75+
* @throws Tp\SoapException
76+
*/
77+
public function setPaymentMethods(
78+
$type,
79+
array $paymentMethods = NULL
80+
) : Tp\DataApi\Responses\SetPaymentMethodsResponse {
81+
return Tp\Helper\DataApi::setPaymentMethods($this->config, $type, $paymentMethods);
82+
}
10383
}

src/Helper/IRadioMerchant.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
<?php
2+
declare(strict_types=1);
23

34
namespace Trejjam\ThePay\Helper;
45

5-
use Tp;
6+
use Tp\Helper\RadioMerchant;
67

78
interface IRadioMerchant
89
{
910
/**
10-
* @return Tp\Helper\RadioMerchant
11+
* @return RadioMerchant
1112
*/
1213
function create();
1314
}

src/IPayment.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
declare(strict_types=1);
23

34
namespace Trejjam\ThePay;
45

src/IPermanentPayment.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
declare(strict_types=1);
23

34
namespace Trejjam\ThePay;
45

src/IReturnedPayment.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
declare(strict_types=1);
23

34
namespace Trejjam\ThePay;
45

src/MerchantConfig.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
declare(strict_types=1);
23

34
namespace Trejjam\ThePay;
45

@@ -13,7 +14,7 @@ class MerchantConfig extends Tp\MerchantConfig
1314
{
1415
public $isDemo = FALSE;
1516

16-
public function isDemo()
17+
public function isDemo() : bool
1718
{
1819
return $this->isDemo;
1920
}

src/Payment.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?php
2+
declare(strict_types=1);
23

34
namespace Trejjam\ThePay;
45

56
use Nette;
67
use Tp;
7-
use Trejjam;
88

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

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

47-
public function getRedirectUrl()
47+
public function getRedirectUrl() : string
4848
{
4949
$queryArgs = $this->getArgs();
5050
$queryArgs['signature'] = $this->getSignature();

src/PermanentPayment.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?php
2+
declare(strict_types=1);
23

34
namespace Trejjam\ThePay;
45

56
use Nette;
67
use Tp;
7-
use Trejjam;
88

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

23-
public function getMerchantData()
23+
public function getMerchantData() : string
2424
{
2525
if (is_null($this->merchantData)) {
2626
throw new PermanentPaymentException('Property merchantData was not set', PermanentPaymentException::UNDEFINED_PROPERTY);
@@ -29,7 +29,7 @@ public function getMerchantData()
2929
return parent::getMerchantData();
3030
}
3131

32-
public function getDescription()
32+
public function getDescription() : string
3333
{
3434
if (is_null($this->description)) {
3535
throw new PermanentPaymentException('Property description was not set', PermanentPaymentException::UNDEFINED_PROPERTY);
@@ -38,7 +38,7 @@ public function getDescription()
3838
return parent::getDescription();
3939
}
4040

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

59-
public function getSignature()
59+
public function getSignature() : string
6060
{
6161
$this->getMerchantData();
6262
$this->getDescription();
@@ -65,7 +65,7 @@ public function getSignature()
6565
return parent::getSignature();
6666
}
6767

68-
public function getSignatureLite()
68+
public function getSignatureLite() : string
6969
{
7070
$this->getMerchantData();
7171

src/exceptions.php src/PermanentPaymentException.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
declare(strict_types=1);
23

34
namespace Trejjam\ThePay;
45

src/ReturnedPayment.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?php
2+
declare(strict_types=1);
23

34
namespace Trejjam\ThePay;
45

56
use Nette;
67
use Tp;
7-
use Trejjam;
88

99
class ReturnedPayment extends Tp\ReturnedPayment
1010
{
@@ -50,8 +50,9 @@ public function setBackToEshopUrl($backToEshopUrl = NULL, $params = [])
5050
parent::setBackToEshopUrl($backToEshopUrl);
5151
}
5252

53-
public function __debugInfo(){
54-
$out=[];
53+
public function __debugInfo()
54+
{
55+
$out = [];
5556

5657
foreach ($this->__sleep() as $v) {
5758
$out[$v] = $this->$v;

tests/TpPayment.phpt tests/TpPaymentTest.phpt

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
declare(strict_types=1);
23

34
namespace Test;
45

tests/app/router/RouterFactory.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<?php
2+
declare(strict_types=1);
23

34
namespace Test\App;
45

5-
use Nette,
6-
Nette\Application\Routers\RouteList,
7-
Nette\Application\Routers\Route;
6+
use Nette;
7+
use Nette\Application\Routers\RouteList;
8+
use Nette\Application\Routers\Route;
89

910

1011
/**

tests/bootstrap.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
2+
declare(strict_types=1);
23

3-
require __DIR__ . '/../vendor/autoload.php';
4+
require dirname(__DIR__) . '/vendor/autoload.php';
45

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

0 commit comments

Comments
 (0)