Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: fix return type in BaseResult #8709

Merged

Conversation

Pebryan354
Copy link
Contributor

@Pebryan354 Pebryan354 commented Apr 4, 2024

Description
when I use the getRow function in the query builder
$this->db->table("table_name")->getWhere(["id" => $id])->getRow("name"), it works fine, but there is a notif or warning "Expected type 'string'...."

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@kenjis kenjis changed the title docs: update return type docs: fix return type in BaseResult Apr 4, 2024
@kenjis kenjis added the bug Verified issues on the current code behavior or pull requests that will fix them label Apr 4, 2024
Copy link
Member

@kenjis kenjis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update ResultInterface, too.

--- a/system/Database/ResultInterface.php
+++ b/system/Database/ResultInterface.php
@@ -63,8 +63,8 @@ interface ResultInterface
      * @param         string                           $type The type of result object. 'array', 'object' or class name.
      * @phpstan-param class-string<T>|'array'|'object' $type
      *
-     * @return         array|object|stdClass|null
-     * @phpstan-return ($type is 'object' ? stdClass|null : ($type is 'array' ? array|null : T|null))
+     * @return         array|float|int|object|stdClass|string|null
+     * @phpstan-return ($n is string ? float|int|string|null : ($type is 'object' ? stdClass|null : ($type is 'array' ? array|null : T|null)))
      */
     public function getRow($n = 0, string $type = 'object');
 

@Pebryan354 Pebryan354 requested a review from kenjis April 5, 2024 07:50
@kenjis kenjis merged commit a5d4f7a into codeigniter4:develop Apr 5, 2024
56 checks passed
@kenjis
Copy link
Member

kenjis commented Apr 5, 2024

@Pebryan354 Thank you!

@Pebryan354 Pebryan354 deleted the Pebryan354/update-return-type branch April 5, 2024 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants