From 6bb7c52c70313ae248a8dc0913145d5be25e27a6 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 24 Nov 2023 17:43:36 +0900 Subject: [PATCH] docs: fix PHPDoc types for Model --- phpstan-baseline.php | 5 ----- system/BaseModel.php | 6 ++++-- system/Model.php | 6 ++++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/phpstan-baseline.php b/phpstan-baseline.php index 7f9182eeeeda..1322685d6fd2 100644 --- a/phpstan-baseline.php +++ b/phpstan-baseline.php @@ -2641,11 +2641,6 @@ 'count' => 1, 'path' => __DIR__ . '/system/Model.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Return type \\(int\\|object\\|string\\|false\\) of method CodeIgniter\\\\Model\\:\\:insert\\(\\) should be covariant with return type \\(bool\\|int\\|string\\) of method CodeIgniter\\\\BaseModel\\:\\:insert\\(\\)$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Model.php', -]; $ignoreErrors[] = [ 'message' => '#^Accessing offset mixed directly on \\$_GET is discouraged\\.$#', 'count' => 1, diff --git a/system/BaseModel.php b/system/BaseModel.php index f9eed92b1d49..1d854256a63c 100644 --- a/system/BaseModel.php +++ b/system/BaseModel.php @@ -740,10 +740,12 @@ public function getInsertID() * Inserts data into the database. If an object is provided, * it will attempt to convert it to an array. * - * @param array|object|null $data Data - * @param bool $returnID Whether insert ID should be returned or not. + * @param array|object|null $data Data + * @phpstan-param row_array|object|null $data + * @param bool $returnID Whether insert ID should be returned or not. * * @return bool|int|string insert ID or true on success. false on failure. + * @phpstan-return ($returnID is true ? int|string|false : bool) * * @throws ReflectionException */ diff --git a/system/Model.php b/system/Model.php index d2f531998fef..3a055531cb5b 100644 --- a/system/Model.php +++ b/system/Model.php @@ -697,9 +697,11 @@ protected function shouldUpdate($data): bool * it will attempt to convert it to an array. * * @param array|object|null $data - * @param bool $returnID Whether insert ID should be returned or not. + * @phpstan-param row_array|object|null $data + * @param bool $returnID Whether insert ID should be returned or not. * - * @return BaseResult|false|int|object|string + * @return false|int|object|string + * @phpstan-return ($returnID is true ? int|string|false : bool) * * @throws ReflectionException */