-
Notifications
You must be signed in to change notification settings - Fork 103
Synchronize Collection::add
with doctrine/collections
#560
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
Conversation
What about older versions? I see true in 1.8.0 |
Oh, do we have to duplicate the stub then ? |
We need conditional including of different stubs based on the version. In a StubFilesExtension. |
835848d
to
3d6353b
Compare
Done |
@@ -59,6 +61,13 @@ public function getFiles(): array | |||
$files[] = $stubsDir . '/ServiceEntityRepository.stub'; | |||
} | |||
|
|||
$collectionVersion = InstalledVersions::getVersion('doctrine/dbal'); |
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.
Please check that InstalledVersions
class exists.
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.
Strictly speaking, we should even catch OutOfBoundsException in case dbal is not installed: https://getcomposer.org/doc/07-runtime.md#knowing-the-version-of-package-x
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.
Oh damn, and the check should be about 'doctrine/collections'
not 'doctrine/dbal'
.
I fixed it and added a class_exists check and the try/catch of OutOfBoundsException.
4193c2a
to
6ff7fcc
Compare
6ff7fcc
to
a419021
Compare
Thank you. |
I messed up and target 1.4.x instead of 1.3.x. Should I reopen a PR on 1.3.x @ondrejmirtes ? |
No, you'll have to wait for release alongside PHPStan 1.11 😊 shouldn't be too far off |
Hi,
Collection::add
returnsvoid
and nottrue
according to doctrine/collectionshttps://github.com/doctrine/collections/blob/9b9c38a3eff3c7477989129b096d21e2b1710ee0/src/Collection.php#L34-L42