phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true ); if ( \T_OPEN_PARENTHESIS !== $this->tokens[ $openParenthesis ]['code'] ) { // Not a function call. return; } if ( ! isset( $this->tokens[ $openParenthesis ]['parenthesis_closer'] ) ) { // Not a function call. return; } // Find the previous non-empty token. $search = Tokens::$emptyTokens; $search[] = \T_BITWISE_AND; $previous = $this->phpcsFile->findPrevious( $search, ( $stackPtr - 1 ), null, true ); if ( \T_FUNCTION === $this->tokens[ $previous ]['code'] ) { // It's a function definition, not a function call. return; } $closer = $this->tokens[ $openParenthesis ]['parenthesis_closer']; if ( ( $closer - 1 ) === $openParenthesis ) { return; } $nextNonWhitespace = $this->phpcsFile->findNext( \T_WHITESPACE, ( $openParenthesis + 1 ), null, true ); if ( $nextNonWhitespace !== $closer ) { // Function has params or comment between parenthesis. return; } $fix = $this->phpcsFile->addFixableError( 'Function calls without parameters should have no spaces between the parenthesis.', ( $openParenthesis + 1 ), 'WhitespaceFound' ); if ( true === $fix ) { // If there is only whitespace between the parenthesis, it will just be the one token. $this->phpcsFile->fixer->replaceToken( ( $openParenthesis + 1 ), '' ); } } }