8000 Merge pull request #4 from Soullivaneuh/cs-fixer · dunglas/symfony@65c27ce · GitHub
[go: up one dir, main page]

Skip to content

Commit 65c27ce

Browse files
committed
Merge pull request #4 from Soullivaneuh/cs-fixer
Configure and apply cs-fixer
2 parents 38cb028 + eb49530 commit 65c27ce

File tree

14 files changed

+104
-75
lines changed

14 files changed

+104
-75
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
/vendor/
22
/composer.phar
33
/composer.lock
4-
4+
.php_cs.cache

.php_cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
$header = <<<EOF
4+
(c) Kévin Dunglas <dunglas@gmail.com>
5+
6+
This source file is subject to the MIT license that is bundled
7+
with this source code in the file LICENSE.
8+
EOF;
9+
10+
Symfony\CS\Fixer\Contrib\HeaderCommentFixer::setHeader($header);
11+
12+
$finder = Symfony\CS\Finder\DefaultFinder::create()
13+
->in(array(__DIR__))
14+
;
15+
16+
return Symfony\CS\Config\Config::create()
17+
->level(Symfony\CS\FixerInterface::SYMFONY_LEVEL)
18+
->fixers(array(
19+
'-psr0',
20+
'header_comment',
21+
'newline_after_open_tag',
22+
'ordered_use',
23+
'short_array_syntax',
24+
))
25+
->setUsingCache(true)
26+
->finder($finder)
27+
;

.travis.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,14 @@ php:
1313
- nightly
1414
- hhvm
1515

16+
env:
17+< D966 div class="diff-text-inner"> global:
18+
- PATH="$HOME/.composer/vendor/bin:$PATH"
19+
1620
matrix:
1721
include:
22+
- php: 5.6
23+
env: CS_FIXER=run
1824
- php: 5.4
1925
env: COMPOSER_FLAGS="--prefer-lowest"
2026
allow_failures:
@@ -25,8 +31,11 @@ matrix:
2531
before_script:
2632
- composer self-update
2733
- composer config -g github-oauth.github.com $GITHUB_OAUTH_TOKEN
34+
- composer global require fabpot/php-cs-fixer --no-update
35+
- composer global update --prefer-dist --no-interaction
2836
- composer update --prefer-dist --no-interaction $COMPOSER_FLAGS
2937

3038
script:
39+
- if [ "$CS_FIXER" = "run" ]; then php-cs-fixer fix --verbose --dry-run ; fi;
3140
- vendor/bin/phpspec run
3241
- vendor/bin/phpunit tests

spec/PropertyInfo/Extractors/DoctrineExtractorSpec.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99

1010
namespace spec\PropertyInfo\Extractors;
1111

12+
use Doctrine\ORM\EntityManager;
1213
use Doctrine\ORM\Mapping\Column;
1314
use Doctrine\ORM\Mapping\Entity;
1415
use Doctrine\ORM\Mapping\Id;
1516
use Doctrine\ORM\Mapping\ManyToMany;
1617
use Doctrine\ORM\Mapping\ManyToOne;
1718
use Doctrine\ORM\Tools\Setup;
18-
use Doctrine\ORM\EntityManager;
1919
use PhpSpec\ObjectBehavior;
2020

2121
/**

src/PropertyInfo/Extractors/NativeExtractor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
abstract class NativeExtractor implements TypeExtractorInterface
2222
{
2323
/**
24-
* @var PhpTypeInfoParser|HhvmTypeInfoParser
24+
* @var PhpTypeInfoParser|HhvmTypeInfoParser
2525
*/
2626
protected $typeInfoParser;
2727

src/PropertyInfo/TypeInfoParsers/HhvmTypeInfoParser.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@
2525
*/
2626
class HhvmTypeInfoParser extends NativeTypeInfoParser
2727
{
28-
protected static $types = array(
28+
protected static $types = [
2929
'HH\\bool' => 'bool',
3030
'HH\\int' => 'int',
3131
'HH\\float' => 'float',
3232
'HH\\double' => 'float',
3333
'HH\\string' => 'string',
3434
'callable' => 'callable',
3535
'array' => 'array',
36-
);
36+
];
3737

3838
/**
3939
* @param \ReflectionProperty $property
@@ -123,7 +123,7 @@ protected function parseContainerTypes($info)
123123

124124
if (false !== ($pos = strpos($info, '<'))) {
125125
$container = substr($info, 0, $pos);
126-
$contents = substr($info, $pos+1, -1);
126+
$contents = substr($info, $pos + 1, -1);
127127
$contents = explode(', ', $contents);
128128

129129
if ('array' === $container) {

src/PropertyInfo/TypeInfoParsers/NativeTypeInfoParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function getSetterParam(\ReflectionProperty $property)
6161
{
6262
$setter = $this->getSetter($property);
6363
if (null === $setter || 1 !== $setter->getNumberOfRequiredParameters()) {
64-
return null;
64+
return;
6565
}
6666

6767
$params = $setter->getParameters();

src/PropertyInfo/TypeInfoParsers/PhpTypeInfoParser.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class PhpTypeInfoParser extends NativeTypeInfoParser
2929
*/
3030
public function getPropertyType(\ReflectionProperty $property)
3131
{
32-
return null;
32+
return;
3333
}
3434

3535
/**
@@ -67,7 +67,6 @@ public function getSetterParamType(\ReflectionProperty $property)
6767
}
6868
}
6969

70-
7170
/**
7271
* @param string $info
7372
*
@@ -81,7 +80,7 @@ public function parse($info)
8180
$class = null;
8281

8382
if ($info === null) {
84-
return null;
83+
return;
8584
} elseif ($info === 'double') {
8685
$info = 'float';
8786
} elseif ($info === 'array') {

tests/DoctrineExtractors/DoctrineExtractorTest.php

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111

1212
use Doctrine\ORM\EntityManager;
1313
use Doctrine\ORM\Tools\Setup;
14-
use PropertyInfo\Extractors\DoctrineExtractor;
1514
use PropertyInfo\PropertyInfo;
16-
use PropertyInfo\Tests\DoctrineExtractors\Data\DoctrineDummy;
1715
use PropertyInfo\Type;
1816
use PropertyInfo\TypeExtractorInterface;
1917

@@ -24,41 +22,41 @@ class DoctrineExtractorTest extends \PHPUnit_Framework_TestCase
2422
{
2523
public function extractorsDataProvider()
2624
{
27-
$properties = array(
28-
array(
29-
'name' => 'id',
30-
'type' => 'int',
25+
$properties = [
26+
[
27+
'name' => 'id',
28+
'type' => 'int',
3129
'collection' => false,
32-
'class' => null,
33-
),
34-
array(
35-
'name' => 'guid',
36-
'type' => 'string',
30+
'class' => null,
31+
],
32+
[
33+
'name' => 'guid',
34+
'type' => 'string',
3735
'collection' => false,
38-
'class' => null,
39-
),
40-
array(
41-
'name' => 'bool',
42-
'type' => 'bool',
36+
'class' => null,
37+
],
38+
[
39+
'name' => 'bool',
40+
'type' => 'bool',
4341
'collection' => false,
44-
'class' => null,
45-
),
46-
array('name' => 'binary', 'type' => 'resource', 'collection' => false, 'class' => null),
47-
array('name' => 'json', 'type' => 'array', 'collection' => true, 'class' => null),
48-
array('name' => 'foo', 'type' => 'object', 'collection' => false, 'class' => 'PropertyInfo\Tests\DoctrineExtractors\Data\DoctrineRelation'),
49-
array(
50-
'name' => 'bar',
51-
'type' => 'object',
52-
'collection' => true,
53-
'class' => 'Doctrine\Common\Collections\Collection',
54-
'collectionType' => array('type' => 'object', 'collection' => false, 'class' => 'PropertyInfo\Tests\DoctrineExtractors\Data\DoctrineRelation'),
55-
),
56-
array('name' => 'notMapped', 'type' => null, 'collection' => false, 'class' => null),
57-
);
42+
'class' => null,
43+
],
44+
['name' => 'binary', 'type' => 'resource', 'collection' => false, 'class' => null],
45+
['name' => 'json', 'type' => 'array', 'collection' => true, 'class' => null],
46+
['name' => 'foo', 'type' => 'object', 'collection' => false, 'class' => 'PropertyInfo\Tests\DoctrineExtractors\Data\DoctrineRelation'],
47+
[
48+
'name' => 'bar',
49+
'type' => 'object',
50+
'collection' => true,
51+
'class' => 'Doctrine\Common\Collections\Collection',
52+
'collectionType' => ['type' => 'object', 'collection' => false, 'class' => 'PropertyInfo\Tests\DoctrineExtractors\Data\DoctrineRelation'],
53+
],
54+
['name' => 'notMapped', 'type' => null, 'collection' => false, 'class' => null],
55+
];
5856

59-
$cases = array(
60-
array('PropertyInfo\Tests\DoctrineExtractors\Data\DoctrineDummy', 'PropertyInfo\Extractors\DoctrineExtractor', $properties),
61-
);
57+
$cases = [
58+
['PropertyInfo\Tests\DoctrineExtractors\Data\DoctrineDummy', 'PropertyInfo\Extractors\DoctrineExtractor', $properties],
59+
];
6260

6361
return $cases;
6462
}

tests/NativeExtractors/DataProviders/Php5DataProvider.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99

1010
namespace PropertyInfo\Tests\NativeExtractors\DataProviders;
1111

12-
use PropertyInfo\Extractors\SetterExtractor;
13-
use PropertyInfo\Tests\NativeExtractors\Data\Php5Data;
14-
1512
/**
1613
* @author Mihai Stancu <stancu.t.mihai@gmail.com>
1714
*/
@@ -32,7 +29,7 @@ public function extractorsDataProvider()
3229
[
3330
'PropertyInfo\Tests\NativeExtractors\Data\Php5Data',
3431
'PropertyInfo\Extractors\SetterExtractor',
35-
$properties
32+
$properties,
3633
],
3734
];
3835

0 commit comments

Comments
 (0)
0