Skip to content

Commit

Permalink
PHP CS fix (make php-cs-fix)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasmure committed Jun 28, 2019
1 parent 30c90ab commit d7fb1b1
Show file tree
Hide file tree
Showing 71 changed files with 754 additions and 779 deletions.
42 changes: 12 additions & 30 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -1,59 +1,41 @@
<?php

/**
* @see https://gist.github.com/codfish/c77d348820c1c6b4ebe4a66dc2291c74
*
* Rules we follow are from PSR-2 as well as the rectified PSR-2 guide.
*
* - https://github.com/FriendsOfPHP/PHP-CS-Fixer
* - https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md
* - https://github.com/php-fig-rectified/fig-rectified-standards/blob/master/PSR-2-R-coding-style-guide-additions.md
*
* If something isn't addressed in either of those, some other common community rules are
* used that might not be addressed explicitly in PSR-2 in order to improve code quality
* (so that devs don't need to comment on them in Code Reviews).
*
* For instance: removing trailing white space, removing extra line breaks where
* they're not needed (back to back, beginning or end of function/class, etc.),
* adding trailing commas in the last line of an array, etc.
*/

$finder = PhpCsFixer\Finder::create()
->exclude('node_modules')
->exclude('vendor')
->in(__DIR__)
;

return PhpCsFixer\Config::create()
->setFinder(PhpCsFixer\Finder::create()
->exclude('vendor')
->in(__DIR__)
)
->setRules([
'@PSR1' => true,
'@PSR2' => true,
'array_syntax' => [ 'syntax' => 'short' ],
'binary_operator_spaces' => [ 'align_equals' => false, 'align_double_arrow' => false ],
'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],
'no_blank_lines_after_class_opening' => true,
'no_blank_lines_after_phpdoc' => true,
'no_break_comment' => false,
'no_extra_consecutive_blank_lines' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_whitespace_in_blank_line' => true,
'no_spaces_around_offset' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_unused_imports' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'no_whitespace_before_comma_in_array' => true,
'no_whitespace_in_blank_line' => true,
'normalize_index_brace' => true,
'PedroTroller/phpspec' => true,
'phpdoc_indent' => true,
'phpdoc_to_comment' => true,
'phpdoc_trim' => true,
'single_quote' => true,
'ternary_to_null_coalescing' => true,
'trailing_comma_in_multiline_array' => true,
'trim_array_spaces' => true,
'method_argument_space' => ['ensure_fully_multiline' => false],
'no_break_comment' => false,
'blank_line_before_statement' => true,
])
->setFinder($finder)
->registerCustomFixers(new PedroTroller\CS\Fixer\Fixers())
;
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ matrix:
- php: '7.3'

before_install:
- make php-cs-compare
- echo "extension = mongodb.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini;
- phpenv config-rm xdebug.ini || echo "xdebug not available"
- docker run -p ${SFTP_PORT}:22 -d atmoz/sftp:alpine ${SFTP_USER}:${SFTP_PASSWORD}:::${SFTP_BASE_DIR}
Expand All @@ -42,5 +41,6 @@ install:
- composer update --prefer-dist --no-progress --no-suggest --ansi

script:
- php vendor/bin/php-cs-fixer fix --diff --dry-run --show-progress=none --verbose
- php vendor/bin/phpspec run -fpretty --verbose
- php vendor/bin/phpunit --verbose
12 changes: 3 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,12 @@ clear-deps:

.PHONY: php-cs-compare
php-cs-compare:
docker run --rm -u $$(id -u):$$(id -g) -v $$(pwd):/project \
herloct/php-cs-fixer fix \
--config=/project/.php_cs.dist \
docker/run-task php${PHP_VERSION} vendor/bin/php-cs-fixer fix \
--diff \
--dry-run \
--show-progress=none \
--verbose \
src spec tests
--verbose

.PHONY: php-cs-fix
php-cs-fix:
docker run --rm -u $$(id -u):$$(id -g) -v $$(pwd):/project \
herloct/php-cs-fixer fix \
--config=/project/.php_cs.dist \
src spec tests
docker/run-task php${PHP_VERSION} vendor/bin/php-cs-fixer fix
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"league/flysystem": "~1.0",
"mongodb/mongodb": "^1.1",
"microsoft/azure-storage-blob": "^1.0",
"akeneo/phpspec-skip-example-extension": "^4.0"
"akeneo/phpspec-skip-example-extension": "^4.0",
"pedrotroller/php-cs-custom-fixer": "^2.17"
},
"suggest": {
"knplabs/knp-gaufrette-bundle": "to use with Symfony2",
Expand Down
32 changes: 16 additions & 16 deletions spec/Gaufrette/Adapter/AclAwareAmazonS3Spec.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function it_delegates_rename_and_update_acl(Adapter $adapter, AmazonS3 $service)
$service
->set_object_acl('bucketName', 'filename2', \AmazonS3::ACL_PRIVATE)
->shouldBeCalled()
->willReturn(new \CFResponse(array(), '', 200))
->willReturn(new \CFResponse([], '', 200))
;
$adapter
->rename('filename', 'filename2')
Expand All @@ -72,7 +72,7 @@ function it_does_not_rename_when_cannot_update_acl(Adapter $adapter, AmazonS3 $s
$service
->set_object_acl('bucketName', 'filename2', \AmazonS3::ACL_PRIVATE)
->shouldBeCalled()
->willReturn(new \CFResponse(array(), '', 500));
->willReturn(new \CFResponse([], '', 500));
$adapter
->rename('filename', 'filename2')
->shouldBeCalled()
Expand All @@ -91,16 +91,16 @@ function it_does_not_rename_when_cannot_update_acl(Adapter $adapter, AmazonS3 $s
function it_updates_acl_with_users_array_when_rename(Adapter $adapter, AmazonS3 $service)
{
$service
->set_object_acl('bucketName', 'filename2', array(array('id' => 'someId', 'permission' => \AmazonS3::GRANT_READ)))
->set_object_acl('bucketName', 'filename2', [['id' => 'someId', 'permission' => \AmazonS3::GRANT_READ]])
->shouldBeCalled()
->willReturn(new \CFResponse(array(), '', 200))
->willReturn(new \CFResponse([], '', 200))
;
$adapter
->rename('filename', 'filename2')
->willReturn(true)
;

$this->setUsers(array(array('id' => 'someId', 'permission' => 'read')));
$this->setUsers([['id' => 'someId', 'permission' => 'read']]);
$this->rename('filename', 'filename2')->shouldReturn(true);
}

Expand All @@ -113,7 +113,7 @@ function it_delegates_write_and_update_acl(Adapter $adapter, AmazonS3 $service)
$service
->set_object_acl('bucketName', 'filename', \AmazonS3::ACL_PRIVATE)
->shouldBeCalled()
->willReturn(new \CFResponse(array(), '', 200))
->willReturn(new \CFResponse([], '', 200))
;
$adapter
->write('filename', 'some content')
Expand All @@ -137,7 +137,7 @@ function it_does_not_write_when_cannot_update_acl(Adapter $adapter, AmazonS3 $se
$service
->set_object_acl('bucketName', 'filename', \AmazonS3::ACL_PRIVATE)
->shouldBeCalled()
->willReturn(new \CFResponse(array(), '', 500))
->willReturn(new \CFResponse([], '', 500))
;
$adapter
->write('filename', 'some content')
Expand All @@ -159,16 +159,16 @@ function it_does_not_write_when_cannot_update_acl(Adapter $adapter, AmazonS3 $se
function it_updates_acl_with_users_array_when_write(Adapter $adapter, AmazonS3 $service)
{
$service
->set_object_acl('bucketName', 'filename', array(array('id' => 'someId', 'permission' => \AmazonS3::GRANT_READ)))
->set_object_acl('bucketName', 'filename', [['id' => 'someId', 'permission' => \AmazonS3::GRANT_READ]])
->shouldBeCalled()
->willReturn(new \CFResponse(array(), '', 200))
->willReturn(new \CFResponse([], '', 200))
;
$adapter
->write('filename', 'some content')
->willReturn(12)
;

$this->setUsers(array(array('id' => 'someId', 'permission' => 'read')));
$this->setUsers([['id' => 'someId', 'permission' => 'read']]);
$this->write('filename', 'some content')->shouldReturn(12);
}

Expand Down Expand Up @@ -213,9 +213,9 @@ function it_delegates_directory_check(Adapter $adapter)
*/
function it_delegates_keys(Adapter $adapter)
{
$adapter->keys()->willReturn(array('filename', 'filename2'));
$adapter->keys()->willReturn(['filename', 'filename2']);

$this->keys()->shouldReturn(array('filename', 'filename2'));
$this->keys()->shouldReturn(['filename', 'filename2']);
}

/**
Expand All @@ -226,11 +226,11 @@ function it_delegates_metadata_handling(TestDelegateAdapter $extendedAdapter, Am
{
$this->beConstructedWith($extendedAdapter, $service, 'bucketName');

$extendedAdapter->setMetadata('filename', array('some'))->shouldBeCalled();
$extendedAdapter->getMetadata('filename')->shouldBeCalled()->willReturn(array('some2'));
$extendedAdapter->setMetadata('filename', ['some'])->shouldBeCalled();
$extendedAdapter->getMetadata('filename')->shouldBeCalled()->willReturn(['some2']);

$this->setMetadata('filename', array('some'));
$this->getMetadata('filename')->shouldReturn(array('some2'));
$this->setMetadata('filename', ['some']);
$this->getMetadata('filename')->shouldReturn(['some2']);
}
}

Expand Down
Loading

0 comments on commit d7fb1b1

Please sign in to comment.