Skip to content

Commit

Permalink
Fix validation rule type hints (#52870)
Browse files Browse the repository at this point in the history
  • Loading branch information
axlon authored Sep 22, 2024
1 parent 33912a9 commit 66384be
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Illuminate/Contracts/Validation/InvokableRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface InvokableRule
*
* @param string $attribute
* @param mixed $value
* @param \Closure(string, ?string = null): \Illuminate\Translation\PotentiallyTranslatedString $fail
* @param \Closure(string, ?string=): \Illuminate\Translation\PotentiallyTranslatedString $fail
* @return void
*/
public function __invoke(string $attribute, mixed $value, Closure $fail);
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Contracts/Validation/ValidationRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface ValidationRule
*
* @param string $attribute
* @param mixed $value
* @param \Closure(string, ?string = null): \Illuminate\Translation\PotentiallyTranslatedString $fail
* @param \Closure(string, ?string=): \Illuminate\Translation\PotentiallyTranslatedString $fail
* @return void
*/
public function validate(string $attribute, mixed $value, Closure $fail): void;
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Foundation/Console/stubs/rule.implicit.stub
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class {{ class }} implements ValidationRule
/**
* Run the validation rule.
*
* @param \Closure(string, ?string = null): \Illuminate\Translation\PotentiallyTranslatedString $fail
* @param \Closure(string, ?string=): \Illuminate\Translation\PotentiallyTranslatedString $fail
*/
public function validate(string $attribute, mixed $value, Closure $fail): void
{
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Foundation/Console/stubs/rule.stub
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class {{ class }} implements ValidationRule
/**
* Run the validation rule.
*
* @param \Closure(string, ?string = null): \Illuminate\Translation\PotentiallyTranslatedString $fail
* @param \Closure(string, ?string=): \Illuminate\Translation\PotentiallyTranslatedString $fail
*/
public function validate(string $attribute, mixed $value, Closure $fail): void
{
Expand Down
13 changes: 13 additions & 0 deletions types/Contracts/Validation/ValidationRule.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

use Illuminate\Contracts\Validation\ValidationRule;

use function PHPStan\Testing\assertType;

new class implements ValidationRule
{
public function validate(string $attribute, mixed $value, Closure $fail): void
{
assertType('Closure(string, string|null=): Illuminate\Translation\PotentiallyTranslatedString', $fail);
}
};

0 comments on commit 66384be

Please sign in to comment.