Type every first-level schema field on all response DTOs#5
Merged
Conversation
Customer, Product, Order, BookedInvoice, Self_, Line and Inventory now expose all first-level properties from the e-conomic JSON schemas as typed fields instead of raw-only access. Object-valued fields map into 25 new all-nullable `final readonly` nested DTOs under Response\Reference (shared FK refs), Response\Document (order/invoice sub-objects incl. Pdf) and Response\Self_. Pure HATEOAS/meta link fields (self, metaData, soap, templates, totals, …) deliberately stay in $raw. Date handling: all new date/timestamp fields are ?\DateTimeImmutable. The new public Client::configureMapperBuilder() helper (mirroring registerNormalizerTransformers()) wires supportDateFormats() with both e-conomic shapes — timestamps and date-only `!Y-m-d`, where the `!` pins the time to midnight UTC so mapped dates are deterministic. supportDateFormats() replaces Valinor's defaults, so the stock formats are re-declared. README's custom-builder examples now use the helper. `customer` references map into the full Customer DTO (the Line::$product precedent); RawStamper fires polymorphically, so nested Resources carry their slice of the body on $raw. Covered by five kitchen-sink full-mapping tests (one per resource) and a date-format matrix: 187 tests / 736 assertions, PHPStan level max, ECS, Rector and Infection (MSI 68%, covered 79%+) all green.
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
Customer(+13),Product(+9),Inventory(+5),Order(+24),BookedInvoice(+24),Line(+14, union of order/invoice line schemas),Self_(+12)final readonlynested DTOs:Response\Reference\*(shared foreign-key refs, each keeping its?string $selflink),Response\Document\*(Recipient,Delivery,Notes,References,Pdf— shared by orders and invoices),ProductGroup,Line\Accrual, and 8Self_sub-DTOsself,metaData,soap,templates,totals,contacts,deliveryLocations,invoices,attachment,sent) deliberately stay raw-only;pdfis typed because consumers feed its download URL toClient::request()?\DateTimeImmutable; new publicClient::configureMapperBuilder()wiressupportDateFormats()with e-conomic's timestamp shape and date-only!Y-m-d(the!pins time to midnight UTC — deterministic). README/CLAUDE.md updated, custom-builder examples now wrap with the helpercustomerreferences map into the fullCustomerDTO (precedent:Line::$product);RawStamperstamps nestedResources, so$order->customer->raw['self']worksBehavioural note
Object fields that previously sat inert in
$rawnow pass through Valinor — a malformed nested object in a 2xx body fails the response withMappingExceptioninstead of being silently reachable-but-garbage. Real API responses conform; hand-built test doubles downstream may not.Test plan
composer phpunit— 187 tests / 736 assertions (14 new tests: five kitchen-sink full-mapping tests asserting every new field incl. nested DTOs, recursiveCustomer → CustomerContact → Customergraph, and a date-format matrix proving date-only fields map to exactly midnight UTC)composer analyse— PHPStan level max, no errorscomposer check-style+vendor/bin/rector --dry-run— cleanvendor/bin/infection— MSI 68% (floor 53.85), covered MSI ≥ 79.25, exit 0