Tuesday, 6 November 2018

Codeception/AspectMock Parent class not found by locator

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 error:

PHP Fatal error: Uncaught InvalidArgumentException: Class [parent class name] was not found by locator in vendor/goaop/parser-reflection/src/ReflectionEngine.php:112

I have very simple setup:

<?php

require_once __DIR__ . '/vendor/autoload.php';

$kernel = AspectMock\Kernel::getInstance();
$kernel->init([
    'debug' => true,
    'includePaths' => [__DIR__. '/lib'],
]);
$kernel->loadFile(__DIR__ . '/autoload.php'); // custom autoloader

$b = new \lib\B();

Class \lib\B:

namespace lib;

class B extends A {}

Class \lib\A:

namespace lib;

class A
{
    public function getName()
    {
        return static::class;
    }
}

Class B is loaded via my custom autoloader, but then the locator tries to load parent class A via composer autoloader and returns this error. Is this a bug, or I'm doing something wrong?



from Codeception/AspectMock Parent class not found by locator

No comments:

Post a Comment