Skip to content

Commit 75cc200

Browse files
authored
Merge pull request rikbruil#20 from rikbruil/housekeeping
Some general housekeeping
2 parents 8772ab6 + 12c1c28 commit 75cc200

11 files changed

+46
-37
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
build/
22
vendor/
3+
.php_cs.cache
34
composer.lock

.php_cs

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
<?php
22

3-
$finder = (new Symfony\Component\Finder\Finder())
4-
->files()
5-
->name('*.php')
6-
->in(__DIR__ . '/src')
7-
->in(__DIR__ . '/spec');
3+
$finder = PhpCsFixer\Finder::create()
4+
->exclude(['vendor', 'build'])
5+
->in(__DIR__);
86

9-
return Symfony\CS\Config::create()
10-
->fixers([
11-
'align_double_arrow',
12-
'align_equals',
13-
'concat_with_spaces',
14-
'header_comment',
15-
'logical_not_operators_with_successor_space',
16-
'multiline_spaces_before_semicolon',
17-
'ordered_use',
18-
'phpdoc_order',
19-
'strict',
20-
'strict_param',
7+
return PhpCsFixer\Config::create()
8+
->setRiskyAllowed(true)
9+
->setRules([
10+
'@Symfony' => true,
11+
'binary_operator_spaces' => [
12+
'align_double_arrow' => true,
13+
'align_equals' => true,
14+
],
15+
'concat_space' => ['spacing' => 'one'],
16+
'not_operator_with_successor_space' => true,
17+
'no_multiline_whitespace_before_semicolons' => true,
18+
'no_useless_else' => true,
19+
'no_useless_return' => true,
20+
'ordered_class_elements' => true,
21+
'ordered_imports' => true,
22+
'phpdoc_order' => true,
23+
'strict_comparison' => true,
24+
'strict_param' => true,
2125
])
22-
->finder($finder);
26+
->setFinder($finder);

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"require-dev": {
2828
"phpspec/phpspec": "^2.0",
2929
"henrikbjorn/phpspec-code-coverage": "^2.0",
30-
"friendsofphp/php-cs-fixer": "^1.12",
30+
"friendsofphp/php-cs-fixer": "^2.0",
3131
"satooshi/php-coveralls": "^1.0"
3232
},
3333
"extra": {

spec/SpecificationRepositorySpec.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Rb\Specification\Doctrine\Exception\LogicException;
1212
use Rb\Specification\Doctrine\Result\ModifierInterface;
1313
use Rb\Specification\Doctrine\SpecificationInterface;
14+
use Rb\Specification\Doctrine\SpecificationRepositoryStub;
1415

1516
class SpecificationRepositorySpec extends ObjectBehavior
1617
{
@@ -22,7 +23,7 @@ class SpecificationRepositorySpec extends ObjectBehavior
2223

2324
public function let(EntityManager $entityManager, ClassMetadata $classMetadata)
2425
{
25-
$this->beAnInstanceOf('Rb\Specification\Doctrine\SpecificationRepositoryStub');
26+
$this->beAnInstanceOf(SpecificationRepositoryStub::class);
2627
$this->beConstructedWith($entityManager, $classMetadata);
2728
}
2829

spec/SpecificationRepositoryStub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Doctrine\ORM\EntityRepository;
66

7-
class SpecificationRepositoryStub extends EntityRepository implements SpecificationAware
7+
class SpecificationRepositoryStub extends EntityRepository implements SpecificationAwareInterface
88
{
99
use SpecificationRepositoryTrait;
1010
}

src/AbstractSpecification.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ public function __construct($field, $dqlAlias = null)
2424
$this->dqlAlias = $dqlAlias;
2525
}
2626

27+
/**
28+
* {@inheritdoc}
29+
*/
30+
public function isSatisfiedBy($value)
31+
{
32+
return true;
33+
}
34+
2735
/**
2836
* Create a formatted string for the given property prefixed with the DQL alias.
2937
*
@@ -56,12 +64,4 @@ protected function createAliasedName($value, $dqlAlias)
5664

5765
return sprintf('%s.%s', $dqlAlias, $value);
5866
}
59-
60-
/**
61-
* {@inheritdoc}
62-
*/
63-
public function isSatisfiedBy($value)
64-
{
65-
return true;
66-
}
6767
}

src/Query/Join.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ public function __construct($field, $newAlias, $dqlAlias = null)
6060
/**
6161
* @param string $type
6262
*
63-
* @return $this
64-
*
6563
* @throws InvalidArgumentException
64+
*
65+
* @return $this
6666
*/
6767
public function setType($type)
6868
{
@@ -75,7 +75,7 @@ public function setType($type)
7575
}
7676

7777
$this->type = $type;
78-
78+
7979
return $this;
8080
}
8181

src/Query/OrderBy.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ class OrderBy extends AbstractSpecification
1414
const ASC = 'ASC';
1515
const DESC = 'DESC';
1616

17-
private static $validOrder = [self::ASC, self::DESC];
18-
1917
/**
2018
* @var string
2119
*/
2220
protected $order;
2321

22+
private static $validOrder = [self::ASC, self::DESC];
23+
2424
/**
2525
* @param string $field
2626
* @param string $order

src/Specification.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class Specification extends ArrayCollection implements SpecificationInterface
2727
*/
2828
public function __construct(array $elements = [])
2929
{
30+
parent::__construct();
31+
3032
$this->setChildren($elements);
3133
}
3234

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/**
99
* SpecificationAware can be used to implement custom repository.
1010
*/
11-
interface SpecificationAware
11+
interface SpecificationAwareInterface
1212
{
1313
/**
1414
* Get the query after matching with given specification.

0 commit comments

Comments
 (0)