Skip to content

Multiple code quality improvements - #40

Merged
ultrono merged 7 commits into
masterfrom
ultrono-patch-8
May 31, 2026
Merged

ultrono merged 7 commits into
masterfrom
ultrono-patch-8

Conversation

@ultrono

@ultrono ultrono commented May 31, 2026 •

Copy link
Copy Markdown
Contributor
  • document fact that respondNoContent() method signature will change in future releases (per RFC 9110, a 204 response MUST NOT include content), add deprecated tag
  • remove magic number from apiResponse() method signature
  • use \Throwable instead of Exception (morphMessage(string|Exception $message) misses Error subclasses (TypeError, ValueError, etc.) - package is now PHP 8.2+, use string|\Throwable)
  • fix indentation in respondCreated() and respondTeapot() methods
  • fix morphToArray() method - jsonSerialize() returns mixed, not array JsonSerializable::jsonSerialize() has a return type of mixed in PHP 8.0+. If an object returns a scalar, the ?array return type annotation is a lie and apiResponse(array $data) will throw a TypeError at runtime
  • redundant null coalescing in respondCreated() and respondNoContent() methods
  • additional helpers methods: respondAccepted(), respondConflict() and respondTooManyRequests() (with tests)
  • refactor data providers within tests to use generators (better readability and memory usage)
  • fix missing type hint for testSuccessResponseDefaults() within tests
  • add missing tests cases for respondAccepted() method
  • add missing tests cases for respondFailedValidation() method
  • add missing tests cases for respondNotFound() method
  • use version ^5.0 for the checkout and cache actions within the GitHub actions file

ultrono added 7 commits May 31, 2026 09:37
- document fact that `respondNoContent` method signature will change in future releases (per RFC 9110, a 204 response MUST NOT include content), add deprecated tag
- remove magic number from `apiResponse` method signature
- Use \Throwable instead of Exception (`morphMessage(string|Exception $message)` misses Error subclasses (TypeError, ValueError, etc.). As the package is now PHP 8.2+, use string|\Throwable)
- fix indentation in `respondCreated` and `respondTeapot` methods
- fix `morphToArray` method. `jsonSerialize()` returns mixed, not array
  `JsonSerializable::jsonSerialize()` has a return type of mixed in PHP 8.0+. If an object returns a scalar, the `?array` return type annotation is a lie and `apiResponse(array $data)` will throw a TypeError at runtime
- redundant null coalescing in `respondCreated` and `respondNoContent` methods
- add `respondTooManyRequests()`, `respondConflict()` and `respondAccepted()` methods
- refactor data providers to use generators
- add missing tests for new helper methods
@ultrono
ultrono merged commit 9f91e20 into master May 31, 2026
44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant