Skip to content

Commit 6e8e562

Browse files
committed
no looking for a global php-cs-fixer
1 parent e1db268 commit 6e8e562

File tree

2 files changed

+2
-52
lines changed

2 files changed

+2
-52
lines changed

src/Util/TemplateLinter.php

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

1414
use Symfony\Bundle\MakerBundle\Exception\RuntimeCommandException;
15-
use Symfony\Component\Process\ExecutableFinder;
1615
use Symfony\Component\Process\Process;
1716

1817
/**
@@ -31,8 +30,8 @@ public function __construct(
3130
private ?string $phpCsFixerBinaryPath = null,
3231
private ?string $phpCsFixerConfigPath = null,
3332
) {
34-
$this->setConfig();
3533
$this->setBinary();
34+
$this->setConfig();
3635
}
3736

3837
public function lintFiles(array $templateFilePaths): void
@@ -91,29 +90,6 @@ private function setBinary(): void
9190
return;
9291
}
9392

94-
$finder = new ExecutableFinder();
95-
$finder->addSuffix('.phar');
96-
97-
($process = Process::fromShellCommandline('composer config bin-dir && composer global config bin-dir --absolute'))
98-
->run();
99-
100-
$composerBinPaths = explode(\PHP_EOL, $process->getOutput());
101-
102-
$this->phpCsFixerBinaryPath = $finder->find(
103-
name: 'php-cs-fixer',
104-
extraDirs: [
105-
...$composerBinPaths,
106-
'tools/php-cs-fixer/vendor/bin',
107-
'tools/php-cs-fixer/bin',
108-
]
109-
);
110-
111-
if (null !== $this->phpCsFixerBinaryPath) {
112-
$this->usingBundledPhpCsFixer = false;
113-
114-
return;
115-
}
116-
11793
$this->phpCsFixerBinaryPath = \dirname(__DIR__).'/Resources/bin/php-cs-fixer-v3.13.0.phar';
11894
}
11995

tests/Maker/TemplateLinterTest.php

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function getTestDetails(): \Generator
7979

8080
self::assertStringContainsString('Linted with stock php-cs-config', $generatedTemplate);
8181

82-
$expectedOutput = 'System PHP-CS-Fixer (bin/php-cs-fixer) & System PHP-CS-Fixer Configuration (.php-cs-fixer.dist.php)';
82+
$expectedOutput = 'Bundled PHP-CS-Fixer & System PHP-CS-Fixer Configuration (.php-cs-fixer.dist.php)';
8383
self::assertStringContainsString($expectedOutput, $output);
8484
}),
8585
];
@@ -93,31 +93,5 @@ public function getTestDetails(): \Generator
9393
self::assertStringContainsString($expectedOutput, $output);
9494
}),
9595
];
96-
97-
yield 'lints_templates_with_php_cs_fixer_in_tools_dir' => [$this->createMakerTest()
98-
->run(function (MakerTestRunner $runner) {
99-
$runner->writeFile('tools/php-cs-fixer/.gitignore', ''); // create the dir
100-
$runner->runProcess('composer require --working-dir=tools/php-cs-fixer friendsofphp/php-cs-fixer');
101-
102-
// Voter class name
103-
$output = $runner->runMaker(['FooBar']);
104-
105-
$expectedOutput = 'System PHP-CS-Fixer (tools/php-cs-fixer/bin/php-cs-fixer) & Bundled PHP-CS-Fixer Configuration';
106-
self::assertStringContainsString($expectedOutput, $output);
107-
}),
108-
];
109-
110-
yield 'lints_templates_with_composer_global_php_cs_fixer' => [$this->createMakerTest()
111-
->run(function (MakerTestRunner $runner) {
112-
$runner->runProcess('composer global require friendsofphp/php-cs-fixer');
113-
114-
// Voter class name
115-
$output = $runner->runMaker(['FooBar']);
116-
117-
// We don't know the prefix to the global "composer" dir. e.g. /your/system/composer/....
118-
$expectedOutput = 'composer/bin/php-cs-fixer) & Bundled PHP-CS-Fixer Configuration';
119-
self::assertStringContainsString($expectedOutput, $output);
120-
}),
121-
];
12296
}
12397
}

0 commit comments

Comments
 (0)