From 3ab60f5bd570c0dbd9d070a3ef87477cf80fc5c0 Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Mon, 18 Feb 2019 15:47:10 +0300 Subject: [PATCH] Fix compatibility with the PHP-CS-Fixer 2.13.3 and above --- .travis.yml | 3 ++- composer.lock | 1 + src/Fixer/Whitespace/BlankLineAroundClassBodyFixer.php | 5 +++-- src/Fixer/Whitespace/LineBreakAfterStatementsFixer.php | 5 +++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 062bd4e..0780ba1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ php: - '7.0' - '7.1' - '7.2' + - '7.3' - nightly cache: @@ -25,7 +26,7 @@ stages: jobs: include: - stage: Static Code Analysis - php: 7.2 + php: 7.3 script: - vendor/bin/php-cs-fixer fix -v --dry-run allow_failures: diff --git a/composer.lock b/composer.lock index 2d9c1d8..ae3e1a4 100644 --- a/composer.lock +++ b/composer.lock @@ -1887,6 +1887,7 @@ "mock", "xunit" ], + "abandoned": true, "time": "2018-08-07T07:02:44+00:00" }, { diff --git a/src/Fixer/Whitespace/BlankLineAroundClassBodyFixer.php b/src/Fixer/Whitespace/BlankLineAroundClassBodyFixer.php index 15d7e0a..730469f 100644 --- a/src/Fixer/Whitespace/BlankLineAroundClassBodyFixer.php +++ b/src/Fixer/Whitespace/BlankLineAroundClassBodyFixer.php @@ -10,10 +10,10 @@ use PhpCsFixer\FixerConfiguration\FixerConfigurationResolver; use PhpCsFixer\FixerConfiguration\FixerOptionBuilder; use PhpCsFixer\FixerDefinition\CodeSample; use PhpCsFixer\FixerDefinition\FixerDefinition; +use PhpCsFixer\Preg; use PhpCsFixer\Tokenizer\Token; use PhpCsFixer\Tokenizer\Tokens; use PhpCsFixer\Tokenizer\TokensAnalyzer; -use PhpCsFixer\Utils; /** * This is copy of the PR https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/3688 @@ -142,7 +142,8 @@ new class extends Foo { } // The final bit of the whitespace must be the next statement's indentation - $lines = Utils::splitLines($content); + Preg::matchAll('/[^\n\r]+[\r\n]*/', $content, $matches); + $lines = $matches[0]; $eol = $this->whitespacesConfig->getLineEnding(); $tokens[$index] = new Token([T_WHITESPACE, str_repeat($eol, $countLines + 1) . end($lines)]); } diff --git a/src/Fixer/Whitespace/LineBreakAfterStatementsFixer.php b/src/Fixer/Whitespace/LineBreakAfterStatementsFixer.php index 39a8824..23ab743 100644 --- a/src/Fixer/Whitespace/LineBreakAfterStatementsFixer.php +++ b/src/Fixer/Whitespace/LineBreakAfterStatementsFixer.php @@ -7,9 +7,9 @@ use Ely\CS\Fixer\AbstractFixer; use PhpCsFixer\Fixer\WhitespacesAwareFixerInterface; use PhpCsFixer\FixerDefinition\CodeSample; use PhpCsFixer\FixerDefinition\FixerDefinition; +use PhpCsFixer\Preg; use PhpCsFixer\Tokenizer\Token; use PhpCsFixer\Tokenizer\Tokens; -use PhpCsFixer\Utils; use SplFileInfo; /** @@ -123,7 +123,8 @@ class Foo } // The final bit of the whitespace must be the next statement's indentation - $lines = Utils::splitLines($content); + Preg::matchAll('/[^\n\r]+[\r\n]*/', $content, $matches); + $lines = $matches[0]; $eol = $this->whitespacesConfig->getLineEnding(); $tokens[$index] = new Token([T_WHITESPACE, str_repeat($eol, $countLines + 1) . end($lines)]); }