-
-
Notifications
You must be signed in to change notification settings - Fork 269
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
Adapt to new type hierarchy #776
Conversation
I tried to cover my change with a new test, but am having a hard time figuring out what I'm doing wrong. I'm getting the following error:
|
c2c3429
to
0ce1129
Compare
The following will do the trick in your test:
|
0ce1129
to
bd10f92
Compare
In recent versions of ORM and ODM, annotation driver no longer extend a base class in doctrine/persistence. Instead of testing for that base class, detecting the number of constructor arguments seems like a more robust way to figure out what arguments to pass.
bd10f92
to
9b5d144
Compare
tests/Service/DriverFactoryTest.php
Outdated
$factory = new DriverFactory('testDriver'); | ||
$driver = $factory->__invoke($serviceManager, AnnotationDriver::class); | ||
$this->assertInstanceOf(AnnotationDriver::class, $driver); | ||
assert($driver instanceof AnnotationDriver); |
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.
I don't understand why this is necessary, but it is. PHPstan and phpstan-phpunit are installed and up to date, yet $driver
is not narrowed down to AnnotationDriver
.
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.
I could have solved that with a simple comment:
/** @var AnnotationDriverORM|AnnotationDriverODM|AnnotationDriverPersistence $driver */
$driver = $factory->__invoke($serviceManager, AnnotationDriver::class);
but PHPCS forced me to do the assert(...)
. This seemed to be the only way to make both tools happy.
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.
I would expect phpstan not to need this thanks to line 117. I think that works in my other projects, so there must be a configuration issue somewhere. It's mentioned in this README: https://github.com/phpstan/phpstan-phpunit
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.
Found the reason: we were only using that extension to add extra rules, not to add functionality.
Now that doctrine/orm#9671 is merged, this MR makes sense only after |
In recent versions of ORM and ODM, annotation driver no longer extend a
base class in doctrine/persistence. Instead of testing for that base
class, detecting the number of constructor arguments seems like a more
robust way to figure out what arguments to pass.
Fixes #774
Alternative to #775