Codeception / Codeception/AspectMock

Parent class not found by locator

Open
#117 10 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
784
Forks
132
PR merge metrics
No merged PRs in 30d

Description

When using custom autoloader and try to get an instance of a class which has parent or implements an interface form the same custom namespace I have an error "PHP Fatal error: Uncaught InvalidArgumentException: Class [parent class name] was not found by locator in /workspace/projects/test/vendor/goaop/parser-reflection/src/ReflectionEngine.php:112".

I have very simple setup:

```
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?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.