diff --git a/.phan/baseline.php b/.phan/baseline.php new file mode 100644 index 0000000..383541a --- /dev/null +++ b/.phan/baseline.php @@ -0,0 +1,56 @@ + [ + 'src/ActivityApi.php' => ['PhanUnextractableAnnotation'], + 'src/BlogsApi.php' => ['PhanUnextractableAnnotation'], + 'src/CamerasApi.php' => ['PhanUnextractableAnnotation'], + 'src/CollectionsApi.php' => ['PhanUnextractableAnnotation'], + 'src/CommonsApi.php' => ['PhanUnextractableAnnotation'], + 'src/ContactsApi.php' => ['PhanUnextractableAnnotation'], + 'src/FavoritesApi.php' => ['PhanUnextractableAnnotation'], + 'src/GalleriesApi.php' => ['PhanTypeMismatchDefault', 'PhanUnextractableAnnotation'], + 'src/GroupsApi.php' => ['PhanUnextractableAnnotation'], + 'src/GroupsDiscussRepliesApi.php' => ['PhanUnextractableAnnotation'], + 'src/GroupsDiscussTopicsApi.php' => ['PhanUnextractableAnnotation'], + 'src/GroupsMembersApi.php' => ['PhanUnextractableAnnotation'], + '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'], + 'src/PhotosCommentsApi.php' => ['PhanUnextractableAnnotation'], + 'src/PhotosGeoApi.php' => ['PhanUnextractableAnnotation'], + 'src/PhotosNotesApi.php' => ['PhanUnextractableAnnotation'], + 'src/PhotosPeopleApi.php' => ['PhanUnextractableAnnotation'], + 'src/PhotosSuggestionsApi.php' => ['PhanUnextractableAnnotation'], + 'src/PhotosTransformApi.php' => ['PhanUnextractableAnnotation'], + 'src/PhotosUploadApi.php' => ['PhanUnextractableAnnotation'], + 'src/PhotosetsCommentsApi.php' => ['PhanUnextractableAnnotation'], + 'src/PhpFlickr.php' => [ + 'PhanInvalidCommentForDeclarationType', 'PhanTypeConversionFromArray', 'PhanTypeMismatchArgumentInternal', + 'PhanTypeMismatchProperty', 'PhanTypeMismatchReturnProbablyReal', 'PhanUndeclaredClassInstanceof', + 'PhanUndeclaredClassMethod', 'PhanUndeclaredMethod', 'PhanUndeclaredTypeParameter', + 'PhanUndeclaredTypeProperty', 'PhanUndeclaredTypeReturnType', 'PhanUnreferencedUseNormal' + ], + 'src/PlacesApi.php' => ['PhanUnextractableAnnotation'], + 'src/PrefsApi.php' => ['PhanUnextractableAnnotation'], + 'src/PushApi.php' => ['PhanUnextractableAnnotation'], + 'src/ReflectionApi.php' => ['PhanUnextractableAnnotation'], + 'src/StatsApi.php' => ['PhanUnextractableAnnotation'], + 'src/TagsApi.php' => ['PhanUnextractableAnnotation'], + 'src/TestApi.php' => ['PhanUndeclaredClassCatch'], + 'src/TestimonialsApi.php' => ['PhanUnextractableAnnotation'], + 'src/Uploader.php' => [ + 'PhanUndeclaredClassMethod', 'PhanUndeclaredProperty', + 'PhanUndeclaredTypeThrowsType', 'PhanUnreferencedUseNormal' + ], + 'src/Util.php' => ['PhanParamSuspiciousOrder'], + ], +]; diff --git a/.phan/config.php b/.phan/config.php new file mode 100644 index 0000000..74a9cab --- /dev/null +++ b/.phan/config.php @@ -0,0 +1,11 @@ + [ + 'src', + ], + 'exclude_file_regex' => '@^vendor/.*/(tests?|Tests?)/@', + 'exclude_analysis_directory_list' => [ + 'vendor/' + ], +]; diff --git a/composer.json b/composer.json index 06e7252..2aa251b 100644 --- a/composer.json +++ b/composer.json @@ -27,14 +27,17 @@ "mediawiki/minus-x": "^0.3 || ^1.0", "phpunit/phpunit": "^9.5", "tedivm/stash": "^0.17.1", - "php-parallel-lint/php-parallel-lint": "^1.3" + "php-parallel-lint/php-parallel-lint": "^1.3", + "phan/phan": "^5.4" }, "scripts": { + "phan": "phan --allow-polyfill-parser --load-baseline .phan/baseline.php", "test": [ "composer validate", "parallel-lint . --exclude node_modules --exclude vendor", "minus-x check . -q", "phpcs -sp", + "@phan", "phpunit", "git status | grep 'nothing to commit, working tree clean'" ] diff --git a/src/PhpFlickr.php b/src/PhpFlickr.php index a6f9c0f..a532e01 100644 --- a/src/PhpFlickr.php +++ b/src/PhpFlickr.php @@ -104,7 +104,7 @@ public function setCacheDefaultExpiry($time) /** * Get a cached request. - * @param string[] Array of request parameters ('api_sig' will be discarded). + * @param string[] $request Array of request parameters ('api_sig' will be discarded). * @return string[] */ public function getCached($request) diff --git a/src/ProfileApi.php b/src/ProfileApi.php index 9d14271..7066432 100644 --- a/src/ProfileApi.php +++ b/src/ProfileApi.php @@ -11,7 +11,7 @@ class ProfileApi extends ApiMethodGroup * * @link https://www.flickr.com/services/api/flickr.profile.getProfile.html * @param string $userId The NSID of the user to fetch profile information for. - * @return + * @return array */ public function getProfile($userId) { diff --git a/src/Util.php b/src/Util.php index de96a4c..1a7ed2c 100644 --- a/src/Util.php +++ b/src/Util.php @@ -42,7 +42,7 @@ public static function base58encode($num) /** * Decode a photo ID from Flickr's short-URL base-58 system. * @link https://www.flickr.com/groups/api/discuss/72157616713786392/ - * @param int $num + * @param string $num * @return bool|int */ public static function base58decode($num) diff --git a/tests/ApiMethodGroup/PhotosApiTest.php b/tests/ApiMethodGroup/PhotosApiTest.php index 6b86535..795c5ed 100644 --- a/tests/ApiMethodGroup/PhotosApiTest.php +++ b/tests/ApiMethodGroup/PhotosApiTest.php @@ -76,6 +76,9 @@ public function testSetTags() $photoInfo = $flickr->photos()->getInfo($testPhotoId); static::assertCount(3, $photoInfo['tags']['tag']); + + // Clean up. + $flickr->photos()->delete($testPhotoId); } public function testSearch()