-
Notifications
You must be signed in to change notification settings - Fork 94
False positive in Tests: Service XY is private #27
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
Comments
I'm also getting these warnings, although since Symfony 4.1 tests allow fetching private services by default. A workaround here is to declare a service public for the test environment:
|
As a workaround, I'm using the parameters:
ignoreErrors:
- message: '#^Service "[^"]+" is private.$#'
path: %rootDir%/../../../tests/ I can't wait for v0.11 to release, since this feature is only available in 0.11+ (therefore |
I plan to try to tackle these false positives in the near future. It's... difficult. Symfony container is not as straightforward as I imagined when I started working with it and writing this extension. 😊 |
By chance there are not that many errors with the container 👍 |
I was struggling with this too, but @Pierstoval's solution worked for me. Maybe it's not as clean as it should be, but resolves my CI issue :) Subscribing to this, so hopefully it can be replaced with proper solution on some point. |
plus 1 😊 @Pierstoval's solution also worked for me in the meantime 👍 |
I created #210 to resolve this issue. |
Fixed by: #210 Merged and released :) |
By the way, the exact same will happen to |
Feel free to send another PR :) |
@ondrejmirtes Is that it? => #212 I have no knowledge on how phpstan works, I just took example on #210, I have no idea on whether it's right or not 😅 |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
When using the
KernelTestCase
and asking PhpStan to analyze a test, I have this error:However, the
static::$container
that is in theKernelTestCase
is supposed to be an instance of theTestContainer
but is typed asContainerInterface
because it might happen that thetest.container
service can be absent from the container, therefore makingstatic::$container
be the full container (as of KernelTestCase here )Here is the code that triggers the error: Pierstoval/AgateApps/.../RedeemerTest.php#L61-L79
If the
test.container
service exists in the container AND for this specific case, I think there shouldn't be any error.The text was updated successfully, but these errors were encountered: