private function checkMethodSignature(Tokens $tokens, $methodName, $methodFunctionIndex)
 {
     $startParenthesisIndex = $tokens->getNextTokenOfKind($methodFunctionIndex, array('('));
     $endParenthesisIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $startParenthesisIndex);
     for ($index = $startParenthesisIndex; $index < $endParenthesisIndex; ++$index) {
         if (!$tokens[$index]->isGivenKind(T_VARIABLE)) {
             continue;
         }
         $tokens->reportAt($index, new Message(E_ERROR, 'check_method_arguments_not_allowed', ['method' => $methodName]));
         break;
     }
 }
Exemplo n.º 2
0
 /**
  * @inheritdoc
  */
 public function check(\SplFileInfo $file, Tokens $tokens)
 {
     $tokenCount = $tokens->count();
     for ($index = 0; $index < $tokenCount; ++$index) {
         $token = $tokens[$index];
         if (!$token->isGivenKind(T_CLASS)) {
             continue;
         }
         $prevToken = $tokens[$tokens->getPrevMeaningfulToken($index)];
         $classStart = $tokens->getNextTokenOfKind($index, array('{'));
         $classEnd = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_CURLY_BRACE, $classStart);
         // ignore class if it is abstract or already final
         if ($prevToken->isGivenKind(array(T_ABSTRACT, T_FINAL))) {
             $index = $classEnd;
             continue;
         }
         $classNameIndex = $tokens->getNextTokenOfKind($index, [[T_STRING]]);
         $className = $tokens[$classNameIndex]->getContent();
         $tokens->reportAt($index, new Message(E_ERROR, 'check_class_should_be_final', ['class' => $className]));
         $index = $classEnd;
     }
 }