Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate correct cs-fixer path in .arclint #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
],
"require": {
"php": "^5.5 || ^7.0",
"ext-json": "*",
"ptlis/diff-parser": "^0.6.0"
},
"require-dev": {
Expand Down
9 changes: 5 additions & 4 deletions composer/ArcConfigParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Composer\Config;
use Composer\Script\Event;
use LinterConfiguration;

class ArcConfigParser
{
Expand All @@ -15,10 +16,10 @@ class ArcConfigParser
public static function parseArcConfig(Event $event)
{
$phpCsBinary = $event->getComposer()->getConfig()
->get('bin-dir', Config::RELATIVE_PATHS) . '/php-cs-fixer';
->get('bin-dir', Config::RELATIVE_PATHS) . '/' . LinterConfiguration::BINARY_FILE;

if (!file_exists($phpCsBinary)) {
$phpCsBinary = 'php-cs-fixer';
$phpCsBinary = LinterConfiguration::BINARY_FILE;
}

$parsedConfig = self::parseAndPrepareArcConfig($phpCsBinary);
Expand Down Expand Up @@ -53,15 +54,15 @@ private static function parseAndPrepareArcConfig($phpCsBinary)
}

if (!isset($arcConfig['lint.php_cs_fixer.fix_paths'])) {
$arcConfig['lint.php_cs_fixer.fix_paths'] = [\LinterConfiguration::SRC_DIRECTORY];
$arcConfig['lint.php_cs_fixer.fix_paths'] = [LinterConfiguration::SRC_DIRECTORY];
}

if (!isset($arcConfig['lint.php_cs_fixer.php_cs_binary'])) {
$arcConfig['lint.php_cs_fixer.php_cs_binary'] = $phpCsBinary;
}

if (!isset($arcConfig['lint.php_cs_fixer.php_cs_file'])) {
$arcConfig['lint.php_cs_fixer.php_cs_file'] = \LinterConfiguration::PHP_CS_FILE;
$arcConfig['lint.php_cs_fixer.php_cs_file'] = LinterConfiguration::PHP_CS_FILE;
}

if (!isset($arcConfig['lint.php_cs_fixer.unified_diff_format'])) {
Expand Down
6 changes: 5 additions & 1 deletion src/Lint/Engine/PhpCsFixerLintEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ public function buildLinters()
$fixerPaths = $configManager
->getConfigFromAnySource('lint.php_cs_fixer.fix_paths', [LinterConfiguration::SRC_DIRECTORY]);
$binaryPath = $configManager
->getConfigFromAnySource('lint.php_cs_fixer.php_cs_binary', LinterConfiguration::BINARY_FILE);
->getConfigFromAnySource(
'lint.php_cs_fixer.php_cs_binary',
LinterConfiguration::BIN_DIRECTORY . LinterConfiguration::BINARY_FILE
)
;

foreach ($paths as $key => $path) {
if (!file_exists($this->getFilePathOnDisk($path))) {
Expand Down
5 changes: 3 additions & 2 deletions src/Lint/Linter/LinterConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
class LinterConfiguration
{
const SRC_DIRECTORY = 'src/';
const BIN_DIRECTORY = 'bin/';
const PHP_CS_FILE = '.php_cs';
const BINARY_FILE = 'bin/paysera-php-cs-fixer';
const BINARY_FILE = 'paysera-php-cs-fixer';

/**
* @var string
Expand All @@ -29,7 +30,7 @@ class LinterConfiguration
public function __construct()
{
$this->paths = [];
$this->binaryFile = self::BINARY_FILE;
$this->binaryFile = self::BIN_DIRECTORY . self::BINARY_FILE;
$this->phpCsFile = self::PHP_CS_FILE;
$this->unifiedDiffFormat = true;
}
Expand Down