Documenting a solution for missing classes (#889)

See https://github.com/rectorphp/rector/issues/6688
This commit is contained in:
Marco Lipparini 2021-09-15 20:10:24 +02:00 committed by GitHub
parent ae01efed9c
commit be1cdc059d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -74,4 +74,19 @@ If the false positive still happen, you can skip the rule applied as last resort
__DIR__ . '/src/HasChildClass.php',
],
]);
```
```
### Dealing with "Class ... was not found while trying to analyse it..."
Sometimes you may encounter this error ([see here for an example](https://github.com/rectorphp/rector/issues/6688)) even if the class is there and it seems to work properly with other tools (e.g. PHPStan).
In this case you may want to try one of the following solutions:
```php
$parameters->set(Option::AUTOLOAD_PATHS, [
// the path to the exact class file
__DIR__ . '/vendor/acme/my-custom-dependency/src/Your/Own/Namespace/TheAffectedClass.php',
// or you can specify a wider scope
__DIR__ . '/vendor/acme/my-custom-dependency/src',
// WARNING: beware of performances, try to narrow down the path
// as much as you can or you will slow down each run
]);
```