Skip to content

Commit

Permalink
[9.x] Fix ProhibitedIf docblock and constructor (#42964)
Browse files Browse the repository at this point in the history
This applies the same fixes to ProhibitIf as ExcludeIf.
- Missing @throws declaration in docblock: laravel/framework#41729
- Enforces a boolean in the constructor: laravel/framework#41931 laravel/framework#41969

Also fixes the ExcludeIf @var docblock to match as a \Closure
  • Loading branch information
BrandonSurowiec authored Jun 27, 2022
1 parent 42052db commit 11206ad
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Rules/ExcludeIf.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ExcludeIf
/**
* The condition that validates the attribute.
*
* @var callable|bool
* @var \Closure|bool
*/
public $condition;

Expand Down
9 changes: 6 additions & 3 deletions Rules/ProhibitedIf.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,29 @@

namespace Illuminate\Validation\Rules;

use Closure;
use InvalidArgumentException;

class ProhibitedIf
{
/**
* The condition that validates the attribute.
*
* @var callable|bool
* @var \Closure|bool
*/
public $condition;

/**
* Create a new prohibited validation rule based on a condition.
*
* @param callable|bool $condition
* @param \Closure|bool $condition
* @return void
*
* @throws \InvalidArgumentException
*/
public function __construct($condition)
{
if (! is_string($condition)) {
if ($condition instanceof Closure || is_bool($condition)) {
$this->condition = $condition;
} else {
throw new InvalidArgumentException('The provided condition must be a callable or boolean.');
Expand Down

0 comments on commit 11206ad

Please sign in to comment.