Skip to content

Commit 4744297

Browse files
authored
Add Phan testing and fix a few issues
1 parent f40a4a5 commit 4744297

File tree

7 files changed

+77
-4
lines changed

7 files changed

+77
-4
lines changed

.phan/baseline.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
return [
4+
'file_suppressions' => [
5+
'src/ActivityApi.php' => ['PhanUnextractableAnnotation'],
6+
'src/BlogsApi.php' => ['PhanUnextractableAnnotation'],
7+
'src/CamerasApi.php' => ['PhanUnextractableAnnotation'],
8+
'src/CollectionsApi.php' => ['PhanUnextractableAnnotation'],
9+
'src/CommonsApi.php' => ['PhanUnextractableAnnotation'],
10+
'src/ContactsApi.php' => ['PhanUnextractableAnnotation'],
11+
'src/FavoritesApi.php' => ['PhanUnextractableAnnotation'],
12+
'src/GalleriesApi.php' => ['PhanTypeMismatchDefault', 'PhanUnextractableAnnotation'],
13+
'src/GroupsApi.php' => ['PhanUnextractableAnnotation'],
14+
'src/GroupsDiscussRepliesApi.php' => ['PhanUnextractableAnnotation'],
15+
'src/GroupsDiscussTopicsApi.php' => ['PhanUnextractableAnnotation'],
16+
'src/GroupsMembersApi.php' => ['PhanUnextractableAnnotation'],
17+
'src/GroupsPoolsApi.php' => ['PhanUnextractableAnnotation'],
18+
'src/InterestingnessApi.php' => ['PhanUnextractableAnnotation'],
19+
'src/MachinetagsApi.php' => ['PhanUnextractableAnnotation'],
20+
'src/Oauth/PhpFlickrService.php' => [
21+
'PhanUndeclaredClass', 'PhanUndeclaredClassMethod', 'PhanUndeclaredExtendedClass',
22+
'PhanUndeclaredMethod', 'PhanUndeclaredProperty', 'PhanUndeclaredTypeParameter',
23+
'PhanUnreferencedUseNormal'
24+
],
25+
'src/PandaApi.php' => ['PhanUnextractableAnnotation'],
26+
'src/PeopleApi.php' => ['PhanUnextractableAnnotation'],
27+
'src/PhotosApi.php' => ['PhanTypeMismatchDefault', 'PhanTypeMismatchForeach', 'PhanUnextractableAnnotation'],
28+
'src/PhotosCommentsApi.php' => ['PhanUnextractableAnnotation'],
29+
'src/PhotosGeoApi.php' => ['PhanUnextractableAnnotation'],
30+
'src/PhotosNotesApi.php' => ['PhanUnextractableAnnotation'],
31+
'src/PhotosPeopleApi.php' => ['PhanUnextractableAnnotation'],
32+
'src/PhotosSuggestionsApi.php' => ['PhanUnextractableAnnotation'],
33+
'src/PhotosTransformApi.php' => ['PhanUnextractableAnnotation'],
34+
'src/PhotosUploadApi.php' => ['PhanUnextractableAnnotation'],
35+
'src/PhotosetsCommentsApi.php' => ['PhanUnextractableAnnotation'],
36+
'src/PhpFlickr.php' => [
37+
'PhanInvalidCommentForDeclarationType', 'PhanTypeConversionFromArray', 'PhanTypeMismatchArgumentInternal',
38+
'PhanTypeMismatchProperty', 'PhanTypeMismatchReturnProbablyReal', 'PhanUndeclaredClassInstanceof',
39+
'PhanUndeclaredClassMethod', 'PhanUndeclaredMethod', 'PhanUndeclaredTypeParameter',
40+
'PhanUndeclaredTypeProperty', 'PhanUndeclaredTypeReturnType', 'PhanUnreferencedUseNormal'
41+
],
42+
'src/PlacesApi.php' => ['PhanUnextractableAnnotation'],
43+
'src/PrefsApi.php' => ['PhanUnextractableAnnotation'],
44+
'src/PushApi.php' => ['PhanUnextractableAnnotation'],
45+
'src/ReflectionApi.php' => ['PhanUnextractableAnnotation'],
46+
'src/StatsApi.php' => ['PhanUnextractableAnnotation'],
47+
'src/TagsApi.php' => ['PhanUnextractableAnnotation'],
48+
'src/TestApi.php' => ['PhanUndeclaredClassCatch'],
49+
'src/TestimonialsApi.php' => ['PhanUnextractableAnnotation'],
50+
'src/Uploader.php' => [
51+
'PhanUndeclaredClassMethod', 'PhanUndeclaredProperty',
52+
'PhanUndeclaredTypeThrowsType', 'PhanUnreferencedUseNormal'
53+
],
54+
'src/Util.php' => ['PhanParamSuspiciousOrder'],
55+
],
56+
];

.phan/config.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
return [
4+
'directory_list' => [
5+
'src',
6+
],
7+
'exclude_file_regex' => '@^vendor/.*/(tests?|Tests?)/@',
8+
'exclude_analysis_directory_list' => [
9+
'vendor/'
10+
],
11+
];

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,17 @@
2727
"mediawiki/minus-x": "^0.3 || ^1.0",
2828
"phpunit/phpunit": "^9.5",
2929
"tedivm/stash": "^0.17.1",
30-
"php-parallel-lint/php-parallel-lint": "^1.3"
30+
"php-parallel-lint/php-parallel-lint": "^1.3",
31+
"phan/phan": "^5.4"
3132
},
3233
"scripts": {
34+
"phan": "phan --allow-polyfill-parser --load-baseline .phan/baseline.php",
3335
"test": [
3436
"composer validate",
3537
"parallel-lint . --exclude node_modules --exclude vendor",
3638
"minus-x check . -q",
3739
"phpcs -sp",
40+
"@phan",
3841
"phpunit",
3942
"git status | grep 'nothing to commit, working tree clean'"
4043
]

src/PhpFlickr.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function setCacheDefaultExpiry($time)
104104

105105
/**
106106
* Get a cached request.
107-
* @param string[] Array of request parameters ('api_sig' will be discarded).
107+
* @param string[] $request Array of request parameters ('api_sig' will be discarded).
108108
* @return string[]
109109
*/
110110
public function getCached($request)

src/ProfileApi.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class ProfileApi extends ApiMethodGroup
1111
*
1212
* @link https://www.flickr.com/services/api/flickr.profile.getProfile.html
1313
* @param string $userId The NSID of the user to fetch profile information for.
14-
* @return
14+
* @return array
1515
*/
1616
public function getProfile($userId)
1717
{

src/Util.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static function base58encode($num)
4242
/**
4343
* Decode a photo ID from Flickr's short-URL base-58 system.
4444
* @link https://www.flickr.com/groups/api/discuss/72157616713786392/
45-
* @param int $num
45+
* @param string $num
4646
* @return bool|int
4747
*/
4848
public static function base58decode($num)

tests/ApiMethodGroup/PhotosApiTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ public function testSetTags()
7676

7777
$photoInfo = $flickr->photos()->getInfo($testPhotoId);
7878
static::assertCount(3, $photoInfo['tags']['tag']);
79+
80+
// Clean up.
81+
$flickr->photos()->delete($testPhotoId);
7982
}
8083

8184
public function testSearch()

0 commit comments

Comments
 (0)