Skip to content

Commit

Permalink
Update phpstan/phpstan-mockery requirement from ^1.0 to ^1.0 || ^2.0 (#…
Browse files Browse the repository at this point in the history
…140)

* Update phpstan/phpstan-mockery requirement from ^1.0 to ^1.0 || ^2.0

Updates the requirements on [phpstan/phpstan-mockery](https://github.com/phpstan/phpstan-mockery) to permit the latest version.
- [Release notes](https://github.com/phpstan/phpstan-mockery/releases)
- [Commits](phpstan/phpstan-mockery@1.0.0...2.0.0)

---
updated-dependencies:
- dependency-name: phpstan/phpstan-mockery
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>

* Fix phpstan issues

* Fix phpstan issues

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: zingimmick <[email protected]>
  • Loading branch information
dependabot[bot] and zingimmick authored Jan 22, 2025
1 parent 127680a commit 879bf61
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 9 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"require-dev": {
"league/flysystem-adapter-test-utilities": "^3.7",
"mockery/mockery": "~1.3.3 || ^1.4.2",
"phpstan/phpstan-mockery": "^1.0",
"phpstan/phpstan-mockery": "^1.0 || ^2.0",
"phpunit/phpunit": "^9.3.3 || ^10.0 || ^11.0",
"zing/coding-standard": "^6.4 || ^7.0"
},
Expand Down
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ parameters:
- tests
ignoreErrors:
- '#unction GuzzleHttp\\Psr7\\stream_for not found.#'
- '#Method Zing\\Flysystem\\Obs\\Tests\\TestCase::streamFor\(\) should return Psr\\Http\\Message\\StreamInterface but returns mixed.#'
10 changes: 7 additions & 3 deletions src/ObsAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,9 @@ public function visibility(string $path): FileAttributes
throw UnableToRetrieveMetadata::visibility($path, $obsException->getMessage(), $obsException);
}

$visibility = $this->visibilityConverter->aclToVisibility((array) $result->get('Grants'));
/** @var array<array{Grantee?: array<string, mixed>, Permission?: string}> $grants */
$grants = (array) $result->get('Grants');
$visibility = $this->visibilityConverter->aclToVisibility($grants);

return new FileAttributes($path, null, $visibility);
}
Expand Down Expand Up @@ -362,15 +364,16 @@ public function listContents(string $path, bool $deep): iterable
private function getMetadata(string $path, string $type): FileAttributes
{
try {
/** @var array{Key: string|null, Prefix: string|null, ContentLength?: int, Size?: int, LastModified?: string, ContentType?: string} $metadata */
$metadata = $this->obsClient->getObjectMetadata([
'Bucket' => $this->bucket,
'Key' => $this->pathPrefixer->prefixPath($path),
]);
])->toArray();
} catch (ObsException $obsException) {
throw UnableToRetrieveMetadata::create($path, $type, $obsException->getMessage(), $obsException);
}

$attributes = $this->mapObjectMetadata($metadata->toArray(), $path);
$attributes = $this->mapObjectMetadata($metadata, $path);

if (! $attributes instanceof FileAttributes) {
throw UnableToRetrieveMetadata::create($path, $type);
Expand Down Expand Up @@ -704,6 +707,7 @@ public function checksum(string $path, Config $config): string
}

try {
/** @var array{ETag?: string} $metadata */
$metadata = $this->getMetadata($path, 'checksum')
->extraMetadata();
} catch (UnableToRetrieveMetadata $unableToRetrieveMetadata) {
Expand Down
2 changes: 1 addition & 1 deletion tests/BucketEndpointTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ protected function isBucketEndpoint(): bool
return true;
}

protected function signature(): ?string
protected function signature(): string
{
return 'v4';
}
Expand Down
20 changes: 19 additions & 1 deletion tests/MockAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use League\Flysystem\FileAttributes;
use League\Flysystem\StorageAttributes;
use League\Flysystem\UnableToCopyFile;
use League\Flysystem\UnableToDeleteDirectory;
use League\Flysystem\UnableToRetrieveMetadata;
use League\Flysystem\Visibility;
use Obs\Internal\Common\Model;
Expand Down Expand Up @@ -480,6 +481,7 @@ public function testDeleteDir(): void
],
])->andThrow(new ObsException());
$this->legacyMock->shouldReceive('deleteObjects')
->once()
->withArgs([
[
'Bucket' => 'test',
Expand All @@ -494,7 +496,23 @@ public function testDeleteDir(): void
],
])->andReturn(new Model());
$this->obsAdapter->deleteDirectory('path');
$this->assertTrue(true);
$this->legacyMock->shouldReceive('deleteObjects')
->once()
->withArgs([
[
'Bucket' => 'test',
'Objects' => [
[
'Key' => 'path/',
],
[
'Key' => 'path/file.txt',
],
],
],
])->andThrow(new ObsException());
$this->expectException(UnableToDeleteDirectory::class);
$this->obsAdapter->deleteDirectory('path');
}

public function testWriteStream(): void
Expand Down
4 changes: 1 addition & 3 deletions tests/ValidAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ public function testListContents(): void
$this->assertNull($file->mimeType());
$this->assertNotNull($file->lastModified());
$this->assertNull($file->visibility());
$this->assertIsArray($file->extraMetadata());
$this->assertInstanceOf(DirectoryAttributes::class, $directory);
$this->assertSame('fixture/path/dir', $directory->path());
}
Expand Down Expand Up @@ -277,11 +276,10 @@ public function testImage(): void

$this->obsAdapter->write('fixture/image.png', $contents, new Config());

/** @var array{int, int} $info */
$info = getimagesize($this->obsAdapter->getTemporaryUrl('fixture/image.png', 10, [
'x-image-process' => 'image/crop,w_200,h_100',
]));

$this->assertNotFalse($info);
$this->assertSame(200, $info[0]);
$this->assertSame(100, $info[1]);
}
Expand Down

0 comments on commit 879bf61

Please sign in to comment.