Просмотр исходного кода

rules - change default options

Dariusz Ruminski 7 лет назад
Родитель
Сommit
9993d51053
10 измененных файлов с 394 добавлено и 61 удалено
  1. 6 4
      .composer-require-checker.json
  2. 3 1
      .gitattributes
  3. 35 17
      .php_cs.dist
  4. 31 9
      .travis.yml
  5. 211 0
      CHANGELOG.md
  6. 71 13
      README.rst
  7. 9 0
      UPGRADE-v3.md
  8. 10 10
      benchmark.sh
  9. 16 7
      check_trailing_spaces.sh
  10. 2 0
      circle.yml

+ 6 - 4
.composer-require-checker.json

@@ -1,12 +1,15 @@
 {
     "symbol-whitelist" : [
-        "HHVM_VERSION_ID",
-        "PHPUnit\\Framework\\TestCase", "Prophecy\\Argument",
-        "GeckoPackages\\PHPUnit\\Constraints\\SameStringsConstraint",
+        "PhpCsFixer\\Tests\\Test\\Constraint\\SameStringsConstraint",
+        "PHPUnit\\Framework\\Constraint\\IsIdentical",
+        "PHPUnit\\Framework\\TestCase",
+        "PHPUnit\\Runner\\Version",
         "PHPUnitGoodPractices\\Traits\\ExpectationViaCodeOverAnnotationTrait",
         "PHPUnitGoodPractices\\Traits\\ExpectOverSetExceptionTrait",
         "PHPUnitGoodPractices\\Traits\\IdentityOverEqualityTrait",
         "PHPUnitGoodPractices\\Traits\\ProphecyOverMockObjectTrait",
+        "PHPUnitGoodPractices\\Traits\\ProphesizeOnlyInterfaceTrait",
+        "Prophecy\\Argument",
 
         "null", "true", "false",
         "static", "self", "parent",
@@ -14,7 +17,6 @@
     ],
     "php-core-extensions" : [
         "dom", "mbstring", "Phar",
-
         "Core", "date", "pcre", "Reflection", "SPL", "standard"
     ]
 }

+ 3 - 1
.gitattributes

@@ -1,4 +1,4 @@
-# @TODO 3.0 replace following `tests/... exportignore` with single `tests/ export-ignore`
+# @TODO 3.0 replace following `tests/... export-ignore` with single `tests/ export-ignore`
 tests/**/*Test.php export-ignore
 tests/AbstractDoctrineAnnotationFixerTestCase.php export-ignore
 tests/Differ/AbstractDifferTestCase.php export-ignore
@@ -6,6 +6,7 @@ tests/Fixtures/ export-ignore
 tests/Linter/AbstractLinterTestCase.php export-ignore
 tests/Report/AbstractReporterTestCase.php export-ignore
 tests/Test/AbstractTransformerTestCase.php export-ignore
+tests/Test/Constraint/XmlMatchesXsdConstraint.php export-ignore
 
 .appveyor.yml export-ignore
 .composer-require-checker.json export-ignore
@@ -19,6 +20,7 @@ box.json export-ignore
 check_trailing_spaces.sh export-ignore
 phpmd.xml export-ignore
 phpunit.xml.dist export-ignore
+
 *       text=auto eol=lf
 *.php   text whitespace=blank-at-eol,blank-at-eof,space-before-tab,tab-in-indent,tabwidth=4 diff=php
 *.json  text whitespace=blank-at-eol,blank-at-eof,space-before-tab,tab-in-indent,tabwidth=4

+ 35 - 17
.php_cs.dist

@@ -10,6 +10,18 @@ This source file is subject to the MIT license that is bundled
 with this source code in the file LICENSE.
 EOF;
 
+$finder = PhpCsFixer\Finder::create()
+    ->exclude('tests/Fixtures')
+    ->in(__DIR__)
+;
+
+if (PHP_VERSION_ID < 70000) {
+    $finder
+        ->notPath('tests/Test/Constraint/SameStringsConstraintForV7.php')
+        ->notPath('tests/Test/Constraint/XmlMatchesXsdConstraintForV7.php')
+    ;
+}
+
 $config = PhpCsFixer\Config::create()
     ->setRiskyAllowed(true)
     ->setRules([
@@ -18,21 +30,26 @@ $config = PhpCsFixer\Config::create()
         '@Symfony' => true,
         '@Symfony:risky' => true,
         'align_multiline_comment' => true,
+        'array_indentation' => true,
         'array_syntax' => ['syntax' => 'short'],
         'blank_line_before_statement' => true,
         'combine_consecutive_issets' => true,
         'combine_consecutive_unsets' => true,
+        'comment_to_phpdoc' => true,
         'compact_nullable_typehint' => true,
         'escape_implicit_backslashes' => true,
         'explicit_indirect_variable' => true,
         'explicit_string_variable' => true,
         'final_internal_class' => true,
+        'fully_qualified_strict_types' => true,
+        'function_to_constant' => true,
         'header_comment' => ['header' => $header],
         'heredoc_to_nowdoc' => true,
         'list_syntax' => ['syntax' => 'long'],
-        'method_chaining_indentation' => true,
         'method_argument_space' => ['ensure_fully_multiline' => true],
+        'method_chaining_indentation' => true,
         'multiline_comment_opening_closing' => true,
+        'no_alternative_syntax' => true,
         'no_extra_blank_lines' => ['tokens' => ['break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block']],
         'no_null_property_initialization' => true,
         'no_short_echo_tag' => true,
@@ -44,6 +61,8 @@ $config = PhpCsFixer\Config::create()
         'no_useless_return' => true,
         'ordered_class_elements' => true,
         'ordered_imports' => true,
+        'php_unit_ordered_covers' => true,
+        'php_unit_set_up_tear_down_visibility' => true,
         'php_unit_strict' => true,
         'php_unit_test_annotation' => true,
         'php_unit_test_class_requires_covers' => true,
@@ -54,27 +73,26 @@ $config = PhpCsFixer\Config::create()
         'single_line_comment_style' => true,
         'strict_comparison' => true,
         'strict_param' => true,
+        'string_line_ending' => true,
         'yoda_style' => true,
     ])
-    ->setFinder(
-        PhpCsFixer\Finder::create()
-            ->exclude('tests/Fixtures')
-            ->in(__DIR__)
-    )
+    ->setFinder($finder)
 ;
 
 // special handling of fabbot.io service if it's using too old PHP CS Fixer version
-try {
-    PhpCsFixer\FixerFactory::create()
-        ->registerBuiltInFixers()
-        ->registerCustomFixers($config->getCustomFixers())
-        ->useRuleSet(new PhpCsFixer\RuleSet($config->getRules()));
-} catch (PhpCsFixer\ConfigurationException\InvalidConfigurationException $e) {
-    $config->setRules([]);
-} catch (UnexpectedValueException $e) {
-    $config->setRules([]);
-} catch (InvalidArgumentException $e) {
-    $config->setRules([]);
+if (false !== getenv('FABBOT_IO')) {
+    try {
+        PhpCsFixer\FixerFactory::create()
+            ->registerBuiltInFixers()
+            ->registerCustomFixers($config->getCustomFixers())
+            ->useRuleSet(new PhpCsFixer\RuleSet($config->getRules()));
+    } catch (PhpCsFixer\ConfigurationException\InvalidConfigurationException $e) {
+        $config->setRules([]);
+    } catch (UnexpectedValueException $e) {
+        $config->setRules([]);
+    } catch (InvalidArgumentException $e) {
+        $config->setRules([]);
+    }
 }
 
 return $config;

+ 31 - 9
.travis.yml

@@ -8,6 +8,7 @@ git:
 cache:
     directories:
         - $HOME/.composer
+        - $HOME/bin
 
 env:
     global:
@@ -33,25 +34,45 @@ jobs:
 
                 - travis_retry composer update $DEFAULT_COMPOSER_FLAGS $COMPOSER_FLAGS
                 - composer info -D | sort
+
+                - wget --no-clobber --output-document=$HOME/bin/checkbashisms https://sourceforge.net/projects/checkbaskisms/files/2.0.0.2/checkbashisms/download || true
+                - chmod +x $HOME/bin/checkbashisms
             before_script:
                 - if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then COMMIT_RANGE=$TRAVIS_COMMIT_RANGE; else COMMIT_RANGE="HEAD~..HEAD"; fi;
                 - export COMMIT_SCA_FILES=`git diff --name-only --diff-filter=ACMRTUXB $COMMIT_RANGE`
             script:
                 # @TODO remove at 3.0
-                - git archive -o /dev/null HEAD -v 2>&1 | grep tests | grep \.php | grep -v tests/TestCase.php | grep -v tests/Test/Assert/AssertTokensTrait.php | grep -v tests/Test/AbstractFixerTestCase.php | grep -v tests/Test/AbstractIntegrationTestCase.php | grep -v tests/Test/IntegrationCase.php | grep -v tests/Test/IntegrationCaseFactory.php && (echo "UNKNOWN FILES DETECTED" && travis_terminate 1) || echo "NO UNKNOWN FILES"
-
+                - |
+                  git archive -o /dev/null HEAD -v 2>&1 | grep tests | grep \.php \
+                    | grep -v tests/Test/AbstractFixerTestCase.php \
+                    | grep -v tests/Test/AbstractIntegrationCaseFactory.php \
+                    | grep -v tests/Test/AbstractIntegrationTestCase.php \
+                    | grep -v tests/Test/Assert/AssertTokensTrait.php \
+                    | grep -v tests/Test/Constraint/SameStringsConstraint.php \
+                    | grep -v tests/Test/Constraint/SameStringsConstraintForV5.php \
+                    | grep -v tests/Test/Constraint/SameStringsConstraintForV7.php \
+                    | grep -v tests/Test/Constraint/XmlMatchesXsdConstraint.php \
+                    | grep -v tests/Test/Constraint/XmlMatchesXsdConstraintForV5.php \
+                    | grep -v tests/Test/Constraint/XmlMatchesXsdConstraintForV7.php \
+                    | grep -v tests/Test/IntegrationCase.php \
+                    | grep -v tests/Test/IntegrationCaseFactory.php \
+                    | grep -v tests/Test/IntegrationCaseFactoryInterface.php \
+                    | grep -v tests/Test/InternalIntegrationCaseFactory.php \
+                    | grep -v tests/TestCase.php \
+                    && (echo "UNKNOWN FILES DETECTED" && travis_terminate 1) || echo "NO UNKNOWN FILES"
                 - ./check_trailing_spaces.sh || travis_terminate 1
-                - if [ -n "$COMMIT_SCA_FILES" ]; then ./dev-tools/vendor/bin/phpmd `echo "$COMMIT_SCA_FILES" | grep -Ev "^(src/Resources|tests/Fixtures)" | xargs | sed 's/ /,/g'` text phpmd.xml || travis_terminate 1; fi
-                - ./dev-tools/vendor/bin/composer-require-checker check composer.json --config-file=.composer-require-checker.json
-
+                - if [ -n "$COMMIT_SCA_FILES" ]; then ./dev-tools/vendor/bin/phpmd `echo "$COMMIT_SCA_FILES" | grep -Ev "^tests/Fixtures" | xargs | sed 's/ /,/g'` text phpmd.xml || travis_terminate 1; fi
+                - ./dev-tools/vendor/bin/composer-require-checker check composer.json --config-file=.composer-require-checker.json || travis_terminate 1
+                - composer normalize -d ./dev-tools ./../composer.json --dry-run
+                - ./dev-tools/check-shell-scripts.sh
 
         - &STANDARD_TEST_JOB
             stage: Fast Test
             php: 7.0
             install:
                 # Composer: enforce given Symfony components version
-                - 'if [ "$SYMFONY_VERSION" != "" ]; then sed -i "s/\"symfony\/\([^\"]*\)\": \"^3[^\"]*\"/\"symfony\/\1\": \"$SYMFONY_VERSION\"/g" composer.json; fi'
-                - 'if [ "$MIN_STABILITY" != "" ]; then composer config minimum-stability $MIN_STABILITY; fi'
+                - if [ "$SYMFONY_VERSION" != "" ]; then composer require --no-update symfony/force-lowest:$SYMFONY_VERSION; fi
+                - if [ "$SYMFONY_VERSION" != "" ]; then composer require --no-update symfony/lts:$(echo $SYMFONY_VERSION | grep -o 'v[0-9]\+') || true; fi
 
                 - travis_retry composer update $DEFAULT_COMPOSER_FLAGS $COMPOSER_FLAGS
                 - composer info -D | sort
@@ -69,7 +90,7 @@ jobs:
             <<: *STANDARD_TEST_JOB
             stage: Test
             php: 7.1
-            env: SYMFONY_DEPRECATIONS_HELPER=weak SYMFONY_VERSION="^4.0" MIN_STABILITY=dev
+            env: SYMFONY_DEPRECATIONS_HELPER=weak SYMFONY_VERSION="v4.0"
 
         -
             <<: *STANDARD_TEST_JOB
@@ -84,7 +105,8 @@ jobs:
                 - if [ $TRAVIS_TAG ]; then export COLLECT_COVERAGE=0; fi
             script:
                 - if [ $COLLECT_COVERAGE == 0 ]; then vendor/bin/phpunit || travis_terminate 1; fi
-                - if [ $COLLECT_COVERAGE == 1 ]; then phpdbg -qrr vendor/bin/phpunit --coverage-clover build/logs/clover.xml || travis_terminate 1; fi
+                - if [ $COLLECT_COVERAGE == 1 ]; then vendor/bin/phpunit --group covers-nothing || travis_terminate 1; fi
+                - if [ $COLLECT_COVERAGE == 1 ]; then phpdbg -qrr vendor/bin/phpunit --exclude-group covers-nothing --coverage-clover build/logs/clover.xml || travis_terminate 1; fi
                 - PHP_CS_FIXER_FUTURE_MODE=1 php php-cs-fixer --diff --dry-run -v fix || travis_terminate 1
                 - if [ $COLLECT_COVERAGE == 1 ]; then php vendor/bin/php-coveralls -v; fi
 

+ 211 - 0
CHANGELOG.md

@@ -3,6 +3,124 @@ CHANGELOG for PHP CS Fixer
 
 This file contains changelogs for stable releases only.
 
+Changelog for v2.11.1
+---------------------
+
+* bug #3626 ArrayIndentationFixer: priority bug with BinaryOperatorSpacesFixer and MethodChainingIndentationFixer (Slamdunk)
+* bug #3632 DateTimeImmutableFixer bug with adding tokens while iterating over them (kubawerlos)
+* minor #3478 PhpUnitDedicateAssertFixer: handle static calls (Slamdunk)
+* minor #3618 DateTimeImmutableFixer - grooming (keradus)
+
+Changelog for v2.11.0
+---------------------
+
+* feature #3135 Add ArrayIndentationFixer (julienfalque)
+* feature #3235 Implement StandardizeIncrementFixer (ntzm, SpacePossum)
+* feature #3260 Add DateTimeImmutableFixer (kubawerlos)
+* feature #3276 Transform Fully Qualified parameters and return types to short version (veewee, keradus)
+* feature #3299 SingleQuoteFixer - fix single quote char (Slamdunk)
+* feature #3340 Verbose LintingException after fixing (Slamdunk)
+* feature #3423 FunctionToConstantFixer - add fix "get_called_class" option (SpacePossum)
+* feature #3434 Add PhpUnitSetUpTearDownVisibilityFixer (BackEndTea, SpacePossum)
+* feature #3442 Add CommentToPhpdocFixer (kubawerlos, keradus)
+* feature #3448 OrderedClassElementsFixer - added sortAlgorithm option (meridius)
+* feature #3454 Add StringLineEndingFixer (iluuu1994, SpacePossum, keradus, julienfalque)
+* feature #3477 PhpUnitStrictFixer: handle static calls (Slamdunk)
+* feature #3479 PhpUnitConstructFixer: handle static calls (Slamdunk)
+* feature #3507 Add PhpUnitOrderedCoversFixer (Slamdunk)
+* feature #3545 Add the 'none' sort algorithm to OrderedImportsFixer (EvgenyOrekhov)
+* feature #3588 Add NoAlternativeSyntaxFixer (eddmash, keradus)
+* minor #3414 DescribeCommand: add fixer class when verbose (Slamdunk)
+* minor #3432 ConfigurationDefinitionFixerInterface - fix deprecation notice (keradus)
+* minor #3527 Deprecate last param of Tokens::findBlockEnd (ntzm, keradus)
+* minor #3539 Update UnifiedDiffOutputBuilder from gecko-packages/gecko-diff-output-builder usage after it was incorporated into sebastian/diff (keradus)
+* minor #3549 DescribeCommand - use our Differ wrapper class, not external one directly (keradus)
+* minor #3592 Support PHPUnit 7 (keradus)
+* minor #3619 Travis - extend additional files list (keradus)
+
+Changelog for v2.10.5
+---------------------
+
+* bug #3344 Fix method chaining indentation in HTML (julienfalque)
+* bug #3594 ElseifFixer - Bug with alternative syntax (kubawerlos)
+* bug #3600 StrictParamFixer - Fix issue when functions are imported (ntzm, keradus)
+* minor #3589 FixerFactoryTest - add missing test (SpacePossum, keradus)
+* minor #3610 make phar extension optional (Tom Klingenberg, keradus)
+* minor #3612 Travis - allow for hhvm failures (keradus)
+* minor #3615 Detect fabbot.io (julienfalque, keradus)
+* minor #3616 FixerFactoryTest - Don't rely on autovivification (keradus)
+* minor #3621 FixerFactoryTest - apply CS (keradus)
+
+Changelog for v2.10.4
+---------------------
+
+* bug #3446 Add PregWrapper (kubawerlos)
+* bug #3464 IncludeFixer - fix incorrect order of fixing (kubawerlos, SpacePossum)
+* bug #3496 Bug in Tokens::removeLeadingWhitespace (kubawerlos, SpacePossum, keradus)
+* bug #3557 AbstractDoctrineAnnotationFixer: edge case bugfix (Slamdunk)
+* bug #3574 GeneralPhpdocAnnotationRemoveFixer - remove PHPDoc if no content is left (SpacePossum)
+* minor #3563 DX add missing covers annotations (keradus)
+* minor #3564 Use ::class keyword when possible (keradus)
+* minor #3565 Use EventDispatcherInterface instead of EventDispatcher when possible (keradus)
+* minor #3566 Update PHPUnitGoodPractices\Traits (keradus)
+* minor #3572 DX: allow for more phpunit-speedtrap versions to support more PHPUnit versions (keradus)
+* minor #3576 Fix Doctrine Annotation test cases merging (julienfalque)
+* minor #3577 DoctrineAnnotationArrayAssignmentFixer - Add test case (julienfalque)
+
+Changelog for v2.10.3
+---------------------
+
+* bug #3504 NoBlankLinesAfterPhpdocFixer - allow blank line before declare statement (julienfalque)
+* bug #3522 Remove LOCK_EX (SpacePossum)
+* bug #3560 SelfAccessorFixer is risky (Slamdunk)
+* minor #3435 Add tests for general_phpdoc_annotation_remove (BackEndTea)
+* minor #3484 Create Tokens::findBlockStart (ntzm)
+* minor #3512 Add missing array typehints (ntzm)
+* minor #3513 Making AppVeyor happy (kubawerlos)
+* minor #3516 Use null|type instead of ?type in PHPDocs (ntzm)
+* minor #3518 FixerFactoryTest - Test each priority test file is listed as test (SpacePossum)
+* minor #3519 Fix typo (SpacePossum)
+* minor #3520 Fix typos: ran vs. run (SpacePossum)
+* minor #3521 Use HTTPS (carusogabriel)
+* minor #3526 Remove gecko dependency (SpacePossum, keradus, julienfalque)
+* minor #3531 Backport PHPMD to LTS version to ease maintainability (keradus)
+* minor #3532 Implement Tokens::findOppositeBlockEdge (ntzm)
+* minor #3533 DX: SCA - drop src/Resources exclusion (keradus)
+* minor #3538 Don't use third parameter of Tokens::findBlockStart (ntzm)
+* minor #3542 Enhancement: Run composer-normalize on Travis CI (localheinz, keradus)
+* minor #3550 AutoReview\FixerFactoryTest - fix missing priority test, mark not fully valid test as incomplete (keradus)
+* minor #3555 DX: composer.json - drop branch-alias, branch is already following the version (keradus)
+* minor #3556 DX: Add AutoReview/ComposerTest (keradus)
+* minor #3559 Don't expose new files under Test namespace (keradus)
+* minor #3561 PHPUnit5 - add in place missing compat layer for PHPUnit6 (keradus)
+
+Changelog for v2.10.2
+---------------------
+
+* bug #3502 Fix missing file in export (keradus)
+
+Changelog for v2.10.1
+---------------------
+
+* bug #3265 YodaFixer - fix problems of block statements followed by ternary statements (weareoutman, keradus, SpacePossum)
+* bug #3367 NoUnusedImportsFixer - fix comment handling (SpacePossum, keradus)
+* bug #3438 PhpUnitTestAnnotationFixer: Do not prepend with test if method is test() (localheinz, SpacePossum)
+* bug #3455 NoEmptyCommentFixer - comment block detection for line ending different than LF (kubawerlos, SpacePossum)
+* bug #3458 SilencedDeprecationErrorFixer - fix edge cases (kubawerlos)
+* bug #3466 no_whitespace_in_blank_line and no_blank_lines_after_phpdoc fixers bug (kubawerlos, keradus)
+* bug #3472  YodaStyleFixer - do not un-Yoda if right side is assignment (SpacePossum, keradus)
+* bug #3492 PhpdocScalarFixer - Add callback pesudo-type to callable type (carusogabriel)
+* minor #3354 Added missing types to the PhpdocTypesFixer (GrahamCampbell)
+* minor #3406 Fix for escaping in README (kubawerlos)
+* minor #3430 Fix integration test (SpacePossum)
+* minor #3431 Add missing tests (SpacePossum)
+* minor #3440 Add a handful of integration tests (BackEndTea)
+* minor #3443 ConfigurableFixerInterface - not deprecated but TODO (SpacePossum)
+* minor #3444 IntegrationTest - ensure tests in priority dir are priority tests indeed (keradus)
+* minor #3494 Add missing PHPDoc param type (ntzm)
+* minor #3495 Swap @var type and element (ntzm)
+* minor #3498 NoUnusedImportsFixer - fix deprecation (keradus)
+
 Changelog for v2.10.0
 ---------------------
 
@@ -20,6 +138,31 @@ Changelog for v2.10.0
 * minor #3418 ConfigurableFixerInterface, ConfigurationDefinitionFixerInterface - update deprecations (keradus)
 * minor #3419 Dont use deprecated fixer in itest (keradus)
 
+Changelog for v2.9.3
+--------------------
+
+* bug #3502 Fix missing file in export (keradus)
+
+Changelog for v2.9.2
+--------------------
+
+* bug #3265 YodaFixer - fix problems of block statements followed by ternary statements (weareoutman, keradus, SpacePossum)
+* bug #3367 NoUnusedImportsFixer - fix comment handling (SpacePossum, keradus)
+* bug #3438 PhpUnitTestAnnotationFixer: Do not prepend with test if method is test() (localheinz, SpacePossum)
+* bug #3455 NoEmptyCommentFixer - comment block detection for line ending different than LF (kubawerlos, SpacePossum)
+* bug #3458 SilencedDeprecationErrorFixer - fix edge cases (kubawerlos)
+* bug #3466 no_whitespace_in_blank_line and no_blank_lines_after_phpdoc fixers bug (kubawerlos, keradus)
+* bug #3472  YodaStyleFixer - do not un-Yoda if right side is assignment (SpacePossum, keradus)
+* minor #3354 Added missing types to the PhpdocTypesFixer (GrahamCampbell)
+* minor #3406 Fix for escaping in README (kubawerlos)
+* minor #3430 Fix integration test (SpacePossum)
+* minor #3431 Add missing tests (SpacePossum)
+* minor #3440 Add a handful of integration tests (BackEndTea)
+* minor #3444 IntegrationTest - ensure tests in priority dir are priority tests indeed (keradus)
+* minor #3494 Add missing PHPDoc param type (ntzm)
+* minor #3495 Swap @var type and element (ntzm)
+* minor #3498 NoUnusedImportsFixer - fix deprecation (keradus)
+
 Changelog for v2.9.1
 --------------------
 
@@ -492,6 +635,74 @@ Changelog for v2.3.0
 * minor #2568 Require PHP 5.6+ (keradus)
 * minor #2672 Bump symfony/* deps (keradus)
 
+Changelog for v2.2.19
+---------------------
+
+* bug #3594 ElseifFixer - Bug with alternative syntax (kubawerlos)
+* bug #3600 StrictParamFixer - Fix issue when functions are imported (ntzm, keradus)
+* minor #3589 FixerFactoryTest - add missing test (SpacePossum, keradus)
+* minor #3610 make phar extension optional (Tom Klingenberg, keradus)
+* minor #3612 Travis - allow for hhvm failures (keradus)
+* minor #3615 Detect fabbot.io (julienfalque, keradus)
+* minor #3616 FixerFactoryTest - Don't rely on autovivification (keradus)
+
+Changelog for v2.2.18
+---------------------
+
+* bug #3446 Add PregWrapper (kubawerlos)
+* bug #3464 IncludeFixer - fix incorrect order of fixing (kubawerlos, SpacePossum)
+* bug #3496 Bug in Tokens::removeLeadingWhitespace (kubawerlos, SpacePossum, keradus)
+* bug #3557 AbstractDoctrineAnnotationFixer: edge case bugfix (Slamdunk)
+* bug #3574 GeneralPhpdocAnnotationRemoveFixer - remove PHPDoc if no content is left (SpacePossum)
+* minor #3563 DX add missing covers annotations (keradus)
+* minor #3565 Use EventDispatcherInterface instead of EventDispatcher when possible (keradus)
+* minor #3572 DX: allow for more phpunit-speedtrap versions to support more PHPUnit versions (keradus)
+* minor #3576 Fix Doctrine Annotation test cases merging (julienfalque)
+
+Changelog for v2.2.17
+---------------------
+
+* bug #3504 NoBlankLinesAfterPhpdocFixer - allow blank line before declare statement (julienfalque)
+* bug #3522 Remove LOCK_EX (SpacePossum)
+* bug #3560 SelfAccessorFixer is risky (Slamdunk)
+* minor #3435 Add tests for general_phpdoc_annotation_remove (BackEndTea)
+* minor #3484 Create Tokens::findBlockStart (ntzm)
+* minor #3512 Add missing array typehints (ntzm)
+* minor #3516 Use null|type instead of ?type in PHPDocs (ntzm)
+* minor #3518 FixerFactoryTest - Test each priority test file is listed as test (SpacePossum)
+* minor #3520 Fix typos: ran vs. run (SpacePossum)
+* minor #3521 Use HTTPS (carusogabriel)
+* minor #3526 Remove gecko dependency (SpacePossum, keradus, julienfalque)
+* minor #3531 Backport PHPMD to LTS version to ease maintainability (keradus)
+* minor #3532 Implement Tokens::findOppositeBlockEdge (ntzm)
+* minor #3533 DX: SCA - drop src/Resources exclusion (keradus)
+* minor #3538 Don't use third parameter of Tokens::findBlockStart (ntzm)
+* minor #3542 Enhancement: Run composer-normalize on Travis CI (localheinz, keradus)
+* minor #3555 DX: composer.json - drop branch-alias, branch is already following the version (keradus)
+* minor #3556 DX: Add AutoReview/ComposerTest (keradus)
+* minor #3559 Don't expose new files under Test namespace (keradus)
+
+Changelog for v2.2.16
+---------------------
+
+* bug #3502 Fix missing file in export (keradus)
+
+Changelog for v2.2.15
+---------------------
+
+* bug #3367 NoUnusedImportsFixer - fix comment handling (SpacePossum, keradus)
+* bug #3455 NoEmptyCommentFixer - comment block detection for line ending different than LF (kubawerlos, SpacePossum)
+* bug #3458 SilencedDeprecationErrorFixer - fix edge cases (kubawerlos)
+* bug #3466 no_whitespace_in_blank_line and no_blank_lines_after_phpdoc fixers bug (kubawerlos, keradus)
+* minor #3354 Added missing types to the PhpdocTypesFixer (GrahamCampbell)
+* minor #3406 Fix for escaping in README (kubawerlos)
+* minor #3431 Add missing tests (SpacePossum)
+* minor #3440 Add a handful of integration tests (BackEndTea)
+* minor #3444 IntegrationTest - ensure tests in priority dir are priority tests indeed (keradus)
+* minor #3494 Add missing PHPDoc param type (ntzm)
+* minor #3495 Swap @var type and element (ntzm)
+* minor #3498 NoUnusedImportsFixer - fix deprecation (keradus)
+
 Changelog for v2.2.14
 ---------------------
 

+ 71 - 13
README.rst

@@ -46,7 +46,7 @@ or with specified version:
 
 .. code-block:: bash
 
-    $ wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.10.0/php-cs-fixer.phar -O php-cs-fixer
+    $ wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.11.1/php-cs-fixer.phar -O php-cs-fixer
 
 or with curl:
 
@@ -245,6 +245,10 @@ Choose from the list of available rules:
     whose lines all start with an asterisk (``phpdocs_like``) or any
     multi-line comment (``all_multiline``); defaults to ``'phpdocs_only'``
 
+* **array_indentation**
+
+  Each element of an array must be indented exactly once.
+
 * **array_syntax**
 
   PHP arrays should be declared using the configured syntax.
@@ -353,6 +357,12 @@ Choose from the list of available rules:
 
   Calling ``unset`` on multiple items should be done in one call.
 
+* **comment_to_phpdoc**
+
+  Comments with annotation should be docblock.
+
+  *Risky rule: risky as new docblocks might began mean more, e.g. Doctrine's entity might have a new column in database.*
+
 * **compact_nullable_typehint**
 
   Remove extra spaces in a nullable typehint.
@@ -366,6 +376,12 @@ Choose from the list of available rules:
   - ``spacing`` (``'none'``, ``'one'``): spacing to apply around concatenation operator;
     defaults to ``'none'``
 
+* **date_time_immutable**
+
+  Class ``DateTimeImmutable`` should be used instead of ``DateTime``.
+
+  *Risky rule: risky when the code relies on modifying ``DateTime`` object or if any of the ``date_create*`` functions are overridden.*
+
 * **declare_equal_normalize** [@Symfony]
 
   Equal sign in declare statement should be surrounded by spaces or not
@@ -578,6 +594,11 @@ Choose from the list of available rules:
   PHP code must use the long ``<?php`` tags or short-echo ``<?=`` tags and not
   other tag variations.
 
+* **fully_qualified_strict_types**
+
+  Transforms imported FQCN parameters and return types in function
+  arguments to short version.
+
 * **function_declaration** [@PSR2, @Symfony]
 
   Spaces should be properly placed in a function declaration.
@@ -596,7 +617,7 @@ Choose from the list of available rules:
   Configuration options:
 
   - ``functions`` (``array``): list of function names to fix; defaults to
-    ``['get_class', 'php_sapi_name', 'phpversion', 'pi']``
+    ``['get_called_class', 'get_class', 'php_sapi_name', 'phpversion', 'pi']``
 
 * **function_typehint_space** [@Symfony]
 
@@ -705,7 +726,7 @@ Choose from the list of available rules:
   Configuration options:
 
   - ``ensure_fully_multiline`` (``bool``): ensure every argument of a multiline
-    argument list is on its own line; defaults to ``false``
+    argument list is on its own line; defaults to ``true``
   - ``keep_multiple_spaces_after_comma`` (``bool``): whether keep multiple spaces
     after comma; defaults to ``false``
 
@@ -763,6 +784,10 @@ Choose from the list of available rules:
 
   *Risky rule: risky when any of the alias functions are overridden.*
 
+* **no_alternative_syntax**
+
+  Replace control structure alternative syntax to use braces.
+
 * **no_blank_lines_after_class_opening** [@Symfony]
 
   There should be no empty lines after class opening brace.
@@ -985,6 +1010,8 @@ Choose from the list of available rules:
     'constant_private', 'property_public', 'property_protected',
     'property_private', 'construct', 'destruct', 'magic', 'phpunit',
     'method_public', 'method_protected', 'method_private']``
+  - ``sortAlgorithm`` (``'alpha'``, ``'none'``): how multiple occurrences of same type
+    statements should be sorted; defaults to ``'none'``
 
 * **ordered_imports**
 
@@ -994,8 +1021,9 @@ Choose from the list of available rules:
 
   - ``importsOrder`` (``array``, ``null``): defines the order of import types; defaults
     to ``null``
-  - ``sortAlgorithm`` (``'alpha'``, ``'length'``): whether the statements should be
-    sorted alphabetically or by length; defaults to ``'alpha'``
+  - ``sortAlgorithm`` (``'alpha'``, ``'length'``, ``'none'``): whether the statements should
+    be sorted alphabetically or by length, or not sorted; defaults to
+    ``'alpha'``
 
 * **php_unit_construct** [@Symfony:risky]
 
@@ -1019,7 +1047,7 @@ Choose from the list of available rules:
   Configuration options:
 
   - ``target`` (``'3.0'``, ``'3.5'``, ``'5.0'``, ``'5.6'``, ``'newest'``): target version of
-    PHPUnit; defaults to ``'5.0'``
+    PHPUnit; defaults to ``'newest'``
 
 * **php_unit_expectation** [@PHPUnit52Migration:risky, @PHPUnit54Migration:risky, @PHPUnit55Migration:risky, @PHPUnit56Migration:risky, @PHPUnit57Migration:risky, @PHPUnit60Migration:risky]
 
@@ -1075,6 +1103,17 @@ Choose from the list of available rules:
     ``'newest'``
   - ``use_class_const`` (``bool``): use ::class notation; defaults to ``true``
 
+* **php_unit_ordered_covers**
+
+  Order ``@covers`` annotation of PHPUnit tests.
+
+* **php_unit_set_up_tear_down_visibility**
+
+  Changes the visibility of the setUp and tearDown functions of phpunit to
+  protected, to match the PHPUnit TestCase.
+
+  *Risky rule: this fixer may change functions named setUp or tearDown outside of PHPUnit tests, when a class is wrongly seen as a PHPUnit test.*
+
 * **php_unit_strict**
 
   PHPUnit methods like ``assertSame`` should be used instead of
@@ -1121,8 +1160,8 @@ Choose from the list of available rules:
 
   Configuration options:
 
-  - ``tags`` (``array``): the tags that should be aligned; defaults to ``['param',
-    'return', 'throws', 'type', 'var']``
+  - ``tags`` (``array``): the tags that should be aligned; defaults to ``['method',
+    'param', 'property', 'return', 'throws', 'type', 'var']``
 
 * **phpdoc_annotation_without_dot** [@Symfony]
 
@@ -1280,11 +1319,13 @@ Choose from the list of available rules:
   - ``space_before`` (``'none'``, ``'one'``): spacing to apply before colon; defaults to
     ``'none'``
 
-* **self_accessor** [@Symfony]
+* **self_accessor** [@Symfony:risky]
 
   Inside class or interface element "self" should be preferred to the
   class name itself.
 
+  *Risky rule: risky when using dynamic calls like get_called_class() or late static binding.*
+
 * **semicolon_after_instruction** [@Symfony]
 
   Instructions must be terminated with a semicolon.
@@ -1346,6 +1387,11 @@ Choose from the list of available rules:
 
   Convert double quotes to single quotes for simple strings.
 
+  Configuration options:
+
+  - ``strings_containing_single_quote_chars`` (``bool``): whether to fix
+    double-quoted strings that contains single-quotes; defaults to ``false``
+
 * **space_after_semicolon** [@Symfony]
 
   Fix whitespace after a semicolon.
@@ -1355,6 +1401,10 @@ Choose from the list of available rules:
   - ``remove_in_empty_for_expressions`` (``bool``): whether spaces should be removed
     for empty ``for`` expressions; defaults to ``false``
 
+* **standardize_increment** [@Symfony]
+
+  Increment and decrement operators should be used if possible.
+
 * **standardize_not_equals** [@Symfony]
 
   Replace all ``<>`` with ``!=``.
@@ -1377,6 +1427,12 @@ Choose from the list of available rules:
 
   *Risky rule: risky when the fixed function is overridden or if the code relies on non-strict usage.*
 
+* **string_line_ending**
+
+  All multi-line strings must use correct line ending.
+
+  *Risky rule: changing the line endings of multi-line strings might affect string comparisons and outputs.*
+
 * **switch_case_semicolon_to_colon** [@PSR2, @Symfony]
 
   A case should be followed by a colon and not a semicolon.
@@ -1456,7 +1512,7 @@ Config file
 
 Instead of using command line options to customize the rule, you can save the
 project configuration in a ``.php_cs.dist`` file in the root directory of your project.
-The file must return an instance of `PhpCsFixer\\ConfigInterface <https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/v2.10.0/src/ConfigInterface.php>`_
+The file must return an instance of `PhpCsFixer\\ConfigInterface <https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/v2.11.1/src/ConfigInterface.php>`_
 which lets you configure the rules, the files and directories that
 need to be analyzed. You may also create ``.php_cs`` file, which is
 the local configuration that will be used instead of the project configuration. It
@@ -1487,7 +1543,7 @@ The example below will add two rules to the default list of PSR2 set rules:
 
 **NOTE**: ``exclude`` will work only for directories, so if you need to exclude file, try ``notPath``.
 
-See `Symfony\\Finder <http://symfony.com/doc/current/components/finder.html>`_
+See `Symfony\\Finder <https://symfony.com/doc/current/components/finder.html>`_
 online documentation for other `Finder` methods.
 
 You may also use a blacklist for the rules instead of the above shown whitelist approach.
@@ -1567,9 +1623,11 @@ Then, add the following command to your CI:
 
 .. code-block:: bash
 
+    $ IFS='
+    $ '
     $ CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRTUXB "${COMMIT_RANGE}")
-    $ if ! echo "${CHANGED_FILES}" | grep -qE "^(\\.php_cs(\\.dist)?|composer\\.lock)$"; then IFS=$'\n' EXTRA_ARGS=('--path-mode=intersection' '--' ${CHANGED_FILES[@]}); fi
-    $ vendor/bin/php-cs-fixer fix --config=.php_cs.dist -v --dry-run --stop-on-violation --using-cache=no "${EXTRA_ARGS[@]}"
+    $ if ! echo "${CHANGED_FILES}" | grep -qE "^(\\.php_cs(\\.dist)?|composer\\.lock)$"; then EXTRA_ARGS=$(printf -- '--path-mode=intersection\n--\n%s' "${CHANGED_FILES}"); fi
+    $ vendor/bin/php-cs-fixer fix --config=.php_cs.dist -v --dry-run --stop-on-violation --using-cache=no ${EXTRA_ARGS}
 
 Where ``$COMMIT_RANGE`` is your range of commits, eg ``$TRAVIS_COMMIT_RANGE`` or ``HEAD~..HEAD``.
 

+ 9 - 0
UPGRADE-v3.md

@@ -56,3 +56,12 @@ Rule | Option | Change
 `is_null`                          | `use_yoda_style` | option was removed, use `yoda_style` rule instead
 `no_extra_consecutive_blank_lines` | `tokens`    | one of possible values, `useTrait`, was renamed to `use_trait`
 `php_unit_dedicate_assert`         | `functions` | option was removed, use `target` instead
+
+### Changed default values of options
+
+Rule | Option | Old value | New value
+---- | ---- | ---- | ----
+`function_to_constant` | `functions` | `['get_class', 'php_sapi_name', 'phpversion', 'pi']` | `['get_called_class', 'get_class', 'php_sapi_name', 'phpversion', 'pi']`
+`method_argument_space` | `ensure_fully_multiline` | `false` | `true`
+`php_unit_dedicate_assert` | `target` | `5.0` | `newest`
+`phpdoc_align` | `tags` | `['param', 'return', 'throws', 'type', 'var']` | `['method', 'param', 'property', 'return', 'throws', 'type', 'var']`

+ 10 - 10
benchmark.sh

@@ -1,21 +1,21 @@
-#!/bin/bash
+#!/bin/sh
 
-command -v php >/dev/null 2>&1 || { echo "I require `php` but it's not available. Aborting." >&2; exit 255; }
-command -v grep >/dev/null 2>&1 || { echo "I require `grep` but it's not available. Aborting." >&2; exit 255; }
-command -v awk >/dev/null 2>&1 || { echo "I require `awk` but it's not available. Aborting." >&2; exit 255; }
+command -v php >/dev/null 2>&1 || { echo "I require \`php\` but it's not available. Aborting." >&2; exit 255; }
+command -v grep >/dev/null 2>&1 || { echo "I require \`grep\` but it's not available. Aborting." >&2; exit 255; }
+command -v awk >/dev/null 2>&1 || { echo "I require \`awk\` but it's not available. Aborting." >&2; exit 255; }
 
-if [ "" == "$1" ] || [ "" == "$2" ];
+if [ "" = "$1" ] || [ "" = "$2" ];
 then
     echo "Usage: bash benchmark.sh BRANCH1 BRANCH2 ...BRANCHN"
     exit 1;
 fi
 
-for BRANCH in $@
+for BRANCH in "$@"
 do
-    git checkout $BRANCH &> /dev/null &&
-    git reset --hard &> /dev/null &&
-    echo -n $BRANCH
-    (for i in {1..10}; do php php-cs-fixer fix --dry-run 2> /dev/null ; done) | grep -i seconds | awk '
+    git checkout "$BRANCH" > /dev/null 2>&1 &&
+    git reset --hard > /dev/null 2>&1 &&
+    printf '%s' "$BRANCH"
+    (for _ in $(seq 1 10); do php php-cs-fixer fix --dry-run 2> /dev/null ; done) | grep -i seconds | awk '
     {
         total += $5;
         ++count;

+ 16 - 7
check_trailing_spaces.sh

@@ -1,14 +1,23 @@
-#!/bin/bash
+#!/bin/sh
 
-files_with_trailing_spaces=$(find . -type f -not -path "./.git/*" -not -path "./dev-tools/vendor/*" -not -path "./vendor/*" -not -path "./tests/Fixtures/*" -exec egrep -nH " $" {} \;)
+files_with_trailing_spaces=$(
+    find . \
+        -type f \
+        -not -path "./.git/*" \
+        -not -path "./dev-tools/vendor/*" \
+        -not -path "./vendor/*" \
+        -not -path "./tests/Fixtures/*" \
+        -exec grep -EIHn "\\s$" {} \; \
+    | sort -fh
+)
 
-if [[ $files_with_trailing_spaces ]]
+if [ "$files_with_trailing_spaces" ]
 then
-    echo -e "\e[97;41mTrailing spaces detected:\e[0m"
+    printf '\033[97;41mTrailing whitespaces detected:\033[0m\n'
     e=$(printf '\033')
-    echo "${files_with_trailing_spaces}" | sed -E "s/^\.\/([^:]+):([0-9]+):(.*[^ ])( +)$/${e}[0;31m - in ${e}[0;33m\1${e}[0;31m at line ${e}[0;33m\2\n   ${e}[0;31m>${e}[0m \3${e}[41m\4${e}[0m/"
+    echo "${files_with_trailing_spaces}" | sed -E "s/^\\.\\/([^:]+):([0-9]+):(.*[^\\t ])?([\\t ]+)$/${e}[0;31m - in ${e}[0;33m\\1${e}[0;31m at line ${e}[0;33m\\2\\n   ${e}[0;31m>${e}[0m \\3${e}[41;1m\\4${e}[0m/"
 
-    exit 1
+    exit 3
 fi
 
-echo -e "\e[0;32mNo trailing spaces detected.\e[0m"
+printf '\033[0;32mNo trailing whitespaces detected.\033[0m\n'

+ 2 - 0
circle.yml

@@ -14,6 +14,8 @@ dependencies:
         - brew update
         - brew tap homebrew/homebrew-php
         - brew install php71
+        - mkdir $(brew --prefix)/etc/php/7.1/conf.d
+        - echo "memory_limit = 512M" > $(brew --prefix)/etc/php/7.1/conf.d/memory.ini
         - curl -sS https://getcomposer.org/installer | php
         - php composer.phar global show hirak/prestissimo -q || php composer.phar global require --no-interaction --no-progress --optimize-autoloader hirak/prestissimo
     override:

Некоторые файлы не были показаны из-за большого количества измененных файлов