-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Merge 3.1.x into 3.2.x #4668
Merge 3.1.x into 3.2.x #4668
Commits on May 6, 2021
-
Fix doctrine#4637 by duplicating the type definition for `DriverManag…
…er::getConnection($args)` params As per doctrine#4637, `vimeo/psalm:4.6.4` cannot introduce templated parameters within a re-used imported type: this is understandable, since imported types are copy-paste aided by the type checker, but do not carry any template information with them (and it would be too complex to do so anyway). Quoting the initial issue: Minimal reproducer: https://psalm.dev/r/62a0a5854d ```php <?php class Connection {} class MyConnection extends Connection{} /** * @psalm-type Params = array{ * charset?: string, * wrapperClass?: class-string<Connection>, * } */ final class DriverManager { /** * @param array<string,mixed> $params * @param Configuration|null $config The configuration to use. * @param EventManager|null $eventManager The event manager to use. * * @phpstan-param array<string,mixed> $params * @psalm-param Params $params * @psalm-return ($params is array{wrapperClass:mixed} ? T : Connection) * @template T of Connection */ public static function getConnection( array $params ): Connection { throw new \Exception('irrelevant'); } } function mkConnection(): MyConnection { return DriverManager::getConnection(['wrapperClass' => MyConnection::class]); } ``` Which produces: ``` Psalm output (using commit aa854ae): INFO: MixedInferredReturnType - 31:26 - Could not verify return type 'MyConnection' for mkConnection ``` The issue is that the `Param` alias type is not templated: this is potentially a psalm limitation, but also an understandable one, since there is no syntax to specify template arguments for an imported type (AFAIK). Here is a potential fix: https://psalm.dev/r/8ef9909bb9 ```php <?php class Connection {} class MyConnection extends Connection{} /** * @psalm-type Params = array{ * charset?: string, * wrapperClass?: class-string<Connection>, * } */ final class DriverManager { /** * @psalm-param array{ * charset?: string, * wrapperClass?: class-string<T>, * } $params * @psalm-return ($params is array{wrapperClass: mixed} ? T : Connection) * @template T of Connection */ public static function getConnection( array $params ): Connection { throw new \Exception('irrelevant'); } } function mkConnection(): MyConnection { return DriverManager::getConnection(['wrapperClass' => MyConnection::class]); } ``` It's a bit ugly, but the idea is that we replace `Params` with the concrete definition again, but this time including `T`, so that the type inference can correctly fill the type variable with the given input: ``` Psalm output (using commit aa854ae): No issues! ``` The idea therefore is to re-introduce some duplication at the advantage of better type inference later on. In order to verify that the change had an effect, we introduced a new `tests/Doctrine/StaticAnalysis` directory, to be checked via `vendor/bin/psalm -c psalm-strict.xml`, which will tell us exactly whether there are obvious type-checker issues around our code. Since `psalm.xml.dist` uses `errorLevel="2"`, it is not sufficient to integrate this directory within the normal workflow. Because this project uses a custom github action for running `vimeo/psalm`, it is not really possible to run this in CI, and therefore that part of the patch has been omitted. It is endorsed that maintainers of `doctrine/dbal` in future: 1. commit `composer.lock` 2. set up dependabot to track dependency upgrades 3. use the standard `vimeo/psalm` via `require-dev`, and run the CI static analysis checks from the same environment that runs normal unit/integration tests
Configuration menu - View commit details
-
Copy full SHA for af2a31e - Browse repository at this point
Copy the full SHA af2a31eView commit details -
Rework the caching documentation
I have tried making it more obvious what all the mandatory steps are to get the caching feature to work.
Configuration menu - View commit details
-
Copy full SHA for 3a79540 - Browse repository at this point
Copy the full SHA 3a79540View commit details -
Configuration menu - View commit details
-
Copy full SHA for 9402241 - Browse repository at this point
Copy the full SHA 9402241View commit details
Commits on May 7, 2021
-
Add type-inference tests to github actions, so that we test also that…
… types match up The normal psalm checks run in CI are not sufficient, since they run with level 2 checks (too lax), and therefore we need a dedicated action to be run when verifying the contents of `tests/Doctrine/StaticAnalysis`, which is designed to verify type inference and type-checking details provided by the library.
Configuration menu - View commit details
-
Copy full SHA for 5c4063f - Browse repository at this point
Copy the full SHA 5c4063fView commit details -
Rewrote
DriverManagerTest
replica/shards test scenarios to verify w……hole data structure equality While it is true that such tests are accessing unknown/undocumented array keys that are not part of the psalm type definitions, we still need to verify equality on the retrieved data structure, in order to avoid accidentally introducing a BC break while messing with them. This change therefore: * makes the type-checker a bit happier (was failing before, due to undocumented keys) * makes the tests a bit more strict around potential undocumented keys in these arrays
Configuration menu - View commit details
-
Copy full SHA for cb8b389 - Browse repository at this point
Copy the full SHA cb8b389View commit details
Commits on May 9, 2021
-
Merge pull request doctrine#4638 from Ocramius/fix/doctrine#4637-rest…
…ore-type-inference-for-wrapped-connection-class Fix doctrine#4637 by duplicating the type definition for `DriverManager::getConnection($args)` params
Configuration menu - View commit details
-
Copy full SHA for b728198 - Browse repository at this point
Copy the full SHA b728198View commit details
Commits on May 12, 2021
-
[doctrineGH-4645] Use error suppression instead of an error handler i…
…n MySQLi Connection
Configuration menu - View commit details
-
Copy full SHA for b9b30b2 - Browse repository at this point
Copy the full SHA b9b30b2View commit details
Commits on May 13, 2021
-
Merge pull request doctrine#4647 from morozov/issues/4645
[doctrineGH-4645] Use error suppression instead of an error handler in MySQLi Connection
Configuration menu - View commit details
-
Copy full SHA for 21f5eb5 - Browse repository at this point
Copy the full SHA 21f5eb5View commit details
Commits on May 14, 2021
-
Configuration menu - View commit details
-
Copy full SHA for bd18ec4 - Browse repository at this point
Copy the full SHA bd18ec4View commit details -
Merge pull request doctrine#4648 from morozov/issues/4643
[doctrineGH-4643] Fix SQLServerPlatform::quoteIdentifier()
Configuration menu - View commit details
-
Copy full SHA for 69ad868 - Browse repository at this point
Copy the full SHA 69ad868View commit details
Commits on May 15, 2021
-
Merge pull request doctrine#4640 from greg0ire/make-footgun-more-obvious
Make footgun more obvious
Configuration menu - View commit details
-
Copy full SHA for 2c19354 - Browse repository at this point
Copy the full SHA 2c19354View commit details
Commits on Jun 5, 2021
-
Configuration menu - View commit details
-
Copy full SHA for ce7db44 - Browse repository at this point
Copy the full SHA ce7db44View commit details -
Merge pull request doctrine#4663 from derrabus/bump/cs
Bump doctrine/coding-standard
Configuration menu - View commit details
-
Copy full SHA for 2f286f4 - Browse repository at this point
Copy the full SHA 2f286f4View commit details
Commits on Jun 6, 2021
-
Make Table::removeUniqueConstraint() actually work
Table::removeUniqueConstraint() used the wrong method (hasForeignKey()) instead of hasUniqueConstraint() to check for existing unique constraint, causing removeUniqueConstraint() to fail unconditionally. Also adding tests for removeUniqueConstraint().
Configuration menu - View commit details
-
Copy full SHA for 0e398ec - Browse repository at this point
Copy the full SHA 0e398ecView commit details -
Merge pull request doctrine#4667 from hschletz/fix-removeUniqueConstr…
…aint-wrong-method Make Table::removeUniqueConstraint() actually work
Configuration menu - View commit details
-
Copy full SHA for 7ef2a33 - Browse repository at this point
Copy the full SHA 7ef2a33View commit details
Commits on Jun 7, 2021
-
* 2.13.x: Bump doctrine/coding-standard [doctrineGH-4643] Fix SQLServerPlatform::quoteIdentifier() [doctrineGH-4645] Use error suppression instead of an error handler in MySQLi Connection Rewrote `DriverManagerTest` replica/shards test scenarios to verify whole data structure equality Add type-inference tests to github actions, so that we test also that types match up Add warnings in docblocks Rework the caching documentation Fix doctrine#4637 by duplicating the type definition for `DriverManager::getConnection($args)` params Signed-off-by: Alexander M. Turek <me@derrabus.de>
Configuration menu - View commit details
-
Copy full SHA for e6add29 - Browse repository at this point
Copy the full SHA e6add29View commit details -
Configuration menu - View commit details
-
Copy full SHA for 490f725 - Browse repository at this point
Copy the full SHA 490f725View commit details