Skip to content

Commit c0aad86

Browse files
committed
Fixed mixed type not considered nullable
1 parent 3d2e1db commit c0aad86

File tree

4 files changed

+39
-4
lines changed

4 files changed

+39
-4
lines changed

composer.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/PHPStan/Analyser/NodeScopeResolverTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,10 @@ public function dataFileAsserts(): iterable
587587
yield from $this->gatherAssertTypes(__DIR__ . '/data/enums-import-alias.php');
588588
}
589589

590+
if (PHP_VERSION_ID >= 80000) {
591+
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-6293.php');
592+
}
593+
590594
yield from $this->gatherAssertTypes(__DIR__ . '/data/classPhpDocs-phpstanPropertyPrefix.php');
591595
}
592596

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace Bug6239;
4+
5+
use function PHPStan\Testing\assertNativeType;
6+
use function PHPStan\Testing\assertType;
7+
8+
class UnionWithNullFails
9+
{
10+
/**
11+
* @param int|null|bool $value
12+
*/
13+
public function withPhpDoc(mixed $value): void
14+
{
15+
assertType('bool|int|null', $value);
16+
assertNativeType('mixed', $value);
17+
}
18+
19+
public function doFoo(): void
20+
{
21+
$this->withPhpDoc(null);
22+
}
23+
}

tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2273,4 +2273,12 @@ public function testEnums(): void
22732273
]);
22742274
}
22752275

2276+
public function testBug6239(): void
2277+
{
2278+
$this->checkThisOnly = false;
2279+
$this->checkNullables = true;
2280+
$this->checkUnionTypes = true;
2281+
$this->analyse([__DIR__ . '/../../Analyser/data/bug-6293.php'], []);
2282+
}
2283+
22762284
}

0 commit comments

Comments
 (0)