Skip to content

Commit 347e848

Browse files
committed
added failling test
1 parent c235ff7 commit 347e848

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3667,4 +3667,15 @@ public function testBug12735(): void
36673667
$this->analyse([__DIR__ . '/data/bug-12735.php'], []);
36683668
}
36693669

3670+
public function testBug12735b(): void
3671+
{
3672+
$this->checkThisOnly = false;
3673+
$this->checkNullables = true;
3674+
$this->checkUnionTypes = true;
3675+
$this->checkExplicitMixed = true;
3676+
$this->checkImplicitMixed = true;
3677+
3678+
$this->analyse([__DIR__ . '/data/bug-12735b.php'], []);
3679+
}
3680+
36703681
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace Bug12735b;
4+
5+
use DateTimeImmutable;
6+
7+
class HelloWorld
8+
{
9+
public function test(): void
10+
{
11+
$now = null;
12+
if (rand(0,1)) {
13+
$now = new DateTimeImmutable();
14+
}
15+
16+
$this->foo(
17+
$now ??= new DateTimeImmutable(),
18+
$now,
19+
);
20+
21+
$this->foo($now, $now);
22+
}
23+
24+
private function foo(DateTimeImmutable $a, DateTimeImmutable $b): void {}
25+
}

0 commit comments

Comments
 (0)