Firm up Callback arguments and document $context
parameter.
#379
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.
Changes the Callback validator so that the callable always receives
(mixed $value, array $context, ...$otherArgs)
- this stabilizes the args for all environments, i.e. standalone usage and when part of input-filter etc.Because the Callback validator is used internally, by the CreditCard validator, this also affects the signature of the
service
option to include context and declares the$context
param inCreditCard::isValid()
so that it can correctly be passed to the composed callback validator.Will need to document this change in #253
Edit: a bit more clarity…
Previously, the callback might receive
(mixed $value, ...$userDefinedArgs)
or(mixed $value, array $context, ...$userDefinedArgs)
depending on whether the context was given toCallback::isValid()
as the second param. This is difficult to document and hard to understand when the given arguments might differ.This change means that the required signature of the callback is consistent at all times, but
$context
might be === [] in standalone usage.