Skip to content
Merged
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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"require": {
"php": ">=7.4",
"friendsofphp/php-cs-fixer": "v3.89.1",
"friendsofphp/php-cs-fixer": "v3.95.1",
"composer-runtime-api": ">=2.0"
},
"require-dev": {
Expand Down
8 changes: 6 additions & 2 deletions src/lib/PhpCsFixer/InternalConfigFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,12 @@ public function buildConfig(): ConfigInterface
$this->customRules,
));

if ($this->runInParallel && $config instanceof ParallelAwareConfigInterface) {
$config->setParallelConfig(ParallelConfigFactory::detect());
if ($config instanceof ParallelAwareConfigInterface) {
$config->setParallelConfig(
$this->runInParallel
? ParallelConfigFactory::detect()
: ParallelConfigFactory::sequential()
);
}

return $config;
Expand Down
134 changes: 79 additions & 55 deletions tests/lib/PhpCsFixer/Rule/MultilineParametersFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,76 +41,100 @@ public function testFix(
public static function provideFixCases(): iterable
{
yield 'single parameter should not be modified' => [
'<?php
function bar(array $package): void {
}',
'<?php
function bar(array $package): void {
}',
<<<'PHP'
<?php
function bar(array $package): void {
}
PHP,
<<<'PHP'
<?php
function bar(array $package): void {
}
PHP,
];

yield 'single parameter with type hints should not be modified' => [
'<?php
function bar(?string $package = null): void {
}',
'<?php
function bar(?string $package = null): void {
}',
<<<'PHP'
<?php
function bar(?string $package = null): void {
}
PHP,
<<<'PHP'
<?php
function bar(?string $package = null): void {
}
PHP,
];

yield 'multiple parameters should be split' => [
'<?php
function foo(array $package, string $expectedRuleSetClass): void {
}',
'<?php
function foo(
array $package,
string $expectedRuleSetClass
): void {
}',
<<<'PHP'
<?php
function foo(array $package, string $expectedRuleSetClass): void {
}
PHP,
<<<'PHP'
<?php
function foo(
array $package,
string $expectedRuleSetClass
): void {
}
PHP,
];

yield 'multiple parameters with type hints should be split' => [
'<?php
function test(?string $foo = null, int $bar = 42): string {
}',
'<?php
function test(
?string $foo = null,
int $bar = 42
): string {
}',
<<<'PHP'
<?php
function test(?string $foo = null, int $bar = 42): string {
}
PHP,
<<<'PHP'
<?php
function test(
?string $foo = null,
int $bar = 42
): string {
}
PHP,
];

yield 'constructor with properties should be split' => [
'<?php
class Test {
public function __construct(string $foo, int $bar) {
}
}',
'<?php
class Test {
public function __construct(
string $foo,
int $bar
) {
}
}',
<<<'PHP'
<?php
class Test {
public function __construct(string $foo, int $bar) {
}
}
PHP,
<<<'PHP'
<?php
class Test {
public function __construct(
string $foo,
int $bar
) {
}
}
PHP,
];

yield 'already multiline should not be modified' => [
'<?php
function test(
string $foo,
int $bar
): void {
}',
'<?php
function test(
string $foo,
int $bar
): void {
}',
<<<'PHP'
<?php
function test(
string $foo,
int $bar
): void {
}
PHP,
<<<'PHP'
<?php
function test(
string $foo,
int $bar
): void {
}
PHP,
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,5 @@
'fully_qualified_strict_types' => [
'import_symbols' => true,
],
'attribute_block_no_spaces' => true,
];
Loading