/**
  * This method checks if a method is not named in camelCase
  * and emits a rule violation.
  *
  * @param PHP_PMD_AbstractNode $node The context source code node.
  *
  * @return void
  */
 public function apply(PHP_PMD_AbstractNode $node)
 {
     if (!in_array($node->getName(), $this->ignoredMethods)) {
         if (!preg_match('/^[a-z][a-zA-Z0-9]*$/', $node->getName())) {
             $this->addViolation($node, array($node->getName()));
         }
     }
 }
 /**
  * Extracts all variable and variable declarator nodes from the given node
  * and checks the variable name length against the configured minimum
  * length.
  *
  * @param PHP_PMD_AbstractNode $node The context source code node.
  *
  * @return void
  */
 public function apply(PHP_PMD_AbstractNode $node)
 {
     if (strcasecmp($node->getName(), $node->getParentName()) !== 0) {
         return;
     }
     $this->addViolation($node);
 }
Exemple #3
0
 /**
  * Extracts all variable and variable declarator nodes from the given node
  * and checks the variable name length against the configured minimum
  * length.
  *
  * @param PHP_PMD_AbstractNode $node The context source code node.
  *
  * @return void
  */
 public function apply(PHP_PMD_AbstractNode $node)
 {
     if ($this->getIntProperty('minimum') <= strlen($node->getName())) {
         return;
     }
     $this->addViolation($node, array($node->getParentName(), $node->getName()));
 }
 /**
  * This method checks if a class is not named in CamelCase
  * and emits a rule violation.
  *
  * @param PHP_PMD_AbstractNode $node The context source code node.
  *
  * @return void
  */
 public function apply(PHP_PMD_AbstractNode $node)
 {
     if (!preg_match('/^[A-Z][a-zA-Z0-9]*$/', $node->getName())) {
         $this->addViolation($node, array($node->getName()));
     }
 }
Exemple #5
0
 /**
  * This method checks if a given function or method contains an eval-expression
  * and emits a rule violation when it exists.
  *
  * @param PHP_PMD_AbstractNode $node The context source code node.
  *
  * @return void
  */
 public function apply(PHP_PMD_AbstractNode $node)
 {
     foreach ($node->findChildrenOfType('EvalExpression') as $eval) {
         $this->addViolation($eval, array($node->getType(), $node->getName()));
     }
 }
Exemple #6
0
 /**
  * Constructs a new rule violation instance.
  *
  * @param PHP_PMD_AbstractRule $rule             PHP_PMD rule for violation.
  * @param PHP_PMD_AbstractNode $node             The source node of evil.
  * @param string               $violationMessage The error/report message.
  */
 public function __construct(PHP_PMD_AbstractRule $rule, PHP_PMD_AbstractNode $node, $violationMessage)
 {
     $this->_rule = $rule;
     $this->_node = $node;
     $this->_description = $violationMessage;
     if ($node instanceof PHP_PMD_Node_AbstractType) {
         $this->_className = $node->getName();
     } else {
         if ($node instanceof PHP_PMD_Node_Method) {
             $this->_className = $node->getParentName();
             $this->_CodeMethodName = $node->getName();
         } else {
             if ($node instanceof PHP_PMD_Node_Function) {
                 $this->_functionName = $node->getName();
             }
         }
     }
 }
 /**
  * This method should implement the violation analysis algorithm of concrete
  * rule implementations. All extending classes must implement this method.
  *
  * @param PHP_PMD_AbstractNode $node The current context for analysis.
  *
  * @return void
  */
 public function apply(PHP_PMD_AbstractNode $node)
 {
     foreach ($node->findChildrenOfType('GotoStatement') as $goto) {
         $this->addViolation($goto, array($node->getType(), $node->getName()));
     }
 }