refactor: Ensure `findById` returns `null` instead of an array when ID is null
Description
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.
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
Unit Testing: Unit testing is expected for all CodeIgniter components. We use PHPUnit, and run unit tests using GitHub Actions for each PR submitted or changed.
So please write a unit test or update the existing tests.
See unit testing for more info.