class not found when extending a non-autoloaded class #7159
-
|
Rector is using runtime reflection ( in ClassBlacklistReflectionProvider ) to parse the src file, Am I misunderstanding the // rector.php
declare(strict_types=1);
return static function (\Rector\Config\RectorConfig $rectorConfig): void
{
$rectorConfig->paths([ __DIR__ . '/src' ]);
$rectorConfig->autoloadPaths([ __DIR__ . '/includes' ]);
$rectorConfig->rule(\Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector::class);
};// composer.json
{
"name": "rector-sandbox/rector-sandbox",
"type": "project",
"autoload": {
"psr-4": {
"RectorSandbox\\": "src/"
}
},
"require-dev": {
"rector/rector": "^0.12.23"
}
}// src/ExtendNonAutoloadedClass.php
declare(strict_types=1);
namespace RectorSandbox;
class ExtendNonAutoloadedClass extends \RectorSandbox_NonAutoloadedClass
{
}// includes/RectorSandbox_NonAutoloadedClass.php
declare(strict_types=1);
class RectorSandbox_NonAutoloadedClass
{
} |
Beta Was this translation helpful? Give feedback.
Answered by
samsonasik
May 11, 2022
Replies: 1 comment
-
|
That usually solve the issue, if that still not found, possibly overlapped, you can register to "autoload-dev": {
"files": [
"vendor/acme/my-custom-dependency/src/Your/Own/Namespace/TheAffectedClass.php"
]
}and run: composer dump-autoloadit is documented at https://github.com/rectorphp/rector/blob/main/docs/static_reflection_and_autoload.md#dealing-with-class--was-not-found-while-trying-to-analyse-it |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
samsonasik
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That usually solve the issue, if that still not found, possibly overlapped, you can register to
composer.jsonunderfiles:and run:
it is documented at https://github.com/rectorphp/rector/blob/main/docs/static_reflection_and_autoload.md#dealing-with-class--was-not-found-while-trying-to-analyse-it