-
Notifications
You must be signed in to change notification settings - Fork 52
Closed
Description
$ composer show | grep phpstan
phpstan/phpdoc-parser 0.4.4 PHPDoc parser with support for nul...
phpstan/phpstan 0.12.50 PHPStan - PHP Static Analysis Tool
phpstan/phpstan-strict-rules
Consider the following test:
<?php
declare(strict_types=1);
namespace SomeNamespace;
use PHPUnit\Framework\TestCase;
use function rand;
class PHPStanTest extends TestCase
{
public function testCurrentDate(): void
{
$data = $this->f2();
self::assertNotFalse($data);
$this->f1(...$data);
}
private function f1(int $a, int $b): void
{
}
/** @return array<int,int>|false */
private function f2()
{
return rand(-1, 1) > 0 ? [1, 2] : false;
}
}PHPStan flags it as:
$ phpstan a PHPStanTest.php
Note: Using configuration file phpstan.neon.dist.
1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
------ -----------------------------------------------------------------------------
Line PHPStanTest.php
------ -----------------------------------------------------------------------------
18 Only iterables can be unpacked, array<int, int>|false given in argument #1.
------ -----------------------------------------------------------------------------
[ERROR] Found 1 error
Replacing self::assertNotFalse($data) with assert($data !== false) works around the problem.
Metadata
Metadata
Assignees
Labels
No labels