Skip to content

Commit

Permalink
Fixed mixed type not considered nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Jan 3, 2022
1 parent 3d2e1db commit c0aad86
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 4 deletions.
8 changes: 4 additions & 4 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions tests/PHPStan/Analyser/NodeScopeResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,10 @@ public function dataFileAsserts(): iterable
yield from $this->gatherAssertTypes(__DIR__ . '/data/enums-import-alias.php');
}

if (PHP_VERSION_ID >= 80000) {
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-6293.php');
}

yield from $this->gatherAssertTypes(__DIR__ . '/data/classPhpDocs-phpstanPropertyPrefix.php');
}

Expand Down
23 changes: 23 additions & 0 deletions tests/PHPStan/Analyser/data/bug-6293.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace Bug6239;

use function PHPStan\Testing\assertNativeType;
use function PHPStan\Testing\assertType;

class UnionWithNullFails
{
/**
* @param int|null|bool $value
*/
public function withPhpDoc(mixed $value): void
{
assertType('bool|int|null', $value);
assertNativeType('mixed', $value);
}

public function doFoo(): void
{
$this->withPhpDoc(null);
}
}
8 changes: 8 additions & 0 deletions tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2273,4 +2273,12 @@ public function testEnums(): void
]);
}

public function testBug6239(): void
{
$this->checkThisOnly = false;
$this->checkNullables = true;
$this->checkUnionTypes = true;
$this->analyse([__DIR__ . '/../../Analyser/data/bug-6293.php'], []);
}

}

0 comments on commit c0aad86

Please sign in to comment.