Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fall back to default config for trailing_comma_in_multiline #72

Draft
wants to merge 3 commits into
base: 1.x
Choose a base branch
from
Draft
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Changelog
---------

## [1.3.0] - TBA
- Drop support for Symfony below 5.4 (#72)
- Require PHP-CS-Fixer 3.53+ (#72)

## [1.2.0] - 2024-01-22
- Add new `numeric_literal_separator` rule (#65)
- Map new heredoc rules as "to be discussed" (`heredoc_closing_marker`, `multiline_string_to_heredoc`)
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"php": "^7.4 || ^8.0",
"ext-json": "*",
"composer-plugin-api": "^1.1 || ^2.0",
"friendsofphp/php-cs-fixer": "^3.4",
"symfony/console": "^4.0 || ^5.0 || ^6.0 || ^7.0",
"friendsofphp/php-cs-fixer": "^3.53",
"symfony/console": "^5.4 || ^6.0 || ^7.0",
"symfony/polyfill-php80": "^1.0"
},
"require-dev": {
Expand Down
2 changes: 1 addition & 1 deletion src/AutoloadPathProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private function reduceAutoload(array $autoload): array
return array_reduce(
$autoload,
\Closure::fromCallable([$this, 'autoloadReducer']),
[]
[],
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Installer/Command/CreateConfigCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected function configure(): void
->setHelp(
<<<'HELP'
Write config file in <comment>.php-cs-fixer.dist.php</comment>.
HELP
HELP,
)
;
}
Expand All @@ -59,7 +59,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$configWriter->writeConfigFile(
'.php-cs-fixer.dist.php',
(bool) $input->getOption('no-dev'),
(bool) $input->getOption('no-risky')
(bool) $input->getOption('no-risky'),
);

return 0;
Expand Down
8 changes: 4 additions & 4 deletions src/Installer/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
Composer $composer,
?string $projectRoot = null,
?string $composerPath = null,
?PhpCsConfigWriterInterface $phpCsWriter = null
?PhpCsConfigWriterInterface $phpCsWriter = null,
) {
$this->io = $io;
// Get composer.json location
Expand Down Expand Up @@ -100,7 +100,7 @@
' <error>You are upgrading "' . $currentPackage->getPrettyName() . '" with possible BC breaks.</error>',
sprintf(
' <question>%s</question>',
'Do you want to write the new configuration? (Y/n)'
'Do you want to write the new configuration? (Y/n)',
),
];

Expand Down Expand Up @@ -170,7 +170,7 @@
$question = [
sprintf(
" <question>%s</question>\n",
'Do you want to create the CS configuration in your project root? (Y/n)'
'Do you want to create the CS configuration in your project root? (Y/n)',
),
' <info>It will create a .php-cs-fixer.dist.php file in your project root directory.</info> ',
];
Expand Down Expand Up @@ -205,7 +205,7 @@
$question = [
sprintf(
" <question>%s</question>\n",
'Do you want to add scripts to composer.json? (Y/n)'
'Do you want to add scripts to composer.json? (Y/n)',

Check warning on line 208 in src/Installer/Installer.php

View check run for this annotation

Codecov / codecov/patch

src/Installer/Installer.php#L208

Added line #L208 was not covered by tests
),
' <info>It will add two scripts:</info>',
' - <info>cs-check</info>',
Expand Down
3 changes: 0 additions & 3 deletions src/Rules/DefaultRulesProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,6 @@ public function getRules(): array
'standardize_not_equals' => true,
'switch_continue_to_break' => true,
'ternary_to_null_coalescing' => true,
'trailing_comma_in_multiline' => [
'elements' => ['arrays'],
],
'trim_array_spaces' => true,
'type_declaration_spaces' => true,
'types_spaces' => true,
Expand Down
6 changes: 3 additions & 3 deletions tests/AutoloadPathProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function testGetPathsWithDevOn(): void
$provider = new AutoloadPathProvider(
$this->composerFilePath,
$this->projectRoot,
true
true,
);

$expected = ['src/', 'tests/'];
Expand All @@ -56,7 +56,7 @@ public function testGetPathsWithDevOff(): void
$provider = new AutoloadPathProvider(
$this->composerFilePath,
$this->projectRoot,
false
false,
);

$expected = ['src/'];
Expand Down Expand Up @@ -86,7 +86,7 @@ public function testGetPathsWithInvalidComposerJson(): void
$provider = new AutoloadPathProvider(
$this->composerFilePath,
$this->projectRoot,
false
false,
);

file_put_contents($this->composerFilePath, '');
Expand Down
2 changes: 1 addition & 1 deletion tests/Installer/Command/CreateConfigCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function testExecute(array $args, bool $noDev, bool $noRisky): void
$writer->writeConfigFile(
'.php-cs-fixer.dist.php',
$noDev,
$noRisky
$noRisky,
)
->shouldBeCalled();

Expand Down
14 changes: 7 additions & 7 deletions tests/Installer/InstallerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function testCheckUpgradeTestNotNecessary(array $currentPackageV, array $
$composer->reveal(),
$this->projectRoot,
$this->composerFilePath,
$phpCsWriter->reveal()
$phpCsWriter->reveal(),
);

$io->isInteractive()
Expand Down Expand Up @@ -123,7 +123,7 @@ public function testCheckUpgradeTestNecessary(array $currentPackageV, array $tar
$composer->reveal(),
$this->projectRoot,
$this->composerFilePath,
$phpCsWriter->reveal()
$phpCsWriter->reveal(),
);

$io->isInteractive()
Expand All @@ -149,7 +149,7 @@ public function testCheckUpgrade(): void
$composer->reveal(),
$this->projectRoot,
$this->composerFilePath,
$phpCsWriter->reveal()
$phpCsWriter->reveal(),
);

$io->isInteractive()
Expand Down Expand Up @@ -179,7 +179,7 @@ public function testCheckUpgradeShouldntWriteWithNoInteractiveInput(): void
$composer->reveal(),
$this->projectRoot,
$this->composerFilePath,
$phpCsWriter->reveal()
$phpCsWriter->reveal(),
);

$io->isInteractive()
Expand Down Expand Up @@ -215,7 +215,7 @@ public function testRequestCreateCsConfigWithAlreadyExistingFile(): void
$composer->reveal(),
$this->projectRoot,
$this->composerFilePath,
$phpCsWriter->reveal()
$phpCsWriter->reveal(),
);
$installer->requestCreateCsConfig();
}
Expand All @@ -238,7 +238,7 @@ public function testRequestCreateCsConfigWithAnswerNo(): void
$composer->reveal(),
$this->projectRoot,
$this->composerFilePath,
$phpCsWriter->reveal()
$phpCsWriter->reveal(),
);

$installer->requestCreateCsConfig();
Expand All @@ -264,7 +264,7 @@ public function testRequestCreateCsConfig(): void
$composer->reveal(),
$this->projectRoot,
$this->composerFilePath,
$phpCsWriter->reveal()
$phpCsWriter->reveal(),
);

$installer->requestCreateCsConfig();
Expand Down
10 changes: 5 additions & 5 deletions tests/Rules/AbstractRulesProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function testRuleAreRiskyAsExpected(string $ruleName): void
$this->assertSame(
$this->shouldBeRisky(),
$fixer->isRisky(),
sprintf('Fixer %s is %s as expected', $ruleName, $this->shouldBeRisky() ? 'risky' : 'NOT risky')
sprintf('Fixer %s is %s as expected', $ruleName, $this->shouldBeRisky() ? 'risky' : 'NOT risky'),
);
}

Expand All @@ -49,7 +49,7 @@ public function testRuleSetsAreRiskyAsExpected(string $ruleSetName): void
$this->assertSame(
$this->shouldBeRisky(),
$fixer->isRisky(),
sprintf('Ruleset %s includes %s rules, such as %s', $ruleSetName, $this->shouldBeRisky() ? 'risky' : 'NOT risky', $ruleName)
sprintf('Ruleset %s includes %s rules, such as %s', $ruleSetName, $this->shouldBeRisky() ? 'risky' : 'NOT risky', $ruleName),
);
}
}
Expand Down Expand Up @@ -148,18 +148,18 @@ private function assertConfigurationIsSameAsRuleSet(RuleSet $ruleSet, string $ru

$this->assertEquals($defaultConfiguration, $ruleConfiguration, sprintf(
'Ruleset relies on default configuration for rule %s, but it is being overridden',
$ruleName
$ruleName,
));
} elseif ($ruleConfiguration === true) {
$this->assertEquals($ruleSetConfiguration, $defaultConfiguration, sprintf(
'Ruleset does not use the default config for rule %s, and it is being overridden with "true" in %s',
$ruleName,
\get_class($rulesProvider)
\get_class($rulesProvider),
));
} else {
$this->assertEquals($ruleSetConfiguration, $ruleConfiguration, sprintf(
'Rule %s has a different configuration from the one from ruleset',
$ruleName
$ruleName,
));
}
}
Expand Down
Loading