From 3d4b50fe6043fbed855cc8c17671b0ba74bd7dd0 Mon Sep 17 00:00:00 2001 From: azjezz Date: Thu, 12 Aug 2021 23:46:07 +0100 Subject: [PATCH] fix static analysis build Signed-off-by: azjezz --- src/Psl/RandomSequence/Internal/MersenneTwisterTrait.php | 4 +++- src/Psl/Regex/every_match.php | 1 + src/Psl/Type/Type.php | 2 +- src/Psl/Type/TypeInterface.php | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Psl/RandomSequence/Internal/MersenneTwisterTrait.php b/src/Psl/RandomSequence/Internal/MersenneTwisterTrait.php index 410505e6..511c002c 100644 --- a/src/Psl/RandomSequence/Internal/MersenneTwisterTrait.php +++ b/src/Psl/RandomSequence/Internal/MersenneTwisterTrait.php @@ -10,7 +10,7 @@ trait MersenneTwisterTrait { /** - * @var array + * @var non-empty-array */ private array $state; @@ -50,8 +50,10 @@ final public function next(): int $state[$i] = $this->twist($state[$i + 397], $state[$i], $state[$i + 1]); } for (; $i < 623; $i++) { + /** @psalm-suppress PossiblyInvalidArrayOffset */ $state[$i] = $this->twist($state[$i - 227], $state[$i], $state[$i + 1]); } + /** @psalm-suppress InvalidArrayOffset */ $state[623] = $this->twist($state[396], $state[623], $state[0]); $this->state = $state; diff --git a/src/Psl/Regex/every_match.php b/src/Psl/Regex/every_match.php index 9c187f8e..c5fdbccb 100644 --- a/src/Psl/Regex/every_match.php +++ b/src/Psl/Regex/every_match.php @@ -45,6 +45,7 @@ static function () use ($subject, $pattern, $offset): ?array { $capture_groups ??= Type\dict(Type\array_key(), Type\string()); try { + /** @psalm-suppress InvalidArgument */ return Type\vec($capture_groups)->coerce($matching); } catch (InvariantViolationException | Type\Exception\CoercionException $e) { throw new Exception\RuntimeException('Invalid capture groups', 0, $e); diff --git a/src/Psl/Type/Type.php b/src/Psl/Type/Type.php index e56fee6e..9bc647f1 100644 --- a/src/Psl/Type/Type.php +++ b/src/Psl/Type/Type.php @@ -8,7 +8,7 @@ use Psl\Type\Exception\TypeTrace; /** - * @template T + * @template-covariant T * * @implements TypeInterface */ diff --git a/src/Psl/Type/TypeInterface.php b/src/Psl/Type/TypeInterface.php index 0633fa86..4c1831da 100644 --- a/src/Psl/Type/TypeInterface.php +++ b/src/Psl/Type/TypeInterface.php @@ -9,7 +9,7 @@ use Psl\Type\Exception\TypeTrace; /** - * @template T + * @template-covariant T */ interface TypeInterface {