Skip to content

Commit

Permalink
Update PHP-CS-Fixer to v2.16 (#6)
Browse files Browse the repository at this point in the history
Also add Travis, and some small changes.
  • Loading branch information
dmvdbrugge authored Nov 4, 2019
2 parents 435f2c1 + 4c84bdf commit b45a67c
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 17 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
.idea/
.php_cs.cache

# Libraries should ignore the lock file
composer.lock

vendor/
10 changes: 8 additions & 2 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
<?php

declare(strict_types=1);

use Mollie\PhpCodingStandards\PhpCsFixer\Rules;
use PhpCsFixer\Config;
use PhpCsFixer\Finder;

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

$overrides = [
'declare_strict_types' => true,
];

return Config::create()
->setFinder($finder)
->setRiskyAllowed(true)
->setRules(Rules::getForPhp71());
->setRules(Rules::getForPhp71($overrides));
32 changes: 32 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
language: php

dist: xenial

matrix:
fast_finish: true
allow_failures:
- php: 7.4snapshot
- php: nightly
include:
- php: 7.1
- php: 7.2
- php: 7.3
- php: 7.4snapshot
- php: nightly

sudo: false

cache:
directories:
- "$HOME/.composer/cache"

env:
- COMPOSER_NO_INTERACTION=1

install:
- travis_retry composer install --no-suggest

script:
- composer validate --strict
- find src -name *.php | xargs -n 1 php -l
- vendor/bin/php-cs-fixer fix -v --dry-run
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mollie/php-coding-standards",
"description": "Contains PHP coding standards like rules for PHP-CS-Fixer that serves for purpose of standardization.",
"license": "proprietary",
"license": "BSD-2-Clause",
"type": "library",
"authors": [
{
Expand All @@ -17,6 +17,6 @@
"minimum-stability": "stable",
"require": {
"php": "^7.1.3",
"friendsofphp/php-cs-fixer": "^2.15"
"friendsofphp/php-cs-fixer": "^2.16"
}
}
32 changes: 19 additions & 13 deletions src/PhpCsFixer/Rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Mollie\PhpCodingStandards\PhpCsFixer;

/*
* Last updated for php-cs-fixer version: 2.15
* Last updated for php-cs-fixer version: 2.16
*/
class Rules
{
Expand Down Expand Up @@ -46,10 +46,7 @@ private static function getBaseRules(): array
'align_multiline_comment' => [
'comment_type' => 'all_multiline',
],
'array_indentation' => true,
'array_syntax' => [
'syntax' => 'short',
],
'array_indentation' => true,
'binary_operator_spaces' => [
'default' => 'align_single_space_minimal',
],
Expand All @@ -75,6 +72,7 @@ private static function getBaseRules(): array
'explicit_string_variable' => true,
'fully_qualified_strict_types' => true,
'function_to_constant' => true,
'global_namespace_import' => true,
// 'header_comment' => [ // Has too many issues atm
// 'header' => '',
// ],
Expand Down Expand Up @@ -105,14 +103,15 @@ private static function getBaseRules(): array
// TODO: Add 'use' when php-cs-fixer #3582 is fixed
],
],
'no_null_property_initialization' => true,
'no_superfluous_elseif' => true,
'no_superfluous_phpdoc_tags' => true,
'no_unset_cast' => true,
'no_unset_on_property' => false, // It's purposely used for the side effect :(
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_class_elements' => [
'no_null_property_initialization' => true,
'no_superfluous_elseif' => true,
'no_superfluous_phpdoc_tags' => true,
'no_unset_cast' => true,
'no_unset_on_property' => false, // It's purposely used for the side effect :(
'no_useless_else' => true,
'no_useless_return' => true,
'nullable_type_declaration_for_default_null_value' => true,
'ordered_class_elements' => [
'order' => [
'use_trait',
'constant_public', 'constant_protected', 'constant_private',
Expand All @@ -123,6 +122,12 @@ private static function getBaseRules(): array
'ordered_imports' => [
'imports_order' => ['class', 'function', 'const'],
],
'phpdoc_line_span' => [
'const' => 'single',
'method' => 'multi',
'property' => 'single',
],
'phpdoc_no_empty_return' => true,
'php_unit_construct' => true,
'php_unit_dedicate_assert_internal_type' => true,
'php_unit_method_casing' => true,
Expand All @@ -149,6 +154,7 @@ private static function getBaseRules(): array
'simple_to_complex_string_variable' => true,
'simplified_null_return' => false, // Too many old code places that become implicit, also ignores doc blocks.
'single_class_element_per_statement' => true,
'single_line_throw' => false,
'single_quote' => false,
'single_trait_insert_per_statement' => true,
'space_after_semicolon' => [
Expand Down

0 comments on commit b45a67c

Please sign in to comment.