From b5e9899291896acd052fc6e5326fe3f9d0f3227f Mon Sep 17 00:00:00 2001 From: Sam Wilson Date: Wed, 18 Dec 2024 07:18:48 +0800 Subject: [PATCH] Fix Phan issue and improve uploads example --- .phan/baseline.php | 5 ----- examples/uploads.php | 8 ++++++-- src/Oauth/PhpFlickrService.php | 2 ++ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.phan/baseline.php b/.phan/baseline.php index 383541a..6db375d 100644 --- a/.phan/baseline.php +++ b/.phan/baseline.php @@ -17,11 +17,6 @@ 'src/GroupsPoolsApi.php' => ['PhanUnextractableAnnotation'], 'src/InterestingnessApi.php' => ['PhanUnextractableAnnotation'], 'src/MachinetagsApi.php' => ['PhanUnextractableAnnotation'], - 'src/Oauth/PhpFlickrService.php' => [ - 'PhanUndeclaredClass', 'PhanUndeclaredClassMethod', 'PhanUndeclaredExtendedClass', - 'PhanUndeclaredMethod', 'PhanUndeclaredProperty', 'PhanUndeclaredTypeParameter', - 'PhanUnreferencedUseNormal' - ], 'src/PandaApi.php' => ['PhanUnextractableAnnotation'], 'src/PeopleApi.php' => ['PhanUnextractableAnnotation'], 'src/PhotosApi.php' => ['PhanTypeMismatchDefault', 'PhanTypeMismatchForeach', 'PhanUnextractableAnnotation'], diff --git a/examples/uploads.php b/examples/uploads.php index e86a9c4..7486dfc 100644 --- a/examples/uploads.php +++ b/examples/uploads.php @@ -35,5 +35,9 @@ true, true ); -$info = $phpFlickr->photos()->getInfo($result['photoid']); -echo "The new photo is: " . $info['urls']['url'][0]['_content'] . "\n"; +if ($result['stat'] === 'fail') { + echo $result['message'] . "\n"; +} else { + $info = $phpFlickr->photos()->getInfo($result['photoid']); + echo "The new photo is: " . $info['urls']['url'][0]['_content'] . "\n"; +} diff --git a/src/Oauth/PhpFlickrService.php b/src/Oauth/PhpFlickrService.php index 35aba6e..442efed 100644 --- a/src/Oauth/PhpFlickrService.php +++ b/src/Oauth/PhpFlickrService.php @@ -9,6 +9,7 @@ use OAuth\Common\Storage\TokenStorageInterface; use OAuth\OAuth1\Service\Flickr; use OAuth\OAuth1\Signature\SignatureInterface; +use OAuth\OAuth1\Token\TokenInterface; class PhpFlickrService extends Flickr { @@ -71,6 +72,7 @@ public function service() public function getAuthorizationForPostingToAlternateUrl($args, $uri) { $token = $this->storage->retrieveAccessToken($this->service()); + assert($token instanceof TokenInterface); $this->signature->setTokenSecret($token->getAccessTokenSecret()); $authParameters = $this->getBasicAuthorizationHeaderInfo(); if (isset($authParameters['oauth_callback'])) {