-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Closed
Labels
Milestone
Description
This is a (multiple allowed):
-
feature-discussion (RFC)
-
CakePHP Version: 4
What you did
->add('pr', 'unique-issue', [
'rule' => ['validateUniqueIssue', ['scope' => ['repository']],
'message' => 'This PR is already linked to a group with this issue.',
'provider' => 'table',
]);
and
/**
* @param string $value
* @param array $additional
* @param array $context
*
* @return bool
*/
public function validateUniqueIssue($value, array $additional, array $context)
What happened
This is fine until you remove the additional scope
->add('pr', 'unique-issue', [
'rule' => ['validateUniqueIssue'],
'message' => 'This PR is already linked to a group with this issue.',
'provider' => 'table',
]);
Then it breaks as the arguments into the method fail with "ArgumentCountError: Too few arguments to function ...".
It now suddenly expects
/**
* @param string $value
* @param array $context
*
* @return bool
*/
public function validateUniqueIssue($value, array $context)
What you expected to happen
To have a more reliable and reusable kind of signature here, consistent in both cases so if used in one table validator with and in another without it still works out.
Either we keep 2 args and merge the additional keys into the existing context.
Or we always have 3 and the 2nd can be an empty array here.