Skip to content

feat!: release v5.0.0#70

Merged
usernane merged 12 commits into
mainfrom
dev
Jun 10, 2026
Merged

feat!: release v5.0.0#70
usernane merged 12 commits into
mainfrom
dev

Conversation

@usernane

Copy link
Copy Markdown
Member

Summary

Release v5.0.0 — major version with breaking encoding changes, new attribute system, typed deserialization, and static configuration API.

Motivation

All planned v5 enhancements implemented and merged to dev. Ready for production release.

Changes

How to Test / Verify

composer install
composer test

Breaking Changes and Migration Steps

  1. Associative arrays auto-detected as objectsaddArray() now encodes associative arrays as JSON objects. Remove explicit $asObject = true (still works, just redundant).
  2. Getter-derived names normalized — with styles other than none, getName()name (camel), name (snake). Style none unchanged.
  3. Error suppression removed — real errors propagate; getters requiring params are skipped.
  4. Global constants deprecatedJSON_STYLE, JSON_CASE, WF_VERBOSE trigger E_USER_DEPRECATED.

Checklist

  • I reviewed my own diff before requesting review
  • My commits follow Conventional Commits
  • The title of the pull request follows Conventional Commits
  • I added/updated tests (or explained why not)
  • I updated docs (if needed)
  • I ran lint/cs-fixer (if applicable)
  • I considered backward compatibility
  • I considered security

Related issues

Closes #56, #58, #59, #60, #61, #63

Ibrahim BinAlshikh and others added 12 commits June 10, 2026 23:25
…eter check

Remove set_error_handler(null)/restore_error_handler() and use
ReflectionMethod::getNumberOfRequiredParameters() to skip getters
that require arguments. Real errors now propagate instead of being
silently swallowed.

Closes #60
…nProperty] attribute

- Fix CaseConverter::toCamelCase() to lowercase first character of PascalCase input
- Add #[JsonProperty] attribute for explicit name override on getters and properties
- Add nameIsExplicit flag to Property to prevent style conversion on explicit names
- Check for #[JsonProperty] in objectToJson() for both getters and public properties

Style 'none' preserves backward-compatible PascalCase getter names.
Other styles now properly normalize (e.g. getName() -> 'name' in camel).

Closes #58
…ects

Add isIndexedArr() check in arrayToJsonString() to automatically treat
arrays with non-integer keys as JSON objects. The $asObject parameter
remains as an explicit override.

This aligns encoding behavior with json_encode() and prevents silent
data loss when associative arrays are passed without $asObject = true.

Updated test expectations to reflect the new correct behavior.

Closes #56
Add Json::setDefaults() and Json::resetDefaults() static methods for
application-wide configuration of style, case, and formatted output.

Static defaults take priority over global constants. Constructor
parameters override both. Global constants (JSON_STYLE, JSON_CASE,
WF_VERBOSE) now trigger E_USER_DEPRECATED notices when used.

Closes #61
Add Json::decodeAs() for deserializing JSON strings into typed objects.
Add JsonDeserializer class implementing the hydration algorithm:
  1. Static fromJSON(Json) factory method (custom deserialization)
  2. Constructor parameter reflection with recursive type resolution
  3. Setter/public property fallback for remaining keys

Add #[JsonType] attribute for annotating array-of-objects parameters
where PHP's type system is insufficient.

Add Json::setTypeMap() for runtime type mapping on decoded instances,
enabling typed returns from get() without attributes.

Closes #59
Restructure README to match the WebFiori ecosystem standard:
- Centered badges block (matching webfiori/collections style)
- Table of Contents
- composer require installation
- Contributing, License, Support, and Changelog sections
- Updated content to reflect all v5 features

Closes #63
…ures

Updated:
- 02-arrays.php: show auto-detection of associative arrays (no $asObject flag)
- 04-object-auto-mapping.php: show #[JsonProperty], #[JsonIgnore], normalization

Added:
- 08-json-property-attribute.php: explicit name override immune to style conversion
- 09-typed-deserialization.php: decodeAs(), nested hydration, #[JsonType], setTypeMap()
- 10-set-defaults.php: Json::setDefaults() and resetDefaults()
- Updated examples/README.md with new entries
Add JsonDeserializerTest covering:
- decodeAs() basic, nested, deep nesting
- fromJSON factory method support
- #[JsonType] attribute on constructor params and properties
- setTypeMap() runtime type registry
- setDefaults/resetDefaults
- #[JsonProperty] encoding behavior
- Associative array auto-detection
- Property nameIsExplicit flag
- CaseConverter camelCase fix

Add JsonCoverageTest covering:
- Setter-based hydration with typed params
- hydrateByJsonType edge cases
- Getter with required params skipped
- toJsonFile error paths
- addBoolean type guard

Coverage: 78% → 97.8% (remaining lines are constant-deprecation
branches, filesystem failure edges, and dead type guards)
@codecov

codecov Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.14894% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.05%. Comparing base (830e8b1) to head (bb05169).
⚠️ Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
WebFiori/Json/JsonDeserializer.php 92.66% 8 Missing ⚠️
WebFiori/Json/Json.php 93.02% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main      #70      +/-   ##
============================================
- Coverage     98.97%   98.05%   -0.93%     
- Complexity      250      342      +92     
============================================
  Files             4        7       +3     
  Lines           587      771     +184     
============================================
+ Hits            581      756     +175     
- Misses            6       15       +9     
Flag Coverage Δ
php-8.1 98.05% <94.14%> (-0.93%) ⬇️
php-8.2 98.05% <94.14%> (-0.93%) ⬇️
php-8.3 98.05% <94.14%> (-0.93%) ⬇️
php-8.4 98.05% <94.14%> (-0.93%) ⬇️
php-8.5 98.05% <94.14%> (-0.93%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sonarqubecloud

Copy link
Copy Markdown

@usernane usernane merged commit a6bd41f into main Jun 10, 2026
18 of 20 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.

feat(encoding): Auto-detect associative arrays and encode as JSON objects

1 participant