-
-
Notifications
You must be signed in to change notification settings - Fork 228
Description
Feature Request
What
Support retrieving references in getReference and similar methods using parent classes or interfaces.
Currently, references are stored and retrieved using the exact class name as a key. This breaks when trying to retrieve an object using a parent class or interface, as the system performs a strict class name check.
Why
This limitation makes it impossible to work with inheritance hierarchies in fixtures.
For example:
class AdminRole extends Role {}
$this->addReference('admin-role', new AdminRole());
// Later in another fixture:
$role = $this->getReference('admin-role', Role::class); // This failsHow
-
When calling
addReference, internally store the reference under all parent classes and interfaces of the object usingclass_parents()andclass_implements(). -
Alternatively, during
getReference, resolve all parent classes in case the reference is not found by the original class
These improvements would make fixture references more flexible while preserving the current design for strict lookups.