phpmd/phpmd — pull request #221 by gooh (2014-11-01 06:52:36+00:00)
Title: Closes #220: ignore php4 style ctor in interfaces and namespaces

PHPMD will report violations when it finds a method with the same name as the enclosing class, e.g. php4 style constructors. However, as of PHP 5.3 such methods will not be considered constructors when they are in a namespace. PHPMD should not mark these methods then.

PHPMD will also report methods with the same name as the enclosing interface. Given that interfaces should not contain constructors, marking those methods as such seems wrong to me. A dedicated sniff for finding constructors in interfaces as suggested in #31 seems more useful here.

The commit adds checks for the above two cases. When found, PHPMD will no longer mark those cases as ConstructorWithNameAsEnclosingClass violations. I've also added two tests to verify the behavior.