Skip to content

Conversation

@carlos-granados
Copy link
Contributor

@carlos-granados carlos-granados commented Jan 29, 2026

When the JsonValidateRector rule converts the json_decode function call to a json_validate function call, it incorrectly preserves the "associative" parameter if it is present. This is wrong because json_validate does not have an "associative" argument (it does not create json output, so this argument would be useless). This results in code which is either incorrect (passing the associative parameter to the flags argument) or an error if named arguments are used.

See https://getrector.com/demo/99b22fb6-f24a-485d-a5fe-e402ed53f886

This PR fixes this problem by removing the "associative" parameter if present. It also updates existing fixtures so that they show the new, correct, output

Fixes rectorphp/rector#9623

…json_validate

- json_validate() does not have associative parameter that json_decode() has
- Remove associative arg by position (1) or name before converting
- Updated fixture files to reflect correct expected output
@TomasVotruba
Copy link
Member

LGTM, thank you 👍

@TomasVotruba TomasVotruba merged commit e4a0507 into rectorphp:main Jan 29, 2026
57 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.

JsonValidateRector rule incorrectly preserves the associative argument

3 participants