Skip to content

Commit 6d80c20

Browse files
authored
Merge pull request #40 from FriendsOfCXML/php_8.4
Php 8.4
2 parents 14a7930 + 35297bd commit 6d80c20

32 files changed

+73
-66
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
php-version: [
2020
'8.2',
2121
'8.3',
22+
'8.4'
2223
]
2324

2425
steps:

rector.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Rector\Caching\ValueObject\Storage\FileCacheStorage;
66
use Rector\Config\RectorConfig;
7+
use Rector\Php84\Rector\Param\ExplicitNullableParamTypeRector;
78
use Rector\PHPUnit\Set\PHPUnitSetList;
89
use Rector\Set\ValueObject\SetList;
910
use Rector\Symfony\Set\JMSSetList;
@@ -13,9 +14,13 @@
1314
__DIR__ . '/src',
1415
__DIR__ . '/tests',
1516
])
17+
->withPhpVersion(Rector\ValueObject\PhpVersion::PHP_84) //need this to enable PHP 8.4 features although lower requirement in composer
18+
->withRules([
19+
ExplicitNullableParamTypeRector::class, // php8.4 feature, compatible with php8.0
20+
])
1621
->withSets([
1722
JMSSetList::ANNOTATIONS_TO_ATTRIBUTES,
18-
PHPUnitSetList::PHPUNIT_100,
23+
PHPUnitSetList::PHPUNIT_110,
1924
PHPUnitSetList::PHPUNIT_CODE_QUALITY,
2025
PHPUnitSetList::ANNOTATIONS_TO_ATTRIBUTES,
2126
SetList::TYPE_DECLARATION,
@@ -33,9 +38,10 @@
3338
\Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPromotedPropertyRector::class,
3439
//allow to use promoted properties that only purpose is to get serialized
3540
\Rector\DeadCode\Rector\ClassMethod\RemoveEmptyClassMethodRector::class,
36-
//this is stupid and makes code unreadable
41+
//this makes code unreadable
3742
\Rector\Strict\Rector\Ternary\BooleanInTernaryOperatorRuleFixerRector::class,
38-
\Rector\Strict\Rector\BooleanNot\BooleanInBooleanNotRuleFixerRector::class
43+
\Rector\Strict\Rector\BooleanNot\BooleanInBooleanNotRuleFixerRector::class,
44+
\Rector\Php81\Rector\Property\ReadOnlyPropertyRector::class,
3945
])
4046
->withFileExtensions(['php'])
4147
->withCache(

src/CXml/Builder.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,17 +123,17 @@ class Builder
123123

124124
private ?Status $status = null;
125125

126-
private function __construct(private ?string $senderUserAgent, private readonly ?string $locale = null, PayloadIdentityFactoryInterface $payloadIdentityFactory = null)
126+
private function __construct(private ?string $senderUserAgent, private readonly ?string $locale = null, ?PayloadIdentityFactoryInterface $payloadIdentityFactory = null)
127127
{
128128
$this->payloadIdentityFactory = $payloadIdentityFactory ?? new DefaultPayloadIdentityFactory();
129129
}
130130

131-
public static function create(string $senderUserAgent = 'cxml-php UserAgent', string $locale = null, PayloadIdentityFactoryInterface $payloadIdentityFactory = null): self
131+
public static function create(string $senderUserAgent = 'cxml-php UserAgent', ?string $locale = null, ?PayloadIdentityFactoryInterface $payloadIdentityFactory = null): self
132132
{
133133
return new self($senderUserAgent, $locale, $payloadIdentityFactory);
134134
}
135135

136-
public function payload(PayloadInterface $payload = null): self
136+
public function payload(?PayloadInterface $payload = null): self
137137
{
138138
$this->payload = $payload;
139139

@@ -199,7 +199,7 @@ private function buildHeader(): Header
199199
/**
200200
* @throws CXmlException
201201
*/
202-
public function build(string $deploymentMode = null): CXml
202+
public function build(?string $deploymentMode = null): CXml
203203
{
204204
switch (true) {
205205
case $this->payload instanceof RequestPayloadInterface:

src/CXml/Builder/OrderRequestBuilder.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ public static function create(
7878

7979
public static function fromPunchOutOrderMessage(
8080
PunchOutOrderMessage $punchOutOrderMessage,
81-
string $currency = null,
82-
string $orderId = null,
83-
DateTimeInterface $orderDate = null,
81+
?string $currency = null,
82+
?string $orderId = null,
83+
?DateTimeInterface $orderDate = null,
8484
string $language = 'en',
8585
): self {
8686
if (($supplierOrderInfo = $punchOutOrderMessage->getPunchOutOrderMessageHeader()->getSupplierOrderInfo()) instanceof SupplierOrderInfo) {
@@ -126,13 +126,13 @@ public static function fromPunchOutOrderMessage(
126126

127127
public function billTo(
128128
string $name,
129-
PostalAddress $postalAddress = null,
130-
string $addressId = null,
131-
string $addressIdDomain = null,
132-
string $email = null,
133-
Phone $phone = null,
134-
string $fax = null,
135-
string $url = null,
129+
?PostalAddress $postalAddress = null,
130+
?string $addressId = null,
131+
?string $addressIdDomain = null,
132+
?string $email = null,
133+
?Phone $phone = null,
134+
?string $fax = null,
135+
?string $url = null,
136136
): self {
137137
$this->billTo = new BillTo(
138138
new Address(
@@ -154,8 +154,8 @@ public function shipTo(
154154
string $name,
155155
PostalAddress $postalAddress,
156156
array $carrierIdentifiers = [],
157-
string $carrierAccountNo = null,
158-
string $carrierShippingMethod = null,
157+
?string $carrierAccountNo = null,
158+
?string $carrierShippingMethod = null,
159159
): self {
160160
$transportInformation = null;
161161
if (null !== $carrierAccountNo || null != $carrierShippingMethod) {
@@ -263,7 +263,7 @@ public function addItem(
263263
return $item;
264264
}
265265

266-
public function addComment(string $value = null, string $type = null, string $lang = null, string $attachmentUrl = null): self
266+
public function addComment(?string $value = null, ?string $type = null, ?string $lang = null, ?string $attachmentUrl = null): self
267267
{
268268
$this->comments[] = new Comment(
269269
$value,

src/CXml/Builder/ProductActivityMessageBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public static function create(string $messageId, string $warehouseCodeDomain): s
2929
return new self($messageId, $warehouseCodeDomain);
3030
}
3131

32-
public function addProductActivityDetail(string $sku, string $warehouseCode, int $stockLevel, array $extrinsics = null): self
32+
public function addProductActivityDetail(string $sku, string $warehouseCode, int $stockLevel, ?array $extrinsics = null): self
3333
{
3434
$inventory = Inventory::create()
3535
->setStockOnHandQuantity(new InventoryQuantity($stockLevel, 'EA'));

src/CXml/Builder/PunchOutOrderMessageBuilder.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ private function __construct(private readonly string $language, private readonly
4747
{
4848
}
4949

50-
public static function create(string $language, string $buyerCookie, string $currency, string $operationAllowed = null): self
50+
public static function create(string $language, string $buyerCookie, string $currency, ?string $operationAllowed = null): self
5151
{
5252
return new self($language, $buyerCookie, $currency, $operationAllowed);
5353
}
5454

55-
public function orderReference(string $orderId, DateTimeInterface $orderDate = null): self
55+
public function orderReference(string $orderId, ?DateTimeInterface $orderDate = null): self
5656
{
5757
$this->orderId = $orderId;
5858
$this->orderDate = $orderDate;
@@ -64,8 +64,8 @@ public function shipTo(
6464
string $name,
6565
PostalAddress $postalAddress,
6666
array $carrierIdentifiers = [],
67-
string $carrierAccountNo = null,
68-
string $carrierShippingMethod = null,
67+
?string $carrierAccountNo = null,
68+
?string $carrierShippingMethod = null,
6969
): self {
7070
$transportInformation = null;
7171
if (null !== $carrierAccountNo || null != $carrierShippingMethod) {
@@ -124,10 +124,10 @@ public function addPunchoutOrderMessageItem(
124124
string $unitOfMeasure,
125125
int $unitPrice,
126126
array $classifications,
127-
string $manufacturerPartId = null,
128-
string $manufacturerName = null,
129-
int $leadTime = null,
130-
array $extrinsics = null,
127+
?string $manufacturerPartId = null,
128+
?string $manufacturerName = null,
129+
?int $leadTime = null,
130+
?array $extrinsics = null,
131131
): self {
132132
$itemDetail = ItemDetail::create(
133133
new Description(

src/CXml/Endpoint.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function __construct(
2121
private Serializer $serializer,
2222
private DtdValidator $dtdValidator,
2323
private Processor $processor,
24-
LoggerInterface $logger = null,
24+
?LoggerInterface $logger = null,
2525
) {
2626
$this->logger = $logger ?? new NullLogger();
2727
}
@@ -30,7 +30,7 @@ public function __construct(
3030
* @throws CXmlException
3131
* @throws CXmlInvalidException
3232
*/
33-
public function parseAndProcessStringAsCXml(string $xml, Context $context = null): ?CXml
33+
public function parseAndProcessStringAsCXml(string $xml, ?Context $context = null): ?CXml
3434
{
3535
$this->logger->info('Processing incoming CXml message', ['xml' => $xml]);
3636

src/CXml/Exception/CXmlCredentialInvalidException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class CXmlCredentialInvalidException extends CXmlExpectationFailedException
1111
{
12-
public function __construct(string $message, private readonly ?Credential $credential = null, Throwable $previous = null)
12+
public function __construct(string $message, private readonly ?Credential $credential = null, ?Throwable $previous = null)
1313
{
1414
parent::__construct($message . ($credential instanceof Credential ? "\nCredential was:" . $credential : ''), $previous);
1515
}

src/CXml/Exception/CXmlException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class CXmlException extends Exception
1111
{
12-
public function __construct(string $message, Throwable $previous = null)
12+
public function __construct(string $message, ?Throwable $previous = null)
1313
{
1414
parent::__construct($message, 0, $previous);
1515
}

src/CXml/Handler/Exception/CXmlHandlerNotFoundException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
class CXmlHandlerNotFoundException extends CXmlNotImplementedException
1313
{
14-
public function __construct(string $handlerId, Throwable $previous = null)
14+
public function __construct(string $handlerId, ?Throwable $previous = null)
1515
{
1616
parent::__construct(sprintf('Handler for %s not found. Register first.', $handlerId), $previous);
1717
}

0 commit comments

Comments
 (0)