Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicitly declare nullable types to fix deprecation in PHP 8.4 #269

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-versions: ['7.0', '7.1', '7.2', '7.3', '7.4']
php-versions: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-versions: ['7.0', '7.1', '7.2', '7.3', '7.4']
php-versions: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']

steps:
- uses: actions/checkout@v2
Expand Down
1 change: 1 addition & 0 deletions .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ return PhpCsFixer\Config::create()
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'nullable_type_declaration_for_default_null_value' => true,
])
->setFinder($finder)
;
2 changes: 1 addition & 1 deletion src/Adapter/Guzzle.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Guzzle implements Adapter
/**
* @inheritDoc
*/
public function __construct(Auth $auth, string $baseURI = null)
public function __construct(Auth $auth, ?string $baseURI = null)
{
if ($baseURI === null) {
$baseURI = 'https://api.cloudflare.com/client/v4/';
Expand Down
4 changes: 2 additions & 2 deletions src/Endpoints/AccessRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function createRule(
string $zoneID,
string $mode,
Configurations $configuration,
string $notes = null
?string $notes = null
): bool {
$options = [
'mode' => $mode,
Expand All @@ -116,7 +116,7 @@ public function updateRule(
string $zoneID,
string $ruleID,
string $mode,
string $notes = null
?string $notes = null
): bool {
$options = [
'mode' => $mode
Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/CustomHostnames.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public function updateHostname(
string $sslType = '',
array $sslSettings = [],
string $customOriginServer = '',
bool $wildcard = null,
?bool $wildcard = null,
string $bundleMethod = '',
array $customSsl = []
): \stdClass {
Expand Down
8 changes: 4 additions & 4 deletions src/Endpoints/Firewall.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public function createFirewallRule(
string $zoneID,
string $expression,
FirewallRuleOptions $options,
string $description = null,
int $priority = null
?string $description = null,
?int $priority = null
): bool {
$rule = array_merge([
'filter' => [
Expand Down Expand Up @@ -92,8 +92,8 @@ public function updateFirewallRule(
string $filterID,
string $expression,
FirewallRuleOptions $options,
string $description = null,
int $priority = null
?string $description = null,
?int $priority = null
): \stdClass {
$rule = array_merge([
'id' => $ruleID,
Expand Down
22 changes: 11 additions & 11 deletions src/Endpoints/PageRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function createPageRule(
PageRulesTargets $target,
PageRulesActions $actions,
bool $active = true,
int $priority = null
?int $priority = null
): bool {
$options = [
'targets' => $target->getArray(),
Expand Down Expand Up @@ -68,10 +68,10 @@ public function createPageRule(

public function listPageRules(
string $zoneID,
string $status = null,
string $order = null,
string $direction = null,
string $match = null
?string $status = null,
?string $order = null,
?string $direction = null,
?string $match = null
): array {
if ($status != null && !in_array($status, ['active', 'disabled'])) {
throw new EndpointException('Page Rules can only be listed by status of active or disabled.');
Expand Down Expand Up @@ -114,8 +114,8 @@ public function editPageRule(
string $ruleID,
PageRulesTargets $target,
PageRulesActions $actions,
bool $active = null,
int $priority = null
?bool $active = null,
?int $priority = null
): bool {
$options = [];
$options['targets'] = $target->getArray();
Expand Down Expand Up @@ -143,10 +143,10 @@ public function editPageRule(
public function updatePageRule(
string $zoneID,
string $ruleID,
PageRulesTargets $target = null,
PageRulesActions $actions = null,
bool $active = null,
int $priority = null
?PageRulesTargets $target = null,
?PageRulesActions $actions = null,
?bool $active = null,
?int $priority = null
): bool {
$options = [];

Expand Down
6 changes: 3 additions & 3 deletions src/Endpoints/UARules.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public function createRule(
string $zoneID,
string $mode,
Configurations $configuration,
string $ruleID = null,
string $description = null
?string $ruleID = null,
?string $description = null
): bool {
$options = [
'mode' => $mode,
Expand Down Expand Up @@ -82,7 +82,7 @@ public function updateRule(
string $ruleID,
string $mode,
\Cloudflare\API\Configurations\UARules $configuration,
string $description = null
?string $description = null
): bool {
$options = [
'mode' => $mode,
Expand Down
6 changes: 3 additions & 3 deletions src/Endpoints/ZoneLockdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public function createLockdown(
string $zoneID,
array $urls,
\Cloudflare\API\Configurations\ZoneLockdown $configuration,
string $lockdownID = null,
string $description = null
?string $lockdownID = null,
?string $description = null
): bool {
$options = [
'urls' => $urls,
Expand Down Expand Up @@ -81,7 +81,7 @@ public function updateLockdown(
string $lockdownID,
array $urls,
\Cloudflare\API\Configurations\ZoneLockdown $configuration,
string $description = null
?string $description = null
): bool {
$options = [
'urls' => $urls,
Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/Zones.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public function cachePurgeEverything(string $zoneID, bool $includeEnvironments =
/**
* @SuppressWarnings(PHPMD)
*/
public function cachePurge(string $zoneID, array $files = null, array $tags = null, array $hosts = null, bool $includeEnvironments = false): bool
public function cachePurge(string $zoneID, ?array $files = null, ?array $tags = null, ?array $hosts = null, bool $includeEnvironments = false): bool
{
if ($files === null && $tags === null && $hosts === null) {
throw new EndpointException('No files, tags or hosts to purge.');
Expand Down