Skip to content

Commit 21ab33c

Browse files
committed
use finder to get the php-cs-fixer executable
1 parent aaa0d31 commit 21ab33c

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/Util/TemplateLinter.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bundle\MakerBundle\Util;
1313

1414
use Symfony\Bundle\MakerBundle\Exception\RuntimeCommandException;
15+
use Symfony\Component\Process\ExecutableFinder;
1516
use Symfony\Component\Process\Process;
1617

1718
/**
@@ -52,6 +53,7 @@ public function lintPhpTemplate(string|array $templateFilePath): void
5253

5354
foreach ($templateFilePath as $filePath) {
5455
$process = Process::fromShellCommandline(sprintf('php %s --config=%s --using-cache=no fix %s', $this->phpCsFixerBinaryPath, $this->phpCsFixerConfigPath, $filePath));
56+
5557
$process->run();
5658
}
5759
}
@@ -64,15 +66,10 @@ private function setBinary(): void
6466
return;
6567
}
6668

67-
$defaultBinaryPath = 'bin/php-cs-fixer';
68-
69-
if (file_exists($defaultBinaryPath)) {
70-
$this->phpCsFixerBinaryPath = $defaultBinaryPath;
71-
72-
return;
73-
}
74-
75-
$this->phpCsFixerBinaryPath = \dirname(__DIR__).'/Resources/bin/php-cs-fixer-v3.13.0.phar';
69+
$this->phpCsFixerBinaryPath = (new ExecutableFinder())->find(
70+
'php-cs-fixer',
71+
\dirname(__DIR__).'/Resources/bin/php-cs-fixer-v3.13.0.phar'
72+
);
7673
}
7774

7875
private function setConfig(): void

0 commit comments

Comments
 (0)