From 33f92d4cf58d77406fc898095b00ba5296fd3432 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Bar=C3=A1=C5=A1ek?= Date: Tue, 24 Mar 2020 22:38:01 +0100 Subject: [PATCH] Fix PhpStan errors --- phpstan.neon | 3 ++- src/GitLabApi.php | 7 ++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index 2003a9f..7085165 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -3,4 +3,5 @@ includes: - vendor/phpstan/phpstan-nette/rules.neon parameters: - checkGenericClassInNonGenericObjectType: false \ No newline at end of file + checkGenericClassInNonGenericObjectType: false + checkMissingIterableValueType: false \ No newline at end of file diff --git a/src/GitLabApi.php b/src/GitLabApi.php index 648998e..2aa3304 100644 --- a/src/GitLabApi.php +++ b/src/GitLabApi.php @@ -269,10 +269,7 @@ public function validateToken(string $token): bool { $response = $this->request('projects', null, '1 hour', $token); - return (\is_array($response) === false - && $response->offsetExists('message') - && $response->message === '401 Unauthorized' - ) === false; + return ($response instanceof ApiData && $response->offsetExists('message') && $response->message === '401 Unauthorized') === false; } @@ -295,7 +292,7 @@ private function mapToApiData($haystack) if ($haystack instanceof \stdClass) { $return = new ApiData; - foreach ($haystack as $key => $value) { + foreach ((array) $haystack as $key => $value) { $return->{$key} = $value; }