Skip to content

Commit

Permalink
Explicitly declare nullable tyhpes
Browse files Browse the repository at this point in the history
  • Loading branch information
xPaw committed Jan 2, 2025
1 parent 2d3f198 commit 8709104
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 26 deletions.
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

0 comments on commit 8709104

Please sign in to comment.