phpat
phpat copied to clipboard
Interfaces extending other interfaces are not matched by shouldExtend()
Bug Description AFAICS PHPat does not handle interfaces extending other interfaces correctly.
If a rule requires interfaces to extend a specific interface, even interfaces that fulfill the requirement are reported.
Note that interfaces may extend multiple other interfaces, and listing only one of them after shouldExtend() needs to work in that case.
Additional context
- Have a
ValueObjectInterfacesomewhere - Have other interfaces with suffix
ValueObjectInterfacesomewhere that extendValueObjectInterface - Reference (import/use) the
ValueObjectInterfacein below test case
class MyArchTest {
public function testValueObjectInterfacesExtendBaseInterface(): BuildStep
{
return PHPat::rule()
->classes(Selector::classname('/ValueObjectInterface$/', regex: true))
->excluding(Selector::classname(ValueObjectInterface::class))
->shouldExtend()
->classes(Selector::classname(ValueObjectInterface::class))
->because('Value object interfaces must extend ValueObjectInterface');
}
}