Skip to content

Commit b45a67c

Browse files
authored
Update PHP-CS-Fixer to v2.16 (#6)
Also add Travis, and some small changes.
2 parents 435f2c1 + 4c84bdf commit b45a67c

File tree

5 files changed

+67
-17
lines changed

5 files changed

+67
-17
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1+
.idea/
12
.php_cs.cache
3+
4+
# Libraries should ignore the lock file
5+
composer.lock
6+
7+
vendor/

.php_cs.dist

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
use Mollie\PhpCodingStandards\PhpCsFixer\Rules;
46
use PhpCsFixer\Config;
57
use PhpCsFixer\Finder;
68

79
$finder = Finder::create()
8-
->name('.php_cs.dist') // Fix this file as well
10+
->name('.php_cs.dist') // Fix this file as well
911
->in(__DIR__);
1012

13+
$overrides = [
14+
'declare_strict_types' => true,
15+
];
16+
1117
return Config::create()
1218
->setFinder($finder)
1319
->setRiskyAllowed(true)
14-
->setRules(Rules::getForPhp71());
20+
->setRules(Rules::getForPhp71($overrides));

.travis.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
language: php
2+
3+
dist: xenial
4+
5+
matrix:
6+
fast_finish: true
7+
allow_failures:
8+
- php: 7.4snapshot
9+
- php: nightly
10+
include:
11+
- php: 7.1
12+
- php: 7.2
13+
- php: 7.3
14+
- php: 7.4snapshot
15+
- php: nightly
16+
17+
sudo: false
18+
19+
cache:
20+
directories:
21+
- "$HOME/.composer/cache"
22+
23+
env:
24+
- COMPOSER_NO_INTERACTION=1
25+
26+
install:
27+
- travis_retry composer install --no-suggest
28+
29+
script:
30+
- composer validate --strict
31+
- find src -name *.php | xargs -n 1 php -l
32+
- vendor/bin/php-cs-fixer fix -v --dry-run

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "mollie/php-coding-standards",
33
"description": "Contains PHP coding standards like rules for PHP-CS-Fixer that serves for purpose of standardization.",
4-
"license": "proprietary",
4+
"license": "BSD-2-Clause",
55
"type": "library",
66
"authors": [
77
{
@@ -17,6 +17,6 @@
1717
"minimum-stability": "stable",
1818
"require": {
1919
"php": "^7.1.3",
20-
"friendsofphp/php-cs-fixer": "^2.15"
20+
"friendsofphp/php-cs-fixer": "^2.16"
2121
}
2222
}

src/PhpCsFixer/Rules.php

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace Mollie\PhpCodingStandards\PhpCsFixer;
66

77
/*
8-
* Last updated for php-cs-fixer version: 2.15
8+
* Last updated for php-cs-fixer version: 2.16
99
*/
1010
class Rules
1111
{
@@ -46,10 +46,7 @@ private static function getBaseRules(): array
4646
'align_multiline_comment' => [
4747
'comment_type' => 'all_multiline',
4848
],
49-
'array_indentation' => true,
50-
'array_syntax' => [
51-
'syntax' => 'short',
52-
],
49+
'array_indentation' => true,
5350
'binary_operator_spaces' => [
5451
'default' => 'align_single_space_minimal',
5552
],
@@ -75,6 +72,7 @@ private static function getBaseRules(): array
7572
'explicit_string_variable' => true,
7673
'fully_qualified_strict_types' => true,
7774
'function_to_constant' => true,
75+
'global_namespace_import' => true,
7876
// 'header_comment' => [ // Has too many issues atm
7977
// 'header' => '',
8078
// ],
@@ -105,14 +103,15 @@ private static function getBaseRules(): array
105103
// TODO: Add 'use' when php-cs-fixer #3582 is fixed
106104
],
107105
],
108-
'no_null_property_initialization' => true,
109-
'no_superfluous_elseif' => true,
110-
'no_superfluous_phpdoc_tags' => true,
111-
'no_unset_cast' => true,
112-
'no_unset_on_property' => false, // It's purposely used for the side effect :(
113-
'no_useless_else' => true,
114-
'no_useless_return' => true,
115-
'ordered_class_elements' => [
106+
'no_null_property_initialization' => true,
107+
'no_superfluous_elseif' => true,
108+
'no_superfluous_phpdoc_tags' => true,
109+
'no_unset_cast' => true,
110+
'no_unset_on_property' => false, // It's purposely used for the side effect :(
111+
'no_useless_else' => true,
112+
'no_useless_return' => true,
113+
'nullable_type_declaration_for_default_null_value' => true,
114+
'ordered_class_elements' => [
116115
'order' => [
117116
'use_trait',
118117
'constant_public', 'constant_protected', 'constant_private',
@@ -123,6 +122,12 @@ private static function getBaseRules(): array
123122
'ordered_imports' => [
124123
'imports_order' => ['class', 'function', 'const'],
125124
],
125+
'phpdoc_line_span' => [
126+
'const' => 'single',
127+
'method' => 'multi',
128+
'property' => 'single',
129+
],
130+
'phpdoc_no_empty_return' => true,
126131
'php_unit_construct' => true,
127132
'php_unit_dedicate_assert_internal_type' => true,
128133
'php_unit_method_casing' => true,
@@ -149,6 +154,7 @@ private static function getBaseRules(): array
149154
'simple_to_complex_string_variable' => true,
150155
'simplified_null_return' => false, // Too many old code places that become implicit, also ignores doc blocks.
151156
'single_class_element_per_statement' => true,
157+
'single_line_throw' => false,
152158
'single_quote' => false,
153159
'single_trait_insert_per_statement' => true,
154160
'space_after_semicolon' => [

0 commit comments

Comments
 (0)