Repository navigation
Release 3.0.0 - #39
Merged
Merged
Conversation
CI runs on pushes and pull requests to 3.x, and a dev-3.x branch alias lets applications try it as 3.0.x-dev. UPGRADE-3.0.md describes each planned behaviour change, who is affected and what to do; the migrate-from-v2-to-v3 skill walks a codebase through it. Both are updated in the pull request that implements each change (milestone 3.0.0). CONTRIBUTING.md documents which branch takes which kind of change.
COPY . . copied the host's vendor/ over the dependencies composer install had just put into the image, so local test runs used whatever the host had installed instead of composer.lock: Laravel 13.23 locally while CI ran 13.44, which hid a failure until CI. node_modules/ and build/ are host artefacts too. (cherry picked from commit bad02fb)
Rules of a nested data class and of #[DataCollection] items apply when the parent is validated. Nullable, defaulted and Optional nested properties are validated only when present, at every depth. Closes #22.
fromValidated(), validate() and fromValidatedResult() pipe the input once, validate the piped values and hydrate them with a pipe-less hydrator compiled on first use. A failing pipe is a validation error. from() is unchanged. Closes #23.
* Throw on an invalid enum value for a nullable property A non-null value that matches no case throws DataHydrationException whether the property is nullable or not. EnumCast without a default keeps the old behaviour. Closes #25. * Flush metadata before the service provider cache path tests The cache file is written only when metadata is built, so the test failed when an earlier test had already loaded UserData.
finite now defaults to true; finite: false keeps accepting non-finite values. Closes #27.
Built-in casts check the input type instead of raising PHP warnings; any exception from a cast, a property pipe or a data collection is rethrown as DataHydrationException naming the field, with the original as the previous exception. Closes #26.
A key given through $key, $env or $provider that is not 32 random bytes throws InvalidArgumentException unless a keyring is configured; next to a keyring it is accepted for reading and stays deprecated. Closes #28.
Hydrators compile with strict_types; when the constructor rejects an argument, plain int, float, string and bool fields are converted only if lossless and the call is retried, so input of the declared type costs nothing extra. Lossy input throws DataHydrationException naming the field. Closes #24.
CHANGELOG [3.0.0], branch alias dev-main 3.x-dev, final UPGRADE-3.0, an Upgrading from 2.x docs page linking the migration skill, the docs version switcher for v3/v2/v1 and the Pages build of v2.
# Conflicts: # CONTRIBUTING.md
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.
3.0 changes how input is validated and coerced. Each change makes the library reject input that 2.x accepted silently or turned into something else. No public API is removed. Most applications need no code changes, only a check of the classes each section of UPGRADE-3.0.md names. The
migrate-from-v2-to-v3skill walks a codebase through it with Claude Code.Changed (breaking)
#[Rules]apply without#[InferRules](Apply nested #[Rules] without #[InferRules] on the parent #22). The rules of a nested data class, and of a#[DataCollection]item class, apply when the parent is validated. Rules for nullable, defaulted orOptionalnested values apply only when the value is present.fromValidated(),validate()andfromValidatedResult()validate the piped values and hydrate from them without running the pipes again. A pipe that throws becomes a validation error.int,float,stringorboolproperty without a cast takes"3"and3.0intoint, and"false"intoboolasfalse. Lossy input such as"1.9"intointthrowsDataHydrationExceptionnaming the field. Union types are checked in strict mode and are not converted.null.EnumCastkeeps the old behaviour.DataHydrationException(Report cast failures as DataHydrationException #26). The exception names the field and keeps the original asgetPrevious(). Built-in casts check the input type before using it.FloatCastrejectsINFandNANby default (Make FloatCast reject INF and NAN by default #27). Passfinite: falseto accept them.EncryptedCastkeys are rejected (Reject weak legacy EncryptedCast keys used as the only key #28) when they are the only key. Next tokeyring:they are still accepted for reading and raise a deprecation notice.The metadata cache format is
sdo-cache-5; caches written by 2.x are rebuilt on first use.Performance
Local benchmarks against 2.9.0, best of 7 rounds, ops/s. Hydration (flat, nested, collection) and serialization are within ±2%. The casts scenario is about 5% slower (cold 985k → 938k, warm 984k → 933k), the cost of the type checks the casts now do before using their input.
Documentation
The 3.x docs are at the site root, and the 2.x docs moved to /v2/. New page: Upgrading from 2.x.
2.x keeps receiving fixes on the
v2branch.