Repository navigation
Conversation
|
tomaj
force-pushed
the
feat/197-typed-input
branch
3 times, most recently
from
November 5, 2026 20:09
17e5f42 to
2fe3988
Compare
cursor
Bot
force-pushed
the
feat/197-typed-input
branch
5 times, most recently
from
November 6, 2026 00:45
2c60265 to
fe84a3a
Compare
tomaj
marked this pull request as ready for review
November 6, 2026 01:06
tomaj
force-pushed
the
feat/197-typed-input
branch
8 times, most recently
from
November 14, 2026 14:22
3ad84c4 to
9bfeea1
Compare
tomaj
force-pushed
the
feat/197-typed-input
branch
3 times, most recently
from
November 21, 2026 15:31
6ecf81b to
b3a3fde
Compare
Typed input DTOs are a second, equal way to declare handler input next
to params(). TypedHandler reads a readonly DTO from handleDto() and turns
its #[Query], #[Path], #[Header], #[Body] and #[File] properties into
InputParam objects, so validation, OpenAPI and the API console keep
using the existing pipeline.
- URL templates with {name} segments, matched by ApiDecider::matchPath()
after static endpoints; ApiLink and the console fill them
- PathInputParam, HeaderInputParam and BodyInputParam for params()
- strict conversion of int, float, bool, backed enums, DateTimeImmutable,
list<T> and nested DTOs from JSON, form and multipart bodies
- constraints Range, Length, Pattern, Email; casters DateFormat,
UnixTimestamp, Split; FileUpload for #[File]
- #[Consumes] and 415 Unsupported Media Type after authorization
- DTO metadata compiled into the DI container
- docs (EN and SK) and the typed-input example
Refs #197
tomaj
force-pushed
the
feat/197-typed-input
branch
from
November 21, 2026 16:41
b3a3fde to
7b72168
Compare
This branch has not been deployed
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.
Refs #197
Adds typed input DTOs as a second, equal way to declare handler input next to
params().TypedHandlerreads a readonly DTO fromhandleDto(SomeInput $input)and turns its properties intoInputParamobjects, so validation, OpenAPI and the API console keep using the existing pipeline.BaseHandler::params()/handle(array $params)are unchanged.What's in it
#[Query],#[Path],#[Header],#[Body],#[File]on readonly promoted properties. Nullable or defaulted means optional.{name}segments ({id}/detail). Static endpoints still win; templates are matched by the newApiDecider::matchPath(),getApi()keeps its 3.x signature.ApiLink::link()fills{name}from the params of the same name.params()too:PathInputParam,HeaderInputParam,BodyInputParam(OpenAPIin: path/in: header).DateTimeImmutable(RFC 3339),list<T>and nested DTOs. JSON, form (bracket notation) and multipart bodies; errors carry paths likeitems[1].quantity, at most 100 per request.Range,Length,Pattern,Email+ConstraintInterface; casters#[Cast]withDateFormat,UnixTimestamp,Split+CasterInterface.FileUploadvalue object for#[File].#[Consumes]restricts body media types; anything else is415, answered after authorization and rate limiting.examples/typed-inputin the examples CI matrix, typedGreetHandlerinexamples/attributesandexamples/di-extension.BC notes (4.0)
ErrorHandlerInterface::handleUnsupportedMediaType(string $detail)is new; custom error handlers must implement it. The bundled handlers do.ParamTypehas new casesPath,Header,Body;InputParamhas new public methodssetOpenApiSchema(),getOpenApiSchema(),setContentTypes(),getContentTypes().ApiDecider::getApi()itself must callmatchPath($method, $version, $package, $apiAction, $params)with the router values whengetApi()finds no endpoint (or returns a template for its literal URL), to support URL templates.InputParamsubclass whose$typeis'PATH','HEADER'or'BODY'now behaves as the new param of that type.params()handlers keep their existing (looser) conversion and OpenAPI output; snapshots of existing endpoints are unchanged.Decisions
InputParamobjects, so there is one path for validation, OpenAPI and the console.1ais not an int, typed strings must be valid UTF-8);params()behaviour is untouched.{}and[]stay distinguishable.FileUpload::$error, as withFileInputParam.[]list names anddeepObjectencoding for objects; multipart lists the fields of an object one by one (address[street]), because OpenAPI applies encoding styles only to URL-encoded forms. A body with a list of objects (not describable in OpenAPI 3.0 form encoding) is advertised as JSON only, though the runtime still accepts the form.Patternis PCRE; OpenAPI getspatternonly when the regex means the same in ECMA 262, otherwisex-pattern.#[Header('Accept')],Content-TypeandAuthorizationare compile-time errors: OpenAPI ignores header parameters with these names, so they would be undocumented input.near location line:columnsuffix that PHP 8.6 adds is dropped.<params>fillsparamsfrom the query string; such a value is ignored, so?params=detailcannot pick another endpoint.Review log
%2Fin a path value no longer routes to another endpoint; a literal{id}in a request no longer reaches a template;params()of plain handlers is no longer called an extra time per request;list<T>docblocks on inherited constructors resolve in the declaring class;list<Enum>params expose available values; header names are deduplicated case-insensitively;-00:00offsets accepted;Rangerejects INF/NAN;BodyInputParamfromparams()appears in OpenAPI and reads PUT forms; OpenAPI form/multipart schemas match what PHP parses; no trailing slash in templated package links. Cleanup: the hand-written container export/import layer replaced byserialize(); sharedSourceAttributeinterface; tests regrouped by topic; docs trimmed.ApiLinkrejects'',.and..path values. Tests added for mutation coverage.forward()and masks withoutv); overlapping or malformed templates and aPathInputParamwithout{name}fail ataddApi();createLink()fills templates;list<T>from a trait resolves in the trait; empty upload slots are dropped; a request without a body never gets 415 for optional body fields; truncated multipart is a 400; a field namedbodyis refused;BodyInputParamshares the typed body parsing; files of constants used in attributes rebuild the container.CastStringmutant inEndpointTemplate::fill()is gone (Strings::replaceinstead ofpreg_replace_callbackplus a cast); the PHP 8.6 JSON error text is normalized (see decision 8).?params=from the query string no longer selects a template or bypasses the%2Fguard;.and..(also as%2E%2E) are no longer captured as path values, matching whatApiLinkrefuses.post_max_sizeis a400 Request body is too largeinstead of an empty form (post_max_size = 0means no limit);BodyInputParamgives arrays for JSON objects, asparams()handlers expect;HeaderInputParam('X_Request_Id')findsX-Request-Id;Splitrejects invalid UTF-8 like other string fields;DateFormatwith a format that cannot parse its own output ('c') fails at compile time instead of rejecting every request.params()handler withBodyInputParamdocuments its415; reserved header names are refused (decision 7).BodyInputParamdefault media types and array values, multipart objects, reserved header names;UPGRADE-4.0.mdsays whenparams()handlers get 415 and that a custom'PATH'param needs a{name}segment.HeaderInputParamin the console is still sent empty, like otherparams()fields;non-empty-list<T>is read aslist<T>as documented;+24:00offsets and very large Unix timestamps are accepted. The one PHP 8.6 deprecation (NetteCacheStorage::NAMESPACE) and the 42 deprecations of the lowest-dependencies job come from master and are the same there.Verification