Add conditional return type for sanitize_term_field #382
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.
The return type of
sanitize_term_field()depends on both the$fieldbeing sanitised and the$context.For integer fields
it returns a non-negative integer. The exact constant value cannot be inferred from the input
$value, as the passed$values are strings.For all other fields, the type depends on the
$context:'raw':$valueis returned as is, which is handled via the templateT; for constant strings, the same constant string is returned.'attribute'|'edit'|'js':$valueis escaped--and may be transformed--usingesc_attr(),esc_html(), oresc_js(). Assuming the filters in these functions do not alter the type, the returned type isstring, even if$valueis a constant string.$contextvalues:$valueis not escaped but is filtered, with the filter callback documented as returningmixed. Therefore, the default return type ofmixedis retained.