From 4022c2fc36509ec0d72a98c6080492a2a7e0f57c Mon Sep 17 00:00:00 2001 From: Taka Oyama Date: Mon, 3 Jun 2024 13:42:11 +0900 Subject: [PATCH] chore: fix stan errors --- phpstan.neon | 2 +- src/Connection.php | 2 +- src/Eloquent/Model.php | 3 ++- src/Schema/Grammar.php | 5 +---- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index 325089c4..1a6cb9b1 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,9 +1,9 @@ parameters: level: max - checkMissingIterableValueType: false paths: - src ignoreErrors: + - identifier: missingType.iterableValue - '#^Access to an undefined property Illuminate\\Support\\Fluent.*$#' - '#^Call to an undefined method Illuminate\\Support\\Fluent.*$#' - '#^Access to an undefined property Colopl\\Spanner\\Schema\\IndexDefinition.*$#' diff --git a/src/Connection.php b/src/Connection.php index e14e27cf..ed885cfe 100644 --- a/src/Connection.php +++ b/src/Connection.php @@ -459,7 +459,7 @@ protected function escapeArray(array $value, bool $binary): string { if (array_is_list($value)) { $escaped = array_map(function (mixed $v) use ($binary): string { - return !is_array($v) + return is_scalar($v) ? $this->escape($v, $binary) : throw new LogicException('Nested arrays are not supported by Cloud Spanner'); }, $value); diff --git a/src/Eloquent/Model.php b/src/Eloquent/Model.php index 1fab4d80..797be74c 100644 --- a/src/Eloquent/Model.php +++ b/src/Eloquent/Model.php @@ -17,6 +17,7 @@ namespace Colopl\Spanner\Eloquent; +use Illuminate\Contracts\Database\Eloquent\Builder as BuilderContract; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model as BaseModel; use Illuminate\Database\Eloquent\Relations\Relation; @@ -44,7 +45,7 @@ class Model extends BaseModel * @param BaseModel|Relation $query * @param mixed $value * @param string|null $field - * @return Relation + * @return BuilderContract */ public function resolveRouteBindingQuery($query, $value, $field = null) { diff --git a/src/Schema/Grammar.php b/src/Schema/Grammar.php index 6d7260bb..6164901d 100644 --- a/src/Schema/Grammar.php +++ b/src/Schema/Grammar.php @@ -253,10 +253,7 @@ public function compileDropSequenceIfExists(Blueprint $blueprint, object $comman protected function formatSequenceOptions(mixed $definition): string { $optionAsStrings = Arr::map($definition->getOptions(), function (mixed $v, string $k): string { - return Str::snake($k) . '=' . match (get_debug_type($v)) { - 'string' => $this->quoteString($v), - default => $v, - }; + return Str::snake($k) . '=' . (is_string($v) ? $this->quoteString($v) : $v); }); return 'options (' . implode(', ', $optionAsStrings) . ')'; }