Skip to content

Commit

Permalink
💚 Update PHP CS Fixer! (#659)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nek- authored Sep 21, 2022
1 parent 75b5eb3 commit bab98cb
Show file tree
Hide file tree
Showing 15 changed files with 132 additions and 72 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ composer.lock
doc/.couscous
.env
.php_cs.cache
.php-cs-fixer.cache
phpunit.xml
tests/adapters/*
!tests/adapters/*.dist
Expand Down
10 changes: 5 additions & 5 deletions .php_cs.dist → .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

return PhpCsFixer\Config::create()
return (new PhpCsFixer\Config())
->setFinder(PhpCsFixer\Finder::create()
->exclude('vendor')
->in(__DIR__)
Expand All @@ -9,17 +9,17 @@
'@PSR1' => true,
'@PSR2' => true,
'array_syntax' => [ 'syntax' => 'short' ],
'binary_operator_spaces' => [ 'align_equals' => false, 'align_double_arrow' => false ],
'binary_operator_spaces' => true,
'blank_line_before_statement' => true,
'cast_spaces' => true,
'combine_consecutive_unsets' => true,
'concat_space' => [ 'spacing' => 'one' ],
'linebreak_after_opening_tag' => true,
'method_argument_space' => ['ensure_fully_multiline' => false],
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
'no_blank_lines_after_class_opening' => true,
'no_blank_lines_after_phpdoc' => true,
'no_break_comment' => false,
'no_extra_consecutive_blank_lines' => true,
'no_extra_blank_lines' => true,
'no_spaces_around_offset' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_unused_imports' => true,
Expand All @@ -34,7 +34,7 @@
'phpdoc_trim' => true,
'single_quote' => true,
'ternary_to_null_coalescing' => true,
'trailing_comma_in_multiline_array' => true,
'trailing_comma_in_multiline' => ['elements' => ['arrays']],
'trim_array_spaces' => true,
])
->registerCustomFixers(new PedroTroller\CS\Fixer\Fixers())
Expand Down
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
"require-dev": {
"phpspec/phpspec": "^7.0",
"phpunit/phpunit": "~8.0",
"mikey179/vfsstream": "v1.x-dev as 1.7.0"
"mikey179/vfsstream": "v1.x-dev as 1.7.0",
"friendsofphp/php-cs-fixer": "^3.9",
"pedrotroller/php-cs-custom-fixer": "^2.28"
},
"suggest": {
"knplabs/knp-gaufrette-bundle": "to use with Symfony",
Expand Down
24 changes: 18 additions & 6 deletions spec/Gaufrette/Adapter/AzureBlobStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,12 @@ function it_should_not_mask_exception_when_rename($blobProxyFactory, $blobProxy)
function it_should_write_file($blobProxyFactory, $blobProxy)
{
$blobProxy
->createBlockBlob('containerName', 'filename', 'some content',
\Mockery::type('\WindowsAzure\Blob\Models\CreateBlobOptions'))
->createBlockBlob(
'containerName',
'filename',
'some content',
\Mockery::type('\WindowsAzure\Blob\Models\CreateBlobOptions')
)
->shouldBeCalled();

$blobProxyFactory
Expand All @@ -174,8 +178,12 @@ function it_should_write_file($blobProxyFactory, $blobProxy)
function it_should_return_false_when_cannot_write($blobProxyFactory, $blobProxy)
{
$blobProxy
->createBlockBlob('containerName', 'filename', 'some content',
\Mockery::type('\WindowsAzure\Blob\Models\CreateBlobOptions'))
->createBlockBlob(
'containerName',
'filename',
'some content',
\Mockery::type('\WindowsAzure\Blob\Models\CreateBlobOptions')
)
->willThrow(new ServiceException(500));

$blobProxyFactory
Expand All @@ -193,8 +201,12 @@ function it_should_return_false_when_cannot_write($blobProxyFactory, $blobProxy)
function it_should_not_mask_exception_when_write($blobProxyFactory, $blobProxy)
{
$blobProxy
->createBlockBlob('containerName', 'filename', 'some content',
\Mockery::type('\WindowsAzure\Blob\Models\CreateBlobOptions'))
->createBlockBlob(
'containerName',
'filename',
'some content',
\Mockery::type('\WindowsAzure\Blob\Models\CreateBlobOptions')
)
->willThrow(new \RuntimeException('write'));

$blobProxyFactory
Expand Down
9 changes: 6 additions & 3 deletions spec/Gaufrette/Adapter/DoctrineDbalSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ function it_writes_to_new_file(Connection $connection)
'"mtime"' => strtotime('2012-10-10 23:10:10'),
'"checksum"' => '9893532233caff98cd083a116b013c0b',
'"key"' => 'filename',
])
]
)
->shouldBeCalled();

$this->write('filename', 'some content')->shouldReturn(12);
Expand Down Expand Up @@ -107,7 +108,8 @@ function it_write_file(Connection $connection)
],
[
'"key"' => 'filename',
])
]
)
->shouldBeCalled();

$this->write('filename', 'some content')->shouldReturn(12);
Expand Down Expand Up @@ -182,7 +184,8 @@ function it_renames_file(Connection $connection)
],
[
'"key"' => 'filename',
])
]
)
->shouldBeCalled()
->willReturn(1);

Expand Down
12 changes: 6 additions & 6 deletions spec/Gaufrette/Adapter/OpenCloudSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,13 @@ function it_returns_files_as_sorted_array(Container $container, Collection $obje
$objects = [$object1, $object2, $object3];

$objectList->next()->will(
function () use ($objects, &$index) {
if ($index < count($objects)) {
$index++;
function () use ($objects, &$index) {
if ($index < count($objects)) {
$index++;

return $objects[$index - 1];
}
}
return $objects[$index - 1];
}
}
) ->shouldBeCalledTimes(count($objects) + 1);

$container->objectList()->willReturn($objectList);
Expand Down
1 change: 0 additions & 1 deletion spec/Gaufrette/Adapter/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,3 @@ function apc_exists($path)

return true;
}

2 changes: 1 addition & 1 deletion spec/Gaufrette/FileSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use PhpSpec\ObjectBehavior;

interface MetadataAdapter extends \Gaufrette\Adapter,
\Gaufrette\Adapter\MetadataSupporter
\Gaufrette\Adapter\MetadataSupporter
{
}

Expand Down
10 changes: 5 additions & 5 deletions spec/Gaufrette/FilesystemSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
use Prophecy\Argument;

interface ExtendedAdapter extends \Gaufrette\Adapter,
\Gaufrette\Adapter\FileFactory,
\Gaufrette\Adapter\StreamFactory,
\Gaufrette\Adapter\ChecksumCalculator,
\Gaufrette\Adapter\MetadataSupporter,
\Gaufrette\Adapter\MimeTypeProvider
\Gaufrette\Adapter\FileFactory,
\Gaufrette\Adapter\StreamFactory,
\Gaufrette\Adapter\ChecksumCalculator,
\Gaufrette\Adapter\MetadataSupporter,
\Gaufrette\Adapter\MimeTypeProvider
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/Gaufrette/Adapter/AsyncAwsS3.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ protected function ensureBucketExists()
$this->service->createBucket([
'Bucket' => $this->bucket,
'CreateBucketConfiguration' => [
'LocationConstraint' => $this->service->getConfiguration()->get(Configuration::OPTION_REGION)
'LocationConstraint' => $this->service->getConfiguration()->get(Configuration::OPTION_REGION),
],
]);
$this->bucketExists = true;
Expand Down
6 changes: 4 additions & 2 deletions src/Gaufrette/Adapter/DoctrineDbal.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,12 @@ public function listKeys($prefix = '')

return [
'dirs' => [],
'keys' => array_map(function ($value) {
'keys' => array_map(
function ($value) {
return $value['_key'];
},
$keys),
$keys
),
];
}

Expand Down
60 changes: 30 additions & 30 deletions src/Gaufrette/Adapter/Zip.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,46 +163,46 @@ protected function reinitZipArchive()

if (true !== ($resultCode = $this->zipArchive->open($this->zipFile, ZipArchive::CREATE))) {
switch ($resultCode) {
case ZipArchive::ER_EXISTS:
$errMsg = 'File already exists.';
case ZipArchive::ER_EXISTS:
$errMsg = 'File already exists.';

break;
case ZipArchive::ER_INCONS:
$errMsg = 'Zip archive inconsistent.';
break;
case ZipArchive::ER_INCONS:
$errMsg = 'Zip archive inconsistent.';

break;
case ZipArchive::ER_INVAL:
$errMsg = 'Invalid argument.';
break;
case ZipArchive::ER_INVAL:
$errMsg = 'Invalid argument.';

break;
case ZipArchive::ER_MEMORY:
$errMsg = 'Malloc failure.';
break;
case ZipArchive::ER_MEMORY:
$errMsg = 'Malloc failure.';

break;
case ZipArchive::ER_NOENT:
$errMsg = 'Invalid argument.';
break;
case ZipArchive::ER_NOENT:
$errMsg = 'Invalid argument.';

break;
case ZipArchive::ER_NOZIP:
$errMsg = 'Not a zip archive.';
break;
case ZipArchive::ER_NOZIP:
$errMsg = 'Not a zip archive.';

break;
case ZipArchive::ER_OPEN:
$errMsg = 'Can\'t open file.';
break;
case ZipArchive::ER_OPEN:
$errMsg = 'Can\'t open file.';

break;
case ZipArchive::ER_READ:
$errMsg = 'Read error.';
break;
case ZipArchive::ER_READ:
$errMsg = 'Read error.';

break;
case ZipArchive::ER_SEEK:
$errMsg = 'Seek error.';
break;
case ZipArchive::ER_SEEK:
$errMsg = 'Seek error.';

break;
default:
$errMsg = 'Unknown error.';
break;
default:
$errMsg = 'Unknown error.';

break;
break;
}

throw new \RuntimeException(sprintf('%s', $errMsg));
Expand Down
30 changes: 25 additions & 5 deletions tests/Gaufrette/Functional/Adapter/DoctrineDbalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,30 +72,50 @@ public function shouldListKeys(): void
$this->assertEquals(
$this->filesystem->keys(),
$keys['keys'],
'', 0, 10, true);
'',
0,
10,
true
);

$keys = $this->filesystem->listKeys('foo/foob');
$this->assertEquals(
['foo/foobar/bar.txt'],
$keys['keys'],
'', 0, 10, true);
'',
0,
10,
true
);

$keys = $this->filesystem->listKeys('foo/');
$this->assertEquals(
['foo/foobar/bar.txt', 'foo/bar/buzz.txt'],
$keys['keys'],
'', 0, 10, true);
'',
0,
10,
true
);

$keys = $this->filesystem->listKeys('foo');
$this->assertEquals(
['foo/foobar/bar.txt', 'foo/bar/buzz.txt', 'foobarbuz.txt', 'foo'],
$keys['keys'],
'', 0, 10, true);
'',
0,
10,
true
);

$keys = $this->filesystem->listKeys('fooz');
$this->assertEquals(
[],
$keys['keys'],
'', 0, 10, true);
'',
0,
10,
true
);
}
}
3 changes: 2 additions & 1 deletion tests/Gaufrette/Functional/Adapter/FunctionalTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ protected function setUp(): void
);

if (!file_exists($filename)) {
$this->markTestSkipped(<<<EOF
$this->markTestSkipped(
<<<EOF
To run the {$basename} filesystem tests, you must:
1. Copy the file "{$filename}.dist" as "{$filename}"
Expand Down
Loading

0 comments on commit bab98cb

Please sign in to comment.