Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add PHP JsonSerializable Preset #1491

Merged
merged 6 commits into from
Aug 26, 2023

Commits on Aug 24, 2023

  1. feat: PHP JsonSerializable Preset

    In PHP objects (and also arrays and scalars) can be serialized to JSON
    using the function `json_encode()`. In order to maintain the correct
    property names and values for Enums, normalization of values needs to be
    implemented manually using the `JsonSerializable` interface.
    
    The serialization to JSON can be enabled by using the optional preset
    `PHP_JSON_SERIALIZABLE_PRESET`.
    
    This way of serializing PHP objects does not require any user land
    package and works out of the box with each PHP version. It is also
    compatible with different serialization frameworks, like Symfony.
    markuspoerschke committed Aug 24, 2023
    Configuration menu
    Copy the full SHA
    ca14b8d View commit details
    Browse the repository at this point in the history
  2. Update docs/languages/Php.md

    Co-authored-by: Jonas Lagoni <[email protected]>
    markuspoerschke and jonaslagoni authored Aug 24, 2023
    Configuration menu
    Copy the full SHA
    18459f3 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    1304e30 View commit details
    Browse the repository at this point in the history

Commits on Aug 25, 2023

  1. Apply feedback from code review

    * remove import of JsonSerializable
    * add test for mixed (int and string) enums
    markuspoerschke committed Aug 25, 2023
    Configuration menu
    Copy the full SHA
    048c9e1 View commit details
    Browse the repository at this point in the history
  2. Apply code review feedback

    * extract serializing properties to own variable to make
      code more readable.
    * use ConstrainedDictionaryModel to detect additional properties
    markuspoerschke committed Aug 25, 2023
    Configuration menu
    Copy the full SHA
    f2616f9 View commit details
    Browse the repository at this point in the history
  3. Fix tests

    markuspoerschke committed Aug 25, 2023
    Configuration menu
    Copy the full SHA
    6e8fba3 View commit details
    Browse the repository at this point in the history