Coding Standards: Fix/ignore the WordPress.NamingConventions.ValidFunctionName violations.

See #47632



git-svn-id: https://develop.svn.wordpress.org/trunk@45580 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Gary Pendergast 2019-07-01 08:00:12 +00:00
parent d2c4198623
commit ef5a9dfda6
26 changed files with 50 additions and 43 deletions

View File

@ -1720,7 +1720,7 @@ function copy_dir( $from, $to, $skip_list = array() ) {
* @param bool $allow_relaxed_file_ownership Optional. Whether to allow Group/World writable. Default false.
* @return bool|null True on success, false on failure, null if the filesystem method class file does not exist.
*/
function WP_Filesystem( $args = false, $context = false, $allow_relaxed_file_ownership = false ) {
function WP_Filesystem( $args = false, $context = false, $allow_relaxed_file_ownership = false ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
global $wp_filesystem;
require_once( ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php' );

View File

@ -831,7 +831,7 @@ function iis7_add_rewrite_rule( $filename, $rewrite_rule ) {
* @param DOMDocument $doc
* @param string $filename
*/
function saveDomDocument( $doc, $filename ) {
function saveDomDocument( $doc, $filename ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
$config = $doc->saveXML();
$config = preg_replace( "/([^\r])\n/", "$1\r\n", $config );
$fp = fopen( $filename, 'w' );

View File

@ -2453,7 +2453,7 @@ function get_alloptions_110() {
* @param string $setting Option name.
* @return mixed
*/
function __get_option( $setting ) {
function __get_option( $setting ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore
global $wpdb;
if ( $setting == 'home' && defined( 'WP_HOME' ) ) {
@ -2522,7 +2522,7 @@ function deslash( $content ) {
* Default true.
* @return array Strings containing the results of the various update queries.
*/
function dbDelta( $queries = '', $execute = true ) {
function dbDelta( $queries = '', $execute = true ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
global $wpdb;
if ( in_array( $queries, array( '', 'all', 'blog', 'global', 'ms_global' ), true ) ) {

View File

@ -31,7 +31,7 @@ global $opml;
* @param string $tagName XML element name.
* @param array $attrs XML element attributes.
*/
function startElement( $parser, $tagName, $attrs ) {
function startElement( $parser, $tagName, $attrs ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
global $names, $urls, $targets, $descriptions, $feeds;
if ( 'OUTLINE' === $tagName ) {
@ -68,7 +68,7 @@ function startElement( $parser, $tagName, $attrs ) {
* @param mixed $parser XML Parser resource.
* @param string $tagName XML tag name.
*/
function endElement( $parser, $tagName ) {
function endElement( $parser, $tagName ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
// Nothing to do.
}

View File

@ -563,6 +563,6 @@ function is_multi_author() {
* @since 3.2.0
* @access private
*/
function __clear_multi_author_cache() {
function __clear_multi_author_cache() { //phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore
delete_transient( 'is_multi_author' );
}

View File

@ -105,7 +105,7 @@ function get_the_category( $id = false ) {
* @param int $cat_ID Category ID.
* @return string|WP_Error Category name on success, WP_Error on failure.
*/
function get_the_category_by_ID( $cat_ID ) {
function get_the_category_by_ID( $cat_ID ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
$cat_ID = (int) $cat_ID;
$category = get_term( $cat_ID );

View File

@ -197,7 +197,7 @@ function get_category_by_slug( $slug ) {
* @param string $cat_name Category name.
* @return int 0, if failure and ID of category on success.
*/
function get_cat_ID( $cat_name ) {
function get_cat_ID( $cat_name ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
$cat = get_term_by( 'name', $cat_name, 'category' );
if ( $cat ) {
return $cat->term_id;

View File

@ -647,7 +647,7 @@ class WP_Http {
* @param string $strResponse The full response string
* @return array Array with 'headers' and 'body' keys.
*/
public static function processResponse( $strResponse ) {
public static function processResponse( $strResponse ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid
$res = explode( "\r\n\r\n", $strResponse, 2 );
return array(
@ -669,7 +669,7 @@ class WP_Http {
* @return array Processed string headers. If duplicate headers are encountered,
* Then a numbered array is returned as the value of that header-key.
*/
public static function processHeaders( $headers, $url = '' ) {
public static function processHeaders( $headers, $url = '' ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid
// Split headers, one per array element.
if ( is_string( $headers ) ) {
// Tolerate line terminator: CRLF = LF (RFC 2616 19.3).
@ -752,7 +752,7 @@ class WP_Http {
*
* @param array $r Full array of args passed into ::request()
*/
public static function buildCookieHeader( &$r ) {
public static function buildCookieHeader( &$r ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid
if ( ! empty( $r['cookies'] ) ) {
// Upgrade any name => value cookie pairs to WP_HTTP_Cookie instances.
foreach ( $r['cookies'] as $name => $value ) {
@ -788,7 +788,7 @@ class WP_Http {
* @param string $body Body content
* @return string Chunked decoded body on success or raw body on failure.
*/
public static function chunkTransferDecode( $body ) {
public static function chunkTransferDecode( $body ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid
// The body is not chunked encoded or is malformed.
if ( ! preg_match( '/^([0-9a-f]+)[^\r\n]*\r\n/i', trim( $body ) ) ) {
return $body;

View File

@ -211,7 +211,7 @@ class WP_Http_Cookie {
*
* @return string Header encoded cookie name and value.
*/
public function getHeaderValue() {
public function getHeaderValue() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid
if ( ! isset( $this->name ) || ! isset( $this->value ) ) {
return '';
}
@ -234,7 +234,7 @@ class WP_Http_Cookie {
*
* @return string
*/
public function getFullHeader() {
public function getFullHeader() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid
return 'Cookie: ' . $this->getHeaderValue();
}

View File

@ -147,7 +147,7 @@ class WP_HTTP_Response {
*
* @return mixed Any JSON-serializable value.
*/
public function jsonSerialize() {
public function jsonSerialize() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid
return $this->get_data();
}
}

View File

@ -262,7 +262,7 @@ function comment_author_link( $comment_ID = 0 ) {
* Default current comment.
* @return string Comment author's IP address.
*/
function get_comment_author_IP( $comment_ID = 0 ) {
function get_comment_author_IP( $comment_ID = 0 ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
$comment = get_comment( $comment_ID );
/**
@ -287,7 +287,7 @@ function get_comment_author_IP( $comment_ID = 0 ) {
* @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's IP address.
* Default current comment.
*/
function comment_author_IP( $comment_ID = 0 ) {
function comment_author_IP( $comment_ID = 0 ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
echo esc_html( get_comment_author_IP( $comment_ID ) );
}
@ -651,7 +651,7 @@ function comment_excerpt( $comment_ID = 0 ) {
*
* @return int The comment ID.
*/
function get_comment_ID() {
function get_comment_ID() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
$comment = get_comment();
/**
@ -671,7 +671,7 @@ function get_comment_ID() {
*
* @since 0.71
*/
function comment_ID() {
function comment_ID() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
echo get_comment_ID();
}

View File

@ -434,6 +434,7 @@ if ( ! interface_exists( 'JsonSerializable' ) ) {
* @since 4.4.0
*/
interface JsonSerializable {
// phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid
public function jsonSerialize();
}
}

View File

@ -2427,7 +2427,7 @@ function convert_invalid_entities( $content ) {
* @param bool $force If true, forces balancing, ignoring the value of the option. Default false.
* @return string Balanced text
*/
function balanceTags( $text, $force = false ) {
function balanceTags( $text, $force = false ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
if ( $force || get_option( 'use_balanceTags' ) == 1 ) {
return force_balance_tags( $text );
} else {

View File

@ -5631,7 +5631,7 @@ function get_file_data( $file, $default_headers, $context = '' ) {
*
* @return true True.
*/
function __return_true() {
function __return_true() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore
return true;
}
@ -5646,7 +5646,7 @@ function __return_true() {
*
* @return false False.
*/
function __return_false() {
function __return_false() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore
return false;
}
@ -5659,7 +5659,7 @@ function __return_false() {
*
* @return int 0.
*/
function __return_zero() {
function __return_zero() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore
return 0;
}
@ -5672,7 +5672,7 @@ function __return_zero() {
*
* @return array Empty array.
*/
function __return_empty_array() {
function __return_empty_array() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore
return array();
}
@ -5685,7 +5685,7 @@ function __return_empty_array() {
*
* @return null Null value.
*/
function __return_null() {
function __return_null() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore
return null;
}
@ -5700,7 +5700,7 @@ function __return_null() {
*
* @return string Empty string.
*/
function __return_empty_string() {
function __return_empty_string() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore
return '';
}

View File

@ -4548,7 +4548,7 @@ function readonly( $readonly, $current = true, $echo = true ) {
* @param string $type The type of checked|selected|disabled|readonly we are doing
* @return string html attribute or empty string
*/
function __checked_selected_helper( $helper, $current, $echo, $type ) {
function __checked_selected_helper( $helper, $current, $echo, $type ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore
if ( (string) $helper === (string) $current ) {
$result = " $type='$type'";
} else {

View File

@ -26,7 +26,7 @@ function wp_get_server_protocol() {
* @since 2.1.0
* @access private
*/
function wp_unregister_GLOBALS() {
function wp_unregister_GLOBALS() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
if ( ! ini_get( 'register_globals' ) ) {
return;
}

View File

@ -2252,7 +2252,7 @@ function force_ssl_content( $force = '' ) {
* @param string $url URL
* @return string URL with https as the scheme
*/
function filter_SSL( $url ) {
function filter_SSL( $url ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
if ( ! is_string( $url ) ) {
return get_bloginfo( 'url' ); // Return home blog url with proper scheme
}

View File

@ -34,7 +34,7 @@ if ( ! class_exists( 'POMO_Reader', false ) ) :
*
* @param string $endian Set the endianness of the file. Accepts 'big', or 'little'.
*/
function setEndian( $endian ) {
function setEndian( $endian ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid
$this->endian = $endian;
}

View File

@ -13,7 +13,7 @@
*
* @since 0.71
*/
function the_ID() {
function the_ID() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
echo get_the_ID();
}
@ -24,7 +24,7 @@ function the_ID() {
*
* @return int|false The ID of the current item in the WordPress Loop. False if $post is not set.
*/
function get_the_ID() {
function get_the_ID() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
$post = get_post();
return ! empty( $post ) ? $post->ID : false;
}

View File

@ -96,7 +96,7 @@ exit;
* @param string $io Whether input or output
* @param string $msg Information describing logging reason.
*/
function logIO( $io, $msg ) {
function logIO( $io, $msg ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
_deprecated_function( __FUNCTION__, '3.4.0', 'error_log()' );
if ( ! empty( $GLOBALS['xmlrpc_logging'] ) ) {
error_log( $io . ' - ' . $msg );

View File

@ -37,6 +37,7 @@ class Basic_Object {
return call_user_func_array( array( $this, $name ), $arguments );
}
// phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid
private function callMe() {
return 'maybe';
}

View File

@ -21,7 +21,7 @@ function tests_get_phpunit_version() {
/**
* Resets various `$_SERVER` variables that can get altered during tests.
*/
function tests_reset__SERVER() {
function tests_reset__SERVER() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
$_SERVER['HTTP_HOST'] = WP_TESTS_DOMAIN;
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
$_SERVER['REQUEST_METHOD'] = 'GET';

View File

@ -761,6 +761,7 @@ function wp_cache_add_non_persistent_groups( $groups ) {
$wp_object_cache->add_non_persistent_groups( $groups );
}
// phpcs:disable WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid
class WP_Object_Cache {
/**
@ -2160,3 +2161,4 @@ class WP_Object_Cache {
$this->blog_prefix = ( is_multisite() ? $blog_id : $table_prefix ) . ':';
}
}
// phpcs:enable

View File

@ -17,6 +17,7 @@ if ( class_exists( 'PHPUnit\Runner\Version' ) && version_compare( PHPUnit\Runner
class PHPUnit_Util_Test {
// phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid
public static function getTickets( $className, $methodName ) {
$annotations = PHPUnit\Util\Test::parseTestMethodAnnotations( $className, $methodName );

View File

@ -13,7 +13,7 @@ class TracTickets {
*
* @return bool|null true if the ticket is resolved, false if not resolved, null on error
*/
public static function isTracTicketClosed( $trac_url, $ticket_id ) {
public static function isTracTicketClosed( $trac_url, $ticket_id ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid
if ( ! extension_loaded( 'openssl' ) ) {
$trac_url = preg_replace( '/^https:/', 'http:', $trac_url );
}
@ -44,12 +44,14 @@ class TracTickets {
return ! in_array( $ticket_id, self::$trac_ticket_cache[ $trac_url ] );
}
// phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid
public static function usingLocalCache() {
echo PHP_EOL . "\x1b[0m\x1b[30;43m\x1b[2K";
echo 'INFO: Trac was inaccessible, so a local ticket status cache was used.' . PHP_EOL;
echo "\x1b[0m\x1b[2K";
}
// phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid
public static function forcingKnownBugs() {
echo PHP_EOL . "\x1b[0m\x1b[37;41m\x1b[2K";
echo "ERROR: Trac was inaccessible, so known bugs weren't able to be skipped." . PHP_EOL;

View File

@ -182,7 +182,7 @@ class MockAction {
// convert valid xml to an array tree structure
// kinda lame but it works with a default php 4 installation
class testXMLParser {
class TestXMLParser {
var $xml;
var $data = array();
@ -193,8 +193,8 @@ class testXMLParser {
$this->xml = xml_parser_create();
xml_set_object( $this->xml, $this );
xml_parser_set_option( $this->xml, XML_OPTION_CASE_FOLDING, 0 );
xml_set_element_handler( $this->xml, array( $this, 'startHandler' ), array( $this, 'endHandler' ) );
xml_set_character_data_handler( $this->xml, array( $this, 'dataHandler' ) );
xml_set_element_handler( $this->xml, array( $this, 'start_handler' ), array( $this, 'end_handler' ) );
xml_set_character_data_handler( $this->xml, array( $this, 'data_handler' ) );
$this->parse( $in );
}
@ -214,19 +214,19 @@ class testXMLParser {
return true;
}
function startHandler( $parser, $name, $attributes ) {
function start_handler( $parser, $name, $attributes ) {
$data['name'] = $name;
if ( $attributes ) {
$data['attributes'] = $attributes; }
$this->data[] = $data;
}
function dataHandler( $parser, $data ) {
function data_handler( $parser, $data ) {
$index = count( $this->data ) - 1;
@$this->data[ $index ]['content'] .= $data;
}
function endHandler( $parser, $name ) {
function end_handler( $parser, $name ) {
if ( count( $this->data ) > 1 ) {
$data = array_pop( $this->data );
$index = count( $this->data ) - 1;
@ -236,7 +236,7 @@ class testXMLParser {
}
function xml_to_array( $in ) {
$p = new testXMLParser( $in );
$p = new TestXMLParser( $in );
return $p->data;
}