New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix DSN detection in the IBM DB2 driver #4066
Conversation
$params['protocol'] = 'TCPIP'; | ||
} | ||
$params['user'] = $username; | ||
$params['password'] = $password; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
User credentials and driver options are passed to the driver both via individual parameters and as part of $params
which is awkward:
Lines 352 to 356 in 48625f1
$driverOptions = $this->params['driverOptions'] ?? []; | |
$user = $this->params['user'] ?? null; | |
$password = $this->params['password'] ?? null; | |
$this->_conn = $this->_driver->connect($this->params, $user, $password, $driverOptions); |
This can be improved by simplifying the signature of Driver::connect()
to just Driver::connect(array $params)
(a separate issue is to be filed). Once it's done, the lines above will be removed.
2e6bd40
to
bb2f529
Compare
Codecov Report
@@ Coverage Diff @@
## 2.10.x #4066 +/- ##
============================================
+ Coverage 73.30% 73.39% +0.08%
- Complexity 5031 5036 +5
============================================
Files 215 216 +1
Lines 12825 12838 +13
============================================
+ Hits 9401 9422 +21
+ Misses 3424 3416 -8
Continue to review full report at Codecov.
|
/** | ||
* Creates the object from an array representation | ||
* | ||
* @param array<string,mixed> $params |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's document the possible keys with an array shape?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method doesn't limit the keys that can be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Array shapes do not limit the keys that can be used either, it will allow you to document what keys are mandatory or optional and the type they should have if present.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So what will be the behavior if the key being passed is not mandatory or optional?
In this specific case, it's still a map of any string to any value that can be cast to a string. But instead of defining it as an array shape, I'd rather have an object/structure. If we don't do that soon, we may define an array shape later when bumping the Psalm level and it demands it. This way, we'll make sure that our type annotations are valid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So what will be the behavior if the key being passed is not mandatory or optional?
Not the one I thought apparently… I could have sworn this was OK: https://psalm.dev/r/cd931bdda1
Sorry for polluting you with this nonsense 🤦
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries. I wasn't sure about how Psalm works either, so now we're on the same page 👍
Fixes #4065.