Repository navigation
Remove the 2^62 length cap from RandomGenerator - #2
Merged
Merged
Conversation
…ss review findings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
RandomGeneratorbuilds each string symbol by symbol and never needs the keyspace capacity as an integer, so the2^62ceiling that the Feistel permutation requires no longer limits its length.RandomGenerator::generate()accepts any length, as the policy default or a per-call override. The remaining checks are>= 1and the policy'smaximumLength, which is now the only upper bound.RandomGeneratorconstructor accepts a default or maximum length beyond the ceiling, e.g.new LengthPolicy(24)ornew LengthPolicy(8, 32).RandomGenerator::generateWithAutoLengthIncrement()escalates up tomaximumLength, however long, and requires one: with no keyspace ceiling to stop at, it throwsInvalidLengthExceptionwhen the policy has no maximum.PermutationGeneratorstill rejects lengths whose capacity exceeds2^62. ItsgenerateWithAutoLengthIncrement()now throwsInvalidLengthExceptionfor a start length beyond the ceiling when no maximum is set, instead of a misleadingKeyspaceExhaustedException.maximumLengthis the only guard onRandomGeneratorlengths, and expands the capacity table to cover all four included alphabets. Docblocks updated to match.0.0.1,0.0.2) with compare links, plus a0.1.0entry for this change. The breaking change toRandomGenerator::generateWithAutoLengthIncrement()makes this a minor bump.Testing
tests/Unit/Generator/RandomGeneratorTest.php: the tests asserting that lengths beyond the ceiling are rejected, and that auto-increment falls back to the keyspace ceiling, are replaced with tests covering:maximumLengthstill rejecting overrides above itmaximumLengthInvalidLengthExceptionwhen nomaximumLengthis configuredtests/Unit/Generator/PermutationGeneratorTest.php: new test for an auto-increment override beyond the keyspace ceiling throwingInvalidLengthException.User Actions
0.1.0onmainand push the tag[0.1.0]heading in CHANGELOG.md