From 59b92bc1694c4c780c4437d5f8b3236bc8d7cdd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Tvrd=C3=ADk?= Date: Wed, 8 Mar 2023 12:51:08 +0100 Subject: [PATCH] increase phpstan level to 6 --- phpstan.neon | 3 ++- src/Schema/Elements/AnyOf.php | 2 +- src/Schema/Elements/Base.php | 6 +++--- src/Schema/Elements/Structure.php | 4 ++-- src/Schema/Elements/Type.php | 2 +- src/Schema/Processor.php | 4 ++-- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index 8a634ad..bccf823 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,5 +1,6 @@ parameters: - level: 5 + level: 6 + checkMissingIterableValueType: false paths: - src diff --git a/src/Schema/Elements/AnyOf.php b/src/Schema/Elements/AnyOf.php index 3d649df..0bb548b 100644 --- a/src/Schema/Elements/AnyOf.php +++ b/src/Schema/Elements/AnyOf.php @@ -63,7 +63,7 @@ public function normalize(mixed $value, Context $context): mixed } - public function merge($value, $base): mixed + public function merge(mixed $value, mixed $base): mixed { if (is_array($value) && isset($value[Helpers::PreventMerging])) { unset($value[Helpers::PreventMerging]); diff --git a/src/Schema/Elements/Base.php b/src/Schema/Elements/Base.php index e7df04c..3d5b344 100644 --- a/src/Schema/Elements/Base.php +++ b/src/Schema/Elements/Base.php @@ -30,7 +30,7 @@ trait Base private ?string $deprecated = null; - public function default($value): self + public function default(mixed $value): self { $this->default = $value; return $this; @@ -161,7 +161,7 @@ private function isInRange(mixed $value, array $range): bool } - private function doFinalize(mixed $value, Context $context) + private function doFinalize(mixed $value, Context $context): mixed { if ($this->castTo) { if (Nette\Utils\Validators::isBuiltinType($this->castTo)) { @@ -183,7 +183,7 @@ private function doFinalize(mixed $value, Context $context) Nette\Schema\Message::FailedAssertion, ['value' => $value, 'assertion' => $expected], ); - return; + return null; } } diff --git a/src/Schema/Elements/Structure.php b/src/Schema/Elements/Structure.php index cafc538..88552dc 100644 --- a/src/Schema/Elements/Structure.php +++ b/src/Schema/Elements/Structure.php @@ -43,7 +43,7 @@ public function __construct(array $items) } - public function default($value): self + public function default(mixed $value): self { throw new Nette\InvalidStateException('Structure cannot have default value.'); } @@ -110,7 +110,7 @@ public function normalize(mixed $value, Context $context): mixed } - public function merge(mixed $value, $base): mixed + public function merge(mixed $value, mixed $base): mixed { if (is_array($value) && isset($value[Helpers::PreventMerging])) { unset($value[Helpers::PreventMerging]); diff --git a/src/Schema/Elements/Type.php b/src/Schema/Elements/Type.php index 22bcb16..e95514e 100644 --- a/src/Schema/Elements/Type.php +++ b/src/Schema/Elements/Type.php @@ -130,7 +130,7 @@ public function normalize(mixed $value, Context $context): mixed } - public function merge(mixed $value, $base): mixed + public function merge(mixed $value, mixed $base): mixed { if (is_array($value) && isset($value[Helpers::PreventMerging])) { unset($value[Helpers::PreventMerging]); diff --git a/src/Schema/Processor.php b/src/Schema/Processor.php index 53d14a9..7280548 100644 --- a/src/Schema/Processor.php +++ b/src/Schema/Processor.php @@ -24,7 +24,7 @@ final class Processor private bool $skipDefaults = false; - public function skipDefaults(bool $value = true) + public function skipDefaults(bool $value = true): void { $this->skipDefaults = $value; } @@ -34,7 +34,7 @@ public function skipDefaults(bool $value = true) * Normalizes and validates data. Result is a clean completed data. * @throws ValidationException */ - public function process(Schema $schema, $data): mixed + public function process(Schema $schema, mixed $data): mixed { $this->createContext(); $data = $schema->normalize($data, $this->context);