Skip to content

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

Merged
paulbalandan merged 1 commit into
1.xfrom
model-find
Dec 16, 2023
Merged

Fix inference of type of Model::find() to base on framework behavior#18
paulbalandan merged 1 commit into
1.xfrom
model-find

Conversation

@paulbalandan

@paulbalandanpaulbalandan commented Nov 19, 2023

Copy link
Copy Markdown
Collaborator

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)

@paulbalandanpaulbalandan added the bug Something isn't working label Nov 22, 2023

@MGatnerMGatner left a comment

Copy link
Copy Markdown
Member

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.xDec 16, 2023
@paulbalandan
paulbalandan deleted the model-find branch December 16, 2023 16:50
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugSomething isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Model::find() returns incorrect type

2 participants

@paulbalandan@MGatner