Skip to content

Commit

Permalink
Removed unnecessary checks as is_callable would return false for lite…
Browse files Browse the repository at this point in the history
…rals other than strings anyway, fixed tests (#37700)
  • Loading branch information
0xcrypto committed Jun 16, 2021
1 parent c550e09 commit a048f99
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 7 deletions.
2 changes: 1 addition & 1 deletion src/Illuminate/Validation/Rules/RequiredIf.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class RequiredIf
*/
public function __construct($condition)
{
if (! is_string($condition) && (is_bool($condition) || is_callable($condition))) {
if (! is_string($condition)) {
$this->condition = $condition;
} else {
throw new InvalidArgumentException('The provided condition must be a callable or boolean.');
Expand Down
6 changes: 0 additions & 6 deletions tests/Validation/ValidationRequiredIfTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ public function testItOnlyCallableAndBooleanAreAcceptableArgumentsOfTheRule()
$this->expectException(\InvalidArgumentException::class);

$rule = new RequiredIf('phpinfo');

$rule = new RequiredIf(12.3);

$rule = new RequiredIf(new stdClass());
}

public function testItReturnedRuleIsNotSerializable()
Expand All @@ -52,7 +48,5 @@ public function testItReturnedRuleIsNotSerializable()
$rule = serialize(new RequiredIf(function () {
return true;
}));

$rule = serialize(new RequiredIf());
}
}

0 comments on commit a048f99

Please sign in to comment.