From df2c8751374cb927999bd622d87726f5a25a975b Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Tue, 9 Aug 2022 10:43:38 +0200 Subject: [PATCH 1/2] Add documentation how to ignore container checks for test directory --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 78f02320..93d6739d 100644 --- a/README.md +++ b/README.md @@ -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: From 71f9e2bc08ff5ecc6df2571f5d3cc2eeb2404c0b Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Tue, 9 Aug 2022 10:44:21 +0200 Subject: [PATCH 2/2] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 93d6739d..b1111f99 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ parameters: ## 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: +Inside tests maybe inlined or private container services are accessed. To disable the ruleset for `tests` directory following can be added to the `phpstan.neon` file: ```neon parameters: