From 04542e76f65dd0ba0a4a9adfb52390927fe1bf29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentinas=20Bartusevi=C4=8Dius?= Date: Wed, 5 Dec 2018 17:34:46 +0200 Subject: [PATCH] properly handle dependencies in `setLinterConfigurationValue` --- CHANGELOG.md | 5 +++++ src/Lint/Linter/PhpCsFixerLinter.php | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fc5010..30065f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## 1.3.2 + +### Fixed +- properly handle dependencies in `setLinterConfigurationValue` + ## 1.2.0 ### Added diff --git a/src/Lint/Linter/PhpCsFixerLinter.php b/src/Lint/Linter/PhpCsFixerLinter.php index aadd746..84b68a9 100644 --- a/src/Lint/Linter/PhpCsFixerLinter.php +++ b/src/Lint/Linter/PhpCsFixerLinter.php @@ -2,6 +2,8 @@ class PhpCsFixerLinter extends \ArcanistExternalLinter { + const U_DIFF_FLAG = '--diff-format=udiff'; + /** * @var array */ @@ -47,7 +49,7 @@ public function __construct(LinterConfiguration $configuration = null) version_compare($this->getVersion(), '2.8.0', '>=') && $this->configuration->isUnifiedDiffFormat() ) { - $this->defaultFlags[] = '--diff-format=udiff'; + $this->defaultFlags[] = self::U_DIFF_FLAG; $unifiedDiffFormat = true; } @@ -138,6 +140,10 @@ public function setLinterConfigurationValue($key, $value) return; case 'unified_diff_format': $this->configuration->setUnifiedDiffFormat($value); + $this->lintMessageBuilder = new LintMessageBuilder($value); + if ($value === false && in_array(self::U_DIFF_FLAG, $this->defaultFlags, true)) { + unset($this->defaultFlags[array_search(self::U_DIFF_FLAG, $this->defaultFlags)]); + } return; }