Skip to content

Conversation

@charjr
Copy link

@charjr charjr commented Jan 30, 2026

Handles new constant added since 8.1 (not currently documented in table but exists here

\JSON_ERROR_UNSUPPORTED_TYPE => 'A value of a type that cannot be encoded was given',
\JSON_ERROR_INVALID_PROPERTY_NAME => 'A property name that cannot be encoded was given',
\JSON_ERROR_UTF16 => 'Malformed UTF-16 characters, possibly incorrectly encoded',
\JSON_ERROR_NON_BACKED_ENUM ?? 11 => 'Value contains a non-backed enum which cannot be serialized.',
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the ?? 11? None of the others have a numeric fallback. Since it's a lookup table, it shouldn't get hit even on an older version. (See the getExceptionMessage() method below.)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, well, looks like the tests fail anyway on 8.0, because of the undefined constant, even with that fallback.

Possible solutions:

  1. According to Packagist, there's ~8% of installs on 7.4(!) right now. Otherwise, nearly everyone is on 8.1 or higher. So we could just bump the version requirement to 8.1 (or, really, 8.2 or 8.3), release a new minor, and move on with life. I have little interest in expending effort to support unsupported PHP versions.
  2. Change the map from a const to just a protected array, and then conditionally add an extra value to it in the constructor if the constant is defined.

Thoughts?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with 1.

7.4 reached eol 3+ years ago. 8.1 reached eol last month.

8.2 and 8.3 only get security support at this point, but I see no harm in supporting them if they aren't causing issues.

@Crell Crell mentioned this pull request Feb 2, 2026
@Crell
Copy link
Owner

Crell commented Feb 2, 2026

master now requires PHP 8.3. Please rebase/rebuild this branch on master (without the now-unnecessary fallback) and force push. I can release a new minor once it's merged.

Handles new constant added since 8.1 (not currently documented in table but [exists here](https://www.php.net/manual/en/json.constants.php#constant.json-error-non-backed-enum)
@charjr
Copy link
Author

charjr commented Feb 2, 2026

master now requires PHP 8.3.

Thank you.

Please rebase/rebuild this branch on master (without the now-unnecessary fallback) and force push.

Done. ✔️

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.

2 participants