Skip to content
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
14 changes: 14 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,19 @@
'fopen_flags' => false,
'protected_to_private' => false,
])
->setRuleCustomisationPolicy(new class implements PhpCsFixer\Config\RuleCustomisationPolicyInterface {
public function getPolicyVersionForCache(): string
{
return hash_file('xxh128', __FILE__);
}

public function getRuleCustomisers(): array
{
return [
// test methods must not have a return type
'void_return' => static fn (SplFileInfo $file) => !str_starts_with($file->getPathname(), __DIR__.'/tests/'),

@GromNaN GromNaN Oct 14, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fabbot's PHP-CS-Fixer step adds : void to test methods (void_return from @symfony:risky), while its next step requires test methods not to have a return type. The PHP-CS-Fixer config now disables void_return in tests/, like symfony/symfony does.

Great but complex fix! We have the same issue on other MakerBundle and MonologBundle.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI Twig and Symfony UX do not follow this rule anymore, ref: symfony-tools/fabbot#18

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah :/

];
}
})
->setRiskyAllowed(true)
;
4 changes: 2 additions & 2 deletions tests/Configurator/CopyFromPackageConfiguratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ public function testConfigureAndOverwriteFiles()
$lock = $this->createStub(Lock::class);

$ioCalls = [];
$io = $this->createStub(IOInterface::class);
$io = $this->createMock(IOInterface::class);
$io->method('writeError')->willReturnCallback(static function (array $lines) use (&$ioCalls) { $ioCalls[] = $lines; });
$io->method('askConfirmation')->with('File "build/public/file" has uncommitted changes, overwrite? [y/N] ')->willReturn(true);
$io->expects($this->once())->method('askConfirmation')->with('File "build/public/file" has uncommitted changes, overwrite? [y/N] ')->willReturn(true);

$this->assertFileExists($this->targetFile);
$this->createConfigurator($io)->configure(
Expand Down
4 changes: 2 additions & 2 deletions tests/Configurator/CopyFromRecipeConfiguratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ public function testConfigureAndOverwriteFiles()
$lock = $this->createStub(Lock::class);

$ioCalls = [];
$io = $this->createStub(IOInterface::class);
$io = $this->createMock(IOInterface::class);
$io->method('writeError')->willReturnCallback(static function (array $lines) use (&$ioCalls) { $ioCalls[] = $lines; });
$io->method('askConfirmation')->with('File "build/config/file" has uncommitted changes, overwrite? [y/N] ')->willReturn(true);
$io->expects($this->once())->method('askConfirmation')->with('File "build/config/file" has uncommitted changes, overwrite? [y/N] ')->willReturn(true);

$this->assertFileExists($this->targetFile);
$this->createConfigurator($io)->configure(
Expand Down
2 changes: 1 addition & 1 deletion tests/Configurator/DockerComposeConfiguratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public function testReconfigureDoesNotDuplicateLaterTopLevelKey()
{
$this->configurator->configure($this->recipeDb, self::CONFIG_DB, $this->lock);

$servicesOnlyRecipe = $this->getMockBuilder(Recipe::class)->disableOriginalConstructor()->getMock();
$servicesOnlyRecipe = $this->createStub(Recipe::class);
$servicesOnlyRecipe->method('getName')->willReturn('acme/services-only');
$servicesOnlyConfig = [
'services' => [
Expand Down
10 changes: 5 additions & 5 deletions tests/Configurator/MakefileConfiguratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,14 @@ public function testUpdate()
public function testConfigureCreatesBoilerplateWithTabIndentation()
{
$configurator = new MakefileConfigurator(
$this->getMockBuilder(Composer::class)->getMock(),
$this->getMockBuilder(IOInterface::class)->getMock(),
$this->createStub(Composer::class),
$this->createStub(IOInterface::class),
new Options(['root-dir' => FLEX_TEST_DIR])
);
$lock = $this->getMockBuilder(Lock::class)->disableOriginalConstructor()->getMock();
$lock = $this->createStub(Lock::class);

$recipe = $this->getMockBuilder(Recipe::class)->disableOriginalConstructor()->getMock();
$recipe->expects($this->any())->method('getName')->willReturn('FooBundle');
$recipe = $this->createStub(Recipe::class);
$recipe->method('getName')->willReturn('FooBundle');

$makefile = FLEX_TEST_DIR.'/Makefile';
@unlink($makefile);
Expand Down
7 changes: 1 addition & 6 deletions tests/FlexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@

class FlexTest extends TestCase
{
protected function tearDown(): void
{
@unlink(__DIR__.'/Fixtures/symfony.lock');
}

public function testPostInstall()
{
$data = [
Expand Down Expand Up @@ -165,7 +160,7 @@ public function testContribRecipeNotApprovedIsRemovedFromLock()
// Recipe should NOT be installed
$configurator->expects($this->never())->method('install');

$lock = new Lock(__DIR__.'/Fixtures/symfony.lock');
$lock = new Lock('php://memory');
$composer = $this->mockComposer($this->mockLocker(), $rootPackage);
$flex = $this->mockFlexCustom($io, $composer, $configurator, $downloader, $lock);

Expand Down
12 changes: 4 additions & 8 deletions tests/ScriptExecutorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Composer\Util\ProcessExecutor;
use PHPUnit\Framework\Attributes\BackupGlobals;
use PHPUnit\Framework\TestCase;
use PHPUnit\Runner\Version;
use Symfony\Component\Process\PhpExecutableFinder;
use Symfony\Flex\Options;
use Symfony\Flex\ScriptExecutor;
Expand All @@ -29,8 +28,8 @@ public function testMemoryLimit()
$command = './command.php';
$memoryLimit = '32M';
putenv("COMPOSER_MEMORY_LIMIT={$memoryLimit}");
$executorStub = $this->createStub(ProcessExecutor::class);
$scriptExecutor = new ScriptExecutor(new Composer(), new NullIO(), new Options(), $executorStub);
$executorMock = $this->createMock(ProcessExecutor::class);
$scriptExecutor = new ScriptExecutor(new Composer(), new NullIO(), new Options(), $executorMock);

$phpFinder = new PhpExecutableFinder();
if (!$php = $phpFinder->find(false)) {
Expand All @@ -50,16 +49,13 @@ public function testMemoryLimit()

$expectedCommand = ProcessExecutor::escape($php).($phpArgs ? ' '.$phpArgs : '').' '.$command;

$executorStub
$executorMock
->expects($this->once())
->method('execute')
->with($expectedCommand)
->willReturn(0)
;

if (10 === Version::majorVersionNumber()) {
$this->expectNotToPerformAssertions();
}

$scriptExecutor->execute('php-script', $command);
}
}
6 changes: 3 additions & 3 deletions tests/Update/RecipePatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ public function testGeneratePatch(array $originalFiles, array $newFiles, string
preg_match_all('/index\ ([0-9|a-z]+)\.\./', $patch->getPatch(), $matches);
$expectedBlobs = $matches[1];
// new files (0000000) do not need a blob
$expectedBlobs = array_values(array_filter($expectedBlobs, function ($blob) {
$expectedBlobs = array_values(array_filter($expectedBlobs, static function ($blob) {
return '0000000' !== $blob;
}));

$actualShortenedBlobs = array_map(function ($blob) {
$actualShortenedBlobs = array_map(static function ($blob) {
return substr($blob, 0, 7);
}, array_keys($patch->getBlobs()));

Expand Down Expand Up @@ -380,7 +380,7 @@ public static function getApplyPatchTests(string $projectRootPath): iterable
[
$dotEnvClean['hash'] => $dotEnvClean['blob'],
$packageJsonConflict['hash'] => $packageJsonConflict['blob'],
$webpackEncoreAdded['hash'] => $webpackEncoreAdded['blob'],
// no blob needed for the new webpack_encore.yaml file
$securityRemoved['hash'] => $securityRemoved['blob'],
],
[
Expand Down
Loading