Skip to content

Add documentation how to ignore container service checks for tests directory #298

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

Open
wants to merge 2 commits into
base: 1.2.x
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add documentation how to ignore container checks for test directory
  • Loading branch information
alexander-schranz authored Aug 9, 2022
commit df2c8751374cb927999bd622d87726f5a25a975b
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,20 @@ parameters:
- var/cache/dev/Symfony/Config
```

## Ignore container service checks for tests

Inside tests maybe inlined or private container services are accessed. To disable the ruleset for test directory follwoig can be added to the `phpstan.neon` file:

```neon
parameters:
# ...
ignoreErrors:
- path: "tests/"
message: '#Service "(.*)" is not registered in the container.#'
- path: "tests/"
message: '#Service "(.*)" is private.#'
```

## Constant hassers

Sometimes, when you are dealing with optional dependencies, the `::has()` methods can cause problems. For example, the following construct would complain that the condition is always either on or off, depending on whether you have the dependency for `service` installed:
Expand Down