|
12 | 12 | namespace Symfony\Bundle\MakerBundle\Util;
|
13 | 13 |
|
14 | 14 | use Symfony\Bundle\MakerBundle\Exception\RuntimeCommandException;
|
15 |
| -use Symfony\Bundle\MakerBundle\FileManager; |
16 | 15 | use Symfony\Component\Console\Output\OutputInterface;
|
17 | 16 | use Symfony\Component\Process\ExecutableFinder;
|
18 | 17 | use Symfony\Component\Process\Process;
|
|
26 | 25 | */
|
27 | 26 | final class TemplateLinter
|
28 | 27 | {
|
| 28 | + // Version must match bundled version file name. e.g. php-cs-fixer-v3.49.9.phar |
| 29 | + public const BUNDLED_PHP_CS_FIXER_VERSION = '3.49.0'; |
| 30 | + |
29 | 31 | private bool $usingBundledPhpCsFixer = true;
|
30 | 32 | private bool $usingBundledPhpCsFixerConfig = true;
|
31 | 33 | private bool $needsPhpCmdPrefix = true;
|
32 | 34 |
|
33 | 35 | public function __construct(
|
34 |
| - private FileManager $fileManager, |
35 | 36 | private ?string $phpCsFixerBinaryPath = null,
|
36 | 37 | private ?string $phpCsFixerConfigPath = null,
|
37 | 38 | ) {
|
@@ -97,15 +98,9 @@ public function writeLinterMessage(OutputInterface $output): void
|
97 | 98 |
|
98 | 99 | private function setBinary(): void
|
99 | 100 | {
|
100 |
| - // Use Bundled (shim) PHP-CS-Fixer |
| 101 | + // Use Bundled PHP-CS-Fixer |
101 | 102 | if (null === $this->phpCsFixerBinaryPath) {
|
102 |
| - $shimLocation = \sprintf('%s/vendor/bin/php-cs-fixer', \dirname(__DIR__, 2)); |
103 |
| - |
104 |
| - if (is_file($shimLocation)) { |
105 |
| - $this->phpCsFixerBinaryPath = $shimLocation; |
106 |
| - |
107 |
| - return; |
108 |
| - } |
| 103 | + $this->phpCsFixerBinaryPath = \sprintf('%s/Resources/bin/php-cs-fixer-v%s.phar', \dirname(__DIR__), self::BUNDLED_PHP_CS_FIXER_VERSION); |
109 | 104 |
|
110 | 105 | return;
|
111 | 106 | }
|
@@ -134,8 +129,7 @@ private function setBinary(): void
|
134 | 129 | private function setConfig(): void
|
135 | 130 | {
|
136 | 131 | // No config provided, but there is a dist config file in the project dir
|
137 |
| - $defaultConfigPath = \sprintf('%s/.php-cs-fixer.dist.php', $this->fileManager->getRootDirectory()); |
138 |
| - if (null === $this->phpCsFixerConfigPath && file_exists($defaultConfigPath)) { |
| 132 | + if (null === $this->phpCsFixerConfigPath && file_exists($defaultConfigPath = '.php-cs-fixer.dist.php')) { |
139 | 133 | $this->phpCsFixerConfigPath = $defaultConfigPath;
|
140 | 134 |
|
141 | 135 | $this->usingBundledPhpCsFixerConfig = false;
|
|
0 commit comments