Skip to content

Commit

Permalink
Merge pull request #221 from gooh/master
Browse files Browse the repository at this point in the history
Closes #220: ignore php4 style ctor in interfaces and namespaces
  • Loading branch information
manuelpichler committed Nov 10, 2014
2 parents e16d00e + 22de93c commit ff1bb8b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
Expand Up @@ -44,6 +44,7 @@
use PDepend\Source\AST\ASTTrait;
use PHPMD\AbstractNode;
use PHPMD\AbstractRule;
use PHPMD\Node\InterfaceNode;
use PHPMD\Rule\MethodAware;

/**
Expand Down Expand Up @@ -71,6 +72,13 @@ public function apply(AbstractNode $node)
if (strcasecmp($node->getName(), $node->getParentName()) !== 0) {
return;
}
if ($node->getParentType() instanceof InterfaceNode) {
return;
}
if ($node->getNamespaceName() !== '+global') {
return;
}

$this->addViolation($node);
}
}
Expand Up @@ -93,4 +93,18 @@ public function testRuleNotAppliesToMethodNamedSimilarToEnclosingClass()
$rule->setReport($this->getReportMock(0));
$rule->apply($this->getMethod());
}

public function testRuleNotAppliesToMethodNamedAsEnclosingInterface()
{
$rule = new ConstructorWithNameAsEnclosingClass();
$rule->setReport($this->getReportMock(0));
$rule->apply($this->getMethod());
}

public function testRuleNotAppliesToMethodInNamespaces()
{
$rule = new ConstructorWithNameAsEnclosingClass();
$rule->setReport($this->getReportMock(0));
$rule->apply($this->getMethod());
}
}
@@ -0,0 +1,10 @@
<?php
namespace Foo;

class testRuleNotAppliesToMethodInNamespaces
{
function testRuleNotAppliesToMethodInNamespaces()
{

}
}
@@ -0,0 +1,5 @@
<?php
interface testRuleNotAppliesToMethodNamedAsEnclosingInterface
{
function testRuleNotAppliesToMethodNamedAsEnclosingInterface();
}

0 comments on commit ff1bb8b

Please sign in to comment.