aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSt├ęphane HULARD <s.hulard@chstudio.fr>2018-02-02 12:28:40 +0100
committerSt├ęphane HULARD <s.hulard@chstudio.fr>2018-02-02 12:28:44 +0100
commit9b0e270cd4e97d3aa7fa2d74b8df744629482eb8 (patch)
treeb057348b9bb2f88af0a32041ba58ed3107312e22
parente95b4da5f9fb58482818d17ff5363b57a6a92567 (diff)
downloadDevtools-9b0e270cd4e97d3aa7fa2d74b8df744629482eb8.zip
Devtools-9b0e270cd4e97d3aa7fa2d74b8df744629482eb8.tar.gz
Devtools-9b0e270cd4e97d3aa7fa2d74b8df744629482eb8.tar.bz2
fix(php-cs-fixer) Method signature changed.
Attached to #51. The PhpCsFixer\AbstractLinesBeforeNamespaceFixer::fixLinesBeforeNamespace signature as changed in PHP-CS-Fixer v2.8.1 : * The offending commit : FriendsOfPHP/PHP-CS-Fixer@d3a7101#diff-41cf271d3466dbb2548c606fee86f147L30 Since Hoa rely on the host installed php-cs-fixer binary, we have an edge case to check here...
-rw-r--r--Resource/PHPCSFixer/Fixer/NoBlankLinesBeforeEntity.php26
1 files changed, 25 insertions, 1 deletions
diff --git a/Resource/PHPCSFixer/Fixer/NoBlankLinesBeforeEntity.php b/Resource/PHPCSFixer/Fixer/NoBlankLinesBeforeEntity.php
index 4bc04ca..e942994 100644
--- a/Resource/PHPCSFixer/Fixer/NoBlankLinesBeforeEntity.php
+++ b/Resource/PHPCSFixer/Fixer/NoBlankLinesBeforeEntity.php
@@ -39,6 +39,7 @@ namespace Hoa\Devtools\Resource\PHPCSFixer\Fixer;
use PhpCsFixer\AbstractLinesBeforeNamespaceFixer;
use PhpCsFixer\FixerDefinition\FixerDefinition;
use PhpCsFixer\Tokenizer\Tokens;
+use PhpCsFixer\Console\Application;
use SplFileInfo;
/**
@@ -51,6 +52,21 @@ use SplFileInfo;
*/
class NoBlankLinesBeforeEntity extends AbstractLinesBeforeNamespaceFixer
{
+ /**
+ * Are we using php-cs-fixer > 2.8.0
+ * @var boolean
+ */
+ private $v28 = false;
+
+ public function __construct()
+ {
+ parent::__construct();
+
+ if (version_compare(Application::VERSION, '2.8.0') > 0) {
+ $this->v28 = true;
+ }
+ }
+
protected function applyfix(SplFileInfo $file, Tokens $tokens)
{
foreach ($tokens as $index => $token) {
@@ -64,7 +80,15 @@ class NoBlankLinesBeforeEntity extends AbstractLinesBeforeNamespaceFixer
false
);
$firstSignificantIndex = $tokens->getNextNonWhitespace($docCommentIndex);
- $this->fixLinesBeforeNamespace($tokens, $firstSignificantIndex, 1);
+
+ //The fixLinesBeforeNamespace has changed signature after the
+ //php-cs-fixer v2.8.1 release.
+ //@see https://github.com/FriendsOfPHP/PHP-CS-Fixer/commit/d3a71014777b2d5f35da75944c1ad2a6e983aed4#diff-41cf271d3466dbb2548c606fee86f147
+ if (true === $this->v28) {
+ $this->fixLinesBeforeNamespace($tokens, $firstSignificantIndex, 0, 1);
+ } else {
+ $this->fixLinesBeforeNamespace($tokens, $firstSignificantIndex, 1);
+ }
}
}