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

Let user run PHP-CS-Fixer 2 and fix CS #70

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 3 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
* text=auto

.travis.yml export-ignore
.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.editorconfig export-ignore
.php_cs.dist export-ignore
.travis.yml export-ignore
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ composer.phar
composer.lock
vendor/
build/
.php_cs
.php_cs.cache
2 changes: 1 addition & 1 deletion .php_cs → .php_cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use PhpCsFixer\Config;
use PhpCsFixer\Finder;

$finder = Finder::create()
->in('src');
->in(['src', 'tests']);

return Config::create()
->setFinder($finder)
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"require-dev": {
"php-vcr/phpunit-testlistener-vcr": "^1.1",
"jakub-onderka/php-parallel-lint": "^0.9.2",
"jakub-onderka/php-console-highlighter": "^0.3.2"
"jakub-onderka/php-console-highlighter": "^0.3.2",
"friendsofphp/php-cs-fixer": "~2"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as with phpunit, let's not add dependencies just for convenience's sake.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, nevertheless this allows people to provide consistent CS on PR they submit.
Also projects require this library use the --no-dev during the build process, so this dependencies will be excluded.

In this case in might be complicate for a developer to install the right version of php-cs-fixer (~1 and ~2) are not compatibles, and not force them to install a specific version globally

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that the 1 vs 2 will be an issue here but the rule of "anything that can be a phar should be" is not one I'm willing to compromise on. Many of the same dependencies used by these tools are also used by code generation libraries and one of those will probably end up in this SDK at some point. With PHP/composer only supporting a single version for each library I'd rather be extra careful and avoid version clashes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

},
"autoload": {
"psr-4": {
Expand Down
4 changes: 2 additions & 2 deletions src/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class Query
*
* @var array
*/
private $select = [];
private $select = [];

/**
* Query constructor.
Expand Down Expand Up @@ -390,5 +390,5 @@ public function select(array $select)
$this->select = $select;

return $this;
}
}
}
4 changes: 2 additions & 2 deletions tests/Unit/Delivery/DynamicEntryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public function testLinkResolution()

$client->expects($this->any())
->method('resolveLink')
->willReturnCallback(function(Link $link) use ($garfieldEntry, $crookshanksEntry) {
->willReturnCallback(function (Link $link) use ($garfieldEntry, $crookshanksEntry) {
$id = $link->getId();

if ($id === 'garfield') {
Expand Down Expand Up @@ -270,7 +270,7 @@ public function testOneToManyReferenceWithMissingEntry()

$client->expects($this->any())
->method('resolveLink')
->willReturnCallback(function(Link $link) use ($garfieldEntry, $crookshanksEntry) {
->willReturnCallback(function (Link $link) use ($garfieldEntry, $crookshanksEntry) {
$id = $link->getId();

if ($id === 'garfield') {
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Delivery/ImageOptionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ public function testQueryProgressiveOverridesFormat()
$options = new ImageOptions;
$options
->setFormat('png')
->setProgressive(true);;
->setProgressive(true);

$this->assertSame('jpg', $options->getFormat());
$this->assertSame('fm=jpg&fl=progressive', $options->getQueryString());
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Delivery/Tool/ClassGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ public function getClassProvider()
*/
public function testGetClass($id, $className)
{
$generator = new ClassGenerator;
$contentType = $this->getMockBuilder(ContentType::class)
$generator = new ClassGenerator;
$contentType = $this->getMockBuilder(ContentType::class)
->disableOriginalConstructor()
->getMock();

$contentType->method('getId')
$contentType->method('getId')
->willReturn($id);

$this->assertEquals($className, $generator->getClassName($contentType));
Expand Down
6 changes: 3 additions & 3 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
*
* @return array
*/
function clean_headers_array(\VCR\Request $request) {
function clean_headers_array(\VCR\Request $request)
{
// @todo This can be done much more nicely with PHP 5.6 and ARRAY_FILTER_USE_BOTH
$headers = array_filter($request->getHeaders());

Expand All @@ -24,7 +25,7 @@ function clean_headers_array(\VCR\Request $request) {
\VCR\VCR::configure()
->setMode('once')
->setStorage('json')
->addRequestMatcher('custom_headers', function(\VCR\Request $first, \VCR\Request $second) {
->addRequestMatcher('custom_headers', function (\VCR\Request $first, \VCR\Request $second) {
$first = clean_headers_array($first);
$second = clean_headers_array($second);

Expand All @@ -34,4 +35,3 @@ function clean_headers_array(\VCR\Request $request) {

\VCR\VCR::turnOn();
\VCR\VCR::turnOff();