[Doc] Autoload Troubleshooting (#860)

* [Doc] Autoload Troubleshooting

* more detailed usage

* update to skip rector rule if children still not detected even with composer dump-autoload -o
This commit is contained in:
Abdul Malik Ikhsan 2021-09-10 16:28:58 +07:00 committed by GitHub
parent 40bd8926d3
commit 0c36bf8769
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -52,3 +52,26 @@ Listed files will be executed like:
```php
include $filePath;
```
## Troubleshooting
Sometime, when we run Rector to class that detect children class, like `\Rector\Privatization\Rector\Class_\FinalizeClassesWithoutChildrenRector`, we may experience that parent class changed to final while it has children class, it because of the `PHPStan\Reflection\ReflectionProvider` cannot get all classes on scanning it on usage via `FamilyRelationsAnalyzer` service.
To avoid this issue, you may dump all classes via composer:
```bash
composer dump-autoload -o
```
before run the rector.
If the false positive still happen, you can skip the rule applied as last resort to do:
```php
$parameters->set(Option::SKIP, [
\Rector\Privatization\Rector\Class_\FinalizeClassesWithoutChildrenRector::class => [
// classes that has children, and not detected even with composer dump-autoload -o
__DIR__ . '/src/HasChildClass.php',
],
]);
```