From e58434257069f7f578c0ab982bc6f2744939afdf Mon Sep 17 00:00:00 2001 From: Maarten Paauw Date: Thu, 30 Apr 2026 13:23:44 +0200 Subject: [PATCH] chore(json-schema): add PHPStan assertions to `ValidationResult` helpers Add `@phpstan-assert-if-true` annotations to `isValid()` and `hasError()`in ValidationResult. This project does not run PHPStan itself, but these annotations improve type inference for projects that consume this package and do use PHPStan. --- src/ValidationResult.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ValidationResult.php b/src/ValidationResult.php index 08ca63f..23bd019 100644 --- a/src/ValidationResult.php +++ b/src/ValidationResult.php @@ -33,11 +33,17 @@ public function error(): ?ValidationError return $this->error; } + /** + * @phpstan-assert-if-true null $this->error + */ public function isValid(): bool { return $this->error === null; } + /** + * @phpstan-assert-if-true ValidationError $this->error + */ public function hasError(): bool { return $this->error !== null;