Skip to content

Begin adding types, starting with $pdo on the Driver classes.#48

Open
rrigby wants to merge 5 commits intoelvanto:masterfrom
rrigby:enforce-pdo-type
Open

Begin adding types, starting with $pdo on the Driver classes.#48
rrigby wants to merge 5 commits intoelvanto:masterfrom
rrigby:enforce-pdo-type

Conversation

@rrigby
Copy link
Contributor

@rrigby rrigby commented Mar 6, 2026

This is the first PR in an attempt to slowly bring types into this library. There's some key areas that need to be tackled manually first like this before I can bring in automated tooling like Rector.

I typed $pdo as ?PDO, made it private and updated all usages to access it via getConnection().
I've added a setConnection() method to allow children to set it.
I've opted to make getConnection() throw an exception if the connection isn't established.
This was the least intrusive change as this maintains the existing contract all the code was working under, that it always returns PDO.

Other small fixes:

  • Typed a handful of other private class properties on the drivers ($requiredAttributes and $schemaTable)
  • Fixed a type issue in getSqlFromPreparedStatement that would occur if there were more items in $values than '?' in $sql (Unlikely to actually happen, but Psalm picked it up)
  • Added Psalm as a composer command.

rrigby added 5 commits March 6, 2026 23:40
Make $pdo private and create a setter method
Make getConnection throw an exception is $pdo is null
…e are '?' in the query. (very unlikely, but keeps psalm happy)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant