Codeception/AspectMock Parent class not found by locator

后端 未结 2 898
我寻月下人不归
我寻月下人不归 2021-02-19 16:41

I have a problem with Codeception/AspectMock. When using custom autoloader and try to create an instance of a class which has parent form the same custom namespace I have this

2条回答
  •  逝去的感伤
    2021-02-19 17:11

    The topic starter has already got an answer on GitHub.

    In order to use custom autoloader you should re-init ReflectionEngine with composite class locator that will be able to locate your classes or you can use CallableLocator with closure for resolving paths.

    Or, even better you could switch your code base to the PSR0/PSR-4

    For example:

    $kernel->loadFile(__DIR__ . '/autoload.php'); // custom autoloader
    
    \Go\ParserReflection\ReflectionEngine::init(
        new class implements \Go\ParserReflection\LocatorInterface {
            public function locateClass($className) {
                return (new ReflectionClass($className))->getFileName();
            }
         }
    );
    
    $b = new \lib\B(); // here you go
    

提交回复
热议问题