Skip to content

Commit f0a53b7

Browse files
authored
clean up php 8.4 and other changes (#156)
1 parent 9ba4ed0 commit f0a53b7

16 files changed

Lines changed: 230 additions & 183 deletions

CHANGELOG.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
### Added
11+
- Full PHP 8.4 compatibility and support
12+
- Explicit nullable parameter type declarations for better type safety
13+
14+
### Changed
15+
- Upgraded PHPUnit from ^9 to ^10.0 for better PHP 8.4 compatibility
16+
- Updated PHPDoc type annotations to match actual method signatures
17+
- Fixed all implicit nullable parameter deprecation warnings in PHP 8.4
18+
19+
### Fixed
20+
- Resolved 20+ PHP 8.4 deprecation warnings related to implicit nullable parameters
21+
- Fixed PHPStan static analysis issues with type mismatches
22+
- Corrected return type declaration for `processRestRequest()` method
23+
24+
### Technical Details
25+
- Updated `PostmarkAdminClient.php` - Fixed 15+ method parameters with explicit nullable types
26+
- Updated `PostmarkAttachment.php` - Fixed constructor and static method parameters
27+
- Updated `WebhookConfiguration.php` and `WebhookConfigurationTriggers.php` - Fixed nullable parameters
28+
- Updated various model classes with proper nullable type declarations
29+
- All tests pass on PHP 8.1, 8.2, 8.3, and 8.4
30+
- Zero deprecation warnings on PHP 8.4

README.md

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

55
With Postmark, you can send and _receive_ emails effortlessly.
66

7+
## Requirements
8+
9+
- PHP 8.1, 8.2, 8.3, or 8.4
10+
- Guzzle HTTP client
11+
12+
## Getting Started
13+
714
[Check out our wiki](https://github.com/ActiveCampaign/postmark-php/wiki/Getting-Started) to get started using Postmark-PHP now.
815

916
[![Build Status](https://circleci.com/gh/ActiveCampaign/postmark-php.svg?style=shield)](https://circleci.com/gh/ActiveCampaign/postmark-php)

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"guzzlehttp/guzzle": "^7.8"
1414
},
1515
"require-dev": {
16-
"phpunit/phpunit": "^9",
16+
"phpunit/phpunit": "^10.0",
1717
"phpstan/phpstan": "^1.10",
1818
"friendsofphp/php-cs-fixer": "^3.40"
1919
},

phpunit.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<testsuites>
1010
<testsuite name="unit">
1111
<directory>tests/</directory>
12+
<exclude>tests/PostmarkClientBaseTest.php</exclude>
1213
</testsuite>
1314
</testsuites>
1415

src/Postmark/Models/PostmarkAttachment.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,25 @@ class PostmarkAttachment implements JsonSerializable
1212
private $data;
1313
private $contentId;
1414

15-
private function __construct($base64EncodedData, $attachmentName, $mimeType = 'application/octet-stream', $contentId = null)
15+
private function __construct($base64EncodedData, $attachmentName, $mimeType = 'application/octet-stream', ?string $contentId = null)
1616
{
1717
$this->name = $attachmentName;
1818
$this->data = $base64EncodedData;
1919
$this->mimeType = $mimeType;
2020
$this->contentId = $contentId;
2121
}
2222

23-
public static function fromRawData($data, $attachmentName, $mimeType = null, $contentId = null)
23+
public static function fromRawData($data, $attachmentName, ?string $mimeType = null, ?string $contentId = null)
2424
{
2525
return new PostmarkAttachment(base64_encode($data), $attachmentName, $mimeType, $contentId);
2626
}
2727

28-
public static function fromBase64EncodedData($base64EncodedData, $attachmentName, $mimeType = null, $contentId = null)
28+
public static function fromBase64EncodedData($base64EncodedData, $attachmentName, ?string $mimeType = null, ?string $contentId = null)
2929
{
3030
return new PostmarkAttachment($base64EncodedData, $attachmentName, $mimeType, $contentId);
3131
}
3232

33-
public static function fromFile($filePath, $attachmentName, $mimeType = null, $contentId = null)
33+
public static function fromFile($filePath, $attachmentName, ?string $mimeType = null, ?string $contentId = null)
3434
{
3535
return new PostmarkAttachment(base64_encode(file_get_contents($filePath)), $attachmentName, $mimeType, $contentId);
3636
}

src/Postmark/Models/PostmarkClick.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,15 @@ public function setOS(mixed $OS): PostmarkClick
155155
}
156156

157157
/**
158-
* @return mixed|string
158+
* @return string
159159
*/
160160
public function getReceivedAt(): string
161161
{
162162
return $this->ReceivedAt;
163163
}
164164

165165
/**
166-
* @param mixed|string $ReceivedAt
166+
* @param string $ReceivedAt
167167
*/
168168
public function setReceivedAt(string $ReceivedAt): PostmarkClick
169169
{

src/Postmark/Models/PostmarkMessageBase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public function getMetadata(): array
179179
/**
180180
* @param ?array $Metadata
181181
*/
182-
public function setMetadata(array $Metadata = null): PostmarkMessageBase
182+
public function setMetadata(?array $Metadata = null): PostmarkMessageBase
183183
{
184184
$this->Metadata = $Metadata;
185185

src/Postmark/Models/Suppressions/SuppressionChangeRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class SuppressionChangeRequest implements JsonSerializable
1616
*
1717
* @param string $emailAddress address of the recipient whose suppression status should be changed
1818
*/
19-
public function __construct($emailAddress = null)
19+
public function __construct(?string $emailAddress = null)
2020
{
2121
$this->EmailAddress = $emailAddress;
2222
}

src/Postmark/Models/Webhooks/HttpAuth.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class HttpAuth implements JsonSerializable
1818
* @param string $username username to use
1919
* @param string $password password to use
2020
*/
21-
public function __construct($username = null, $password = null)
21+
public function __construct(?string $username = null, ?string $password = null)
2222
{
2323
$this->username = $username;
2424
$this->password = $password;

src/Postmark/Models/Webhooks/WebhookConfiguration.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ public function __construct()
5555

5656
public function Build(
5757
int $ID = 0,
58-
string $Url = null,
59-
string $MessageStream = null,
58+
?string $Url = null,
59+
?string $MessageStream = null,
6060
?HttpAuth $HttpAuth = null,
6161
array $HttpHeaders = [],
62-
WebhookConfigurationTriggers $Triggers = null
62+
?WebhookConfigurationTriggers $Triggers = null
6363
) {
6464
$this->ID = $ID;
6565
$this->Url = $Url;

0 commit comments

Comments
 (0)