Skip to content

fix: $message param accepts any type (Throwable, WP_Error, string, array, object)#21

Merged
frugan-dev merged 1 commit into
mainfrom
fix/mixed-type-hint
Sep 5, 2025
Merged

fix: $message param accepts any type (Throwable, WP_Error, string, array, object)#21
frugan-dev merged 1 commit into
mainfrom
fix/mixed-type-hint

Conversation

@frugan-dev

@frugan-dev frugan-dev commented Sep 5, 2025

Copy link
Copy Markdown
Contributor

MESSAGE TYPE COMPATIBILITY:

  • Wonolog (primary target): Accepts truly mixed types natively
    ✅ Throwable, WP_Error, Arrays, Objects, Strings - all supported

  • PSR Log ^1.0: Uses mixed type hint but expects primarily strings
    ⚠️ Throwable/Objects/Arrays not officially supported by spec

  • PSR Log ^2.0+: Strictly enforces string|\Stringable only
    ❌ Throwable, Arrays, Objects cause TypeError

DESIGN DECISION:
WP Logger maintains Wonolog-compatible design for maximum flexibility in the WordPress ecosystem. When Wonolog is active, all mixed types are passed through natively. In fallback mode, types are converted to strings via formatMessage().

…ray, object)

MESSAGE TYPE COMPATIBILITY:
- Wonolog (primary target): Accepts truly mixed types natively
✅ Throwable, WP_Error, Arrays, Objects, Strings - all supported

- PSR Log ^1.0: Uses mixed type hint but expects primarily strings
⚠️  Throwable/Objects/Arrays not officially supported by spec

- PSR Log ^2.0+: Strictly enforces string|\Stringable only
❌ Throwable, Arrays, Objects cause TypeError

DESIGN DECISION:
WP Logger maintains Wonolog-compatible design for maximum flexibility
in the WordPress ecosystem. When Wonolog is active, all mixed types
are passed through natively. In fallback mode, types are converted
to strings via formatMessage().
@codecov

codecov Bot commented Sep 5, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.88889% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/Logger.php 88.88% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@frugan-dev frugan-dev merged commit 5e940bf into main Sep 5, 2025
10 checks passed
@frugan-dev frugan-dev deleted the fix/mixed-type-hint branch September 5, 2025 13:42
github-actions Bot added a commit that referenced this pull request Sep 5, 2025
## [2.1.2](v2.1.1...v2.1.2) (2025-09-05)

### Bug Fixes

* $message param accepts any type (Throwable, WP_Error, string, array, object) ([#21](#21)) ([5e940bf](5e940bf))
@github-actions

github-actions Bot commented Sep 5, 2025

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 2.1.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant