Skip to content

[2.x] fix(testing): narrow database types via PHPDoc to fix Intelephense warnings#4450

Merged
imorland merged 1 commit into2.xfrom
im/fix-4432-testcase-database-phpdoc
Mar 15, 2026
Merged

[2.x] fix(testing): narrow database types via PHPDoc to fix Intelephense warnings#4450
imorland merged 1 commit into2.xfrom
im/fix-4432-testcase-database-phpdoc

Conversation

@imorland
Copy link
Copy Markdown
Member

Summary

  • Keeps ConnectionInterface as the actual PHP type on Bootstrapper::$database and TestCase::database() so custom connection implementations remain compatible at runtime
  • Adds @var Connection|null and @return Connection PHPDoc annotations so Intelephense / PHPStan resolve concrete methods (e.g. getDriverName(), getSchemaBuilder())

Fixes #4432

Test plan

  • Confirm Intelephense no longer reports "Undefined method 'getDriverName'" on $this->database()->getDriverName() in test files
  • Existing integration tests pass

🤖 Generated with Claude Code

…atic analysis

Intelephense reports "Undefined method 'getDriverName'" (and similar)
because the `database` property and `TestCase::database()` return
`ConnectionInterface`, which doesn't declare concrete `Connection`
methods.

Keep `ConnectionInterface` as the actual PHP type so custom connection
implementations (e.g. swapping drivers in tests) remain compatible at
runtime, but add `@var Connection|null` / `@return Connection` PHPDoc
annotations so Intelephense and PHPStan resolve the concrete methods.

Fixes #4432

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@imorland imorland changed the title fix(testing): narrow database types via PHPDoc to fix Intelephense warnings [2.x] fix(testing): narrow database types via PHPDoc to fix Intelephense warnings Mar 15, 2026
@imorland imorland marked this pull request as ready for review March 15, 2026 07:01
@imorland imorland requested a review from a team as a code owner March 15, 2026 07:01
@imorland imorland added this to the 2.0.0-beta.8 milestone Mar 15, 2026
@imorland imorland merged commit f1dca36 into 2.x Mar 15, 2026
27 checks passed
@imorland imorland deleted the im/fix-4432-testcase-database-phpdoc branch March 15, 2026 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[2.x] Undefined method 'getDriverName'.

1 participant