Skip to content

Commit 0af6b24

Browse files
authored
Merge pull request #41 from freddiegar/feature/fix-deprecations-in-php8.3
Feature/fix deprecations in PHP 8.2
2 parents 6899fb0 + 1332425 commit 0af6b24

File tree

7 files changed

+163
-12
lines changed

7 files changed

+163
-12
lines changed

.github/workflows/.ci-php.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ jobs:
1111
- "8.0"
1212
- "8.1"
1313
- "8.2"
14+
- "8.3"
15+
- "8.4"
1416
dependency-versions:
1517
- "lowest"
1618
- "highest"

.php-cs-fixer.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@
1414
'blank_line_before_statement' => [
1515
'statements' => ['declare'],
1616
],
17-
'braces' => true,
17+
'single_space_around_construct' => true,
18+
'control_structure_braces' => true,
19+
'control_structure_continuation_position' => true,
20+
'declare_parentheses' => true,
21+
'no_multiple_statements_per_line' => true,
22+
'braces_position' => true,
23+
'statement_indentation' => true,
24+
'no_extra_blank_lines' => true,
1825
'cast_spaces' => [
1926
'space' => 'none',
2027
],
@@ -27,7 +34,7 @@
2734
'encoding' => true,
2835
'full_opening_tag' => true,
2936
'function_declaration' => true,
30-
'function_typehint_space' => true,
37+
'type_declaration_spaces' => true,
3138
'single_line_comment_style' => [
3239
'comment_types' => ['hash'],
3340
],
@@ -59,8 +66,8 @@
5966
'no_singleline_whitespace_before_semicolons' => true,
6067
'no_spaces_after_function_name' => true,
6168
'no_spaces_around_offset' => true,
62-
'no_spaces_inside_parenthesis' => true,
63-
'no_trailing_comma_in_list_call' => true,
69+
'spaces_inside_parentheses' => false,
70+
'no_trailing_comma_in_singleline' => true,
6471
'no_trailing_whitespace' => true,
6572
'no_trailing_whitespace_in_comment' => true,
6673
'no_unneeded_control_parentheses' => true,
@@ -109,8 +116,7 @@
109116
'logical_operators' => true,
110117
'short_scalar_cast' => true,
111118
'no_unset_cast' => true,
112-
'no_trailing_comma_in_singleline_array' => true,
113-
'single_blank_line_before_namespace' => true,
119+
'blank_lines_before_namespace' => true,
114120
];
115121

116122
$finder = Finder::create()

phpunit.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,9 @@
1414
<directory suffix="Test.php">./tests</directory>
1515
</testsuite>
1616
</testsuites>
17+
<php>
18+
<ini name="error_reporting" value="-1"/>
19+
<server name="PHPUNIT_ERROR_HANDLER" value="PHPUnit\Util\ErrorHandler::handleDeprecation"/>
20+
</php>
1721
<logging/>
1822
</phpunit>

src/Entities/Amount.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,23 @@ class Amount extends AmountBase
1313
*/
1414
protected array $details = [];
1515

16-
protected $tip;
17-
protected $insurance;
16+
/**
17+
* Details Available:
18+
* @var float
19+
* @see https://docs.placetopay.dev/checkout/tax-details#amount-details
20+
*/
21+
protected float $discount;
22+
protected float $additional;
23+
protected float $vatDevolutionBase;
24+
protected float $shipping;
25+
protected float $handlingFee;
26+
protected float $insurance;
27+
protected float $giftWrap;
28+
protected float $subtotal;
29+
protected float $fee;
30+
protected float $tip;
31+
protected float $airline;
32+
protected float $interest;
1833

1934
public function __construct($data = [])
2035
{

tests/Entities/AmountTest.php

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
<?php
2+
3+
namespace Tests\Entities;
4+
5+
use Dnetix\Redirection\Entities\Amount;
6+
use Tests\BaseTestCase;
7+
8+
class AmountTest extends BaseTestCase
9+
{
10+
public function testItWorksWithTaxes()
11+
{
12+
$amount = new Amount([
13+
'taxes' => $taxes = [
14+
[
15+
'kind' => 'valueAddedTax',
16+
'amount' => 100,
17+
'base' => 10,
18+
],
19+
[
20+
'kind' => 'exciseDuty',
21+
'amount' => 200,
22+
'base' => 20,
23+
],
24+
[
25+
'kind' => 'ice',
26+
'amount' => 300,
27+
'base' => 30,
28+
],
29+
[
30+
'kind' => 'airportTax',
31+
'amount' => 400,
32+
'base' => 40,
33+
],
34+
[
35+
'kind' => 'stateTax',
36+
'amount' => 500,
37+
'base' => 50,
38+
],
39+
[
40+
'kind' => 'municipalTax',
41+
'amount' => 600,
42+
'base' => 60,
43+
],
44+
[
45+
'kind' => 'reducedStateTax',
46+
'amount' => 700,
47+
'base' => 70,
48+
],
49+
],
50+
]);
51+
52+
$this->assertCount(7, $amount->taxes());
53+
54+
foreach ($taxes as $i => $tax) {
55+
$this->assertInstanceOf('Dnetix\Redirection\Entities\TaxDetail', $amount->taxes()[$i]);
56+
$this->assertSame($tax['kind'], $amount->taxes()[$i]->kind());
57+
$this->assertSame((float)$tax['amount'], $amount->taxes()[$i]->amount());
58+
$this->assertSame((float)$tax['base'], $amount->taxes()[$i]->base());
59+
}
60+
}
61+
62+
public function testItWorksWithDetails()
63+
{
64+
$amount = new Amount([
65+
'details' => $details = [
66+
[
67+
'kind' => 'discount',
68+
'amount' => 10,
69+
],
70+
[
71+
'kind' => 'additional',
72+
'amount' => 20,
73+
],
74+
[
75+
'kind' => 'vatDevolutionBase',
76+
'amount' => 30,
77+
],
78+
[
79+
'kind' => 'shipping',
80+
'amount' => 40,
81+
],
82+
[
83+
'kind' => 'handlingFee',
84+
'amount' => 50,
85+
],
86+
[
87+
'kind' => 'insurance',
88+
'amount' => 60,
89+
],
90+
[
91+
'kind' => 'giftWrap',
92+
'amount' => 70,
93+
],
94+
[
95+
'kind' => 'subtotal',
96+
'amount' => 80,
97+
],
98+
[
99+
'kind' => 'fee',
100+
'amount' => 90,
101+
],
102+
[
103+
'kind' => 'tip',
104+
'amount' => 100,
105+
],
106+
[
107+
'kind' => 'airline',
108+
'amount' => 110,
109+
],
110+
[
111+
'kind' => 'interest',
112+
'amount' => 120,
113+
],
114+
],
115+
]);
116+
117+
$this->assertCount(12, $amount->details());
118+
119+
foreach ($details as $i => $detail) {
120+
$this->assertInstanceOf('Dnetix\Redirection\Entities\AmountDetail', $amount->details()[$i]);
121+
$this->assertSame($detail['kind'], $amount->details()[$i]->kind());
122+
$this->assertSame((float)$detail['amount'], $amount->details()[$i]->amount());
123+
}
124+
}
125+
}

tests/Messages/CollectRequestTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ public function testItParsesCorrectlyACollectWithCredit()
4545
'noBuyerFill' => false,
4646
'provider' => 'PROVIDER',
4747
'metadata' => [
48-
"initiatorIndicator" => "AGENT"
49-
]
48+
'initiatorIndicator' => 'AGENT',
49+
],
5050
];
5151
$request = new CollectRequest($data);
5252

@@ -59,6 +59,5 @@ public function testItParsesCorrectlyACollectWithCredit()
5959
$this->assertEquals($data, $request->toArray());
6060
$this->assertEquals($data['metadata'], $request->metadata());
6161
$this->assertEquals($data['provider'], $request->provider());
62-
6362
}
6463
}

tests/Messages/RedirectRequestTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function testItParsesCorrectlyAPaymentRequest()
104104
'captureAddress' => true,
105105
'paymentMethod' => 'CR_VS,_ATH_',
106106
'metadata' => [
107-
"initiatorIndicator" => "AGENT"
107+
'initiatorIndicator' => 'AGENT',
108108
],
109109
];
110110
$request = new RedirectRequest($data);

0 commit comments

Comments
 (0)