Skip to content

Commit 05ec057

Browse files
authored
Merge pull request #114 from Kit/backport-php-7.4-support
Backport PHP 7.1+ Support
2 parents e83a09e + a6d87eb commit 05ec057

5 files changed

Lines changed: 36 additions & 35 deletions

File tree

.github/workflows/coding-standards.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,5 +130,4 @@ jobs:
130130
# Run PHPStan for static analysis.
131131
- name: Run PHPStan Static Analysis
132132
working-directory: ${{ env.PLUGIN_DIR }}
133-
if: ${{ contains('8.0 8.1 8.2 8.3 8.4', matrix.php-versions) }}
134133
run: php vendor/bin/phpstan analyse --memory-limit=1250M

phpstan.neon.dist

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@ includes:
66

77
# Parameters
88
parameters:
9+
# Analyse against the minimum supported PHP version.
10+
# This flags features (union types, enums, str_contains, etc.) that would
11+
# fail on older PHP versions regardless of which PHP version PHPStan runs on.
12+
phpVersion: 70100
13+
914
# Paths to scan
1015
paths:
1116
- src/
1217

1318
# Paths to exclude
14-
# API Traits are excluded as they are statically analysed in the Kit PHP SDK
1519
excludePaths:
16-
- src/class-convertkit-api-traits.php
1720
- src/views/
1821

1922
# Location of WordPress Plugins for PHPStan to scan, building symbols.
@@ -22,7 +25,6 @@ parameters:
2225

2326
# Location of constants for PHPStan to scan, building symbols.
2427
scanFiles:
25-
- src/class-convertkit-api-traits.php
2628
- /home/runner/work/convertkit-wordpress-libraries/convertkit-wordpress-libraries/wordpress/wp-config.php
2729

2830
# Don't report unmatched ignored errors on older PHP versions (7.2, 7.3)

src/class-convertkit-api-traits.php

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
* @author ConvertKit
66
*/
77

8-
namespace ConvertKit_API;
9-
108
/**
119
* ConvertKit API Traits
1210
*/
@@ -144,7 +142,7 @@ public function get_email_stats()
144142
*
145143
* @return false|mixed
146144
*/
147-
public function get_growth_stats(\DateTime|null $starting = null, \DateTime|null $ending = null)
145+
public function get_growth_stats(?\DateTime $starting = null, ?\DateTime $ending = null)
148146
{
149147
return $this->get(
150148
'account/growth_stats',
@@ -344,10 +342,10 @@ public function add_subscriber_to_legacy_form(int $form_id, int $subscriber_id)
344342
public function get_form_subscriptions(
345343
int $form_id,
346344
string $subscriber_state = 'active',
347-
\DateTime|null $created_after = null,
348-
\DateTime|null $created_before = null,
349-
\DateTime|null $added_after = null,
350-
\DateTime|null $added_before = null,
345+
?\DateTime $created_after = null,
346+
?\DateTime $created_before = null,
347+
?\DateTime $added_after = null,
348+
?\DateTime $added_before = null,
351349
bool $include_total_count = false,
352350
string $after_cursor = '',
353351
string $before_cursor = '',
@@ -471,10 +469,10 @@ public function add_subscriber_to_sequence(int $sequence_id, int $subscriber_id)
471469
public function get_sequence_subscriptions(
472470
int $sequence_id,
473471
string $subscriber_state = 'active',
474-
\DateTime|null $created_after = null,
475-
\DateTime|null $created_before = null,
476-
\DateTime|null $added_after = null,
477-
\DateTime|null $added_before = null,
472+
?\DateTime $created_after = null,
473+
?\DateTime $created_before = null,
474+
?\DateTime $added_after = null,
475+
?\DateTime $added_before = null,
478476
bool $include_total_count = false,
479477
string $after_cursor = '',
480478
string $before_cursor = '',
@@ -737,10 +735,10 @@ public function remove_tag_from_subscriber_by_email(int $tag_id, string $email_a
737735
public function get_tag_subscriptions(
738736
int $tag_id,
739737
string $subscriber_state = 'active',
740-
\DateTime|null $created_after = null,
741-
\DateTime|null $created_before = null,
742-
\DateTime|null $tagged_after = null,
743-
\DateTime|null $tagged_before = null,
738+
?\DateTime $created_after = null,
739+
?\DateTime $created_before = null,
740+
?\DateTime $tagged_after = null,
741+
?\DateTime $tagged_before = null,
744742
bool $include_total_count = false,
745743
string $after_cursor = '',
746744
string $before_cursor = '',
@@ -836,10 +834,10 @@ public function get_email_templates(
836834
public function get_subscribers(
837835
string $subscriber_state = 'active',
838836
string $email_address = '',
839-
\DateTime|null $created_after = null,
840-
\DateTime|null $created_before = null,
841-
\DateTime|null $updated_after = null,
842-
\DateTime|null $updated_before = null,
837+
?\DateTime $created_after = null,
838+
?\DateTime $created_before = null,
839+
?\DateTime $updated_after = null,
840+
?\DateTime $updated_before = null,
843841
string $sort_field = 'id',
844842
string $sort_order = 'desc',
845843
bool $include_total_count = false,
@@ -1265,8 +1263,8 @@ public function create_broadcast(
12651263
string $content = '',
12661264
string $description = '',
12671265
bool $public = false,
1268-
\DateTime|null $published_at = null,
1269-
\DateTime|null $send_at = null,
1266+
?\DateTime $published_at = null,
1267+
?\DateTime $send_at = null,
12701268
string $email_address = '',
12711269
string $email_template_id = '',
12721270
string $thumbnail_alt = '',
@@ -1362,9 +1360,11 @@ public function get_broadcast_link_clicks(
13621360
return $this->get(
13631361
sprintf('broadcasts/%s/clicks', $id),
13641362
$this->build_total_count_and_pagination_params(
1365-
after_cursor: $after_cursor,
1366-
before_cursor: $before_cursor,
1367-
per_page: $per_page
1363+
[],
1364+
false,
1365+
$after_cursor,
1366+
$before_cursor,
1367+
$per_page
13681368
)
13691369
);
13701370
}
@@ -1437,8 +1437,8 @@ public function update_broadcast(
14371437
string $content = '',
14381438
string $description = '',
14391439
bool $public = false,
1440-
\DateTime|null $published_at = null,
1441-
\DateTime|null $send_at = null,
1440+
?\DateTime $published_at = null,
1441+
?\DateTime $send_at = null,
14421442
string $email_address = '',
14431443
string $email_template_id = '',
14441444
string $thumbnail_alt = '',
@@ -1841,14 +1841,14 @@ public function create_purchase(
18411841
string $transaction_id,
18421842
array $products,
18431843
string $currency = 'USD',
1844-
string|null $first_name = null,
1845-
string|null $status = null,
1844+
?string $first_name = null,
1845+
?string $status = null,
18461846
float $subtotal = 0,
18471847
float $tax = 0,
18481848
float $shipping = 0,
18491849
float $discount = 0,
18501850
float $total = 0,
1851-
\DateTime|null $transaction_time = null
1851+
?\DateTime $transaction_time = null
18521852
) {
18531853
// Build parameters.
18541854
$options = [

src/class-convertkit-api-v4.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515
class ConvertKit_API_V4 {
1616

17-
use ConvertKit_API\ConvertKit_API_Traits;
17+
use ConvertKit_API_Traits;
1818

1919
/**
2020
* The SDK version.

src/class-convertkit-resource-v4.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class ConvertKit_Resource_V4 {
5959
*
6060
* @var WP_Error|array|bool|null
6161
*/
62-
public $resources = array();
62+
public $resources;
6363

6464
/**
6565
* The key to use when alphabetically sorting resources.

0 commit comments

Comments
 (0)