Current Problem
Engine implementations like SqliteEngine declare return types using generic interfaces:
public function makeInsert(): Query\InsertQuery
{
return new Query\Sqlite\InsertQuery($this);
}
This prevents static analysis tools (PHPStan, Psalm, PhpStorm) from inferring the concrete type, making it impossible to use engine-specific methods like onConflictDoUpdate() without manual type assertions.
Proposed Solution
Use covariant return types (available since PHP 7.4, which is already the minimum required version):
public function makeInsert(): Query\Sqlite\InsertQuery
{
return new Query\Sqlite\InsertQuery($this);
}
This is backward compatible (covariance doesn't break Liskov substitution) and provides proper type information for static analysis.
I can provide with a PR.
Benefits
- Better IDE support
- Safer refactoring
- No runtime impact
- No BC break
Current Problem
Engine implementations like
SqliteEnginedeclare return types using generic interfaces:This prevents static analysis tools (PHPStan, Psalm, PhpStorm) from inferring the concrete type, making it impossible to use engine-specific methods like
onConflictDoUpdate()without manual type assertions.Proposed Solution
Use covariant return types (available since PHP 7.4, which is already the minimum required version):
This is backward compatible (covariance doesn't break Liskov substitution) and provides proper type information for static analysis.
I can provide with a PR.
Benefits