From f3f550ab6238229e2df7d4eceb22dde9c6cab216 Mon Sep 17 00:00:00 2001 From: Bart Jaskulski <bjaskulski@protonmail.com> Date: Sat, 18 Nov 2023 02:26:39 +0100 Subject: [PATCH] feat(docs): add section about plugin dependencies Signed-off-by: Bart Jaskulski <bjaskulski@protonmail.com> --- README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/README.md b/README.md index 6c07ad7..05ba8d7 100644 --- a/README.md +++ b/README.md @@ -17,3 +17,29 @@ To run PHPStan, simply execute the following command (`<path>` is only required ```sh vendor/bin/phpstan analyse <path> ``` + +### Dependencies between plugins + +Besides WordPress and WooCommerce, it may be sometimes necessary to analyse dependencies between plugins, e.g. when developing an extension to base plugin, PHPStan needs to be aware of the dependent plugin's codebase. + +In such cases it is necessary to generate the stubs for the dependent plugin with the use of [stub generator library](https://github.com/php-stubs/generator). Try to install it as system-wide utility, rather than plugin's package. + +```sh +composer global require php-stubs/generator +``` + +With the aid of this library, you will be able to provide read-only access to the dependent codebase for PHPStan purposes. Use `stub` extension to ignore this file by your editor analyzers. + +```sh +generate-stubs --out=/path/to/.stubs/dependency.stub -- /path/to/dependency/src +``` + +Remember to regenerate the stubs, whenever there's an important change in upstream plugin. + +Finally, include generated stubs in your PHPStan configuration. + +```neon +parameters: + scanFiles: + - .stubs/dependency.stub +``` -- GitLab