Skip to content

Commit 07db56c

Browse files
committed
PHPStan compat.
1 parent 9ce8350 commit 07db56c

File tree

2 files changed

+40
-38
lines changed

2 files changed

+40
-38
lines changed

src/ConvertKit_API.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,13 +348,13 @@ public function get_resource(string $url)
348348
/**
349349
* Performs an API request using Guzzle.
350350
*
351-
* @param string $endpoint API Endpoint.
352-
* @param string $method Request method.
353-
* @param array<string, bool|integer|float|string|null|array<int|string, float|integer|string|array<string|string>>> $args Request arguments.
351+
* @param string $endpoint API Endpoint.
352+
* @param string $method Request method.
353+
* @param array<string, bool|integer|float|string|null|array<int|string, bool|integer|float|string|array<mixed>>> $args Request arguments.
354354
*
355355
* @throws \Exception If JSON encoding arguments failed.
356356
*
357-
* @return mixed|object
357+
* @return false|mixed
358358
*/
359359
public function request(string $endpoint, string $method, array $args = [])
360360
{

src/ConvertKit_API_Traits.php

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -948,17 +948,17 @@ public function create_subscribers(array $subscribers, string $callback_url = ''
948948
/**
949949
* Filter subscribers based on engagement.
950950
*
951-
* @param array<array<string,string|integer|null>> $all Array of filter conditions where ALL must be met (AND logic)
952-
* - 'type' (string) Type of filter condition ('opens', 'clicks', 'sent', 'delivered', 'subscribed').
953-
* - 'count_greater_than' (int) Minimum count (exclusive). Not applicable for 'subscribed' type.
954-
* - 'count_less_than' (int) Maximum count (exclusive). Not applicable for 'subscribed' type.
955-
* - 'after' (\DateTime|null) Start date. For 'subscribed' type, filters by subscriber_created_at. For other types, filters by event date.
956-
* - 'before' (\DateTime|null) End date. For 'subscribed' type, filters by subscriber_created_at. For other types, filters by event date.
957-
* - 'any' (array) Array of OR conditions for filtering by specific broadcasts or URLs.
958-
* @param boolean $include_total_count To include the total count of records in the response, use true.
959-
* @param string $after_cursor Return results after the given pagination cursor.
960-
* @param string $before_cursor Return results before the given pagination cursor.
961-
* @param integer $per_page Number of results to return.
951+
* @param array<int, array<string, mixed>> $all Array of filter conditions where ALL must be met (AND logic). Each condition can have.
952+
* - 'type' (string).
953+
* - 'count_greater_than' (int|null).
954+
* - 'count_less_than' (int|null).
955+
* - 'after' (\DateTime|null).
956+
* - 'before' (\DateTime|null).
957+
* - 'any' (array<int|string, mixed>|null).
958+
* @param boolean $include_total_count To include the total count of records in the response, use true.
959+
* @param string $after_cursor Return results after the given pagination cursor.
960+
* @param string $before_cursor Return results before the given pagination cursor.
961+
* @param integer $per_page Number of results to return.
962962
*
963963
* @since 2.4.0
964964
*
@@ -973,32 +973,34 @@ public function filter_subscribers(
973973
string $before_cursor = '',
974974
int $per_page = 100
975975
) {
976-
// Build parameters.
977976
$options = [];
978977

979978
foreach ($all as $condition) {
980979
$option = [];
981-
if (!is_null($condition['count_greater_than'])) {
982-
$option['count_greater_than'] = (int) $condition['count_greater_than'];
980+
981+
if (array_key_exists('count_greater_than', $condition) && $condition['count_greater_than'] !== null) {
982+
$option['count_greater_than'] = $condition['count_greater_than'];
983983
}
984-
if (!is_null($condition['count_less_than'])) {
985-
$option['count_less_than'] = (int) $condition['count_less_than'];
984+
985+
if (array_key_exists('count_less_than', $condition) && $condition['count_less_than'] !== null) {
986+
$option['count_less_than'] = $condition['count_less_than'];
986987
}
987-
if (!is_null($condition['after'])) {
988+
989+
if (array_key_exists('after', $condition) && $condition['after'] instanceof \DateTime) {
988990
$option['after'] = $condition['after']->format('Y-m-d');
989991
}
990-
if (!is_null($condition['before'])) {
992+
993+
if (array_key_exists('before', $condition) && $condition['before'] instanceof \DateTime) {
991994
$option['before'] = $condition['before']->format('Y-m-d');
992995
}
993-
if (!empty($condition['any'])) {
996+
997+
if (array_key_exists('any', $condition) && !empty($condition['any'])) {
994998
$option['any'] = (array) $condition['any'];
995999
}
9961000

997-
// Add to options array.
9981001
$options[] = $option;
9991002
}//end foreach
10001003

1001-
// Send request.
10021004
return $this->post(
10031005
'subscribers/filter',
10041006
$this->build_total_count_and_pagination_params(
@@ -1920,15 +1922,15 @@ public function strip_html_head_body_tags(string $markup)
19201922
/**
19211923
* Adds total count and pagination parameters to the given array of existing API parameters.
19221924
*
1923-
* @param array<string, string|integer|bool> $params API parameters.
1924-
* @param boolean $include_total_count Return total count of records.
1925-
* @param string $after_cursor Return results after the given pagination cursor.
1926-
* @param string $before_cursor Return results before the given pagination cursor.
1927-
* @param integer $per_page Number of results to return.
1925+
* @param array<string, string|integer|boolean|list<array<string, mixed>>> $params API parameters.
1926+
* @param boolean $include_total_count Return total count of records.
1927+
* @param string $after_cursor Return results after the given pagination cursor.
1928+
* @param string $before_cursor Return results before the given pagination cursor.
1929+
* @param integer $per_page Number of results to return.
19281930
*
19291931
* @since 2.0.0
19301932
*
1931-
* @return array<string, string|integer|bool>
1933+
* @return array<string, string|int|bool|list<array<string, mixed>>>
19321934
*/
19331935
private function build_total_count_and_pagination_params(
19341936
array $params = [],
@@ -1954,8 +1956,8 @@ private function build_total_count_and_pagination_params(
19541956
/**
19551957
* Performs a GET request to the API.
19561958
*
1957-
* @param string $endpoint API Endpoint.
1958-
* @param array<string, int|string|boolean|array<string, int|string>|string> $args Request arguments.
1959+
* @param string $endpoint API Endpoint.
1960+
* @param array<string, int|string|boolean|array<string, int|string>|list<array<string, mixed>>> $args Request arguments.
19591961
*
19601962
* @return false|mixed
19611963
*/
@@ -1967,8 +1969,8 @@ public function get(string $endpoint, array $args = [])
19671969
/**
19681970
* Performs a POST request to the API.
19691971
*
1970-
* @param string $endpoint API Endpoint.
1971-
* @param array<string, bool|integer|float|string|null|array<int|string, float|integer|string|array<string|string>>> $args Request arguments.
1972+
* @param string $endpoint API Endpoint.
1973+
* @param array<string, bool|integer|float|string|null|array<int|string, array<string|mixed>|boolean|integer|float|string>> $args Request arguments.
19721974
*
19731975
* @return false|mixed
19741976
*/
@@ -2006,9 +2008,9 @@ public function delete(string $endpoint, array $args = [])
20062008
/**
20072009
* Performs an API request.
20082010
*
2009-
* @param string $endpoint API Endpoint.
2010-
* @param string $method Request method.
2011-
* @param array<string, bool|integer|float|string|null|array<int|string, float|integer|string|array<string|string>>> $args Request arguments.
2011+
* @param string $endpoint API Endpoint.
2012+
* @param string $method Request method.
2013+
* @param array<string, bool|integer|float|string|null|array<int|string, bool|integer|float|string|array<string, mixed>>> $args Request arguments.
20122014
*
20132015
* @throws \Exception If JSON encoding arguments failed.
20142016
*

0 commit comments

Comments
 (0)