Skip to content

bug: Model::find() returns incorrect type #7

Description

@kenjis

PHP Version

8.1

PHPStan CodeIgniter Version

v1.4.2.70400

PHPStan Version

1.10.39

What happened?

 ------ ------------------------------------------------------------------------------ Line app/Models/ThreadModel.php ------ ------------------------------------------------------------------------------ 177 Cannot access property $thread_count on array<int, App\Entities\Category>. 177 Cannot access property $thread_count on array<int, App\Entities\Category>. 178 Cannot access property $post_count on array<int, App\Entities\Category>. 183 Cannot access property $id on array<int, App\Entities\Category>. 187 Cannot access property $last_thread_id on array<int, App\Entities\Category>. 188 Cannot access property $last_thread_id on array<int, App\Entities\Category>. 195 Cannot use -- on array|bool|float|int|object|string|null. ------ ------------------------------------------------------------------------------ 

https://github.com/kenjis/forum-example/blob/37a339f050ee2c40ed452e6570cef188dc0f90a0/app/Models/ThreadModel.php#L173-L195

Minimum Reproduction Script

git clone https://github.com/kenjis/forum-example --branch=add-phpstan-codeigniter
cd forum-example/
composer install
vendor/bin/phpstan

Expected Output

No errors on ThreadModel.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions