Skip to content

feat!: include null/false getter values and add #[JsonIgnore] attribute#66

Merged
usernane merged 3 commits into
devfrom
feat/57-include-null-false-add-json-ignore
Jun 8, 2026
Merged

feat!: include null/false getter values and add #[JsonIgnore] attribute#66
usernane merged 3 commits into
devfrom
feat/57-include-null-false-add-json-ignore

Conversation

@usernane

@usernane usernane commented Jun 8, 2026

Copy link
Copy Markdown
Member

Summary

Include all getter return values (including null and false) in serialized output and add #[JsonIgnore] attribute for explicit exclusion.

Motivation

Getters returning null or false were silently dropped, causing boolean data loss and inconsistency with public property handling. Fixes #57.

Changes

  • Removed null/false filter in JsonConverter::objectToJson() — all getter values are now serialized
  • Added #[JsonIgnore] attribute (TARGET_METHOD | TARGET_PROPERTY) for opt-out exclusion
  • Added ObjWithNullFalseGetters and ObjWithIgnoredProps test helpers
  • Added 4 new tests covering null inclusion, false inclusion, and #[JsonIgnore] on both getters and properties

How to Test / Verify

Unit tests: testGetterReturningNullIsIncluded, testGetterReturningFalseIsIncluded, testJsonIgnoreOnGetter, testJsonIgnoreOnPublicProperty.

Breaking Changes and Migration Steps

Breaking: objects that previously relied on returning null or false from getters to hide properties will now have those properties appear in output. Developers should add #[JsonIgnore] to explicitly exclude properties.

Checklist

  • I reviewed my own diff before requesting review
  • My commits follow Conventional Commits
  • I added/updated tests (or explained why not)
  • I updated docs (if needed) Docs Repo
  • I ran lint/cs-fixer (if applicable) (composer fix-cs)
  • I considered backward compatibility
  • I considered security

Related issues

Closes #57

Ibrahim BinAlshikh added 3 commits June 9, 2026 00:35
- Remove the null/false filter in JsonConverter::objectToJson() so all
  getter return values are serialized (null becomes JSON null, false
  becomes JSON false).
- Add #[JsonIgnore] attribute (TARGET_METHOD | TARGET_PROPERTY) for
  explicit exclusion of getters and public properties.
- Add tests for both behaviors.

Closes #57
@usernane usernane merged commit 60dd995 into dev Jun 8, 2026
2 checks passed
@sonarqubecloud

sonarqubecloud Bot commented Jun 8, 2026

Copy link
Copy Markdown

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