Skip to content

Commit b8a8d81

Browse files
SonataCIsoullivaneuh
authored andcommitted
DevKit updates
1 parent e1b2797 commit b8a8d81

7 files changed

+114
-78
lines changed

.php_cs

+2-37
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,5 @@
11
<?php
22

3-
/*
4-
* DO NOT EDIT THIS FILE!
5-
*
6-
* It's auto-generated by sonata-project/dev-kit package.
7-
*
8-
* Package `sllh/php-cs-fixer-styleci-bridge` is required to get it working.
9-
*/
3+
// TO BE REMOVED.
104

11-
require_once __DIR__.'/vendor/sllh/php-cs-fixer-styleci-bridge/autoload.php';
12-
13-
use SLLH\StyleCIBridge\ConfigBridge;
14-
15-
$header = <<<EOF
16-
This file is part of the Sonata Project package.
17-
18-
(c) Thomas Rabaix <[email protected]>
19-
20-
For the full copyright and license information, please view the LICENSE
21-
file that was distributed with this source code.
22-
EOF;
23-
24-
// PHP-CS-Fixer 1.x
25-
if (class_exists('Symfony\CS\Fixer\Contrib\HeaderCommentFixer')) {
26-
\Symfony\CS\Fixer\Contrib\HeaderCommentFixer::setHeader($header);
27-
}
28-
29-
$config = ConfigBridge::create()
30-
->setUsingCache(true)
31-
;
32-
33-
// PHP-CS-Fixer 2.x
34-
if (method_exists($config, 'setRules')) {
35-
$config->setRules(array_merge($config->getRules(), array(
36-
'header_comment' => array('header' => $header)
37-
)));
38-
}
39-
40-
return $config;
5+
return require_once __DIR__.'/.php_cs.dist';

.php_cs.dist

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?php
2+
3+
/**
4+
* DO NOT EDIT THIS FILE!
5+
*
6+
* It's auto-generated by sonata-project/dev-kit package.
7+
*/
8+
9+
$header = <<<'HEADER'
10+
This file is part of the Sonata Project package.
11+
12+
(c) Thomas Rabaix <[email protected]>
13+
14+
For the full copyright and license information, please view the LICENSE
15+
file that was distributed with this source code.
16+
HEADER;
17+
18+
$rules = [
19+
'@Symfony' => true,
20+
'@Symfony:risky' => true,
21+
'array_syntax' => [
22+
'syntax' => 'short',
23+
],
24+
'combine_consecutive_issets' => true,
25+
'combine_consecutive_unsets' => true,
26+
'header_comment' => [
27+
'header' => $header,
28+
],
29+
'no_extra_consecutive_blank_lines' => true,
30+
'no_php4_constructor' => true,
31+
'no_useless_else' => true,
32+
'no_useless_return' => true,
33+
'ordered_class_elements' => true,
34+
'ordered_imports' => true,
35+
'phpdoc_order' => true,
36+
'ternary_to_null_coalescing' => true,
37+
// To be tested before insertion:
38+
// 'strict_comparison' => true,
39+
// 'strict_param' => true,
40+
// 'php_unit_strict' => true,
41+
];
42+
43+
if (\PHP_VERSION_ID >= 50600) {
44+
$rules = array_merge($rules, [
45+
'@PHP56Migration' => true,
46+
'@PHP56Migration:risky' => true,
47+
'@PHPUnit57Migration:risky' => true,
48+
]);
49+
}
50+
if (\PHP_VERSION_ID >= 70000) {
51+
$rules = array_merge($rules, [
52+
'@PHP70Migration:risky' => true,
53+
'@PHPUnit60Migration:risky' => true,
54+
]);
55+
}
56+
if (\PHP_VERSION_ID >= 70100) {
57+
$rules = array_merge($rules, [
58+
'@PHP71Migration:risky' => true,
59+
'compact_nullable_typehint' => true,
60+
]);
61+
}
62+
63+
$finder = PhpCsFixer\Finder::create()
64+
->in(preg_match('/dev-kit\/project$/', __DIR__, $matches) ? __DIR__.'/..' : __DIR__)
65+
->exclude('Tests/Fixtures')
66+
->exclude('tests/Fixtures')
67+
->exclude('Resources/skeleton')
68+
->exclude('Resources/public/vendor')
69+
;
70+
71+
return PhpCsFixer\Config::create()
72+
->setFinder($finder)
73+
->setRiskyAllowed(true)
74+
->setRules($rules)
75+
->setUsingCache(true)
76+
;

.styleci.yml

+1-30
Original file line numberDiff line numberDiff line change
@@ -1,30 +1 @@
1-
# DO NOT EDIT THIS FILE!
2-
#
3-
# It's auto-generated by sonata-project/dev-kit package.
4-
#
5-
# Package `sllh/php-cs-fixer-styleci-bridge` is required to get it working.
6-
7-
preset: symfony
8-
9-
enabled:
10-
- combine_consecutive_unsets
11-
- short_array_syntax
12-
- newline_after_open_tag
13-
- no_php4_constructor
14-
- no_useless_else
15-
- ordered_class_elements
16-
- ordered_use
17-
# Comment strict rules for the moment. Should be uncomment later to see StyleCI PR results
18-
# - strict
19-
# - strict_param
20-
# - php_unit_construct
21-
# - php_unit_strict
22-
23-
finder:
24-
exclude:
25-
- 'Tests/Fixtures'
26-
- 'tests/Fixtures'
27-
# ecommerce special case:
28-
- 'Resources/skeleton'
29-
# ignore vendor assets
30-
- 'Resources/public/vendor'
1+
# TO BE REMOVED

.travis.yml

+12-11
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ php:
1313
- '5.6'
1414
- '7.0'
1515
- '7.1'
16+
- '7.2'
1617
- nightly
1718

1819
sudo: false
@@ -34,29 +35,29 @@ env:
3435
matrix:
3536
fast_finish: true
3637
include:
37-
- php: '7.1'
38+
- php: '7.2'
3839
env: TARGET=docs
39-
- php: '7.1'
40+
- php: '5.6'
4041
env: TARGET=lint
4142
- php: '5.6'
4243
env: COMPOSER_FLAGS="--prefer-lowest"
43-
- php: '7.1'
44+
- php: '7.2'
4445
env: SYMFONY=2.8.*
45-
- php: '7.1'
46+
- php: '7.2'
4647
env: SYMFONY='dev-master as 2.8.x-dev'
47-
- php: '7.1'
48+
- php: '7.2'
4849
env: FOS_USER=1.3.*
49-
- php: '7.1'
50+
- php: '7.2'
5051
env: FOS_USER='dev-master as 1.3.x-dev'
51-
- php: '7.1'
52+
- php: '7.2'
5253
env: SONATA_CORE=3.*
53-
- php: '7.1'
54+
- php: '7.2'
5455
env: SONATA_CORE='dev-master as 3.x-dev'
55-
- php: '7.1'
56+
- php: '7.2'
5657
env: SONATA_ADMIN=3.*
57-
- php: '7.1'
58+
- php: '7.2'
5859
env: SONATA_ADMIN='dev-master as 3.x-dev'
59-
- php: '7.1'
60+
- php: '7.2'
6061
env: SYMFONY_DEPRECATIONS_HELPER=0
6162
allow_failures:
6263
- php: nightly

.travis/install_lint.sh

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
#!/usr/bin/env sh
22
set -ev
33

4+
mkdir --parents "${HOME}/bin"
5+
6+
wget "http://cs.sensiolabs.org/download/php-cs-fixer-v2.phar" --output-document="${HOME}/bin/php-cs-fixer"
7+
chmod u+x "${HOME}/bin/php-cs-fixer"
8+
49
composer global require sllh/composer-lint:@stable --prefer-dist --no-interaction
510

611
gem install yaml-lint

CONTRIBUTING.md

+17
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,23 @@ and run this command before committing your modifications:
7272
php-cs-fixer fix --verbose
7373
```
7474

75+
Please note that we try to keep phpdoc to a minimum, so if an `@param` phpdoc
76+
comment brings nothing more than the type hint and variable name already do,
77+
it should be removed. Descriptions are optional if you want to document a type.
78+
79+
```php
80+
/**
81+
* @param Bar|Baz $foo
82+
* @param int $limit a crucial, highly interesting comment
83+
*/
84+
protected function bar($foo, string $name, int $limit)
85+
{
86+
// ...
87+
}
88+
```
89+
90+
Please also note that multiline signatures are allowed when the line is longer than 120 characters.
91+
7592
#### The documentation
7693

7794
The documentation is mostly written with the `rst` format, and can be found in the `docs` directory.

Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ lint:
1313
find . \( -name '*.xml' -or -name '*.xliff' \) \
1414
-not -path './vendor/*' -not -path './Resources/public/vendor/*' -type f \
1515
-exec xmllint --encode UTF-8 --output '{}' --format '{}' \;
16+
php-cs-fixer fix --verbose
1617
git diff --exit-code
1718

1819
test:

0 commit comments

Comments
 (0)