Skip to content

Tests: Use PHPStan 2.0 #100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 6, 2024
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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"vlucas/phpdotenv": "^5.5",
"phpunit/phpunit": "^5.7 || ^9.0",
"squizlabs/php_codesniffer": "^3.3",
"phpstan/phpstan": "^1.2"
"phpstan/phpstan": "^2.0"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ parameters:

# Should not need to edit anything below here
# Rule Level: https://phpstan.org/user-guide/rule-levels
level: 8
level: 10
6 changes: 3 additions & 3 deletions src/ConvertKit_API.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public function get_oauth_url(string $redirectURI)
* @param string $authCode Authorization Code, returned from get_oauth_url() flow.
* @param string $redirectURI Redirect URI.
*
* @return array<string, int|string> API response
* @return mixed|array<string, int|string> API response
*/
public function get_access_token(string $authCode, string $redirectURI)
{
Expand Down Expand Up @@ -215,7 +215,7 @@ public function get_access_token(string $authCode, string $redirectURI)
* @param string $refreshToken Refresh Token.
* @param string $redirectURI Redirect URI.
*
* @return array<string, int|string> API response
* @return mixed|array<string, int|string> API response
*/
public function refresh_token(string $refreshToken, string $redirectURI)
{
Expand Down Expand Up @@ -338,7 +338,7 @@ public function get_resource(string $url)
*
* @throws \Exception If JSON encoding arguments failed.
*
* @return false|mixed
* @return mixed|object
*/
public function request(string $endpoint, string $method, array $args = [])
{
Expand Down
58 changes: 37 additions & 21 deletions src/ConvertKit_API_Traits.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public function get_growth_stats(\DateTime $starting = null, \DateTime $ending =
*
* @see https://developers.convertkit.com/v4.html#convertkit-api-forms
*
* @return false|array<int,\stdClass>
* @return mixed|array<int,\stdClass>
*/
public function get_forms(
string $status = 'active',
Expand Down Expand Up @@ -198,7 +198,7 @@ public function get_forms(
*
* @see https://developers.convertkit.com/v4.html#convertkit-api-forms
*
* @return false|array<int,\stdClass>
* @return mixed|array<int,\stdClass>
*/
public function get_landing_pages(
string $status = 'active',
Expand Down Expand Up @@ -456,7 +456,7 @@ public function get_sequence_subscriptions(
*
* @see https://developers.convertkit.com/v4.html#list-tags
*
* @return false|array<int,\stdClass>
* @return mixed|array<int,\stdClass>
*/
public function get_tags(
bool $include_total_count = false,
Expand Down Expand Up @@ -863,10 +863,26 @@ public function get_subscriber_id(string $email_address)
['email_address' => $email_address]
);

if (!$subscribers instanceof \stdClass) {
return false;
}

if (!is_array($subscribers->subscribers)) {
return false;
}

if (!count($subscribers->subscribers)) {
return false;
}

if (!$subscribers->subscribers[0] instanceof \stdClass) {
return false;
}

if (!is_int($subscribers->subscribers[0]->id)) {
return false;
}

// Return the subscriber's ID.
return $subscribers->subscribers[0]->id;
}
Expand All @@ -878,7 +894,7 @@ public function get_subscriber_id(string $email_address)
*
* @see https://developers.convertkit.com/v4.html#get-a-subscriber
*
* @return false|integer
* @return mixed|integer
*/
public function get_subscriber(int $subscriber_id)
{
Expand All @@ -895,7 +911,7 @@ public function get_subscriber(int $subscriber_id)
*
* @see https://developers.convertkit.com/v4.html#update-a-subscriber
*
* @return false|mixed
* @return mixed
*/
public function update_subscriber(
int $subscriber_id,
Expand Down Expand Up @@ -930,7 +946,7 @@ public function update_subscriber(
*
* @see https://developers.convertkit.com/v4.html#unsubscribe-subscriber
*
* @return false|object
* @return mixed|object
*/
public function unsubscribe_by_email(string $email_address)
{
Expand All @@ -949,7 +965,7 @@ public function unsubscribe_by_email(string $email_address)
*
* @see https://developers.convertkit.com/v4.html#unsubscribe-subscriber
*
* @return false|object
* @return mixed|object
*/
public function unsubscribe(int $subscriber_id)
{
Expand All @@ -967,7 +983,7 @@ public function unsubscribe(int $subscriber_id)
*
* @see https://developers.convertkit.com/v4.html#list-tags-for-a-subscriber
*
* @return false|array<int,\stdClass>
* @return mixed|array<int,\stdClass>
*/
public function get_subscriber_tags(
int $subscriber_id,
Expand Down Expand Up @@ -1044,7 +1060,7 @@ public function get_broadcasts(
*
* @see https://developers.convertkit.com/v4.html#create-a-broadcast
*
* @return false|object
* @return mixed|object
*/
public function create_broadcast(
string $subject = '',
Expand Down Expand Up @@ -1103,7 +1119,7 @@ public function create_broadcast(
*
* @see https://developers.convertkit.com/v4.html#get-a-broadcast
*
* @return false|object
* @return mixed|object
*/
public function get_broadcast(int $id)
{
Expand All @@ -1118,7 +1134,7 @@ public function get_broadcast(int $id)
*
* @see https://developers.convertkit.com/v4.html#get-stats
*
* @return false|object
* @return mixed|object
*/
public function get_broadcast_stats(int $id)
{
Expand Down Expand Up @@ -1151,7 +1167,7 @@ public function get_broadcast_stats(int $id)
*
* @see https://developers.convertkit.com/#create-a-broadcast
*
* @return false|object
* @return mixed|object
*/
public function update_broadcast(
int $id,
Expand Down Expand Up @@ -1213,7 +1229,7 @@ public function update_broadcast(
*
* @see https://developers.convertkit.com/v4.html#delete-a-broadcast
*
* @return false|object
* @return mixed|object
*/
public function delete_broadcast(int $id)
{
Expand Down Expand Up @@ -1266,7 +1282,7 @@ public function get_webhooks(
*
* @throws \InvalidArgumentException If the event is not supported.
*
* @return false|object
* @return mixed|object
*/
public function create_webhook(string $url, string $event, string $parameter = '')
{
Expand Down Expand Up @@ -1340,7 +1356,7 @@ public function create_webhook(string $url, string $event, string $parameter = '
*
* @see https://developers.convertkit.com/v4.html#delete-a-webhook
*
* @return false|object
* @return mixed|object
*/
public function delete_webhook(int $id)
{
Expand Down Expand Up @@ -1389,7 +1405,7 @@ public function get_custom_fields(
*
* @see https://developers.convertkit.com/v4.html#create-a-custom-field
*
* @return false|object
* @return mixed|object
*/
public function create_custom_field(string $label)
{
Expand All @@ -1409,7 +1425,7 @@ public function create_custom_field(string $label)
*
* @see https://developers.convertkit.com/v4.html#bulk-create-custom-fields
*
* @return false|object
* @return mixed|object
*/
public function create_custom_fields(array $labels, string $callback_url = '')
{
Expand Down Expand Up @@ -1444,7 +1460,7 @@ public function create_custom_fields(array $labels, string $callback_url = '')
*
* @see https://developers.convertkit.com/v4.html#update-a-custom-field
*
* @return false|object
* @return mixed|object
*/
public function update_custom_field(int $id, string $label)
{
Expand All @@ -1463,7 +1479,7 @@ public function update_custom_field(int $id, string $label)
*
* @see https://developers.convertkit.com/#destroy-field
*
* @return false|object
* @return mixed|object
*/
public function delete_custom_field(int $id)
{
Expand Down Expand Up @@ -1510,7 +1526,7 @@ public function get_purchases(
*
* @see https://developers.convertkit.com/v4.html#get-a-purchase
*
* @return false|object
* @return mixed|object
*/
public function get_purchase(int $purchase_id)
{
Expand All @@ -1535,7 +1551,7 @@ public function get_purchase(int $purchase_id)
*
* @see https://developers.convertkit.com/v4.html#create-a-purchase
*
* @return false|object
* @return mixed|object
*/
public function create_purchase(
string $email_address,
Expand Down
Loading