iamfarhad /
validation
| 1 | <?php |
||
| 2 | |||
| 3 | /* |
||
| 4 | * This file is part of persian validation package |
||
| 5 | * |
||
| 6 | * (c) Farhad Zand <[email protected]> |
||
| 7 | * |
||
| 8 | * For the full copyright and license information, please view the LICENSE |
||
| 9 | * file that was distributed with this source code. |
||
| 10 | */ |
||
| 11 | |||
| 12 | namespace Iamfarhad\Validation\Contracts; |
||
| 13 | |||
| 14 | abstract class AbstractValidationRule |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * @var null |
||
| 18 | */ |
||
| 19 | public $validationRule; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @param $attribute |
||
| 23 | * @param $value |
||
| 24 | * @param $parameters |
||
| 25 | * @param $validator |
||
| 26 | * @return bool |
||
| 27 | */ |
||
| 28 | abstract public function rule($attribute, $value, $parameters, $validator): bool; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Set validation Rule name. |
||
| 32 | * |
||
| 33 | * @param string $name |
||
| 34 | */ |
||
| 35 | public function setValidationRule(string $name): void |
||
| 36 | { |
||
| 37 | $this->validationRule = $name; |
||
|
0 ignored issues
–
show
|
|||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Get validation Rule name. |
||
| 42 | * |
||
| 43 | * @return string |
||
| 44 | */ |
||
| 45 | public function getValidationRule(): string |
||
| 46 | { |
||
| 47 | return $this->validationRule; |
||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * Register laravel validation extension. |
||
| 52 | */ |
||
| 53 | public function register(): void |
||
| 54 | { |
||
| 55 | \Validator::extend($this->getValidationRule(), function ($attribute, $value, $parameters, $validator) { |
||
| 56 | return $this->rule($attribute, $value, $parameters, $validator); |
||
| 57 | }); |
||
| 58 | \Validator::replacer($this->getValidationRule(), 'ValidationMessages@message'); |
||
| 59 | } |
||
| 60 | } |
||
| 61 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..