From 472b3254328afbcd5f6ad92f61b3a9da76a92526 Mon Sep 17 00:00:00 2001 From: alex_prokopenko Date: Wed, 29 Mar 2017 18:52:40 +0300 Subject: [PATCH] WPCS: deleted deprecated sniffs in 0.11; Totally removed i18n checks in JC wordpress ruleset --- justcoded/JustcodedWordpress/ruleset.xml | 7 +- .../Classes/ClassOpeningStatementSniff.php | 137 ----------- .../Sniffs/Classes/ValidClassNameSniff.php | 75 ------ .../PHP/DisallowAlternativePHPTagsSniff.php | 228 ------------------ .../Tests/Arrays/ArrayDeclarationUnitTest.inc | 208 ---------------- .../Arrays/ArrayDeclarationUnitTest.inc.fixed | 208 ---------------- .../Tests/Arrays/ArrayDeclarationUnitTest.php | 46 ---- .../Classes/ClassOpeningStatementUnitTest.inc | 81 ------- .../ClassOpeningStatementUnitTest.inc.fixed | 81 ------- .../Classes/ClassOpeningStatementUnitTest.php | 53 ---- .../Tests/Classes/ValidClassNameUnitTest.inc | 7 - .../Tests/Classes/ValidClassNameUnitTest.php | 40 --- .../DisallowAlternativePHPTagsUnitTest.inc | 18 -- ...sallowAlternativePHPTagsUnitTest.inc.fixed | 18 -- .../DisallowAlternativePHPTagsUnitTest.php | 88 ------- .../PHP/DiscouragedFunctionsUnitTest.inc | 54 ----- .../PHP/DiscouragedFunctionsUnitTest.php | 58 ----- 17 files changed, 2 insertions(+), 1405 deletions(-) delete mode 100644 wpcs/WordPress/Sniffs/Classes/ClassOpeningStatementSniff.php delete mode 100644 wpcs/WordPress/Sniffs/Classes/ValidClassNameSniff.php delete mode 100644 wpcs/WordPress/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php delete mode 100644 wpcs/WordPress/Tests/Arrays/ArrayDeclarationUnitTest.inc delete mode 100644 wpcs/WordPress/Tests/Arrays/ArrayDeclarationUnitTest.inc.fixed delete mode 100644 wpcs/WordPress/Tests/Arrays/ArrayDeclarationUnitTest.php delete mode 100644 wpcs/WordPress/Tests/Classes/ClassOpeningStatementUnitTest.inc delete mode 100644 wpcs/WordPress/Tests/Classes/ClassOpeningStatementUnitTest.inc.fixed delete mode 100644 wpcs/WordPress/Tests/Classes/ClassOpeningStatementUnitTest.php delete mode 100644 wpcs/WordPress/Tests/Classes/ValidClassNameUnitTest.inc delete mode 100644 wpcs/WordPress/Tests/Classes/ValidClassNameUnitTest.php delete mode 100644 wpcs/WordPress/Tests/PHP/DisallowAlternativePHPTagsUnitTest.inc delete mode 100644 wpcs/WordPress/Tests/PHP/DisallowAlternativePHPTagsUnitTest.inc.fixed delete mode 100644 wpcs/WordPress/Tests/PHP/DisallowAlternativePHPTagsUnitTest.php delete mode 100644 wpcs/WordPress/Tests/PHP/DiscouragedFunctionsUnitTest.inc delete mode 100644 wpcs/WordPress/Tests/PHP/DiscouragedFunctionsUnitTest.php diff --git a/justcoded/JustcodedWordpress/ruleset.xml b/justcoded/JustcodedWordpress/ruleset.xml index cdb53ff..4f0154c 100644 --- a/justcoded/JustcodedWordpress/ruleset.xml +++ b/justcoded/JustcodedWordpress/ruleset.xml @@ -6,10 +6,8 @@ */vendor/* - - - - + + @@ -48,5 +46,4 @@ - diff --git a/wpcs/WordPress/Sniffs/Classes/ClassOpeningStatementSniff.php b/wpcs/WordPress/Sniffs/Classes/ClassOpeningStatementSniff.php deleted file mode 100644 index c4b9a4b..0000000 --- a/wpcs/WordPress/Sniffs/Classes/ClassOpeningStatementSniff.php +++ /dev/null @@ -1,137 +0,0 @@ -getTokens(); - $scope_identifier = $phpcsFile->findNext( T_STRING, ( $stackPtr + 1 ) ); - $errorData = array( - strtolower( $tokens[ $stackPtr ]['content'] ) . ' ' . $tokens[ $scope_identifier ]['content'] - ); - - if ( ! isset( $tokens[ $stackPtr ]['scope_opener'] ) ) { - $error = 'Possible parse error: %s missing opening or closing brace'; - $phpcsFile->addWarning( $error, $stackPtr, 'MissingBrace', $errorData ); - return; - } - - $openingBrace = $tokens[ $stackPtr ]['scope_opener']; - - /* - * Is the brace on the same line as the class/interface/trait declaration ? - */ - $lastClassLineToken = $phpcsFile->findPrevious( T_STRING, ( $openingBrace - 1 ), $stackPtr ); - $lastClassLine = $tokens[ $lastClassLineToken ]['line']; - $braceLine = $tokens[ $openingBrace ]['line']; - $lineDifference = ( $braceLine - $lastClassLine ); - - if ( $lineDifference > 0 ) { - $phpcsFile->recordMetric( $stackPtr, 'Class opening brace placement', 'new line' ); - $error = 'Opening brace should be on the same line as the declaration for %s'; - $fix = $phpcsFile->addFixableError( $error, $openingBrace, 'BraceOnNewLine', $errorData ); - if ( true === $fix ) { - $phpcsFile->fixer->beginChangeset(); - $phpcsFile->fixer->addContent( $lastClassLineToken, ' {' ); - $phpcsFile->fixer->replaceToken( $openingBrace, '' ); - $phpcsFile->fixer->endChangeset(); - } - } else { - $phpcsFile->recordMetric( $stackPtr, 'Class opening brace placement', 'same line' ); - } - - /* - * Is the opening brace the last thing on the line ? - */ - $next = $phpcsFile->findNext( T_WHITESPACE, ( $openingBrace + 1 ), null, true ); - if ( $tokens[ $next ]['line'] === $tokens[ $openingBrace ]['line'] ) { - if ( $next === $tokens[ $stackPtr ]['scope_closer'] ) { - // Ignore empty classes. - return; - } - - $error = 'Opening brace must be the last content on the line'; - $fix = $phpcsFile->addFixableError( $error, $openingBrace, 'ContentAfterBrace' ); - if ( true === $fix ) { - $phpcsFile->fixer->addNewline( $openingBrace ); - } - } - - // Only continue checking if the opening brace looks good. - if ( $lineDifference > 0 ) { - return; - } - - /* - * Is there precisely one space before the opening brace ? - */ - if ( T_WHITESPACE !== $tokens[ ( $openingBrace - 1 ) ]['code'] ) { - $length = 0; - } elseif ( "\t" === $tokens[ ( $openingBrace - 1 ) ]['content'] ) { - $length = '\t'; - } else { - $length = strlen( $tokens[ ( $openingBrace - 1 ) ]['content'] ); - } - - if ( 1 !== $length ) { - $error = 'Expected 1 space before opening brace; found %s'; - $data = array( $length ); - $fix = $phpcsFile->addFixableError( $error, $openingBrace, 'SpaceBeforeBrace', $data ); - if ( true === $fix ) { - if ( 0 === $length || '\t' === $length ) { - $phpcsFile->fixer->addContentBefore( $openingBrace, ' ' ); - } else { - $phpcsFile->fixer->replaceToken( ( $openingBrace - 1 ), ' ' ); - } - } - } - - } // End process(). - -} // End class. diff --git a/wpcs/WordPress/Sniffs/Classes/ValidClassNameSniff.php b/wpcs/WordPress/Sniffs/Classes/ValidClassNameSniff.php deleted file mode 100644 index 90f3dd2..0000000 --- a/wpcs/WordPress/Sniffs/Classes/ValidClassNameSniff.php +++ /dev/null @@ -1,75 +0,0 @@ -getTokens(); - - if ( ! isset( $tokens[ $stackPtr ]['scope_opener'] ) ) { - $error = 'Possible parse error: '; - $error .= $tokens[ $stackPtr ]['content']; - $error .= ' missing opening or closing brace'; - $phpcsFile->addWarning( $error, $stackPtr, 'MissingBrace' ); - return; - } - - // Determine the name of the class or interface. Note that we cannot - // simply look for the first T_STRING because a class name - // starting with the number will be multiple tokens. - $opener = $tokens[ $stackPtr ]['scope_opener']; - $nameStart = $phpcsFile->findNext( T_WHITESPACE, ( $stackPtr + 1 ), $opener, true ); - $nameEnd = $phpcsFile->findNext( T_WHITESPACE, $nameStart, $opener ); - $name = trim( $phpcsFile->getTokensAsString( $nameStart, ( $nameEnd - $nameStart ) ) ); - - // Check for camel caps format. - $valid = PHP_CodeSniffer::isCamelCaps( str_replace( '_', '', $name ), true, true, false ); - if ( false === $valid ) { - $type = ucfirst( $tokens[ $stackPtr ]['content'] ); - $error = "$type name \"$name\" is not in camel caps format"; - $phpcsFile->addError( $error, $stackPtr, 'NotCamelCaps' ); - } - - } // end process() - -} // End class. diff --git a/wpcs/WordPress/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php b/wpcs/WordPress/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php deleted file mode 100644 index b73e7d3..0000000 --- a/wpcs/WordPress/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php +++ /dev/null @@ -1,228 +0,0 @@ -asp_tags = (bool) ini_get( 'asp_tags' ); - } - - return array( - T_OPEN_TAG, - T_OPEN_TAG_WITH_ECHO, - T_INLINE_HTML, - ); - - } // end register() - - /** - * Processes this test, when one of its tokens is encountered. - * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. - * - * @return void - */ - public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) { - $tokens = $phpcsFile->getTokens(); - $openTag = $tokens[ $stackPtr ]; - $content = $openTag['content']; - - if ( '' === trim( $content ) ) { - return; - } - - if ( T_OPEN_TAG === $openTag['code'] ) { - - if ( '<%' === $content ) { - $error = 'ASP style opening tag used; expected "find_closing_tag( $phpcsFile, $tokens, $stackPtr, '%>' ); - $error_id = 'ASPOpenTagFound'; - - } elseif ( false !== strpos( $content, '' ); - $error_id = 'ScriptOpenTagFound'; - } - - if ( isset( $error, $closer, $error_id ) ) { - $data = array( $content ); - - if ( false === $closer ) { - $phpcsFile->addError( $error, $stackPtr, $error_id, $data ); - } else { - $fix = $phpcsFile->addFixableError( $error, $stackPtr, $error_id, $data ); - if ( true === $fix ) { - $this->add_changeset( $phpcsFile, $tokens, $stackPtr, $closer ); - } - } - } - - return; - } - - if ( T_OPEN_TAG_WITH_ECHO === $openTag['code'] && '<%=' === $content ) { - $error = 'ASP style opening tag used with echo; expected "findNext( T_WHITESPACE, ( $stackPtr + 1 ), null, true ); - $snippet = $this->get_snippet( $tokens[ $nextVar ]['content'] ); - $data = array( - $snippet, - $content, - $snippet, - ); - - $closer = $this->find_closing_tag( $phpcsFile, $tokens, $stackPtr, '%>' ); - - if ( false === $closer ) { - $phpcsFile->addError( $error, $stackPtr, 'ASPShortOpenTagFound', $data ); - } else { - $fix = $phpcsFile->addFixableError( $error, $stackPtr, 'ASPShortOpenTagFound', $data ); - if ( true === $fix ) { - $this->add_changeset( $phpcsFile, $tokens, $stackPtr, $closer, true ); - } - } - - return; - } - - // Account for incorrect script open tags. The "(?:]+)?language=[\'"]?php[\'"]?(?:[^>]+)?>)`i', $content, $match ) ) { - $error = 'Script style opening tag used; expected "get_snippet( $content, $match[1] ); - $data = array( $match[1] . $snippet ); - - $phpcsFile->addError( $error, $stackPtr, 'ScriptOpenTagFound', $data ); - - return; - } - - if ( T_INLINE_HTML === $openTag['code'] && false === $this->asp_tags ) { - if ( false !== strpos( $content, '<%=' ) ) { - $error = 'Possible use of ASP style short opening tags detected. Needs manual inspection. Found: %s'; - $snippet = $this->get_snippet( $content, '<%=' ); - $data = array( '<%=' . $snippet ); - - $phpcsFile->addWarning( $error, $stackPtr, 'MaybeASPShortOpenTagFound', $data ); - - } elseif ( false !== strpos( $content, '<%' ) ) { - $error = 'Possible use of ASP style opening tags detected. Needs manual inspection. Found: %s'; - $snippet = $this->get_snippet( $content, '<%' ); - $data = array( '<%' . $snippet ); - - $phpcsFile->addWarning( $error, $stackPtr, 'MaybeASPOpenTagFound', $data ); - } - } - } // end process() - - /** - * Get a snippet from a HTML token. - * - * @param string $content The content of the HTML token. - * @param string $start_at Partial string to use as a starting point for the snippet. - * @param int $length The target length of the snippet to get. Defaults to 40. - * @return string - */ - private function get_snippet( $content, $start_at = '', $length = 40 ) { - $start_pos = 0; - - if ( '' !== $start_at ) { - $start_pos = strpos( $content, $start_at ); - if ( false !== $start_pos ) { - $start_pos += strlen( $start_at ); - } - } - - $snippet = substr( $content, $start_pos, $length ); - if ( ( strlen( $content ) - $start_pos ) > $length ) { - $snippet .= '...'; - } - - return $snippet; - } - - /** - * Try and find a matching PHP closing tag. - * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param array $tokens The token stack. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. - * @param string $content The expected content of the closing tag to match the opener. - * @return int|false Pointer to the position in the stack for the closing tag or false if not found. - */ - private function find_closing_tag( PHP_CodeSniffer_File $phpcsFile, $tokens, $stackPtr, $content ) { - $closer = $phpcsFile->findNext( T_CLOSE_TAG, ( $stackPtr + 1 ) ); - - if ( false !== $closer && trim( $tokens[ $closer ]['content'] ) === $content ) { - return $closer; - } - - return false; - } - - /** - * Add a changeset to replace the alternative PHP tags. - * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param array $tokens The token stack. - * @param int $open_tag_pointer Stack pointer to the PHP open tag. - * @param int $close_tag_pointer Stack pointer to the PHP close tag. - * @param bool $echo Whether to add 'echo' or not. - */ - private function add_changeset( PHP_CodeSniffer_File $phpcsFile, $tokens, $open_tag_pointer, $close_tag_pointer, $echo = false ) { - // Build up the open tag replacement and make sure there's always whitespace behind it. - $open_replacement = '', $tokens[ $close_tag_pointer ]['content'] ); - - $phpcsFile->fixer->beginChangeset(); - $phpcsFile->fixer->replaceToken( $open_tag_pointer, $open_replacement ); - $phpcsFile->fixer->replaceToken( $close_tag_pointer, $close_replacement ); - $phpcsFile->fixer->endChangeset(); - } - -} // End class. diff --git a/wpcs/WordPress/Tests/Arrays/ArrayDeclarationUnitTest.inc b/wpcs/WordPress/Tests/Arrays/ArrayDeclarationUnitTest.inc deleted file mode 100644 index 12831f7..0000000 --- a/wpcs/WordPress/Tests/Arrays/ArrayDeclarationUnitTest.inc +++ /dev/null @@ -1,208 +0,0 @@ - 'food'), // Bad, no spaces after opening and before closing paranthesis. - // ... - array( - 'post_status' => 'private', - 'orderby' => 'title' // Bad, no comma at the ending. - ) -); -$query = new WP_Query( $query_vars ); - -$query_vars = array_merge( - array( 'post_type' => 'food' ), // Good. - // ... - array( - 'post_status' => 'private', - 'orderby' => 'title', // Good. - ), - array( - 'closure' => function () { // Good, closures allowed. - return array(); - }, - ), - bar( // Good, functions allowed. - 1, - 2 - ) -); -$query = new WP_Query( $query_vars ); - -$defaults = array( 'type'=>'post' ); // Bad, no spaces before and after double arrow. -wp_parse_args( $args, $defaults ); - -class Foo { - function to_markdown( $params = array() ) { - // Parse sections. - $section_formatters = array( - 'Description' => function ( $body ) use ( $params ) { - if ( isset( $params['travis_ci_url'] ) ) { - $body .= sprintf( "\n\n[![Build Status](%s.png)](%s)", $params['travis_ci_url'], $params['travis_ci_url'] ); - } - return $body; - }, - 'Screenshots' => function ( $body ) { - foreach ( $screenshot_matches as $i => $screenshot_match ) { - print (int) $i; - } - }, - 'Food' => sprintf( - '%s,%d', - 'a', - 1 - ), - 'Bard' => add_query_arg( - 'quux', - 'bazd' - ), - ); - } -} - -$primary_order = array( - 'n', // Null. - 'b', // Boolean. - 'i', // Integer. - 'f', // Float. - 's', // String. - 'a', // Array. - 'o', // Object. - 'r', // Resource. - 'p', // SPL_Types object. -); - -$var = array( - 'tab_template' => ' -
  • %s
  • ', - 'panel_template' => ' -
    - %s -
    ', -); - -// This should all be good. -$section_args = array( - 'title' => sprintf( - __( 'Sidebar: %s', 'widget-customizer' ), - $GLOBALS['wp_registered_sidebars'][ $sidebar_id ]['name'] - ), - 'description' => $GLOBALS['wp_registered_sidebars'][ $sidebar_id ]['description'], -); - -$strings = array( - 'hidethings' => ( ( true === $this->settings['enable_hidden_class'] && ( is_array( $this->settings['hidden_classname'] ) && array() !== $this->settings['hidden_classname'] ) ) ? true : false ), - 'enable_async' => ( ( true === $this->settings['enable_async'] && ( is_array( $this->active_mimetypes ) && array() !== $this->active_mimetypes ) ) ? true : false ), - 'enable_async_debug' => ( ( true === $this->settings['enable_async_debug'] && ( is_array( $this->active_mimetypes ) && array() !== $this->active_mimetypes ) ) ? true : false ), -); - -$actions = array( - 'install' => sprintf( - 'Install', - wp_nonce_url( - add_query_arg( - array( - 'page' => TGM_Plugin_Activation::$instance->menu, - 'plugin' => $item['slug'], - 'plugin_name' => $item['sanitized_plugin'], - 'plugin_source' => $item['url'], - 'tgmpa-install' => 'install-plugin', - ), - admin_url( TGM_Plugin_Activation::$instance->parent_url_slug ) - ), - 'tgmpa-install' - ), - $item['sanitized_plugin'] - ), -); - -$custom_fields = array( - 'videoembed', // Press75 Simple Video Embedder. - '_videoembed_manual', // Press75 Simple Video Embedder. - '_videoembed', // Press75 Simple Video Embedder. - '_premise_settings', // Premise. -); - -$item_block_comment = array( - 'item', - /* Some comment. */ -); - -$item_multiple_line_block_comment = array( - 'item', - /* Some comment - over multiple lines. */ -); - -$block_comment = array( - /* Just a comment. */ -); - -$comment = array( - // Just a single comment. -); - -$multidimensional_comments = array( - 'item_block_comment' => array( - 'item', - /* Comment. */ - ), - 'block_comment' => array( - /* Comment. */ - ), - 'item_comment' => array( - 'item', - // Comment. - ), - 'comment' => array( - // Comment. - ), - // Comment. - array( - 'item', - /* Comment. */ - ), - array( - /* Comment. */ - ), - array( - 'item', - // Comment. - ), - array( - // Comment. - ), - // Comment. -); - -$q = new WP_Query( array( - 'meta_query' => array( - 'relation' => 'and', // Ok. - array( - 'key' => 'asdsa', - 'value' => 'asds', - ), - ), -) ); - -array( - 'key', - /** - * Doc comment. - */ -// 'core'. -); - -// Multiple values in an array on a single line is allowed. -array( 1, 2 ); - -// Test for fixing of extra whitespace. -array( 1, 2 ); diff --git a/wpcs/WordPress/Tests/Arrays/ArrayDeclarationUnitTest.inc.fixed b/wpcs/WordPress/Tests/Arrays/ArrayDeclarationUnitTest.inc.fixed deleted file mode 100644 index cbe7ae7..0000000 --- a/wpcs/WordPress/Tests/Arrays/ArrayDeclarationUnitTest.inc.fixed +++ /dev/null @@ -1,208 +0,0 @@ - 'food' ), // Bad, no spaces after opening and before closing paranthesis. - // ... - array( - 'post_status' => 'private', - 'orderby' => 'title',// Bad, no comma at the ending. - ) -); -$query = new WP_Query( $query_vars ); - -$query_vars = array_merge( - array( 'post_type' => 'food' ), // Good. - // ... - array( - 'post_status' => 'private', - 'orderby' => 'title', // Good. - ), - array( - 'closure' => function () { // Good, closures allowed. - return array(); - }, - ), - bar( // Good, functions allowed. - 1, - 2 - ) -); -$query = new WP_Query( $query_vars ); - -$defaults = array( 'type' => 'post' ); // Bad, no spaces before and after double arrow. -wp_parse_args( $args, $defaults ); - -class Foo { - function to_markdown( $params = array() ) { - // Parse sections. - $section_formatters = array( - 'Description' => function ( $body ) use ( $params ) { - if ( isset( $params['travis_ci_url'] ) ) { - $body .= sprintf( "\n\n[![Build Status](%s.png)](%s)", $params['travis_ci_url'], $params['travis_ci_url'] ); - } - return $body; - }, - 'Screenshots' => function ( $body ) { - foreach ( $screenshot_matches as $i => $screenshot_match ) { - print (int) $i; - } - }, - 'Food' => sprintf( - '%s,%d', - 'a', - 1 - ), - 'Bard' => add_query_arg( - 'quux', - 'bazd' - ), - ); - } -} - -$primary_order = array( - 'n', // Null. - 'b', // Boolean. - 'i', // Integer. - 'f', // Float. - 's', // String. - 'a', // Array. - 'o', // Object. - 'r', // Resource. - 'p', // SPL_Types object. -); - -$var = array( - 'tab_template' => ' -
  • %s
  • ', - 'panel_template' => ' -
    - %s -
    ', -); - -// This should all be good. -$section_args = array( - 'title' => sprintf( - __( 'Sidebar: %s', 'widget-customizer' ), - $GLOBALS['wp_registered_sidebars'][ $sidebar_id ]['name'] - ), - 'description' => $GLOBALS['wp_registered_sidebars'][ $sidebar_id ]['description'], -); - -$strings = array( - 'hidethings' => ( ( true === $this->settings['enable_hidden_class'] && ( is_array( $this->settings['hidden_classname'] ) && array() !== $this->settings['hidden_classname'] ) ) ? true : false ), - 'enable_async' => ( ( true === $this->settings['enable_async'] && ( is_array( $this->active_mimetypes ) && array() !== $this->active_mimetypes ) ) ? true : false ), - 'enable_async_debug' => ( ( true === $this->settings['enable_async_debug'] && ( is_array( $this->active_mimetypes ) && array() !== $this->active_mimetypes ) ) ? true : false ), -); - -$actions = array( - 'install' => sprintf( - 'Install', - wp_nonce_url( - add_query_arg( - array( - 'page' => TGM_Plugin_Activation::$instance->menu, - 'plugin' => $item['slug'], - 'plugin_name' => $item['sanitized_plugin'], - 'plugin_source' => $item['url'], - 'tgmpa-install' => 'install-plugin', - ), - admin_url( TGM_Plugin_Activation::$instance->parent_url_slug ) - ), - 'tgmpa-install' - ), - $item['sanitized_plugin'] - ), -); - -$custom_fields = array( - 'videoembed', // Press75 Simple Video Embedder. - '_videoembed_manual', // Press75 Simple Video Embedder. - '_videoembed', // Press75 Simple Video Embedder. - '_premise_settings', // Premise. -); - -$item_block_comment = array( - 'item', - /* Some comment. */ -); - -$item_multiple_line_block_comment = array( - 'item', - /* Some comment - over multiple lines. */ -); - -$block_comment = array( - /* Just a comment. */ -); - -$comment = array( - // Just a single comment. -); - -$multidimensional_comments = array( - 'item_block_comment' => array( - 'item', - /* Comment. */ - ), - 'block_comment' => array( - /* Comment. */ - ), - 'item_comment' => array( - 'item', - // Comment. - ), - 'comment' => array( - // Comment. - ), - // Comment. - array( - 'item', - /* Comment. */ - ), - array( - /* Comment. */ - ), - array( - 'item', - // Comment. - ), - array( - // Comment. - ), - // Comment. -); - -$q = new WP_Query( array( - 'meta_query' => array( - 'relation' => 'and', // Ok. - array( - 'key' => 'asdsa', - 'value' => 'asds', - ), - ), -) ); - -array( - 'key', - /** - * Doc comment. - */ -// 'core'. -); - -// Multiple values in an array on a single line is allowed. -array( 1, 2 ); - -// Test for fixing of extra whitespace. -array( 1, 2 ); diff --git a/wpcs/WordPress/Tests/Arrays/ArrayDeclarationUnitTest.php b/wpcs/WordPress/Tests/Arrays/ArrayDeclarationUnitTest.php deleted file mode 100644 index c206bab..0000000 --- a/wpcs/WordPress/Tests/Arrays/ArrayDeclarationUnitTest.php +++ /dev/null @@ -1,46 +0,0 @@ - => - */ - public function getErrorList() { - return array( - 3 => 1, - 7 => 1, - 9 => 1, - 12 => 2, - 16 => 1, - 40 => 2, - 208 => 2, - ); - - } - - /** - * Returns the lines where warnings should occur. - * - * @return array => - */ - public function getWarningList() { - return array(); - - } - -} // End class. diff --git a/wpcs/WordPress/Tests/Classes/ClassOpeningStatementUnitTest.inc b/wpcs/WordPress/Tests/Classes/ClassOpeningStatementUnitTest.inc deleted file mode 100644 index 1356e5b..0000000 --- a/wpcs/WordPress/Tests/Classes/ClassOpeningStatementUnitTest.inc +++ /dev/null @@ -1,81 +0,0 @@ - => - */ - public function getErrorList() { - - return array( - 19 => 2, - 23 => 1, - 28 => 2, - 34 => 1, - 34 => 1, - 38 => 1, - 41 => 1, - 44 => 1, - 47 => 1, - 70 => 1, - 79 => 1, - ); - - } - - /** - * Returns the lines where warnings should occur. - * - * @return array => - */ - public function getWarningList() { - return array( - 51 => 1, - ); - - } - -} // End class. diff --git a/wpcs/WordPress/Tests/Classes/ValidClassNameUnitTest.inc b/wpcs/WordPress/Tests/Classes/ValidClassNameUnitTest.inc deleted file mode 100644 index f4914ed..0000000 --- a/wpcs/WordPress/Tests/Classes/ValidClassNameUnitTest.inc +++ /dev/null @@ -1,7 +0,0 @@ - => - */ - public function getErrorList() { - return array( - 7 => 1, - ); - - } - - /** - * Returns the lines where warnings should occur. - * - * @return array => - */ - public function getWarningList() { - return array(); - - } - -} // End class. diff --git a/wpcs/WordPress/Tests/PHP/DisallowAlternativePHPTagsUnitTest.inc b/wpcs/WordPress/Tests/PHP/DisallowAlternativePHPTagsUnitTest.inc deleted file mode 100644 index 0f3daa6..0000000 --- a/wpcs/WordPress/Tests/PHP/DisallowAlternativePHPTagsUnitTest.inc +++ /dev/null @@ -1,18 +0,0 @@ -
    - -Some content here. -<% echo $var; %> -

    Some text <% echo $var; %> and some more text

    -<%= $var . ' and some more text to make sure the snippet works'; %> -

    Some text <%= $var %> and some more text

    - - - - -
    diff --git a/wpcs/WordPress/Tests/PHP/DisallowAlternativePHPTagsUnitTest.inc.fixed b/wpcs/WordPress/Tests/PHP/DisallowAlternativePHPTagsUnitTest.inc.fixed deleted file mode 100644 index 2b1c151..0000000 --- a/wpcs/WordPress/Tests/PHP/DisallowAlternativePHPTagsUnitTest.inc.fixed +++ /dev/null @@ -1,18 +0,0 @@ -
    - -Some content here. - -

    Some text and some more text

    - -

    Some text and some more text

    - - - - -
    diff --git a/wpcs/WordPress/Tests/PHP/DisallowAlternativePHPTagsUnitTest.php b/wpcs/WordPress/Tests/PHP/DisallowAlternativePHPTagsUnitTest.php deleted file mode 100644 index e661908..0000000 --- a/wpcs/WordPress/Tests/PHP/DisallowAlternativePHPTagsUnitTest.php +++ /dev/null @@ -1,88 +0,0 @@ -asp_tags = (bool) ini_get( 'asp_tags' ); - } - } - - /** - * Skip this test on HHVM. - * - * @return bool Whether to skip this test. - */ - protected function shouldSkipTest() { - return defined( 'HHVM_VERSION' ); - } - - /** - * Returns the lines where errors should occur. - * - * @return array => - */ - public function getErrorList() { - $errors = array( - 8 => 1, - 11 => 1, - 12 => 1, - 15 => 1, - ); - - if ( true === $this->asp_tags ) { - $errors[4] = 1; - $errors[5] = 1; - $errors[6] = 1; - $errors[7] = 1; - } - - return $errors; - } - - /** - * Returns the lines where warnings should occur. - * - * @return array => - */ - public function getWarningList() { - $warnings = array(); - - if ( false === $this->asp_tags ) { - $warnings = array( - 4 => 1, - 5 => 1, - 6 => 1, - 7 => 1, - ); - } - - return $warnings; - } - -} // End class. diff --git a/wpcs/WordPress/Tests/PHP/DiscouragedFunctionsUnitTest.inc b/wpcs/WordPress/Tests/PHP/DiscouragedFunctionsUnitTest.inc deleted file mode 100644 index b86c3f0..0000000 --- a/wpcs/WordPress/Tests/PHP/DiscouragedFunctionsUnitTest.inc +++ /dev/null @@ -1,54 +0,0 @@ - => - */ - public function getErrorList() { - return array(); - - } - - /** - * Returns the lines where warnings should occur. - * - * @return array => - */ - public function getWarningList() { - return array( - 8 => 1, - 9 => 1, - 15 => 1, - 17 => 1, - 19 => 1, - 21 => 1, - 23 => 1, - 25 => 1, - 27 => 1, - 29 => 1, - 31 => 1, - 33 => 1, - 35 => 1, - 37 => 1, - 39 => 1, - 45 => 1, - 47 => 1, - 52 => 1, - 54 => 1, - ); - - } - -} // End class.