Commit d74c099
authored
fix: Ensure
Although the phpdocs states that the ID ($id) should not be `null`, in some cases, data may be retrieved from the database where the ID is set to `null`.
When `null` is passed to the `find($id)` method, instead of returning null or a User object, it returns an empty array ([]).
This leads to a type mismatch with the method signature, which expects a return type of `?User`, causing the error:
```
CodeIgniter\Shield\Models\UserModel::findById(): Return value must be of type ?CodeIgniter\Shield\Entities\User, array returned ```
This change ensures that the method always adheres to the expected return type (?User), preventing unexpected runtime errors.findById returns null instead of an array when ID is null
1 parent 568a130 commit d74c099
1 file changed
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
185 | | - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
186 | 188 | | |
187 | 189 | | |
188 | 190 | | |
| |||
0 commit comments