Repository navigation
Improve option and result type precision - #613
Merged
Merged
Conversation
GrahamCampbell
force-pushed
the
types/option-result-precision
branch
from
August 24, 2026 17:17
165bc5d to
8b76297
Compare
GrahamCampbell
force-pushed
the
types/option-result-precision
branch
from
August 24, 2026 17:28
8b76297 to
46e982e
Compare
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.
With the covariant option and result types in place, several annotations can now say precisely
what the code does. The five concrete adapters declare create() as returning an option of the
adapter itself rather than of the interface, which removes the widening casts inside them and
gives callers the concrete type. The repository builder's reader, writer and adapter parameters
now document the actual acceptance, an instance of the respective interface or a class-string of
an adapter, which matches the runtime guards exactly and lets the builder closures type-check
without laundering. The string and regex helpers declare the non-negative integer ranges they
actually produce, correcting a wrong-shaped cast in Str::pos. None of this changes behaviour, and
code typed against the old signatures only ever sees narrower types. The phpstan baseline shrinks
from sixteen entries to five as a byproduct.