Skip to content

Commit d5872f9

Browse files
authored
IBX-11773: Bumped friendsofphp/php-cs-fixer to v3.95.1 and related changes (#22)
For more details see https://ibexa.atlassian.net/browse/IBX-11773 and #22 Key changes: * [Composer] Bumped `friendsofphp/php-cs-fixer` to `v3.95.1` * [CS] Adjusted changes to newer version * Used nowdocs in \Ibexa\Tests\CodeStyle\PhpCsFixer\Rule\MultilineParametersFixerTest::provideFixCases
1 parent 6b9b359 commit d5872f9

4 files changed

Lines changed: 87 additions & 58 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
},
1515
"require": {
1616
"php": ">=7.4",
17-
"friendsofphp/php-cs-fixer": "v3.89.1",
17+
"friendsofphp/php-cs-fixer": "v3.95.1",
1818
"composer-runtime-api": ">=2.0"
1919
},
2020
"require-dev": {

src/lib/PhpCsFixer/InternalConfigFactory.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,12 @@ public function buildConfig(): ConfigInterface
8989
$this->customRules,
9090
));
9191

92-
if ($this->runInParallel && $config instanceof ParallelAwareConfigInterface) {
93-
$config->setParallelConfig(ParallelConfigFactory::detect());
92+
if ($config instanceof ParallelAwareConfigInterface) {
93+
$config->setParallelConfig(
94+
$this->runInParallel
95+
? ParallelConfigFactory::detect()
96+
: ParallelConfigFactory::sequential()
97+
);
9498
}
9599

96100
return $config;

tests/lib/PhpCsFixer/Rule/MultilineParametersFixerTest.php

Lines changed: 79 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -41,76 +41,100 @@ public function testFix(
4141
public static function provideFixCases(): iterable
4242
{
4343
yield 'single parameter should not be modified' => [
44-
'<?php
45-
function bar(array $package): void {
46-
}',
47-
'<?php
48-
function bar(array $package): void {
49-
}',
44+
<<<'PHP'
45+
<?php
46+
function bar(array $package): void {
47+
}
48+
PHP,
49+
<<<'PHP'
50+
<?php
51+
function bar(array $package): void {
52+
}
53+
PHP,
5054
];
5155

5256
yield 'single parameter with type hints should not be modified' => [
53-
'<?php
54-
function bar(?string $package = null): void {
55-
}',
56-
'<?php
57-
function bar(?string $package = null): void {
58-
}',
57+
<<<'PHP'
58+
<?php
59+
function bar(?string $package = null): void {
60+
}
61+
PHP,
62+
<<<'PHP'
63+
<?php
64+
function bar(?string $package = null): void {
65+
}
66+
PHP,
5967
];
6068

6169
yield 'multiple parameters should be split' => [
62-
'<?php
63-
function foo(array $package, string $expectedRuleSetClass): void {
64-
}',
65-
'<?php
66-
function foo(
67-
array $package,
68-
string $expectedRuleSetClass
69-
): void {
70-
}',
70+
<<<'PHP'
71+
<?php
72+
function foo(array $package, string $expectedRuleSetClass): void {
73+
}
74+
PHP,
75+
<<<'PHP'
76+
<?php
77+
function foo(
78+
array $package,
79+
string $expectedRuleSetClass
80+
): void {
81+
}
82+
PHP,
7183
];
7284

7385
yield 'multiple parameters with type hints should be split' => [
74-
'<?php
75-
function test(?string $foo = null, int $bar = 42): string {
76-
}',
77-
'<?php
78-
function test(
79-
?string $foo = null,
80-
int $bar = 42
81-
): string {
82-
}',
86+
<<<'PHP'
87+
<?php
88+
function test(?string $foo = null, int $bar = 42): string {
89+
}
90+
PHP,
91+
<<<'PHP'
92+
<?php
93+
function test(
94+
?string $foo = null,
95+
int $bar = 42
96+
): string {
97+
}
98+
PHP,
8399
];
84100

85101
yield 'constructor with properties should be split' => [
86-
'<?php
87-
class Test {
88-
public function __construct(string $foo, int $bar) {
89-
}
90-
}',
91-
'<?php
92-
class Test {
93-
public function __construct(
94-
string $foo,
95-
int $bar
96-
) {
97-
}
98-
}',
102+
<<<'PHP'
103+
<?php
104+
class Test {
105+
public function __construct(string $foo, int $bar) {
106+
}
107+
}
108+
PHP,
109+
<<<'PHP'
110+
<?php
111+
class Test {
112+
public function __construct(
113+
string $foo,
114+
int $bar
115+
) {
116+
}
117+
}
118+
PHP,
99119
];
100120

101121
yield 'already multiline should not be modified' => [
102-
'<?php
103-
function test(
104-
string $foo,
105-
int $bar
106-
): void {
107-
}',
108-
'<?php
109-
function test(
110-
string $foo,
111-
int $bar
112-
): void {
113-
}',
122+
<<<'PHP'
123+
<?php
124+
function test(
125+
string $foo,
126+
int $bar
127+
): void {
128+
}
129+
PHP,
130+
<<<'PHP'
131+
<?php
132+
function test(
133+
string $foo,
134+
int $bar
135+
): void {
136+
}
137+
PHP,
114138
];
115139
}
116140
}

tests/lib/PhpCsFixer/Sets/expected_rules/5_0_rule_set/php_cs_fixer_rules.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,4 +208,5 @@
208208
'fully_qualified_strict_types' => [
209209
'import_symbols' => true,
210210
],
211+
'attribute_block_no_spaces' => true,
211212
];

0 commit comments

Comments
 (0)