From 993622cadd352d64343d1ef0040aee6126b88e28 Mon Sep 17 00:00:00 2001 From: Rhys Lees <43909932+RhysLees@users.noreply.github.com> Date: Wed, 29 Jan 2025 13:04:07 +0000 Subject: [PATCH 1/2] WIP --- src/Actions/InstagramHandler.php | 2 +- src/Data/InstagramUser.php | 2 +- src/Http/Controllers/InstagramController.php | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Actions/InstagramHandler.php b/src/Actions/InstagramHandler.php index d315f7c..3fd83c7 100755 --- a/src/Actions/InstagramHandler.php +++ b/src/Actions/InstagramHandler.php @@ -35,7 +35,7 @@ public static function connector(): InstagramConnector if ($authenticator->hasExpired()) { $authenticator = $connector->refreshAccessToken($authenticator); - Cache::store(config('instagram.cache_store'))->put('instagram.authenticator', $serialized, now()->addDays(60)); + Cache::store(config('instagram.cache_store'))->put('instagram.authenticator', $authenticator->serialize(), now()->addDays(60)); } $connector->authenticate($authenticator); diff --git a/src/Data/InstagramUser.php b/src/Data/InstagramUser.php index e3c10a4..1603b09 100755 --- a/src/Data/InstagramUser.php +++ b/src/Data/InstagramUser.php @@ -27,7 +27,7 @@ public function __construct( public string $username, public string $name, public string $account_type, - public string $profile_picture_url, + public ?string $profile_picture_url, public int $followers_count, public int $follows_count, public int $media_count, diff --git a/src/Http/Controllers/InstagramController.php b/src/Http/Controllers/InstagramController.php index f07777d..a251e2d 100755 --- a/src/Http/Controllers/InstagramController.php +++ b/src/Http/Controllers/InstagramController.php @@ -50,8 +50,6 @@ public function callback(Request $request) $json = $response->json(); - ray($json); - Cache::store(config('instagram.cache_store'))->put('instagram.authenticated', $json, now()->addDays(60)); return response('Authenticated Instagram account: '.Arr::get($json, 'username'), 200); From 365440f181a7a502f2408ab0fe7b1b170d2628f6 Mon Sep 17 00:00:00 2001 From: Rhys Lees <43909932+RhysLees@users.noreply.github.com> Date: Thu, 30 Jan 2025 01:09:44 +0000 Subject: [PATCH 2/2] WIP --- phpstan-baseline.neon | 0 phpstan.neon.dist | 12 ++++++++++++ src/Actions/InstagramHandler.php | 1 + src/Http/Controllers/InstagramController.php | 4 ++-- .../Authentication/GetAccessTokenRequest.php | 4 +--- 5 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 phpstan-baseline.neon create mode 100644 phpstan.neon.dist diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 0000000..e69de29 diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 0000000..4c4eab1 --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,12 @@ +includes: + - phpstan-baseline.neon + +parameters: + level: 4 + paths: + - src + - config + tmpDir: build/phpstan + checkOctaneCompatibility: true + checkModelProperties: true + diff --git a/src/Actions/InstagramHandler.php b/src/Actions/InstagramHandler.php index 3fd83c7..ca5e437 100755 --- a/src/Actions/InstagramHandler.php +++ b/src/Actions/InstagramHandler.php @@ -35,6 +35,7 @@ public static function connector(): InstagramConnector if ($authenticator->hasExpired()) { $authenticator = $connector->refreshAccessToken($authenticator); + // @phpstan-ignore-next-line Cache::store(config('instagram.cache_store'))->put('instagram.authenticator', $authenticator->serialize(), now()->addDays(60)); } diff --git a/src/Http/Controllers/InstagramController.php b/src/Http/Controllers/InstagramController.php index a251e2d..eb2ab2f 100755 --- a/src/Http/Controllers/InstagramController.php +++ b/src/Http/Controllers/InstagramController.php @@ -34,8 +34,8 @@ public function callback(Request $request) $connector = new InstagramConnector; $shortLivedAuthenticator = $connector->getShortLivedAccessToken(code: $request->get('code')); - $authenticator = $connector->getAccessToken(code: $shortLivedAuthenticator->accessToken); - $serialized = $authenticator->serialize(); + $authenticator = $connector->getAccessToken(code: $shortLivedAuthenticator->accessToken); // @phpstan-ignore-line + $serialized = $authenticator->serialize(); // @phpstan-ignore-line Cache::store(config('instagram.cache_store'))->put('instagram.authenticator', $serialized, now()->addDays(60)); diff --git a/src/Requests/Authentication/GetAccessTokenRequest.php b/src/Requests/Authentication/GetAccessTokenRequest.php index 6d2bedc..7d6e21f 100755 --- a/src/Requests/Authentication/GetAccessTokenRequest.php +++ b/src/Requests/Authentication/GetAccessTokenRequest.php @@ -39,10 +39,8 @@ public function __construct(protected string $code, protected OAuthConfig $oauth * * @return array{ * grant_type: string, - * code: string, - * client_id: string, + * access_token: string, * client_secret: string, - * redirect_uri: string, * } */ public function defaultQuery(): array