Skip to content

Commit a8766f1

Browse files
committed
add regression test
1 parent b903d9a commit a8766f1

2 files changed

Lines changed: 56 additions & 0 deletions

File tree

tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3908,6 +3908,14 @@ public function testBug1501(): void
39083908
$this->analyse([__DIR__ . '/data/bug-1501.php'], []);
39093909
}
39103910

3911+
public function testBug12482(): void
3912+
{
3913+
$this->checkThisOnly = false;
3914+
$this->checkNullables = true;
3915+
$this->checkUnionTypes = true;
3916+
$this->analyse([__DIR__ . '/data/bug-12482.php'], []);
3917+
}
3918+
39113919
public function testBug7369(): void
39123920
{
39133921
$this->checkThisOnly = false;
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Bug12482;
6+
7+
class PhpUnitDataProviderMethodOrderFixer
8+
{
9+
/**
10+
* @param list<string> $elements
11+
* @param list<array{string, string}> $pairs
12+
*/
13+
protected function applyPhpUnitClassFix(array $elements, array $pairs): void
14+
{
15+
$providersPlaced = [];
16+
$sameUsageName = false;
17+
$sameProviderName = false;
18+
foreach ($pairs as [$usageName, $providerName]) {
19+
if (!isset($providersPlaced[$providerName])) {
20+
$providersPlaced[$providerName] = true;
21+
22+
$elements = $this->moveMethodElement(
23+
$elements,
24+
$usageName === $sameUsageName
25+
? $sameProviderName
26+
: $usageName,
27+
$providerName,
28+
true
29+
);
30+
31+
// honor multiple providers order for one test
32+
$sameUsageName = $usageName;
33+
$sameProviderName = $providerName;
34+
}
35+
}
36+
}
37+
38+
/**
39+
* @param list<string> $elements
40+
*
41+
* @return list<string>
42+
*/
43+
private function moveMethodElement(array $elements, string $nameKeep, string $nameToMove, bool $after): array
44+
{
45+
return $elements; // do nothing here...
46+
}
47+
}
48+

0 commit comments

Comments
 (0)