Skip to content

Conversation

jnoordsij
Copy link
Contributor

PHP 8.3 introduces a json_validate function, which allows validating if a string contains valid json with less resource and memory consumption than using the json_encode function.

This PR uses the new function when it's available and thus is backwards compatible with older PHP versions, while taking advantage of the new function on PHP >= 8.3.

Note that Symfony has a polyfill for this, which is probably what will be used in practice by most existing Laravel installations using PHP < 8.3 (as the polyfills are loaded with recent versions of symfony/http-foundation), which would allow removing the json_decode call sometime in the future.

See also the RFC.

@taylorotwell taylorotwell merged commit a02a39b into laravel:10.x Sep 12, 2023
@driesvints
Copy link
Member

@jnoordsij nice, thanks!

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.

3 participants