Skip to content

Generic docblocks for DAO collections - #94

Merged
TomK merged 2 commits into
masterfrom
generics
Nov 6, 2026
Merged

TomK merged 2 commits into
masterfrom
generics

Conversation

@TomK

@TomK TomK commented Nov 6, 2026

Copy link
Copy Markdown
Member

IDEs can't tell what a DAO collection holds. For a model like User extends QlDao, User::collection()->first() completes as IDao/QlDao, and foreach gives nothing, so User's properties and methods never complete.

  • User::collection() / loadWhere() / getCollection(): typed as QlDaoCollection<User> (CqlDaoCollection<Thing> for CQL DAOs)
  • ->first(), [$i], foreach, getRawArray(), createNewDao(): resolve to User (User|null for first() and array access)
  • ->where()->limit()->orderBy()… chains: keep the collection's DAO type

Docblock-only, plus removal of an unused use Traversable;. Models need no changes, because the factories return QlDaoCollection<static>.

Test plan

  • php -l clean on all changed files.
  • PHPUnit on PHP 8.5: identical results to master (same 64 errors / 3 failures, all environmental: memcache extension and DB connections).

🤖 Generated with Claude Code

TomK and others added 2 commits November 6, 2026 11:22
Template IDaoCollection/DaoCollection/QlDaoCollection/CqlDaoCollection on
the DAO type, and return QlDaoCollection<static> from QlDao's collection
factories, so User::collection()->where()->first(), foreach and array
access resolve to User. Fluent query-builder methods are declared as
returning $this to keep the type through chains. Docblock-only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@TomK
TomK merged commit e7bc7e4 into master Nov 6, 2026
7 checks passed
@TomK
TomK deleted the generics branch November 6, 2026 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant