Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add typehint on adapter #694

Merged
merged 48 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
20b0b04
feat: add typehint on adapter
KevinArtus Apr 21, 2023
ab3604b
Type interface for adapters
KevinArtus Apr 21, 2023
ed22632
Type AsyncAwsS3
KevinArtus Apr 21, 2023
a7db6fd
Type AwsS3
KevinArtus Apr 21, 2023
7ef46f7
Type AzureBlobStorage
KevinArtus Apr 21, 2023
f4065b1
Type DoctrineDbal
KevinArtus Apr 21, 2023
17fb146
fix constructor AsyncAwsS3
KevinArtus Apr 21, 2023
79eda31
Type Flysystem
KevinArtus Apr 21, 2023
b05376b
Type PhpseclibSftp
KevinArtus Apr 24, 2023
20b4484
Type Zip
KevinArtus Apr 24, 2023
f16ad45
Type GridFS and fix declaration checksum
KevinArtus Apr 24, 2023
1a9a23d
fix muchafm review
KevinArtus Jun 2, 2023
a6487f3
refacto: add types on adapter
Apr 24, 2023
7a1b35c
fix: review
May 26, 2023
7bf16a8
fix: review
Jun 2, 2023
aecd1fa
Refacto: Add type on Stream classes
KevinArtus Apr 24, 2023
c7d798a
fix pedro review
KevinArtus May 25, 2023
1597198
refactor: add typeint to FilesystemMap, StreamWrapper and StreamMode
PedroTroller Apr 24, 2023
aa1b69f
Refacto: Add type on Util classes
KevinArtus Apr 24, 2023
b134d9c
fix muchafm review
KevinArtus Apr 28, 2023
d91a8a2
fix: pedro review
Apr 28, 2023
ffe0412
fix pedro's review
KevinArtus Jun 2, 2023
4a4e4ac
refacto: spec types
Apr 28, 2023
c282e47
fix: review
May 26, 2023
af1fda7
refactor: fix Ftp and StreamWrapper errors
PedroTroller Oct 23, 2023
fd3ac32
refactor: fix lvl5 errors for AwsS3 and AzureBlobStorage adapters
PedroTroller Oct 23, 2023
06d948c
ci: upgrade phpstan to 1.10.39
PedroTroller Oct 23, 2023
dd628b0
test: fix filesystem typehint in phpunit tests
PedroTroller Oct 23, 2023
b3fa95d
fix: fix phpspec tests
PedroTroller Oct 23, 2023
4fbaebf
refactor: apply cs fixing
PedroTroller Oct 27, 2023
178fe56
test: fix phpspec tests
PedroTroller Oct 27, 2023
bc76e74
Update src/Gaufrette/Adapter/AwsS3.php
PedroTroller Oct 27, 2023
ec744b9
Update src/Gaufrette/Adapter/PhpseclibSftp.php
PedroTroller Oct 27, 2023
b99b550
Update src/Gaufrette/Adapter/AzureBlobStorage.php
PedroTroller Oct 27, 2023
826acdf
Update src/Gaufrette/Adapter.php
PedroTroller Oct 27, 2023
8e7ecbe
Update src/Gaufrette/Adapter/AzureBlobStorage.php
PedroTroller Oct 27, 2023
c4fba38
Update src/Gaufrette/Adapter/Ftp.php
PedroTroller Oct 27, 2023
3539ec7
Update src/Gaufrette/Adapter/AzureBlobStorage.php
PedroTroller Oct 27, 2023
94d89cd
Update src/Gaufrette/Adapter/DoctrineDbal.php
PedroTroller Oct 27, 2023
bf12aef
refactor: set type for mimetype aware adapters
PedroTroller Oct 30, 2023
74be6f5
docs: add explanation for bitwire value in StreamWrapper
PedroTroller Oct 30, 2023
e2bcd99
fix: introduction of readonly promoted properties
PedroTroller Oct 30, 2023
64a9a23
Update src/Gaufrette/Adapter/AwsS3.php
KevinArtus Oct 30, 2023
1173c0e
Update src/Gaufrette/Stream/InMemoryBuffer.php
PedroTroller Oct 30, 2023
55ad928
Update src/Gaufrette/Stream/Local.php
PedroTroller Oct 30, 2023
3a5592d
Update src/Gaufrette/Stream/Local.php
PedroTroller Oct 30, 2023
b797abe
Update src/Gaufrette/Adapter/AsyncAwsS3.php
KevinArtus Oct 30, 2023
3881d3e
Update src/Gaufrette/Stream/InMemoryBuffer.php
PedroTroller Oct 30, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Download dependencies
run: |
make require-all
composer require --dev --no-update phpstan/phpstan:1.8.8
composer require --dev --no-update phpstan/phpstan:1.10.39
composer update --no-interaction --prefer-dist

- name: PHPStan
Expand Down
3 changes: 0 additions & 3 deletions spec/Gaufrette/Adapter/AsyncAwsS3Spec.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@

class AsyncAwsS3Spec extends ObjectBehavior
{
/**
* @param \AsyncAws\SimpleS3\SimpleS3Client $service
*/
function let(SimpleS3Client $service)
{
$this->beConstructedWith($service, 'bucketName');
Expand Down
3 changes: 0 additions & 3 deletions spec/Gaufrette/Adapter/AwsS3Spec.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@

class AwsS3Spec extends ObjectBehavior
{
/**
* @param \Aws\S3\S3Client $service
*/
function let(S3Client $service)
{
$this->beConstructedWith($service, 'bucketName');
Expand Down
147 changes: 27 additions & 120 deletions spec/Gaufrette/Adapter/AzureBlobStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

namespace spec\Gaufrette\Adapter;

use Gaufrette\Adapter\AzureBlobStorage\BlobProxyFactoryInterface;
use PhpSpec\ObjectBehavior;

use WindowsAzure\Blob\Internal\IBlob;
use WindowsAzure\Blob\Models\Blob;
use WindowsAzure\Blob\Models\GetBlobResult;
use WindowsAzure\Blob\Models\ListBlobsResult;
use WindowsAzure\Common\ServiceException;

class AzureBlobStorage extends ObjectBehavior
{
/**
* @param \Gaufrette\Adapter\AzureBlobStorage\BlobProxyFactoryInterface $blobProxyFactory
*/
function let($blobProxyFactory)
function let(BlobProxyFactoryInterface $blobProxyFactory)
{
$this->beConstructedWith($blobProxyFactory, 'containerName');
}
Expand All @@ -24,12 +24,7 @@ function it_should_be_initializable()
$this->shouldHaveType('Gaufrette\Adapter\MetadataSupporter');
}

/**
* @param \Gaufrette\Adapter\AzureBlobStorage\BlobProxyFactoryInterface $blobProxyFactory
* @param \WindowsAzure\Blob\Internal\IBlob $blobProxy
* @param \WindowsAzure\Blob\Models\GetBlobResult $getBlobResult
*/
function it_should_read_file($blobProxyFactory, $blobProxy, $getBlobResult)
function it_should_read_file(BlobProxyFactoryInterface $blobProxyFactory, IBlob $blobProxy, GetBlobResult $getBlobResult)
{
$getBlobResult
->getContentStream()
Expand All @@ -50,11 +45,7 @@ function it_should_read_file($blobProxyFactory, $blobProxy, $getBlobResult)
$this->read('filename')->shouldReturn('some content');
}

/**
* @param \Gaufrette\Adapter\AzureBlobStorage\BlobProxyFactoryInterface $blobProxyFactory
* @param \WindowsAzure\Blob\Internal\IBlob $blobProxy
*/
function it_should_return_false_when_cannot_read($blobProxyFactory, $blobProxy)
function it_should_return_false_when_cannot_read(BlobProxyFactoryInterface $blobProxyFactory, IBlob $blobProxy)
{
$blobProxy
->getBlob('containerName', 'filename')
Expand All @@ -69,11 +60,7 @@ function it_should_return_false_when_cannot_read($blobProxyFactory, $blobProxy)
$this->read('filename')->shouldReturn(false);
}

/**
* @param \Gaufrette\Adapter\AzureBlobStorage\BlobProxyFactoryInterface $blobProxyFactory
* @param \WindowsAzure\Blob\Internal\IBlob $blobProxy
*/
function it_should_not_mask_exception_when_read($blobProxyFactory, $blobProxy)
function it_should_not_mask_exception_when_read(BlobProxyFactoryInterface $blobProxyFactory, IBlob $blobProxy)
{
$blobProxy
->getBlob('containerName', 'filename')
Expand All @@ -88,11 +75,7 @@ function it_should_not_mask_exception_when_read($blobProxyFactory, $blobProxy)
$this->shouldThrow(new \RuntimeException('read'))->duringRead('filename');
}

/**
* @param \Gaufrette\Adapter\AzureBlobStorage\BlobProxyFactoryInterface $blobProxyFactory
* @param \WindowsAzure\Blob\Internal\IBlob $blobProxy
*/
function it_should_rename_file($blobProxyFactory, $blobProxy)
function it_should_rename_file(BlobProxyFactoryInterface $blobProxyFactory, IBlob $blobProxy)
{
$blobProxy
->copyBlob('containerName', 'filename2', 'containerName', 'filename1')
Expand All @@ -110,11 +93,7 @@ function it_should_rename_file($blobProxyFactory, $blobProxy)
$this->rename('filename1', 'filename2')->shouldReturn(true);
}

/**
* @param \Gaufrette\Adapter\AzureBlobStorage\BlobProxyFactoryInterface $blobProxyFactory
* @param \WindowsAzure\Blob\Internal\IBlob $blobProxy
*/
function it_should_return_false_when_cannot_rename($blobProxyFactory, $blobProxy)
function it_should_return_false_when_cannot_rename(BlobProxyFactoryInterface $blobProxyFactory, IBlob $blobProxy)
{
$blobProxy
->copyBlob('containerName', 'filename2', 'containerName', 'filename1')
Expand All @@ -129,11 +108,7 @@ function it_should_return_false_when_cannot_rename($blobProxyFactory, $blobProxy
$this->rename('filename1', 'filename2')->shouldReturn(false);
}

/**
* @param \Gaufrette\Adapter\AzureBlobStorage\BlobProxyFactoryInterface $blobProxyFactory
* @param \WindowsAzure\Blob\Internal\IBlob $blobProxy
*/
function it_should_not_mask_exception_when_rename($blobProxyFactory, $blobProxy)
function it_should_not_mask_exception_when_rename(BlobProxyFactoryInterface $blobProxyFactory, IBlob $blobProxy)
{
$blobProxy
->copyBlob('containerName', 'filename2', 'containerName', 'filename1')
Expand All @@ -148,11 +123,7 @@ function it_should_not_mask_exception_when_rename($blobProxyFactory, $blobProxy)
$this->shouldThrow(new \RuntimeException('rename'))->duringRename('filename1', 'filename2');
}

/**
* @param \Gaufrette\Adapter\AzureBlobStorage\BlobProxyFactoryInterface $blobProxyFactory
* @param \WindowsAzure\Blob\Internal\IBlob $blobProxy
*/
function it_should_write_file($blobProxyFactory, $blobProxy)
function it_should_write_file(BlobProxyFactoryInterface $blobProxyFactory, IBlob $blobProxy)
{
$blobProxy
->createBlockBlob(
Expand All @@ -171,11 +142,7 @@ function it_should_write_file($blobProxyFactory, $blobProxy)
$this->write('filename', 'some content')->shouldReturn(12);
}

/**
* @param \Gaufrette\Adapter\AzureBlobStorage\BlobProxyFactoryInterface $blobProxyFactory
* @param \WindowsAzure\Blob\Internal\IBlob $blobProxy
*/
function it_should_return_false_when_cannot_write($blobProxyFactory, $blobProxy)
function it_should_return_false_when_cannot_write(BlobProxyFactoryInterface $blobProxyFactory, IBlob $blobProxy)
{
$blobProxy
->createBlockBlob(
Expand All @@ -194,11 +161,7 @@ function it_should_return_false_when_cannot_write($blobProxyFactory, $blobProxy)
$this->write('filename', 'some content')->shouldReturn(false);
}

/**
* @param \Gaufrette\Adapter\AzureBlobStorage\BlobProxyFactoryInterface $blobProxyFactory
* @param \WindowsAzure\Blob\Internal\IBlob $blobProxy
*/
function it_should_not_mask_exception_when_write($blobProxyFactory, $blobProxy)
function it_should_not_mask_exception_when_write(BlobProxyFactoryInterface $blobProxyFactory, IBlob $blobProxy)
{
$blobProxy
->createBlockBlob(
Expand All @@ -217,12 +180,7 @@ function it_should_not_mask_exception_when_write($blobProxyFactory, $blobProxy)
$this->shouldThrow(new \RuntimeException('write'))->duringWrite('filename', 'some content');
}

/**
* @param \Gaufrette\Adapter\AzureBlobStorage\BlobProxyFactoryInterface $blobProxyFactory
* @param \WindowsAzure\Blob\Internal\IBlob $blobProxy
* @param \WindowsAzure\Blob\Models\GetBlobResult $getBlobResult
*/
function it_should_check_if_file_exists($blobProxyFactory, $blobProxy, $getBlobResult)
function it_should_check_if_file_exists(BlobProxyFactoryInterface $blobProxyFactory, IBlob $blobProxy, GetBlobResult $getBlobResult)
{
$blobProxyFactory
->create()
Expand All @@ -244,11 +202,7 @@ function it_should_check_if_file_exists($blobProxyFactory, $blobProxy, $getBlobR
$this->exists('filename2')->shouldReturn(true);
}

/**
* @param \Gaufrette\Adapter\AzureBlobStorage\BlobProxyFactoryInterface $blobProxyFactory
* @param \WindowsAzure\Blob\Internal\IBlob $blobProxy
*/
function it_should_not_mask_exception_when_check_if_file_exists($blobProxyFactory, $blobProxy)
function it_should_not_mask_exception_when_check_if_file_exists(BlobProxyFactoryInterface $blobProxyFactory, IBlob $blobProxy)
{
$blobProxyFactory
->create()
Expand All @@ -263,13 +217,7 @@ function it_should_not_mask_exception_when_check_if_file_exists($blobProxyFactor
$this->shouldThrow(new \RuntimeException('exists'))->duringExists('filename');
}

/**
* @param \Gaufrette\Adapter\AzureBlobStorage\BlobProxyFactoryInterface $blobProxyFactory
* @param \WindowsAzure\Blob\Internal\IBlob $blobProxy
* @param \WindowsAzure\Blob\Models\GetBlobPropertiesResult $getBlobPropertiesResult
* @param \WindowsAzure\Blob\Models\BlobProperties $blobProperties
*/
function it_should_get_file_mtime($blobProxyFactory, $blobProxy, $getBlobPropertiesResult, $blobProperties)
function it_should_get_file_mtime(BlobProxyFactoryInterface $blobProxyFactory, IBlob $blobProxy, GetBlobPropertiesResult $getBlobPropertiesResult, BlobProperties $blobProperties)
{
$blobProxyFactory
->create()
Expand All @@ -294,11 +242,7 @@ function it_should_get_file_mtime($blobProxyFactory, $blobProxy, $getBlobPropert
$this->mtime('filename')->shouldReturn(strtotime('1987-12-28 20:00:00'));
}

/**
* @param \Gaufrette\Adapter\AzureBlobStorage\BlobProxyFactoryInterface $blobProxyFactory
* @param \WindowsAzure\Blob\Internal\IBlob $blobProxy
*/
function it_should_return_false_when_cannot_mtime($blobProxyFactory, $blobProxy)
function it_should_return_false_when_cannot_mtime(BlobProxyFactoryInterface $blobProxyFactory, IBlob $blobProxy)
{
$blobProxyFactory
->create()
Expand All @@ -313,11 +257,7 @@ function it_should_return_false_when_cannot_mtime($blobProxyFactory, $blobProxy)
$this->mtime('filename')->shouldReturn(false);
}

/**
* @param \Gaufrette\Adapter\AzureBlobStorage\BlobProxyFactoryInterface $blobProxyFactory
* @param \WindowsAzure\Blob\Internal\IBlob $blobProxy
*/
function it_should_not_mask_exception_when_get_mtime($blobProxyFactory, $blobProxy)
function it_should_not_mask_exception_when_get_mtime(BlobProxyFactoryInterface $blobProxyFactory, IBlob $blobProxy)
{
$blobProxyFactory
->create()
Expand All @@ -332,11 +272,7 @@ function it_should_not_mask_exception_when_get_mtime($blobProxyFactory, $blobPro
$this->shouldThrow(new \RuntimeException('mtime'))->duringMtime('filename');
}

/**
* @param \Gaufrette\Adapter\AzureBlobStorage\BlobProxyFactoryInterface $blobProxyFactory
* @param \WindowsAzure\Blob\Internal\IBlob $blobProxy
*/
function it_should_delete_file($blobProxyFactory, $blobProxy)
function it_should_delete_file(BlobProxyFactoryInterface $blobProxyFactory, IBlob $blobProxy)
{
$blobProxyFactory
->create()
Expand All @@ -350,11 +286,7 @@ function it_should_delete_file($blobProxyFactory, $blobProxy)
$this->delete('filename')->shouldReturn(true);
}

/**
* @param \Gaufrette\Adapter\AzureBlobStorage\BlobProxyFactoryInterface $blobProxyFactory
* @param \WindowsAzure\Blob\Internal\IBlob $blobProxy
*/
function it_should_return_false_when_cannot_delete_file($blobProxyFactory, $blobProxy)
function it_should_return_false_when_cannot_delete_file(BlobProxyFactoryInterface $blobProxyFactory, IBlob $blobProxy)
{
$blobProxyFactory
->create()
Expand All @@ -369,11 +301,7 @@ function it_should_return_false_when_cannot_delete_file($blobProxyFactory, $blob
$this->delete('filename')->shouldReturn(false);
}

/**
* @param \Gaufrette\Adapter\AzureBlobStorage\BlobProxyFactoryInterface $blobProxyFactory
* @param \WindowsAzure\Blob\Internal\IBlob $blobProxy
*/
function it_should_not_mask_exception_when_delete($blobProxyFactory, $blobProxy)
function it_should_not_mask_exception_when_delete(BlobProxyFactoryInterface $blobProxyFactory, IBlob $blobProxy)
{
$blobProxyFactory
->create()
Expand All @@ -388,12 +316,7 @@ function it_should_not_mask_exception_when_delete($blobProxyFactory, $blobProxy)
$this->shouldThrow(new \RuntimeException('delete'))->duringDelete('filename');
}

/**
* @param \Gaufrette\Adapter\AzureBlobStorage\BlobProxyFactoryInterface $blobProxyFactory
* @param \WindowsAzure\Blob\Internal\IBlob $blobProxy
* @param \WindowsAzure\Blob\Models\ListBlobsResult $listBlobResult
*/
function it_should_get_keys($blobProxyFactory, $blobProxy, $listBlobResult)
function it_should_get_keys(BlobProxyFactoryInterface $blobProxyFactory, IBlob $blobProxy, ListBlobsResult $listBlobResult)
{
$fileNames = ['aaa', 'aaa/filename', 'filename1', 'filename2'];
$blobs = [];
Expand Down Expand Up @@ -421,11 +344,7 @@ function it_should_get_keys($blobProxyFactory, $blobProxy, $listBlobResult)
$this->keys()->shouldReturn(['aaa', 'aaa/filename', 'filename1', 'filename2']);
}

/**
* @param \Gaufrette\Adapter\AzureBlobStorage\BlobProxyFactoryInterface $blobProxyFactory
* @param \WindowsAzure\Blob\Internal\IBlob $blobProxy
*/
function it_should_not_mask_exception_when_get_keys($blobProxyFactory, $blobProxy)
function it_should_not_mask_exception_when_get_keys(BlobProxyFactoryInterface $blobProxyFactory, IBlob $blobProxy)
{
$blobProxyFactory
->create()
Expand All @@ -440,11 +359,7 @@ function it_should_not_mask_exception_when_get_keys($blobProxyFactory, $blobProx
$this->shouldThrow(new \RuntimeException('keys'))->duringKeys();
}

/**
* @param \Gaufrette\Adapter\AzureBlobStorage\BlobProxyFactoryInterface $blobProxyFactory
* @param \WindowsAzure\Blob\Internal\IBlob $blobProxy
*/
function it_should_handle_dirs($blobProxyFactory, $blobProxy)
function it_should_handle_dirs(BlobProxyFactoryInterface $blobProxyFactory, IBlob $blobProxy)
{
$blobProxyFactory
->create()
Expand All @@ -466,11 +381,7 @@ function it_should_handle_dirs($blobProxyFactory, $blobProxy)
$this->isDirectory('dirname')->shouldReturn(true);
}

/**
* @param \Gaufrette\Adapter\AzureBlobStorage\BlobProxyFactoryInterface $blobProxyFactory
* @param \WindowsAzure\Blob\Internal\IBlob $blobProxy
*/
function it_should_create_container($blobProxyFactory, $blobProxy)
function it_should_create_container(BlobProxyFactoryInterface $blobProxyFactory, IBlob $blobProxy)
{
$blobProxyFactory
->create()
Expand All @@ -484,11 +395,7 @@ function it_should_create_container($blobProxyFactory, $blobProxy)
$this->createContainer('containerName');
}

/**
* @param \Gaufrette\Adapter\AzureBlobStorage\BlobProxyFactoryInterface $blobProxyFactory
* @param \WindowsAzure\Blob\Internal\IBlob $blobProxy
*/
function it_should_fail_when_cannot_create_container($blobProxyFactory, $blobProxy)
function it_should_fail_when_cannot_create_container(BlobProxyFactoryInterface $blobProxyFactory, IBlob $blobProxy)
{
$blobProxyFactory
->create()
Expand Down
5 changes: 1 addition & 4 deletions spec/Gaufrette/Adapter/AzureBlobStorage/BlobProxyFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@

class BlobProxyFactory extends ObjectBehavior
{
/**
* @param string $connectionString
*/
function let($connectionString)
function let(string $connectionString)
{
$this->beConstructedWith($connectionString);
}
Expand Down
Loading
Loading