Skip to content

Commit d19ec8d

Browse files
authored
Merge pull request #100 from Kit/tests-use-phpstan-2.0
Tests: Use PHPStan 2.0
2 parents 627ccd0 + ee65d37 commit d19ec8d

File tree

4 files changed

+42
-26
lines changed

4 files changed

+42
-26
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"vlucas/phpdotenv": "^5.5",
2424
"phpunit/phpunit": "^5.7 || ^9.0",
2525
"squizlabs/php_codesniffer": "^3.3",
26-
"phpstan/phpstan": "^1.2"
26+
"phpstan/phpstan": "^2.0"
2727
},
2828
"autoload": {
2929
"psr-4": {

phpstan.neon.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ parameters:
66

77
# Should not need to edit anything below here
88
# Rule Level: https://phpstan.org/user-guide/rule-levels
9-
level: 8
9+
level: 10

src/ConvertKit_API.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public function get_oauth_url(string $redirectURI)
177177
* @param string $authCode Authorization Code, returned from get_oauth_url() flow.
178178
* @param string $redirectURI Redirect URI.
179179
*
180-
* @return array<string, int|string> API response
180+
* @return mixed|array<string, int|string> API response
181181
*/
182182
public function get_access_token(string $authCode, string $redirectURI)
183183
{
@@ -215,7 +215,7 @@ public function get_access_token(string $authCode, string $redirectURI)
215215
* @param string $refreshToken Refresh Token.
216216
* @param string $redirectURI Redirect URI.
217217
*
218-
* @return array<string, int|string> API response
218+
* @return mixed|array<string, int|string> API response
219219
*/
220220
public function refresh_token(string $refreshToken, string $redirectURI)
221221
{
@@ -338,7 +338,7 @@ public function get_resource(string $url)
338338
*
339339
* @throws \Exception If JSON encoding arguments failed.
340340
*
341-
* @return false|mixed
341+
* @return mixed|object
342342
*/
343343
public function request(string $endpoint, string $method, array $args = [])
344344
{

src/ConvertKit_API_Traits.php

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public function get_growth_stats(\DateTime $starting = null, \DateTime $ending =
161161
*
162162
* @see https://developers.convertkit.com/v4.html#convertkit-api-forms
163163
*
164-
* @return false|array<int,\stdClass>
164+
* @return mixed|array<int,\stdClass>
165165
*/
166166
public function get_forms(
167167
string $status = 'active',
@@ -198,7 +198,7 @@ public function get_forms(
198198
*
199199
* @see https://developers.convertkit.com/v4.html#convertkit-api-forms
200200
*
201-
* @return false|array<int,\stdClass>
201+
* @return mixed|array<int,\stdClass>
202202
*/
203203
public function get_landing_pages(
204204
string $status = 'active',
@@ -456,7 +456,7 @@ public function get_sequence_subscriptions(
456456
*
457457
* @see https://developers.convertkit.com/v4.html#list-tags
458458
*
459-
* @return false|array<int,\stdClass>
459+
* @return mixed|array<int,\stdClass>
460460
*/
461461
public function get_tags(
462462
bool $include_total_count = false,
@@ -863,10 +863,26 @@ public function get_subscriber_id(string $email_address)
863863
['email_address' => $email_address]
864864
);
865865

866+
if (!$subscribers instanceof \stdClass) {
867+
return false;
868+
}
869+
870+
if (!is_array($subscribers->subscribers)) {
871+
return false;
872+
}
873+
866874
if (!count($subscribers->subscribers)) {
867875
return false;
868876
}
869877

878+
if (!$subscribers->subscribers[0] instanceof \stdClass) {
879+
return false;
880+
}
881+
882+
if (!is_int($subscribers->subscribers[0]->id)) {
883+
return false;
884+
}
885+
870886
// Return the subscriber's ID.
871887
return $subscribers->subscribers[0]->id;
872888
}
@@ -878,7 +894,7 @@ public function get_subscriber_id(string $email_address)
878894
*
879895
* @see https://developers.convertkit.com/v4.html#get-a-subscriber
880896
*
881-
* @return false|integer
897+
* @return mixed|integer
882898
*/
883899
public function get_subscriber(int $subscriber_id)
884900
{
@@ -895,7 +911,7 @@ public function get_subscriber(int $subscriber_id)
895911
*
896912
* @see https://developers.convertkit.com/v4.html#update-a-subscriber
897913
*
898-
* @return false|mixed
914+
* @return mixed
899915
*/
900916
public function update_subscriber(
901917
int $subscriber_id,
@@ -930,7 +946,7 @@ public function update_subscriber(
930946
*
931947
* @see https://developers.convertkit.com/v4.html#unsubscribe-subscriber
932948
*
933-
* @return false|object
949+
* @return mixed|object
934950
*/
935951
public function unsubscribe_by_email(string $email_address)
936952
{
@@ -949,7 +965,7 @@ public function unsubscribe_by_email(string $email_address)
949965
*
950966
* @see https://developers.convertkit.com/v4.html#unsubscribe-subscriber
951967
*
952-
* @return false|object
968+
* @return mixed|object
953969
*/
954970
public function unsubscribe(int $subscriber_id)
955971
{
@@ -967,7 +983,7 @@ public function unsubscribe(int $subscriber_id)
967983
*
968984
* @see https://developers.convertkit.com/v4.html#list-tags-for-a-subscriber
969985
*
970-
* @return false|array<int,\stdClass>
986+
* @return mixed|array<int,\stdClass>
971987
*/
972988
public function get_subscriber_tags(
973989
int $subscriber_id,
@@ -1044,7 +1060,7 @@ public function get_broadcasts(
10441060
*
10451061
* @see https://developers.convertkit.com/v4.html#create-a-broadcast
10461062
*
1047-
* @return false|object
1063+
* @return mixed|object
10481064
*/
10491065
public function create_broadcast(
10501066
string $subject = '',
@@ -1103,7 +1119,7 @@ public function create_broadcast(
11031119
*
11041120
* @see https://developers.convertkit.com/v4.html#get-a-broadcast
11051121
*
1106-
* @return false|object
1122+
* @return mixed|object
11071123
*/
11081124
public function get_broadcast(int $id)
11091125
{
@@ -1118,7 +1134,7 @@ public function get_broadcast(int $id)
11181134
*
11191135
* @see https://developers.convertkit.com/v4.html#get-stats
11201136
*
1121-
* @return false|object
1137+
* @return mixed|object
11221138
*/
11231139
public function get_broadcast_stats(int $id)
11241140
{
@@ -1151,7 +1167,7 @@ public function get_broadcast_stats(int $id)
11511167
*
11521168
* @see https://developers.convertkit.com/#create-a-broadcast
11531169
*
1154-
* @return false|object
1170+
* @return mixed|object
11551171
*/
11561172
public function update_broadcast(
11571173
int $id,
@@ -1213,7 +1229,7 @@ public function update_broadcast(
12131229
*
12141230
* @see https://developers.convertkit.com/v4.html#delete-a-broadcast
12151231
*
1216-
* @return false|object
1232+
* @return mixed|object
12171233
*/
12181234
public function delete_broadcast(int $id)
12191235
{
@@ -1266,7 +1282,7 @@ public function get_webhooks(
12661282
*
12671283
* @throws \InvalidArgumentException If the event is not supported.
12681284
*
1269-
* @return false|object
1285+
* @return mixed|object
12701286
*/
12711287
public function create_webhook(string $url, string $event, string $parameter = '')
12721288
{
@@ -1340,7 +1356,7 @@ public function create_webhook(string $url, string $event, string $parameter = '
13401356
*
13411357
* @see https://developers.convertkit.com/v4.html#delete-a-webhook
13421358
*
1343-
* @return false|object
1359+
* @return mixed|object
13441360
*/
13451361
public function delete_webhook(int $id)
13461362
{
@@ -1389,7 +1405,7 @@ public function get_custom_fields(
13891405
*
13901406
* @see https://developers.convertkit.com/v4.html#create-a-custom-field
13911407
*
1392-
* @return false|object
1408+
* @return mixed|object
13931409
*/
13941410
public function create_custom_field(string $label)
13951411
{
@@ -1409,7 +1425,7 @@ public function create_custom_field(string $label)
14091425
*
14101426
* @see https://developers.convertkit.com/v4.html#bulk-create-custom-fields
14111427
*
1412-
* @return false|object
1428+
* @return mixed|object
14131429
*/
14141430
public function create_custom_fields(array $labels, string $callback_url = '')
14151431
{
@@ -1444,7 +1460,7 @@ public function create_custom_fields(array $labels, string $callback_url = '')
14441460
*
14451461
* @see https://developers.convertkit.com/v4.html#update-a-custom-field
14461462
*
1447-
* @return false|object
1463+
* @return mixed|object
14481464
*/
14491465
public function update_custom_field(int $id, string $label)
14501466
{
@@ -1463,7 +1479,7 @@ public function update_custom_field(int $id, string $label)
14631479
*
14641480
* @see https://developers.convertkit.com/#destroy-field
14651481
*
1466-
* @return false|object
1482+
* @return mixed|object
14671483
*/
14681484
public function delete_custom_field(int $id)
14691485
{
@@ -1510,7 +1526,7 @@ public function get_purchases(
15101526
*
15111527
* @see https://developers.convertkit.com/v4.html#get-a-purchase
15121528
*
1513-
* @return false|object
1529+
* @return mixed|object
15141530
*/
15151531
public function get_purchase(int $purchase_id)
15161532
{
@@ -1535,7 +1551,7 @@ public function get_purchase(int $purchase_id)
15351551
*
15361552
* @see https://developers.convertkit.com/v4.html#create-a-purchase
15371553
*
1538-
* @return false|object
1554+
* @return mixed|object
15391555
*/
15401556
public function create_purchase(
15411557
string $email_address,

0 commit comments

Comments
 (0)