コード例 #1
0
ファイル: LongVariable.php プロジェクト: Flesh192/magento
 /**
  * Extracts all variable and variable declarator nodes from the given node
  * and checks the variable name length against the configured maximum
  * length.
  *
  * @param \PHPMD\AbstractNode $node
  * @return void
  */
 public function apply(AbstractNode $node)
 {
     $this->resetProcessed();
     if ($node->getType() === 'class') {
         $fields = $node->findChildrenOfType('FieldDeclaration');
         foreach ($fields as $field) {
             if ($field->isPrivate()) {
                 continue;
             }
             $declarators = $field->findChildrenOfType('VariableDeclarator');
             foreach ($declarators as $declarator) {
                 $this->checkNodeImage($declarator);
             }
         }
     } else {
         $declarators = $node->findChildrenOfType('VariableDeclarator');
         foreach ($declarators as $declarator) {
             $this->checkNodeImage($declarator);
         }
         $variables = $node->findChildrenOfType('Variable');
         foreach ($variables as $variable) {
             $this->checkNodeImage($variable);
         }
     }
     $this->resetProcessed();
 }
コード例 #2
0
 /**
  * This method checks if a given function or method contains an eval-expression
  * and emits a rule violation when it exists.
  *
  * @param \PHPMD\AbstractNode $node
  * @return void
  */
 public function apply(AbstractNode $node)
 {
     foreach ($node->findChildrenOfType('FunctionPostfix') as $postfix) {
         $image = strtolower($postfix->getImage());
         if (false === in_array($image, $this->getSuspectImages())) {
             continue;
         }
         $image = $node->getImage();
         if ($node instanceof MethodNode) {
             $image = sprintf('%s::%s', $node->getParentName(), $node->getImage());
         }
         $this->addViolation($postfix, array($node->getType(), $image, $postfix->getImage()));
     }
 }
コード例 #3
0
ファイル: GotoStatement.php プロジェクト: Flesh192/magento
 /**
  * This method should implement the violation analysis algorithm of concrete
  * rule implementations. All extending classes must implement this method.
  *
  * @param \PHPMD\AbstractNode $node
  * @return void
  */
 public function apply(AbstractNode $node)
 {
     foreach ($node->findChildrenOfType('GotoStatement') as $goto) {
         $this->addViolation($goto, array($node->getType(), $node->getName()));
     }
 }
コード例 #4
0
ファイル: ExitExpression.php プロジェクト: flavius/phpmd
 /**
  * This method checks if a given function or method contains an exit-expression
  * and emits a rule violation when it exists.
  *
  * @param \PHPMD\AbstractNode $node
  * @return void
  */
 public function apply(AbstractNode $node)
 {
     foreach ($node->findChildrenOfType('ExitExpression') as $exit) {
         $this->addViolation($exit, array($node->getType(), $node->getName()));
     }
 }