website/errors/phpstan.variable.md
<?php declare(strict_types = 1);
use function PHPStan\Testing\assertVariableCertainty;
use PHPStan\TrinaryLogic;
function doFoo(): void
{
if (rand(0, 1)) {
$a = 1;
}
assertVariableCertainty(TrinaryLogic::createYes(), $a);
}
This is an internal testing function used in PHPStan's test suite. The assertVariableCertainty() call expects a specific certainty level for a variable (Yes, No, or Maybe), but the actual certainty level is different. In the example above, the variable $a might or might not exist (certainty: Maybe), but the assertion expects it to always exist (certainty: Yes).
Fix the expected certainty to match the actual state:
<?php declare(strict_types = 1);
-assertVariableCertainty(TrinaryLogic::createYes(), $a);
+assertVariableCertainty(TrinaryLogic::createMaybe(), $a);