Skip to content

Commit

Permalink
Fix deprecation with empty rules (#42213)
Browse files Browse the repository at this point in the history
  • Loading branch information
driesvints authored May 2, 2022
1 parent 31dfefc commit 6741fa8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Illuminate/Validation/ValidationRuleParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ protected function explodeExplicitRule($rule, $attribute)
return array_map(
[$this, 'prepareRule'],
$rule,
array_fill(array_key_first($rule), count($rule), $attribute)
array_fill((int) array_key_first($rule), count($rule), $attribute)
);
}

Expand Down
7 changes: 7 additions & 0 deletions tests/Validation/ValidationRuleParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ public function testEmptyRulesArePreserved()
], $rules);
}

public function testEmptyRulesCanBeExploded()
{
$parser = new ValidationRuleParser(['foo' => 'bar']);

$this->assertIsObject($parser->explode(['foo' => []]));
}

public function testConditionalRulesWithDefault()
{
$rules = ValidationRuleParser::filterConditionalRules([
Expand Down

0 comments on commit 6741fa8

Please sign in to comment.