mirror of
https://github.com/rectorphp/rector.git
synced 2024-05-28 23:10:51 +00:00
Revert load vendor/autoload from getcwd and add documentation for using globally (not recommended) (#1685)
This commit is contained in:
parent
4ac5dd6420
commit
6b965fe744
|
@ -91,13 +91,10 @@ final class AutoloadIncluder
|
|||
/**
|
||||
* In case Rector is installed as vendor dependency,
|
||||
* this autoloads the project vendor/autoload.php, including Rector
|
||||
*
|
||||
* This also accounts for running a globally installed Rector from the global composer vendor dir
|
||||
*/
|
||||
public function autoloadProjectAutoloaderFile(): void
|
||||
{
|
||||
$this->loadIfExistsAndNotLoadedYet(__DIR__ . '/../../../autoload.php');
|
||||
$this->loadIfExistsAndNotLoadedYet(getcwd() . '/vendor/autoload.php');
|
||||
}
|
||||
|
||||
public function autoloadFromCommandLine(): void
|
||||
|
|
|
@ -76,10 +76,14 @@ If the false positive still happen, you can skip the rule applied as last resort
|
|||
]);
|
||||
```
|
||||
|
||||
### Dealing with "Class ... was not found while trying to analyse it..."
|
||||
## 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:
|
||||
|
||||
### Register to `Option::AUTOLOAD_PATHS`:
|
||||
|
||||
|
||||
```php
|
||||
$parameters->set(Option::AUTOLOAD_PATHS, [
|
||||
// the path to the exact class file
|
||||
|
@ -91,7 +95,15 @@ In this case you may want to try one of the following solutions:
|
|||
]);
|
||||
```
|
||||
|
||||
Other solution is by register the path of the class to composer.json's `"files"` config, eg:
|
||||
### Call command with `-a` option
|
||||
|
||||
This may happen when you're using rector globally (not recommended as autoload may overlapped)
|
||||
|
||||
```bash
|
||||
rector process -a vendor/autoload.php
|
||||
```
|
||||
|
||||
### Other solution is by register the path of the class to composer.json's `"files"` config, eg:
|
||||
|
||||
```javascript
|
||||
"autoload-dev": {
|
||||
|
|
Loading…
Reference in New Issue
Block a user