Validate query parameters and reject non-scalars #211
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This changeset ensures we properly validate any query parameters and reject unsupported non-scalars such as objects/arrays/resources. This should be in line with the existing design and should not affect any existing code using scalar or
null
values.Most notably, this fixes an old bug that would invalidate the entire connection object if an unexpected value is passed as discussed in #167. With these changes applied, it will now properly reject any invalid values, leaving the connection in a valid state for any following queries. The affected code comes with updated tests that have 100% code coverage.
Additionally, it adds some stricter types to the public API that makes it easier to detect this problem for any static analysis tools such as PHPStan or your favorite IDE.
On top of this, this is done in preparation for named query params as discussed in #41. Among others, this will change the
list
type to anarray
type again. I'll file a follow-up PR once this one is in.If you want to support this project, please consider sponsoring @reactphp – sponsorships really do make a difference ❤️
Builds on top of #210, #186, #40, clue/reactphp-redis#171, and others
Resolves / closes #167
Refs #41