Skip to content

Commit

Permalink
Add Phan testing and fix a few issues
Browse files Browse the repository at this point in the history
  • Loading branch information
samwilson authored Nov 2, 2022
1 parent f40a4a5 commit 4744297
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 4 deletions.
56 changes: 56 additions & 0 deletions .phan/baseline.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

return [
'file_suppressions' => [
'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'],
],
];
11 changes: 11 additions & 0 deletions .phan/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

return [
'directory_list' => [
'src',
],
'exclude_file_regex' => '@^vendor/.*/(tests?|Tests?)/@',
'exclude_analysis_directory_list' => [
'vendor/'
],
];
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
]
Expand Down
2 changes: 1 addition & 1 deletion src/PhpFlickr.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/ProfileApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions tests/ApiMethodGroup/PhotosApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 4744297

Please sign in to comment.