Skip to content
Snippets Groups Projects
Verified Commit f3f550ab authored by Bartek Jaskulski's avatar Bartek Jaskulski
Browse files

feat(docs): add section about plugin dependencies

parent ceba757f
No related branches found
No related tags found
No related merge requests found
...@@ -17,3 +17,29 @@ To run PHPStan, simply execute the following command (`<path>` is only required ...@@ -17,3 +17,29 @@ To run PHPStan, simply execute the following command (`<path>` is only required
```sh ```sh
vendor/bin/phpstan analyse <path> 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
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment