Skip to content

Commit

Permalink
chore: Add cs fixer configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
jubianchi committed Oct 2, 2017
1 parent 1da031b commit 53c0de7
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 42 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/vendor/
composer.lock
/composer.lock
/.php_cs.cache
42 changes: 18 additions & 24 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
<?php

use Symfony\CS;
use PhpCsFixer as CS;

$finder = CS\Finder::create()->in(__DIR__);

return
CS\Config::create()
->level(CS\FixerInterface::PSR2_LEVEL)
->fixers([
'blankline_after_open_tag',
'concat_with_spaces',
'join_function',
'native_function_casing',
'no_blank_lines_after_class_opening',
'ordered_use',
'phpdoc_no_access',
'remove_leading_slash_use',
'remove_leading_slash_uses',
'self_accessor',
'short_array_syntax',
'spaces_cast',
'unused_use',
'whitespacy_lines'
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'blank_line_after_opening_tag' => true,
'concat_space' => ['spacing' => 'one'],
'native_function_casing' => true,
'no_blank_lines_after_class_opening' => true,
'no_unused_imports' => true,
'no_unused_imports' => true,
'no_whitespace_in_blank_line' => true,
'ordered_imports' => true,
'phpdoc_no_access' => true,
'self_accessor' => true
])
->finder(
CS\Finder::create()
->files()
->name(__FILE__)
->name('*.php')
->in(__DIR__)
);
->setFinder($finder)
;
12 changes: 8 additions & 4 deletions classes/score/coverage.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,14 @@ public function merge(self $coverage)
public function addToModel(model $model)
{
$model->coverageIs(
$this->totalLines, $this->coveredLines,
$this->totalBranches, $this->coveredBranches,
$this->totalPaths, $this->coveredPaths,
$this->totalOps, count($this->coveredOps ?: []) + $this->additionalCoveredOps
$this->totalLines,
$this->coveredLines,
$this->totalBranches,
$this->coveredBranches,
$this->totalPaths,
$this->coveredPaths,
$this->totalOps,
count($this->coveredOps ?: []) + $this->additionalCoveredOps
);

return $this;
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"atoum/atoum": "^2.9 | ^3.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "~1.12"
"friendsofphp/php-cs-fixer": "^2"
},
"autoload": {
"psr-4": {
Expand Down
12 changes: 8 additions & 4 deletions tests/units/classes/model/coverage.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@ public function testCoverageIs()
->given(
$this->mockGenerator->shuntParentClassCalls(),
$template = new \mock\mageekguy\atoum\reports\template(uniqid()),
$totalLines = rand(1, PHP_INT_MAX), $coveredLines = rand(1, PHP_INT_MAX),
$totalBranches = rand(1, PHP_INT_MAX), $coveredBranches = rand(1, PHP_INT_MAX),
$totalPaths = rand(1, PHP_INT_MAX), $coveredPaths = rand(1, PHP_INT_MAX),
$totalOps = rand(1, PHP_INT_MAX), $coveredOps = rand(1, PHP_INT_MAX)
$totalLines = rand(1, PHP_INT_MAX),
$coveredLines = rand(1, PHP_INT_MAX),
$totalBranches = rand(1, PHP_INT_MAX),
$coveredBranches = rand(1, PHP_INT_MAX),
$totalPaths = rand(1, PHP_INT_MAX),
$coveredPaths = rand(1, PHP_INT_MAX),
$totalOps = rand(1, PHP_INT_MAX),
$coveredOps = rand(1, PHP_INT_MAX)
)
->if($this->newTestedInstance)
->then
Expand Down
12 changes: 8 additions & 4 deletions tests/units/classes/model/coverage/klass.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@ public function testCoverageIs()
$class = uniqid(),
$this->mockGenerator->shuntParentClassCalls(),
$template = new \mock\mageekguy\atoum\reports\template(uniqid()),
$totalLines = rand(1, PHP_INT_MAX), $coveredLines = rand(1, PHP_INT_MAX),
$totalBranches = rand(1, PHP_INT_MAX), $coveredBranches = rand(1, PHP_INT_MAX),
$totalPaths = rand(1, PHP_INT_MAX), $coveredPaths = rand(1, PHP_INT_MAX),
$totalOps = rand(1, PHP_INT_MAX), $coveredOps = rand(1, PHP_INT_MAX)
$totalLines = rand(1, PHP_INT_MAX),
$coveredLines = rand(1, PHP_INT_MAX),
$totalBranches = rand(1, PHP_INT_MAX),
$coveredBranches = rand(1, PHP_INT_MAX),
$totalPaths = rand(1, PHP_INT_MAX),
$coveredPaths = rand(1, PHP_INT_MAX),
$totalOps = rand(1, PHP_INT_MAX),
$coveredOps = rand(1, PHP_INT_MAX)
)
->if($this->newTestedInstance($class))
->then
Expand Down
12 changes: 8 additions & 4 deletions tests/units/classes/model/coverage/method.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@ public function testCoverageIs()
$method = uniqid(),
$this->mockGenerator->shuntParentClassCalls(),
$template = new \mock\mageekguy\atoum\reports\template(uniqid()),
$totalLines = rand(1, PHP_INT_MAX), $coveredLines = rand(1, PHP_INT_MAX),
$totalBranches = rand(1, PHP_INT_MAX), $coveredBranches = rand(1, PHP_INT_MAX),
$totalPaths = rand(1, PHP_INT_MAX), $coveredPaths = rand(1, PHP_INT_MAX),
$totalOps = rand(1, PHP_INT_MAX), $coveredOps = rand(1, PHP_INT_MAX)
$totalLines = rand(1, PHP_INT_MAX),
$coveredLines = rand(1, PHP_INT_MAX),
$totalBranches = rand(1, PHP_INT_MAX),
$coveredBranches = rand(1, PHP_INT_MAX),
$totalPaths = rand(1, PHP_INT_MAX),
$coveredPaths = rand(1, PHP_INT_MAX),
$totalOps = rand(1, PHP_INT_MAX),
$coveredOps = rand(1, PHP_INT_MAX)
)
->if($this->newTestedInstance($method))
->then
Expand Down

0 comments on commit 53c0de7

Please sign in to comment.