Skip to content

Commit

Permalink
that should do it
Browse files Browse the repository at this point in the history
  • Loading branch information
jrushlow committed Feb 3, 2024
1 parent 0af0b55 commit f915a14
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions src/Util/TemplateLinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,21 @@ public function lintPhpTemplate(string|array $templateFilePath): void
$templateFilePath = [$templateFilePath];
}

foreach ($templateFilePath as $filePath) {
$cmdPrefix = $this->needsPhpCmdPrefix ? 'php ' : '';

if (str_contains(strtolower(\PHP_OS), 'win')) {
$process = Process::fromShellCommandline(sprintf('set PHP_CS_FIXER_IGNORE_ENV=1&%s%s --config=%s --using-cache=no fix %s', $cmdPrefix, $this->phpCsFixerBinaryPath, $this->phpCsFixerConfigPath, $filePath));
} else {
$process = Process::fromShellCommandline(sprintf('PHP_CS_FIXER_IGNORE_ENV=1 %s%s --config=%s --using-cache=no fix %s', $cmdPrefix, $this->phpCsFixerBinaryPath, $this->phpCsFixerConfigPath, $filePath));
}
$ignoreEnv = str_contains(strtolower(\PHP_OS), 'win') ? 'set PHP_CS_FIXER_IGNORE_ENV=1&' : 'PHP_CS_FIXER_IGNORE_ENV=1 ';

$stat = $process->run();
$cmdPrefix = $this->needsPhpCmdPrefix ? 'php ' : '';

dd($stat, ['output' => $process->getOutput(), 'err' => $process->getErrorOutput(), 'exit' => $process->getExitCode()]);
foreach ($templateFilePath as $filePath) {
Process::fromShellCommandline(sprintf(
'%s%s%s --config=%s --using-cache=no fix %s',
$ignoreEnv,
$cmdPrefix,
$this->phpCsFixerBinaryPath,
$this->phpCsFixerConfigPath,
$filePath
))
->run()
;
}
}

Expand All @@ -87,26 +90,19 @@ public function writeLinterMessage(OutputInterface $output): void
;

$output->writeln([$fixerMessage, '']); // Empty string so we have an empty line

dump(['fixer message' => $fixerMessage]);
}

private function setBinary(): void
{
// Use Bundled PHP-CS-Fixer
if (null === $this->phpCsFixerBinaryPath) {
dump(['php-cs-fixer path' => $this->phpCsFixerBinaryPath]);
$this->phpCsFixerBinaryPath = \dirname(__DIR__).'/Resources/bin/php-cs-fixer-v3.13.0.phar';

return;
}

// Path to PHP-CS-Fixer provided
if (is_file($this->phpCsFixerBinaryPath)) {
dump(['is_file' => is_file($this->phpCsFixerBinaryPath),
'is_executable' => (is_file($this->phpCsFixerBinaryPath) && is_executable($this->phpCsFixerBinaryPath)),
'is_readable' => $this->phpCsFixerBinaryPath]
);
$this->usingBundledPhpCsFixer = false;

return;
Expand All @@ -115,7 +111,6 @@ private function setBinary(): void
// PHP-CS-Fixer in the system path?
if (null !== $path = (new ExecutableFinder())->find($this->phpCsFixerBinaryPath)) {
$this->phpCsFixerBinaryPath = $path;
dump(['is in system path' => $this->phpCsFixerBinaryPath]);

$this->needsPhpCmdPrefix = false;
$this->usingBundledPhpCsFixer = false;
Expand Down

0 comments on commit f915a14

Please sign in to comment.