Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into phan-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
samwilson committed Dec 18, 2024
2 parents 4ec69da + 3aced78 commit 4e5c351
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 32 deletions.
10 changes: 3 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@ jobs:

strategy:
matrix:
os: [ ubuntu-latest ]
php: [ '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ]
include:
- os: macos-latest
php: '8.3'
- os: windows-latest
php: '8.3'
os: [ ubuntu-latest, macos-latest, windows-latest ]
# All supported PHP versions https://www.php.net/supported-versions.php
php: [ '8.2','8.3','8.4' ]

runs-on: ${{matrix.os}}

Expand Down
5 changes: 0 additions & 5 deletions .phan/baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,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'],
Expand Down
1 change: 1 addition & 0 deletions .phan/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
return [
'directory_list' => [
'src',
'vendor',
],
'exclude_file_regex' => '@^vendor/.*/(tests?|Tests?)/@',
'exclude_analysis_directory_list' => [
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
}
},
"require": {
"php": "^7.3 || ^8.0",
"php": "^8.2",
"ext-curl": "*",
"ext-json": "*",
"ext-libxml": "*",
Expand All @@ -26,8 +26,8 @@
"squizlabs/php_codesniffer": "^3.0",
"mediawiki/minus-x": "^0.3 || ^1.0",
"phpunit/phpunit": "^9.5",
"symfony/cache": "^5.4",
"symfony/var-dumper": "^5.4",
"symfony/cache": "^5.4|^6.4|^7.0",
"symfony/var-dumper": "^5.4|^6.4|^7.0",
"php-parallel-lint/php-parallel-lint": "^1.3",
"phan/phan": "^5.4"
},
Expand Down
8 changes: 6 additions & 2 deletions examples/uploads.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
11 changes: 6 additions & 5 deletions src/Oauth/PhpFlickrService.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
use OAuth\Common\Http\Uri\Uri;
use OAuth\Common\Http\Uri\UriInterface;
use OAuth\Common\Storage\TokenStorageInterface;
use OAuth\OAuth1\Service\AbstractService;
use OAuth\OAuth1\Service\Flickr;
use OAuth\OAuth1\Signature\SignatureInterface;
use OAuth\OAuth1\Token\TokenInterface;

class PhpFlickrService extends Flickr
{
Expand All @@ -21,7 +21,7 @@ public function __construct(
ClientInterface $httpClient,
TokenStorageInterface $storage,
SignatureInterface $signature,
UriInterface $baseApiUri = null
?UriInterface $baseApiUri = null
) {
if ($baseApiUri === null) {
$baseApiUri = new Uri(static::$baseUrl . '/rest/');
Expand All @@ -37,17 +37,17 @@ public static function setBaseUrl($baseUrl)
static::$baseUrl = rtrim($baseUrl, '/');
}

public function getRequestTokenEndpoint()
public function getRequestTokenEndpoint(): UriInterface
{
return new Uri(static::$baseUrl . '/oauth/request_token');
}

public function getAuthorizationEndpoint()
public function getAuthorizationEndpoint(): UriInterface
{
return new Uri(static::$baseUrl . '/oauth/authorize');
}

public function getAccessTokenEndpoint()
public function getAccessTokenEndpoint(): UriInterface
{
return new Uri(static::$baseUrl . '/oauth/access_token');
}
Expand All @@ -72,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'])) {
Expand Down
4 changes: 2 additions & 2 deletions src/PhotosApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -847,9 +847,9 @@ public function setContentType($photoId, $contentType)
*/
public function setDates(
$photoId,
DateTime $dateTaken = null,
DateTime|null $dateTaken = null,
$dateTakenGranularity = null,
DateTime $datePosted = null
DateTime|null $datePosted = null
) {
$args = ['photo_id' => $photoId];
if (!empty($dateTaken)) {
Expand Down
9 changes: 5 additions & 4 deletions src/PhpFlickr.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use OAuth\Common\Consumer\Credentials;
use OAuth\Common\Http\Client\CurlClient;
use OAuth\Common\Http\Uri\Uri;
use OAuth\Common\Http\Uri\UriInterface;
use OAuth\Common\Storage\Memory;
use OAuth\Common\Storage\TokenStorageInterface;
use OAuth\OAuth1\Service\Flickr;
Expand All @@ -38,7 +39,7 @@
class PhpFlickr
{
/** PhpFlickr version. */
public const VERSION = '5.1.0';
public const VERSION = '6.0.1';

/** @param string */
protected $api_key;
Expand Down Expand Up @@ -81,7 +82,7 @@ class PhpFlickr
* @param string $apiKey
* @param string|null $secret
*/
public function __construct(string $apiKey, string $secret = null)
public function __construct(string $apiKey, string|null $secret = null)
{
$this->api_key = $apiKey;
$this->secret = $secret;
Expand Down Expand Up @@ -281,8 +282,8 @@ public function getOauthService($callbackUrl = 'oob')
$factory->registerService('Flickr', PhpFlickrService::class);
$factory->setHttpClient(new CurlClient());
$storage = $this->getOauthTokenStorage();
/** @var PhpFlickrService $flickrService */
$this->oauthService = $factory->createService('Flickr', $credentials, $storage);
assert($this->oauthService instanceof PhpFlickrService);
return $this->oauthService;
}

Expand All @@ -295,7 +296,7 @@ public function getOauthService($callbackUrl = 'oob')
* @param string $perm One of 'read', 'write', or 'delete'.
* @param string $callbackUrl Defaults to 'oob' ('out-of-band') for when no callback is
* required, for example for console usage.
* @return Uri
* @return UriInterface
*/
public function getAuthUrl($perm = 'read', $callbackUrl = 'oob')
{
Expand Down
3 changes: 2 additions & 1 deletion src/Uploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Uploader
/** @var PhpFlickr */
protected $flickr;

protected $response;
/** @var string */
protected $uploadEndpoint = 'https://up.flickr.com/services/upload/';

Expand Down Expand Up @@ -135,7 +136,7 @@ protected function sendFile($filename, $params)
$uploadResponse['originalsecret'] = (string)$xml->photoid['originalsecret'];
}
if (isset($xml->ticketid)) {
$uploadResponse['ticketid'] = (int)$xml->ticketid;
$uploadResponse['ticketid'] = (string)$xml->ticketid;
}
if (isset($xml->err)) {
$uploadResponse['code'] = (int)$xml->err['code'];
Expand Down
7 changes: 4 additions & 3 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ public function getFlickr(bool $authenticate = false): PhpFlickr
$apiSecret = getenv('FLICKR_API_SECRET');
$accessToken = getenv('FLICKR_ACCESS_TOKEN');
$accessTokenSecret = getenv('FLICKR_ACCESS_SECRET');
if (empty($apiKey) && file_exists(__DIR__ . '/config.php')) {
require __DIR__ . '/config.php';
$configFile = __DIR__ . '/config.php';
if (empty($apiKey) && file_exists($configFile)) {
require $configFile;
}
if (empty($apiKey)) {
// Skip if no key found, so PRs from forks can still be run in CI.
static::markTestSkipped('No Flickr API key set.');
static::markTestSkipped('No Flickr API key set (in either the FLICKR_* env vars or ' . $configFile . ')');
}
try {
$this->flickrs[$authed] = new PhpFlickr($apiKey, $apiSecret);
Expand Down

0 comments on commit 4e5c351

Please sign in to comment.