diff --git a/src/Rule/General/InRule.php b/src/Rule/General/InRule.php index 3f617c2..159de71 100644 --- a/src/Rule/General/InRule.php +++ b/src/Rule/General/InRule.php @@ -18,7 +18,7 @@ class InRule extends ReadableRule { /** * @param RuleChain $ruleChain - * @param Validated $validated + * @param Validated $validated * @param non-empty-string $valueName * @param non-empty-array $values */ diff --git a/src/Rule/Numeric/Numeric.php b/src/Rule/Numeric/Numeric.php index 0b35dff..bb5a73c 100644 --- a/src/Rule/Numeric/Numeric.php +++ b/src/Rule/Numeric/Numeric.php @@ -60,7 +60,6 @@ public function maxDecimal(int $max): Max /** @var Max $maxRule */ $maxRule = new Max( $this->exceptionFactory(), - /** @phpstan-ignore-next-line */ $this->ruleChain(), $this->validated(), $this->valueName(), @@ -93,11 +92,9 @@ public function exactDigit(int $number, int $maxDecimal = 0): Max { $same = new Same( $this->exceptionFactory(), - /** @phpstan-ignore-next-line */ $this->ruleChain(), $this->validated(), $this->valueName(), - /** @phpstan-ignore-next-line */ new DigitCount(), $number, 'digits before decimals' diff --git a/src/Rule/Object/Property.php b/src/Rule/Object/Property.php index 0967b4a..aeb98da 100644 --- a/src/Rule/Object/Property.php +++ b/src/Rule/Object/Property.php @@ -24,7 +24,7 @@ final class Property extends Rule { /** * @param RuleChain $ruleChain - * @param Validated $validated + * @param Validated $validated * @param non-empty-string $valueName */ public function __construct( diff --git a/src/Rule/String/CaseInsensitiveInRule.php b/src/Rule/String/CaseInsensitiveInRule.php index e6d485d..3281558 100644 --- a/src/Rule/String/CaseInsensitiveInRule.php +++ b/src/Rule/String/CaseInsensitiveInRule.php @@ -19,7 +19,7 @@ final class CaseInsensitiveInRule extends InRule { /** * @param RuleChain $ruleChain - * @param Validated $validated + * @param Validated $validated * @param non-empty-string $valueName * @param non-empty-array $values */ diff --git a/src/Rule/String/InRule.php b/src/Rule/String/InRule.php index ff0b701..82268a8 100644 --- a/src/Rule/String/InRule.php +++ b/src/Rule/String/InRule.php @@ -32,11 +32,10 @@ public function __construct( bool $ignoreCharacterSize ) { if ($ignoreCharacterSize) { - /** @var non-empty-array $values */ $values = array_map(fn (string $value): string => strtolower($value), $values); } - /** @phpstan-ignore-next-line todo rewrite char size ignore */ + /** @phpstan-ignore-next-line */ parent::__construct($exceptionFactory, $ruleChain, $validated, $valueName, $values); $this->ignoreCharacterSize = $ignoreCharacterSize; } @@ -48,11 +47,10 @@ public function __construct( protected function validate($value): string { if ($this->ignoreCharacterSize) { - /** @var Tin $value */ $value = strtolower($value); } - /** @phpstan-ignore-next-line todo rewrite char size ignore */ + /** @phpstan-ignore-next-line */ return parent::validate($value); } } diff --git a/src/Rule/String/StringRule.php b/src/Rule/String/StringRule.php index 511a081..69a9773 100644 --- a/src/Rule/String/StringRule.php +++ b/src/Rule/String/StringRule.php @@ -219,7 +219,7 @@ public function url(array $requiredComponents = [], array $forbiddenComponents = */ public function httpUrl(array $requiredComponents = [], array $forbiddenComponents = []): UrlRule { - /** @var UrlRule */ + /** @phpstan-ignore-next-line */ return $this->url($requiredComponents, $forbiddenComponents, ['http', 'https']); } @@ -230,7 +230,7 @@ public function httpUrl(array $requiredComponents = [], array $forbiddenComponen */ public function httpsUrl(array $requiredComponents = [], array $forbiddenComponents = []): UrlRule { - /** @var UrlRule */ + /** @phpstan-ignore-next-line */ return $this->url($requiredComponents, $forbiddenComponents, ['https']); } diff --git a/src/Rule/Url/Component.php b/src/Rule/Url/Component.php index 41242dc..263e882 100644 --- a/src/Rule/Url/Component.php +++ b/src/Rule/Url/Component.php @@ -28,7 +28,7 @@ public function __construct(?Exception $exceptionFactory, RuleChain $ruleChain, { parent::__construct($exceptionFactory, $ruleChain, $validated, $valueName); - /** @var RuleChain> $ruleChain */ + /** @phpstan-ignore-next-line */ $this->key = new Key($exceptionFactory, $ruleChain, $validated, $valueName, $componentName); } diff --git a/src/Rule/Url/ParseQuery.php b/src/Rule/Url/ParseQuery.php index 7b5169d..c444098 100644 --- a/src/Rule/Url/ParseQuery.php +++ b/src/Rule/Url/ParseQuery.php @@ -32,7 +32,7 @@ public function __construct( ) { parent::__construct($exceptionFactory, $ruleChain, $validated, $valueName); - /** @var RuleChain> $ruleChain */ + /** @phpstan-ignore-next-line */ $this->key = new Key($exceptionFactory, $ruleChain, $validated, $valueName, 'query'); } diff --git a/src/Rule/Url/ParseUrl.php b/src/Rule/Url/ParseUrl.php index 6db04f4..e17fa1d 100644 --- a/src/Rule/Url/ParseUrl.php +++ b/src/Rule/Url/ParseUrl.php @@ -70,11 +70,10 @@ public function __construct(?Exception $exceptionFactory, RuleChain $ruleChain, public function scheme(): Scheme { - /** @var RuleChain> $ruleChain */ - $ruleChain = $this->ruleChain(); return new Scheme( $this->exceptionFactory(), - $ruleChain, + /** @phpstan-ignore-next-line */ + $this->ruleChain(), $this->validated(), $this->valueName().' url scheme', 'scheme' diff --git a/src/Rule/Url/Scheme.php b/src/Rule/Url/Scheme.php index d11178f..6f1fe07 100644 --- a/src/Rule/Url/Scheme.php +++ b/src/Rule/Url/Scheme.php @@ -36,6 +36,7 @@ public function __construct( /** @phpstan-ignore-next-line */ new Key( $exceptionFactory, + /** @phpstan-ignore-next-line */ $ruleChain, $validated, $valueName, @@ -51,7 +52,6 @@ public function __construct( */ public function in(array $values): InRule { - /** @phpstan-ignore-next-line todo WTF function template */ return new \SimpleAsFuck\Validator\Rule\String\InRule( $this->exceptionFactory(), $this->ruleChain(), diff --git a/src/Rule/Url/UrlRule.php b/src/Rule/Url/UrlRule.php index f2fd889..909881e 100644 --- a/src/Rule/Url/UrlRule.php +++ b/src/Rule/Url/UrlRule.php @@ -9,7 +9,6 @@ use SimpleAsFuck\Validator\Model\Validated; use SimpleAsFuck\Validator\Model\ValueMust; use SimpleAsFuck\Validator\Rule\General\CastString; -use SimpleAsFuck\Validator\Rule\General\Conversion; use SimpleAsFuck\Validator\Rule\General\Max; use SimpleAsFuck\Validator\Rule\General\ReadableRule; use SimpleAsFuck\Validator\Rule\String\StringLength; @@ -42,7 +41,9 @@ public function __construct( ) { parent::__construct($exceptionFactory, $ruleChain, $validated, $valueName); - $this->parseUrl = new ParseUrl(null, new RuleChain(), $this->validated(), $this->valueName(), $requiredComponents, $forbiddenComponents); + /** @var RuleChain $ruleChain */ + $ruleChain = new RuleChain(); + $this->parseUrl = new ParseUrl(null, $ruleChain, $this->validated(), $this->valueName(), $requiredComponents, $forbiddenComponents); } /** @@ -51,17 +52,15 @@ public function __construct( */ public function max(int $max): Max { - /** @var RuleChain $ruleChain */ - $ruleChain = $this->ruleChain(); - /** @var Conversion $stringLength */ - $stringLength = new StringLength(); /** @var Max */ return new Max( $this->exceptionFactory(), - $ruleChain, + /** @phpstan-ignore-next-line */ + $this->ruleChain(), $this->validated(), $this->valueName(), - $stringLength, + /** @phpstan-ignore-next-line */ + new StringLength(), new CastString(), $max, 'url length' diff --git a/test/Rule/Object/PropertyTest.php b/test/Rule/Object/PropertyTest.php index ebeb785..ea62ca0 100644 --- a/test/Rule/Object/PropertyTest.php +++ b/test/Rule/Object/PropertyTest.php @@ -19,23 +19,23 @@ public function testCustomException(): void $object = new \stdClass(); $object->property = 0; - /** @var mixed $object */ - + /** @var RuleChain $ruleChain */ + $ruleChain = new RuleChain(); $rule = new \SimpleAsFuck\Validator\Rule\Object\Property( new UnexpectedValueException(), - new RuleChain(), + $ruleChain, new Validated($object), 'object', 'property' ); - $this->expectExceptionMessage('object->property must be something not value: 0'); + $this->expectExceptionMessage('object->property must be something not value type: int'); $rule ->custom(new class () implements UserDefinedRule { public function validate($value) { - throw new ValueMust('be something not value: ' . $value); + throw new ValueMust('be something not value type: ' . gettype($value)); } }) ->notNull() diff --git a/test/Rule/String/CaseInsensitiveInRuleTest.php b/test/Rule/String/CaseInsensitiveInRuleTest.php index d7848c4..f860c51 100644 --- a/test/Rule/String/CaseInsensitiveInRuleTest.php +++ b/test/Rule/String/CaseInsensitiveInRuleTest.php @@ -15,16 +15,18 @@ final class CaseInsensitiveInRuleTest extends TestCase * * @param non-empty-array $values */ - public function test(?string $expectedValue, ?string $expectedExceptionMessage, mixed $value, array $values): void + public function test(?string $expectedValue, ?string $expectedExceptionMessage, string $value, array $values): void { if ($expectedExceptionMessage !== null) { $this->expectException(\UnexpectedValueException::class); $this->expectExceptionMessage($expectedExceptionMessage); } + /** @var RuleChain $ruleChain */ + $ruleChain = new RuleChain(); $rule = new CaseInsensitiveInRule( new UnexpectedValueException(), - new RuleChain(), + $ruleChain, new Validated($value), 'variable', $values