Skip to content

Translatable problem details, CursorPage typing, 415 for multipart - #1

Merged
JustSteveKing merged 3 commits into
mainfrom
translatable-problem-details
Oct 20, 2026
Merged

JustSteveKing merged 3 commits into
mainfrom
translatable-problem-details

Conversation

@JustSteveKing

Copy link
Copy Markdown
Owner

Three fixes found while moving JustSteveKing/kit onto the package. Each is its own commit.

Translatable problem details

Every detail the package writes itself (idempotency, negotiation, conditional requests, merge patch, digests, signatures, pagination, async) now comes from resources/lang/en/problems.php, read in the application's locale through Support\Messages.

  • Apps publish with php artisan vendor:publish --tag=api-toolbox-lang and add lang/vendor/api-toolbox/{locale}/problems.php.
  • A line missing from a locale falls back to English. Outside an application, Messages reads the English file directly.
  • type and title don't change with the language, so clients keep branching on type.
  • English text is unchanged, so existing assertions on detail still pass.
  • A test checks that every key the source asks for has an English line.

CursorPage typing

CursorPage::of() took CursorPaginator<array-key, mixed>, which Eloquent's cursorPaginate() result (CursorPaginator<int, Model>) never matches, so every app at a strict PHPStan level needed an ignore. CursorPage and PaginationLinks::for() are now generic over the paginator's key and value types. A fixture controller makes PHPStan check a real Eloquent call.

415 for multipart uploads

consumes: only looked at the raw body. PHP parses multipart/form-data into fields and files and leaves php://input empty, so a multipart upload to a JSON route went through. Form fields and uploaded files now count as content.

Release

No breaking changes. The behaviour change is that multipart requests to consumes: routes are now refused when they don't match, which is what the middleware already promised. Suggest releasing as v0.3.0.

2950 tests pass; PHPStan and Pint are clean.

Every detail the package raises itself now comes from
resources/lang/en/problems.php through Support\Messages, which reads it
in the application's locale. Applications publish the file with
--tag=api-toolbox-lang and add lang/vendor/api-toolbox/{locale}; a
missing line falls back to English. Outside an application the English
file is read directly.

Type and title stay the same in every language, so clients can keep
branching on the type. A test checks every key the source asks for has
an English line.
CursorPage::of() took CursorPaginator<array-key, mixed>. Laravel's TKey
is invariant, so the CursorPaginator<int, Model> that cursorPaginate()
returns never matched, and every application calling it at a strict
PHPStan level needed an ignore. CursorPage and PaginationLinks::for()
are now generic over the paginator's key and value types. A fixture
controller makes PHPStan check a real Eloquent call.
consumes: only looked at the raw body. PHP parses multipart/form-data
into fields and files and leaves php://input empty, so a multipart
upload to a JSON route had no content as far as the middleware could
tell, and went through. Form fields and uploaded files now count as
content. Laravel's post() test helper sends fields the same way, which
is how this surfaced.
@coderabbitai

coderabbitai Bot commented Oct 20, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1329e07e-7287-43fd-b58d-751fe662ac9c
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@JustSteveKing JustSteveKing self-assigned this Oct 20, 2026
@JustSteveKing JustSteveKing added the enhancement New feature or request label Oct 20, 2026
@JustSteveKing
JustSteveKing merged commit 7917bf1 into main Oct 20, 2026
7 checks passed
@JustSteveKing
JustSteveKing deleted the translatable-problem-details branch October 20, 2026 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant