Skip to content

question/feat: Possibility to set the containerXmlPath dynamically in phpstan.dist.neon ? #432

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

Closed
Crovitche-1623 opened this issue Mar 12, 2025 · 4 comments

Comments

@Crovitche-1623
Copy link

Crovitche-1623 commented Mar 12, 2025

Context

In the Symfony documentation, it's written:

Image

I would like to run my tests and phpstan with debug mode disabled in my CI. However, the dumped container XML file does not have the same name if the debug mode is enabled or not.

Examples:

in test env APP_ENV=test with debug mode disabled APP_DEBUG=0:

App_KernelTestContainer.php

in test env APP_ENV=test with debug mode enabled APP_DEBUG=1

App_KernelTestDebugContainer.xml

Questions

Do I need separate phpstan.dist.neon configuration files for each case ? It could be difficult if we have just APP_ENV=dev and APP_ENV=test with different debug mode.

  1. App_KernelTestContainer.php
  2. App_KernelTestDebugContainer.xml
  3. App_KernelDevContainer.php
  4. App_KernelDevDebugContainer.xml
@ondrejmirtes
Copy link
Member

The config file supports environment variables: https://phpstan.org/config-reference#environment-variables

@Crovitche-1623
Copy link
Author

Crovitche-1623 commented Mar 12, 2025

Thanks @ondrejmirtes but do you have any idea how to conditionally add the word Debug depending on an environment variable? Moreover, do you know if the containerXmlPath parameter is case sensitive ? Because APP_ENV=dev will not be the same as APP_ENV=Dev ?

@ondrejmirtes
Copy link
Member

You can add another env variable with the exact container filename.

Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 13, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants