Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Cover Randomizer::getFloat() and nextFloat()
Both were added in PHP 8.3 alongside getBytesFromString(), but unlike it
they have nothing more precise to say than the float they declare - PHPStan
has no float range types - so they get no signature map entry, only
assertions pinning that down.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
  • Loading branch information
2 people authored and staabm committed Sep 18, 2026
commit fc35282da67f60855e0aa8c96c0ac56107ec7891
10 changes: 10 additions & 0 deletions tests/PHPStan/Analyser/nsrt/bug-15256-83.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Bug15256Php83;

use Random\IntervalBoundary;
use Random\Randomizer;
use function PHPStan\Testing\assertType;

Expand All @@ -21,3 +22,12 @@ function getBytesFromString(
assertType('non-empty-string', $randomizer->getBytesFromString($lowercaseString, 5));
assertType('non-empty-string', $randomizer->getBytesFromString('abc', 5));
}

// PHPStan has no float range types, so there is nothing more precise to say
// about these than the float the class declares.
function floatMethods(Randomizer $randomizer, float $float): void
{
assertType('float', $randomizer->nextFloat());
assertType('float', $randomizer->getFloat(0.0, 1.0));
assertType('float', $randomizer->getFloat($float, $float, IntervalBoundary::ClosedClosed));
}