Closes #220: ignore php4 style ctor in interfaces and namespaces #221
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.