Skip to content

Commit aebba48

Browse files
committed
Add regression test for #7924
Closes phpstan/phpstan#7924
1 parent 99accfb commit aebba48

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

‎tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4713,4 +4713,14 @@ public function testBug15431(): void
47134713
$this->analyse([__DIR__ . '/data/bug-15431.php'], []);
47144714
}
47154715

4716+
public function testBug7924(): void
4717+
{
4718+
$this->checkThisOnly = false;
4719+
$this->checkNullables = true;
4720+
$this->checkUnionTypes = true;
4721+
$this->checkExplicitMixed = true;
4722+
$this->checkImplicitMixed = true;
4723+
$this->analyse([__DIR__ . '/data/bug-7924.php'], []);
4724+
}
4725+
47164726
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug7924;
4+
5+
class HelloWorld
6+
{
7+
/**
8+
* @param string|array<int, string>|array<string, 'asc'|'desc'> $field
9+
* @param 'asc'|'desc' $direction
10+
*
11+
* @return $this
12+
*/
13+
public function setOrder($field, string $direction = 'asc')
14+
{
15+
if (is_array($field)) {
16+
foreach ($field as $k => $v) {
17+
\PHPStan\dumpType($v);
18+
19+
if (is_int($k)) {
20+
// format "field"
21+
$this->setOrder($v);
22+
} else {
23+
// format "field" => direction
24+
$this->setOrder($k, $v);
25+
}
26+
}
27+
28+
return $this;
29+
}
30+
31+
return $this;
32+
}
33+
}

0 commit comments

Comments
 (0)