Skip to content
Merged
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
1 change: 0 additions & 1 deletion .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,4 @@ jobs:
# Run PHPStan for static analysis.
- name: Run PHPStan Static Analysis
working-directory: ${{ env.PLUGIN_DIR }}
if: ${{ contains('8.0 8.1 8.2 8.3 8.4', matrix.php-versions) }}
run: php vendor/bin/phpstan analyse --memory-limit=1250M
8 changes: 5 additions & 3 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ includes:

# Parameters
parameters:
# Analyse against the minimum supported PHP version.
# This flags features (union types, enums, str_contains, etc.) that would
# fail on older PHP versions regardless of which PHP version PHPStan runs on.
phpVersion: 70100

# Paths to scan
paths:
- src/

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

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

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

# Don't report unmatched ignored errors on older PHP versions (7.2, 7.3)
Expand Down
58 changes: 29 additions & 29 deletions src/class-convertkit-api-traits.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* @author ConvertKit
*/

namespace ConvertKit_API;

/**
* ConvertKit API Traits
*/
Expand Down Expand Up @@ -144,7 +142,7 @@ public function get_email_stats()
*
* @return false|mixed
*/
public function get_growth_stats(\DateTime|null $starting = null, \DateTime|null $ending = null)
public function get_growth_stats(?\DateTime $starting = null, ?\DateTime $ending = null)
{
return $this->get(
'account/growth_stats',
Expand Down Expand Up @@ -344,10 +342,10 @@ public function add_subscriber_to_legacy_form(int $form_id, int $subscriber_id)
public function get_form_subscriptions(
int $form_id,
string $subscriber_state = 'active',
\DateTime|null $created_after = null,
\DateTime|null $created_before = null,
\DateTime|null $added_after = null,
\DateTime|null $added_before = null,
?\DateTime $created_after = null,
?\DateTime $created_before = null,
?\DateTime $added_after = null,
?\DateTime $added_before = null,
bool $include_total_count = false,
string $after_cursor = '',
string $before_cursor = '',
Expand Down Expand Up @@ -471,10 +469,10 @@ public function add_subscriber_to_sequence(int $sequence_id, int $subscriber_id)
public function get_sequence_subscriptions(
int $sequence_id,
string $subscriber_state = 'active',
\DateTime|null $created_after = null,
\DateTime|null $created_before = null,
\DateTime|null $added_after = null,
\DateTime|null $added_before = null,
?\DateTime $created_after = null,
?\DateTime $created_before = null,
?\DateTime $added_after = null,
?\DateTime $added_before = null,
bool $include_total_count = false,
string $after_cursor = '',
string $before_cursor = '',
Expand Down Expand Up @@ -737,10 +735,10 @@ public function remove_tag_from_subscriber_by_email(int $tag_id, string $email_a
public function get_tag_subscriptions(
int $tag_id,
string $subscriber_state = 'active',
\DateTime|null $created_after = null,
\DateTime|null $created_before = null,
\DateTime|null $tagged_after = null,
\DateTime|null $tagged_before = null,
?\DateTime $created_after = null,
?\DateTime $created_before = null,
?\DateTime $tagged_after = null,
?\DateTime $tagged_before = null,
bool $include_total_count = false,
string $after_cursor = '',
string $before_cursor = '',
Expand Down Expand Up @@ -836,10 +834,10 @@ public function get_email_templates(
public function get_subscribers(
string $subscriber_state = 'active',
string $email_address = '',
\DateTime|null $created_after = null,
\DateTime|null $created_before = null,
\DateTime|null $updated_after = null,
\DateTime|null $updated_before = null,
?\DateTime $created_after = null,
?\DateTime $created_before = null,
?\DateTime $updated_after = null,
?\DateTime $updated_before = null,
string $sort_field = 'id',
string $sort_order = 'desc',
bool $include_total_count = false,
Expand Down Expand Up @@ -1265,8 +1263,8 @@ public function create_broadcast(
string $content = '',
string $description = '',
bool $public = false,
\DateTime|null $published_at = null,
\DateTime|null $send_at = null,
?\DateTime $published_at = null,
?\DateTime $send_at = null,
string $email_address = '',
string $email_template_id = '',
string $thumbnail_alt = '',
Expand Down Expand Up @@ -1362,9 +1360,11 @@ public function get_broadcast_link_clicks(
return $this->get(
sprintf('broadcasts/%s/clicks', $id),
$this->build_total_count_and_pagination_params(
after_cursor: $after_cursor,
before_cursor: $before_cursor,
per_page: $per_page
[],
false,
$after_cursor,
$before_cursor,
$per_page
)
);
}
Expand Down Expand Up @@ -1437,8 +1437,8 @@ public function update_broadcast(
string $content = '',
string $description = '',
bool $public = false,
\DateTime|null $published_at = null,
\DateTime|null $send_at = null,
?\DateTime $published_at = null,
?\DateTime $send_at = null,
string $email_address = '',
string $email_template_id = '',
string $thumbnail_alt = '',
Expand Down Expand Up @@ -1841,14 +1841,14 @@ public function create_purchase(
string $transaction_id,
array $products,
string $currency = 'USD',
string|null $first_name = null,
string|null $status = null,
?string $first_name = null,
?string $status = null,
float $subtotal = 0,
float $tax = 0,
float $shipping = 0,
float $discount = 0,
float $total = 0,
\DateTime|null $transaction_time = null
?\DateTime $transaction_time = null
) {
// Build parameters.
$options = [
Expand Down
2 changes: 1 addition & 1 deletion src/class-convertkit-api-v4.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
class ConvertKit_API_V4 {

use ConvertKit_API\ConvertKit_API_Traits;
use ConvertKit_API_Traits;

/**
* The SDK version.
Expand Down
2 changes: 1 addition & 1 deletion src/class-convertkit-resource-v4.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class ConvertKit_Resource_V4 {
*
* @var WP_Error|array|bool|null
*/
public $resources = array();
public $resources;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is required for PHPStan static analysis to pass for PHP < 8.0, given the docblock comment supports different types.


/**
* The key to use when alphabetically sorting resources.
Expand Down
Loading