Skip to content

Commit

Permalink
# One more internal improvement.
Browse files Browse the repository at this point in the history
git-svn-id: svn://xplib.de/PHP_PMD/trunk@196 0bc4ca42-642f-4eb8-9a60-dc4da71a2dd1
  • Loading branch information
manuelpichler committed Feb 28, 2010
1 parent e12806a commit 975f6a8
Show file tree
Hide file tree
Showing 21 changed files with 100 additions and 99 deletions.
3 changes: 2 additions & 1 deletion source/PHP/PMD/Node/AbstractCodeCallable.php
Expand Up @@ -60,7 +60,8 @@
* @version Release: @package_version@
* @link http://phpmd.org
*/
abstract class PHP_PMD_Node_AbstractCodeCallable extends PHP_PMD_Node_AbstractCodeNode
abstract class PHP_PMD_Node_AbstractCodeCallable
extends PHP_PMD_Node_AbstractCodeNode
{
/**
* Constructs a new callable wrapper.
Expand Down
4 changes: 2 additions & 2 deletions source/PHP/PMD/Node/AbstractCodeType.php
Expand Up @@ -76,13 +76,13 @@ public function __construct(PHP_Depend_Code_AbstractType $node)
* Returns an <b>array</b> with all methods defined in the context class or
* interface.
*
* @return array(PHP_PMD_Node_Method)
* @return array(PHP_PMD_Node_CodeMethod)
*/
public function getMethods()
{
$methods = array();
foreach ($this->getNode()->getMethods() as $method) {
$methods[] = new PHP_PMD_Node_Method($method);
$methods[] = new PHP_PMD_Node_CodeMethod($method);
}
return $methods;
}
Expand Down
Expand Up @@ -60,7 +60,7 @@
* @version Release: @package_version@
* @link http://phpmd.org
*/
class PHP_PMD_Node_Class extends PHP_PMD_Node_AbstractCodeType
class PHP_PMD_Node_CodeClass extends PHP_PMD_Node_AbstractCodeType
{
/**
* Constructs a new class wrapper node.
Expand Down
Expand Up @@ -60,7 +60,7 @@
* @version Release: @package_version@
* @link http://phpmd.org
*/
class PHP_PMD_Node_Function extends PHP_PMD_Node_AbstractCodeCallable
class PHP_PMD_Node_CodeFunction extends PHP_PMD_Node_AbstractCodeCallable
{
/**
* Constructs a new function wrapper.
Expand Down
Expand Up @@ -60,12 +60,12 @@
* @version Release: @package_version@
* @link http://phpmd.org
*/
class PHP_PMD_Node_Method extends PHP_PMD_Node_AbstractCodeCallable
class PHP_PMD_Node_CodeMethod extends PHP_PMD_Node_AbstractCodeCallable
{
/**
* Constructs a new method wrapper.
*
* @param PHP_Depend_Code_Method $node The wrapped method object.
* @param PHP_Depend_Code_CodeMethod $node The wrapped method object.
*/
public function __construct(PHP_Depend_Code_Method $node)
{
Expand Down
14 changes: 7 additions & 7 deletions source/PHP/PMD/Parser.php
Expand Up @@ -49,9 +49,9 @@
require_once 'PHP/Depend/Log/CodeAwareI.php';
require_once 'PHP/Depend/Visitor/AbstractVisitor.php';

require_once 'PHP/PMD/Node/Class.php';
require_once 'PHP/PMD/Node/Function.php';
require_once 'PHP/PMD/Node/Method.php';
require_once 'PHP/PMD/Node/CodeClass.php';
require_once 'PHP/PMD/Node/CodeFunction.php';
require_once 'PHP/PMD/Node/CodeMethod.php';

/**
* Simple wrapper around the php depend engine.
Expand Down Expand Up @@ -204,7 +204,7 @@ public function visitClass(PHP_Depend_Code_Class $node)
return;
}

$this->_apply(new PHP_PMD_Node_Class($node));
$this->_apply(new PHP_PMD_Node_CodeClass($node));
parent::visitClass($node);
}

Expand All @@ -222,13 +222,13 @@ public function visitFunction(PHP_Depend_Code_Function $node)
return;
}

$this->_apply(new PHP_PMD_Node_Function($node));
$this->_apply(new PHP_PMD_Node_CodeFunction($node));
}

/**
* Visits a method node.
*
* @param PHP_Depend_Code_Class $node The method class node.
* @param PHP_Depend_Code_Method $node The method class node.
*
* @return void
* @see PHP_Depend_VisitorI::visitMethod()
Expand All @@ -239,7 +239,7 @@ public function visitMethod(PHP_Depend_Code_Method $node)
return;
}

$this->_apply(new PHP_PMD_Node_Method($node));
$this->_apply(new PHP_PMD_Node_CodeMethod($node));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion source/PHP/PMD/Rule/UnusedFormalParameter.php
Expand Up @@ -108,7 +108,7 @@ public function apply(PHP_PMD_AbstractNode $node)
*/
private function _isAbstractMethod(PHP_PMD_AbstractNode $node)
{
if ($node instanceof PHP_PMD_Node_Method) {
if ($node instanceof PHP_PMD_Node_CodeMethod) {
return $node->isAbstract();
}
return false;
Expand Down
16 changes: 8 additions & 8 deletions source/PHP/PMD/Rule/UnusedPrivateField.php
Expand Up @@ -93,11 +93,11 @@ public function apply(PHP_PMD_AbstractNode $node)
* This method collects all private fields that aren't used by any class
* method.
*
* @param PHP_PMD_Node_Class $class The context class node.
* @param PHP_PMD_Node_CodeClass $class The context class node.
*
* @return array(PHP_PMD_AbstractNode)
*/
private function _collectUnusedPrivateFields(PHP_PMD_Node_Class $class)
private function _collectUnusedPrivateFields(PHP_PMD_Node_CodeClass $class)
{
$this->_fields = array();

Expand All @@ -111,11 +111,11 @@ private function _collectUnusedPrivateFields(PHP_PMD_Node_Class $class)
* This method collects all private fields in the given class and stores
* them in the <b>$_fields</b> property.
*
* @param PHP_PMD_Node_Class $class The context class instance.
* @param PHP_PMD_Node_CodeClass $class The context class instance.
*
* @return void
*/
private function _collectPrivateFields(PHP_PMD_Node_Class $class)
private function _collectPrivateFields(PHP_PMD_Node_CodeClass $class)
{
foreach ($class->findChildrenOfType('FieldDeclaration') as $declaration) {
if ($declaration->isPrivate()) {
Expand Down Expand Up @@ -145,11 +145,11 @@ private function _collectPrivateField(PHP_PMD_Node_ASTNode $declaration)
* removes all fields from the <b>$_fields</b> property that are accessed by
* one of the postfix nodes.
*
* @param PHP_PMD_Node_Class $class The context class instance.
* @param PHP_PMD_Node_CodeClass $class The context class instance.
*
* @return void
*/
private function _removeUsedFields(PHP_PMD_Node_Class $class)
private function _removeUsedFields(PHP_PMD_Node_CodeClass $class)
{
foreach ($class->findChildrenOfType('PropertyPostfix') as $postfix) {
if ($this->_isClassScope($class, $postfix)) {
Expand Down Expand Up @@ -182,13 +182,13 @@ private function _removeUsedField(PHP_PMD_Node_ASTNode $postfix)
* This method checks that the given property postfix is accessed on an
* instance or static reference to the given class.
*
* @param PHP_PMD_Node_Class $class The context class node instance.
* @param PHP_PMD_Node_CodeClass $class The context class node instance.
* @param PHP_PMD_Node_ASTNode $postfix The context property postfix node.
*
* @return boolean
*/
private function _isClassScope(
PHP_PMD_Node_Class $class,
PHP_PMD_Node_CodeClass $class,
PHP_PMD_Node_ASTNode $postfix
) {
$prefix = $postfix->getParent()->getChild(0);
Expand Down
26 changes: 13 additions & 13 deletions source/PHP/PMD/Rule/UnusedPrivateMethod.php
Expand Up @@ -85,11 +85,11 @@ public function apply(PHP_PMD_AbstractNode $class)
* This method collects all methods in the given class that are declared
* as private and are not used in the same class' context.
*
* @param PHP_PMD_Node_Class $class The context class instance.
* @param PHP_PMD_Node_CodeClass $class The context class instance.
*
* @return array(PHP_PMD_AbstractNode)
*/
private function _collectUnusedPrivateMethods(PHP_PMD_Node_Class $class)
private function _collectUnusedPrivateMethods(PHP_PMD_Node_CodeClass $class)
{
$methods = $this->_collectPrivateMethods($class);
return $this->_removeUsedMethods($class, $methods);
Expand All @@ -98,11 +98,11 @@ private function _collectUnusedPrivateMethods(PHP_PMD_Node_Class $class)
/**
* Collects all private methods declared in the given class node.
*
* @param PHP_PMD_Node_Class $class The context class instance.
* @param PHP_PMD_Node_CodeClass $class The context class instance.
*
* @return array(PHP_PMD_AbstractNode)
*/
private function _collectPrivateMethods(PHP_PMD_Node_Class $class)
private function _collectPrivateMethods(PHP_PMD_Node_CodeClass $class)
{
$methods = array();
foreach ($class->getMethods() as $method) {
Expand All @@ -116,12 +116,12 @@ private function _collectPrivateMethods(PHP_PMD_Node_Class $class)
/**
* This method removes all used methods from the given methods array.
*
* @param PHP_PMD_Node_Class $class The context class instance.
* @param array(PHP_PMD_Node_Method) $methods All collected private methods.
* @param PHP_PMD_Node_CodeClass $class The context class instance.
* @param array(PHP_PMD_Node_CodeMethod) $methods All collected private methods.
*
* @return array(PHP_PMD_AbstractNode)
*/
private function _removeUsedMethods(PHP_PMD_Node_Class $class, array $methods)
private function _removeUsedMethods(PHP_PMD_Node_CodeClass $class, array $methods)
{
foreach ($class->findChildrenOfType('MethodPostfix') as $postfix) {
if ($this->_isClassScope($class, $postfix)) {
Expand All @@ -135,14 +135,14 @@ private function _removeUsedMethods(PHP_PMD_Node_Class $class, array $methods)
* Returns <b>true</b> when the given method should be used for this rule's
* analysis.
*
* @param PHP_PMD_Node_Class $class The context class instance.
* @param PHP_PMD_Node_Method $method The context method instance.
* @param PHP_PMD_Node_CodeClass $class The context class instance.
* @param PHP_PMD_Node_CodeMethod $method The context method instance.
*
* @return boolean
*/
private function _acceptMethod(
PHP_PMD_Node_Class $class,
PHP_PMD_Node_Method $method
PHP_PMD_Node_CodeClass $class,
PHP_PMD_Node_CodeMethod $method
) {
return (
$method->isPrivate() &&
Expand All @@ -157,13 +157,13 @@ private function _acceptMethod(
* This method checks that the given method postfix is accessed on an
* instance or static reference to the given class.
*
* @param PHP_PMD_Node_Class $class The context class node instance.
* @param PHP_PMD_Node_CodeClass $class The context class node instance.
* @param PHP_PMD_Node_ASTNode $postfix The context method postfix node.
*
* @return boolean
*/
private function _isClassScope(
PHP_PMD_Node_Class $class,
PHP_PMD_Node_CodeClass $class,
PHP_PMD_Node_ASTNode $postfix
) {
$prefix = $postfix->getParent()->getChild(0);
Expand Down
12 changes: 6 additions & 6 deletions source/PHP/PMD/RuleSet.php
Expand Up @@ -92,9 +92,9 @@ class PHP_PMD_RuleSet implements IteratorAggregate
* @var array(string=>string) $_applyTo
*/
private $_applyTo = array(
'PHP_PMD_Rule_IClassAware' => 'PHP_PMD_Node_Class',
'PHP_PMD_Rule_IFunctionAware' => 'PHP_PMD_Node_Function',
'PHP_PMD_Rule_IMethodAware' => 'PHP_PMD_Node_Method',
'PHP_PMD_Rule_IClassAware' => 'PHP_PMD_Node_CodeClass',
'PHP_PMD_Rule_IFunctionAware' => 'PHP_PMD_Node_CodeFunction',
'PHP_PMD_Rule_IMethodAware' => 'PHP_PMD_Node_CodeMethod',
);

/**
Expand All @@ -103,9 +103,9 @@ class PHP_PMD_RuleSet implements IteratorAggregate
* @var array(string=>array) $_rules
*/
private $_rules = array(
'PHP_PMD_Node_Class' => array(),
'PHP_PMD_Node_Function' => array(),
'PHP_PMD_Node_Method' => array(),
'PHP_PMD_Node_CodeClass' => array(),
'PHP_PMD_Node_CodeFunction' => array(),
'PHP_PMD_Node_CodeMethod' => array(),
);

/**
Expand Down
10 changes: 5 additions & 5 deletions source/PHP/PMD/RuleViolation.php
Expand Up @@ -93,7 +93,7 @@ class PHP_PMD_RuleViolation
*
* @var string
*/
private $_methodName = null;
private $_CodeMethodName = null;

/**
* The name of a function or <b>null</b> when this violation has no function
Expand Down Expand Up @@ -121,10 +121,10 @@ public function __construct(

if ($node instanceof PHP_PMD_Node_AbstractCodeType) {
$this->_className = $node->getName();
} else if ($node instanceof PHP_PMD_Node_Method) {
} else if ($node instanceof PHP_PMD_Node_CodeMethod) {
$this->_className = $node->getParentName();
$this->_methodName = $node->getName();
} else if ($node instanceof PHP_PMD_Node_Function) {
$this->_CodeMethodName = $node->getName();
} else if ($node instanceof PHP_PMD_Node_CodeFunction) {
$this->_functionName = $node->getName();
}
}
Expand Down Expand Up @@ -208,7 +208,7 @@ public function getClassName()
*/
public function getMethodName()
{
return $this->_methodName;
return $this->_CodeMethodName;
}

/**
Expand Down

0 comments on commit 975f6a8

Please sign in to comment.