Skip to content

Fix inference of type of Model::find() to base on framework behavior #18

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

Merged
merged 1 commit into from
Dec 16, 2023

Conversation

paulbalandan
Copy link
Collaborator

@paulbalandan paulbalandan commented Nov 19, 2023

Fixes #7

This is based on https://github.com/codeigniter4/CodeIgniter4/blob/79c1b2f7868642d3de9342817ccad93835765a91/system/Model.php#L182-L203.

To fix that category_id is inferred as mixed, the array shape should be defined, something like:

   /**
     * Recalculate stats for thread.
     *
+    * @param array{data: array{category_id: int}} $data
+    *
     * @throws ReflectionException
     */
    protected function recalculateStats(array $data)

@paulbalandan paulbalandan added the bug Something isn't working label Nov 22, 2023
@paulbalandan paulbalandan requested a review from MGatner December 7, 2023 07:30
Copy link
Member

@MGatner MGatner left a comment

Choose a reason for hiding this comment

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

Looks good!

@paulbalandan paulbalandan merged commit 4637171 into 1.x Dec 16, 2023
@paulbalandan paulbalandan deleted the model-find branch December 16, 2023 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: Model::find() returns incorrect type
2 participants