Skip to content

Commit

Permalink
Merge pull request #509 from owncloud/bump-php-version
Browse files Browse the repository at this point in the history
Bump PHP phan to major version 5
  • Loading branch information
phil-davis authored Nov 18, 2021
2 parents d34ab21 + ee81e04 commit 88b2346
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ config = {
"federatedServerNeeded": True,
"runCoreTests": True,
"runAllSuites": True,
"numberOfParts": 8,
"numberOfParts": 4,
"cron": "nightly",
},
"api-scality-artesca-remote-smoke": {
Expand All @@ -238,7 +238,7 @@ config = {
"federatedServerNeeded": True,
"runCoreTests": True,
"runAllSuites": True,
"numberOfParts": 8,
"numberOfParts": 4,
"cron": "nightly",
},
},
Expand Down
4 changes: 4 additions & 0 deletions lib/s3storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ public function getVersions($urn) {
'Bucket' => $this->getBucket(),
'Prefix' => $urn
]);
// Phan does not understand that $list['Versions'] contains an array.
/* @phan-suppress-next-line PhanTypeMismatchArgumentInternal */
$versions = \array_filter($list['Versions'], static function ($v) use ($urn) {
return ($v['Key'] === $urn) && $v['IsLatest'] !== true;
});
Expand Down Expand Up @@ -242,6 +244,8 @@ public function getVersion($urn, $versionId) {
'Prefix' => $urn,
'VersionIdMarker' => $versionId
]);
// Phan does not understand that $list['Versions'] contains an array.
/* @phan-suppress-next-line PhanTypeMismatchArgumentInternal */
$versions = \array_filter($list['Versions'], static function ($v) use ($urn, $versionId) {
return ($v['Key'] === $urn) && $v['VersionId'] === $versionId;
});
Expand Down
15 changes: 14 additions & 1 deletion lib/streamwrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -661,11 +661,15 @@ private function openReadStream() {
$command = $client->getCommand('GetObject', $this->getOptions(true));
$command['@http']['stream'] = true;
$result = $client->execute($command);
$this->size = $result['ContentLength'];
$this->size = (int) $result['ContentLength'];
$this->body = $result['Body'];

// Wrap the body in a caching entity body if seeking is allowed
// Phan does not understand that Body can be a StreamInterface
// It thinks that body is just a string. Suppress the message.
/* @phan-suppress-next-line PhanNonClassMethodCall */
if ($this->getOption('seekable') && !$this->body->isSeekable()) {
/* @phan-suppress-next-line PhanTypeMismatchArgument */
$this->body = new CachingStream($this->body);
}

Expand All @@ -682,6 +686,9 @@ private function openAppendStream() {
// Get the body of the object and seek to the end of the stream
$client = $this->getClient();
$this->body = $client->getObject($this->getOptions(true))['Body'];
// Phan does not understand that Body can be a StreamInterface
// It thinks that body is just a string. Suppress the message.
/* @phan-suppress-next-line PhanNonClassMethodCall */
$this->body->seek(0, SEEK_END);
return true;
} catch (S3Exception $e) {
Expand Down Expand Up @@ -818,6 +825,12 @@ private function deleteSubfolder($path, $params) {

// Check if the bucket contains keys other than the placeholder
if ($contents = $result['Contents']) {
// Note: In PHP 7 if $contents is just a string, not an array, then
// \count($contents) will return 1 OK. From PHP 8.0 a TypeError is
// returned. Phan detects this possibility. Suppress for now.
// Phan also thinks that $contents should have numeric keys in the
// sub-arrays. Suppress that as well.
/* @phan-suppress-next-line PhanTypeMismatchArgumentInternal, PhanTypeMismatchDimFetch */
return (\count($contents) > 1 || $prefix != $contents[0]['Key'])
? $this->triggerError('Subfolder is not empty')
: $this->unlink(\rtrim($path, '/') . '/');
Expand Down
2 changes: 1 addition & 1 deletion vendor-bin/phan/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"require": {
"phan/phan": "^4.0"
"phan/phan": "^5.2"
}
}

0 comments on commit 88b2346

Please sign in to comment.