From 19a3aacc9470a8c11e4410772a927ac703c7c9fd Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Fri, 29 May 2015 15:43:29 +0000 Subject: [PATCH] Add `@static*` annotations where they are missing. Initialize all static vars that are not, most to `null`. See #32444. Built from https://develop.svn.wordpress.org/trunk@32650 git-svn-id: http://core.svn.wordpress.org/trunk@32620 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../includes/class-wp-filesystem-ftpext.php | 2 +- wp-admin/includes/class-wp-list-table.php | 2 + .../class-wp-ms-themes-list-table.php | 2 +- .../includes/class-wp-plugins-list-table.php | 2 +- wp-admin/includes/class-wp-upgrader.php | 4 ++ wp-admin/includes/deprecated.php | 2 + wp-admin/includes/media.php | 2 + wp-admin/includes/screen.php | 18 ++++++++- wp-admin/includes/template.php | 18 ++++++++- wp-admin/includes/theme.php | 4 +- wp-admin/includes/widgets.php | 2 + wp-includes/capabilities.php | 7 ++++ wp-includes/class-http.php | 40 ++++++++++++++++--- wp-includes/class-oembed.php | 12 ++++-- wp-includes/class-wp-customize-control.php | 2 + wp-includes/class-wp-customize-panel.php | 2 + wp-includes/class-wp-customize-section.php | 2 + wp-includes/class-wp-customize-widgets.php | 3 +- wp-includes/class-wp-image-editor-gd.php | 8 +++- wp-includes/class-wp-image-editor-imagick.php | 4 ++ wp-includes/class-wp-image-editor.php | 8 ++++ wp-includes/class-wp-theme.php | 2 +- wp-includes/comment.php | 2 + wp-includes/compat.php | 2 + wp-includes/default-widgets.php | 6 ++- wp-includes/formatting.php | 29 ++++++++------ wp-includes/functions.php | 4 +- wp-includes/http.php | 6 +-- wp-includes/ms-functions.php | 4 +- wp-includes/plugin.php | 2 +- wp-includes/pomo/po.php | 1 + wp-includes/revision.php | 6 +-- wp-includes/rewrite.php | 2 +- wp-includes/theme.php | 5 ++- wp-includes/vars.php | 7 +++- wp-includes/version.php | 2 +- 36 files changed, 173 insertions(+), 53 deletions(-) diff --git a/wp-admin/includes/class-wp-filesystem-ftpext.php b/wp-admin/includes/class-wp-filesystem-ftpext.php index f9f46e7c81..1f02cef890 100644 --- a/wp-admin/includes/class-wp-filesystem-ftpext.php +++ b/wp-admin/includes/class-wp-filesystem-ftpext.php @@ -379,7 +379,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base { * @return string */ public function parselisting($line) { - static $is_windows; + static $is_windows = null; if ( is_null($is_windows) ) $is_windows = stripos( ftp_systype($this->link), 'win') !== false; diff --git a/wp-admin/includes/class-wp-list-table.php b/wp-admin/includes/class-wp-list-table.php index 86b964b6be..fdeeb3e8fd 100644 --- a/wp-admin/includes/class-wp-list-table.php +++ b/wp-admin/includes/class-wp-list-table.php @@ -900,6 +900,8 @@ class WP_List_Table { * @since 3.1.0 * @access public * + * @staticvar int $cb_counter + * * @param bool $with_id Whether to set the id attribute or not */ public function print_column_headers( $with_id = true ) { diff --git a/wp-admin/includes/class-wp-ms-themes-list-table.php b/wp-admin/includes/class-wp-ms-themes-list-table.php index e78270ba2b..bd53c96cd9 100644 --- a/wp-admin/includes/class-wp-ms-themes-list-table.php +++ b/wp-admin/includes/class-wp-ms-themes-list-table.php @@ -162,7 +162,7 @@ class WP_MS_Themes_List_Table extends WP_List_Table { * @return bool */ public function _search_callback( $theme ) { - static $term; + static $term = null; if ( is_null( $term ) ) $term = wp_unslash( $_REQUEST['s'] ); diff --git a/wp-admin/includes/class-wp-plugins-list-table.php b/wp-admin/includes/class-wp-plugins-list-table.php index 1b3c6d3449..d684f3562e 100644 --- a/wp-admin/includes/class-wp-plugins-list-table.php +++ b/wp-admin/includes/class-wp-plugins-list-table.php @@ -219,7 +219,7 @@ class WP_Plugins_List_Table extends WP_List_Table { * @return boolean */ public function _search_callback( $plugin ) { - static $term; + static $term = null; if ( is_null( $term ) ) $term = wp_unslash( $_REQUEST['s'] ); diff --git a/wp-admin/includes/class-wp-upgrader.php b/wp-admin/includes/class-wp-upgrader.php index 86227e3792..577cbce67d 100644 --- a/wp-admin/includes/class-wp-upgrader.php +++ b/wp-admin/includes/class-wp-upgrader.php @@ -1658,6 +1658,8 @@ class Language_Pack_Upgrader extends WP_Upgrader { * Hooked to the {@see 'upgrader_process_complete'} action by default. * * @since 3.7.0 + * + * @static */ public static function async_upgrade( $upgrader = false ) { // Avoid recursion. @@ -2136,6 +2138,8 @@ class Core_Upgrader extends WP_Upgrader { * * @since 3.7.0 * + * @static + * * @param string $offered_ver The offered version, of the format x.y.z. * @return bool True if we should update to the offered version, otherwise false. */ diff --git a/wp-admin/includes/deprecated.php b/wp-admin/includes/deprecated.php index 59140b7304..30df82ab1b 100644 --- a/wp-admin/includes/deprecated.php +++ b/wp-admin/includes/deprecated.php @@ -732,6 +732,8 @@ function wp_dashboard_quick_press_output() { * @deprecated 3.3.0 * @deprecated Use wp_editor() * @see wp_editor() + * + * @staticvar int $num */ function wp_tiny_mce( $teeny = false, $settings = false ) { _deprecated_function( __FUNCTION__, '3.3', 'wp_editor()' ); diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index 761918cc03..17e1bf5ce3 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -535,6 +535,8 @@ document.body.className = document.body.className.replace('no-js', 'js'); * * @global int $post_ID * + * @staticvar int $instance + * * @param string $editor_id */ function media_buttons($editor_id = 'content') { diff --git a/wp-admin/includes/screen.php b/wp-admin/includes/screen.php index a4d5ac6155..2d836e9358 100644 --- a/wp-admin/includes/screen.php +++ b/wp-admin/includes/screen.php @@ -11,6 +11,8 @@ * * @since 2.7.0 * + * @staticvar array $column_headers + * * @param string|WP_Screen $screen The screen you want the headers for * @return array Containing the headers in the format id => UI String */ @@ -327,6 +329,11 @@ final class WP_Screen { /** * Stores old string-based help. + * + * @static + * @access private + * + * @var array */ private static $_old_compat_help = array(); @@ -343,8 +350,11 @@ final class WP_Screen { * The screen object registry. * * @since 3.3.0 - * @var array + * + * @static * @access private + * + * @var array */ private static $_registry = array(); @@ -372,6 +382,8 @@ final class WP_Screen { * @since 3.3.0 * @access public * + * @static + * * @global string $hook_suffix * * @param string|WP_Screen $hook_name Optional. The hook name (also known as the hook suffix) used to determine the screen. @@ -588,6 +600,8 @@ final class WP_Screen { * * @since 3.3.0 * + * @static + * * @param WP_Screen $screen A screen object. * @param string $help Help text. */ @@ -974,7 +988,7 @@ final class WP_Screen { /** * * @global array $wp_meta_boxes - * + * * @return bool */ public function show_screen_options() { diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index 03ac33944d..84ee164edb 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -605,17 +605,19 @@ function list_meta( $meta ) { * * @since 2.5.0 * + * @staticvar string $update_nonce + * * @param array $entry * @param int $count * @return string */ function _list_meta_row( $entry, &$count ) { - static $update_nonce = false; + static $update_nonce = ''; if ( is_protected_meta( $entry['meta_key'], 'post' ) ) return ''; - if ( !$update_nonce ) + if ( ! $update_nonce ) $update_nonce = wp_create_nonce( 'add-meta' ); $r = ''; @@ -1991,6 +1993,8 @@ final class WP_Internal_Pointers { * Individual pointers (e.g. wp390_widgets) can be disabled using the following: * remove_action( 'admin_print_footer_scripts', array( 'WP_Internal_Pointers', 'pointer_wp390_widgets' ) ); * + * @static + * * @param string $hook_suffix The current admin page. */ public static function enqueue_scripts( $hook_suffix ) { @@ -2047,6 +2051,8 @@ final class WP_Internal_Pointers { * * @since 3.3.0 * + * @static + * * @param string $pointer_id The pointer ID. * @param string $selector The HTML elements, on which the pointer should be attached. * @param array $args Arguments to be passed to the pointer JS (see wp-pointer.js). @@ -2094,6 +2100,9 @@ final class WP_Internal_Pointers { public static function pointer_wp350_media() {} public static function pointer_wp360_revisions() {} + /** + * @static + */ public static function pointer_wp360_locks() { if ( ! is_multi_author() ) { return; @@ -2108,6 +2117,9 @@ final class WP_Internal_Pointers { ) ); } + /** + * @static + */ public static function pointer_wp390_widgets() { if ( ! current_theme_supports( 'widgets' ) ) { return; @@ -2165,6 +2177,8 @@ final class WP_Internal_Pointers { * * @since 3.3.0 * + * @static + * * @param int $user_id User ID. */ public static function dismiss_pointers_for_new_users( $user_id ) { diff --git a/wp-admin/includes/theme.php b/wp-admin/includes/theme.php index 18d8687819..fe35006dcc 100644 --- a/wp-admin/includes/theme.php +++ b/wp-admin/includes/theme.php @@ -136,11 +136,13 @@ function theme_update_available( $theme ) { * * @since 3.8.0 * + * @staticvar object $themes_update + * * @param WP_Theme $theme WP_Theme object. * @return false|string HTML for the update link, or false if invalid info was passed. */ function get_theme_update_available( $theme ) { - static $themes_update; + static $themes_update = null; if ( !current_user_can('update_themes' ) ) return false; diff --git a/wp-admin/includes/widgets.php b/wp-admin/includes/widgets.php index b01ccf5cf6..6b0a498ad7 100644 --- a/wp-admin/includes/widgets.php +++ b/wp-admin/includes/widgets.php @@ -104,6 +104,8 @@ function wp_list_widget_controls( $sidebar, $sidebar_name = '' ) { * * @global array $wp_registered_widgets * + * @staticvar int $i + * * @param array $params * @return array */ diff --git a/wp-includes/capabilities.php b/wp-includes/capabilities.php index 5d8b628111..c800ea4d0a 100644 --- a/wp-includes/capabilities.php +++ b/wp-includes/capabilities.php @@ -489,6 +489,11 @@ class WP_User { */ var $filter = null; + /** + * @static + * @access private + * @var array + */ private static $back_compat_keys; /** @@ -562,6 +567,8 @@ class WP_User { * * @since 3.3.0 * + * @static + * * @global wpdb $wpdb * * @param string $field The field to query against: 'id', 'slug', 'email' or 'login' diff --git a/wp-includes/class-http.php b/wp-includes/class-http.php index 622d2c105e..c014004c05 100644 --- a/wp-includes/class-http.php +++ b/wp-includes/class-http.php @@ -341,6 +341,8 @@ class WP_Http { * The order for requests is cURL, and then PHP Streams. * * @since 3.2.0 + * + * @static * @access private * * @param string $url URL to Request @@ -626,6 +628,9 @@ class WP_Http { * @link https://core.trac.wordpress.org/ticket/8927 Allow preventing external requests. * @link https://core.trac.wordpress.org/ticket/14636 Allow wildcard domains in WP_ACCESSIBLE_HOSTS * + * @staticvar array|null $accessible_hosts + * @staticvar array $wildcard_regex + * * @param string $uri URI of url. * @return bool True to block, false to allow. */ @@ -656,9 +661,9 @@ class WP_Http { if ( !defined('WP_ACCESSIBLE_HOSTS') ) return true; - static $accessible_hosts; - static $wildcard_regex = false; - if ( null == $accessible_hosts ) { + static $accessible_hosts = null; + static $wildcard_regex = array(); + if ( null === $accessible_hosts ) { $accessible_hosts = preg_split('|,\s*|', WP_ACCESSIBLE_HOSTS); if ( false !== strpos(WP_ACCESSIBLE_HOSTS, '*') ) { @@ -687,6 +692,8 @@ class WP_Http { * when URL parsing failed. * * @since 4.1.0 + * + * @static * @access protected * * @param string $url The URL to parse. @@ -725,7 +732,9 @@ class WP_Http { * * @since 3.4.0 * + * @static * @access public + * * @param string $maybe_relative_path The URL which might be relative * @param string $url The URL which $maybe_relative_path is relative to * @return string An Absolute URL, in a failure condition where the URL cannot be parsed, the relative URL will be returned. @@ -796,6 +805,8 @@ class WP_Http { * * @since 3.7.0 * + * @static + * * @param string $url The URL which was requested. * @param array $args The Arguments which were used to make the request. * @param array $response The Response of the HTTP request. @@ -1798,6 +1809,9 @@ class WP_HTTP_Proxy { * * @since 2.8.0 * + * @staticvar array|null $bypass_hosts + * @staticvar array $wildcard_regex + * * @param string $uri URI to check. * @return bool True, to send through the proxy and false if, the proxy should not be used. */ @@ -1837,9 +1851,9 @@ class WP_HTTP_Proxy { if ( !defined('WP_PROXY_BYPASS_HOSTS') ) return true; - static $bypass_hosts; - static $wildcard_regex = false; - if ( null == $bypass_hosts ) { + static $bypass_hosts = null; + static $wildcard_regex = array(); + if ( null === $bypass_hosts ) { $bypass_hosts = preg_split('|,\s*|', WP_PROXY_BYPASS_HOSTS); if ( false !== strpos(WP_PROXY_BYPASS_HOSTS, '*') ) { @@ -2087,6 +2101,8 @@ class WP_Http_Encoding { * * @since 2.8.0 * + * @static + * * @param string $raw String to compress. * @param int $level Optional, default is 9. Compression level, 9 is highest. * @param string $supports Optional, not used. When implemented it will choose the right compression based on what the server supports. @@ -2106,6 +2122,8 @@ class WP_Http_Encoding { * * @since 2.8.0 * + * @static + * * @param string $compressed String to decompress. * @param int $length The optional length of the compressed data. * @return string|bool False on failure. @@ -2151,6 +2169,8 @@ class WP_Http_Encoding { * @link http://au2.php.net/manual/en/function.gzinflate.php#70875 * @link http://au2.php.net/manual/en/function.gzinflate.php#77336 * + * @static + * * @param string $gzData String to decompress. * @return string|bool False on failure. */ @@ -2190,6 +2210,8 @@ class WP_Http_Encoding { * * @since 2.8.0 * + * @static + * * @param string $url * @param array $args * @return string Types of encoding to accept. @@ -2236,6 +2258,8 @@ class WP_Http_Encoding { * * @since 2.8.0 * + * @static + * * @return string Content-Encoding string to send in the header. */ public static function content_encoding() { @@ -2247,6 +2271,8 @@ class WP_Http_Encoding { * * @since 2.8.0 * + * @static + * * @param array|string $headers All of the available headers. * @return bool */ @@ -2270,6 +2296,8 @@ class WP_Http_Encoding { * * @since 2.8.0 * + * @static + * * @return bool */ public static function is_available() { diff --git a/wp-includes/class-oembed.php b/wp-includes/class-oembed.php index f3d6e08248..706660c134 100644 --- a/wp-includes/class-oembed.php +++ b/wp-includes/class-oembed.php @@ -19,6 +19,10 @@ */ class WP_oEmbed { public $providers = array(); + /** + * @static + * @var array + */ public static $early_providers = array(); private $compat_methods = array( '_fetch_with_format', '_parse_json', '_parse_xml', '_parse_body' ); @@ -611,15 +615,15 @@ class WP_oEmbed { * @since 2.9.0 * @access private * - * @see WP_oEmbed + * @staticvar WP_oEmbed $wp_oembed * * @return WP_oEmbed object. */ function _wp_oembed_get_object() { - static $wp_oembed; + static $wp_oembed = null; - if ( is_null($wp_oembed) ) + if ( is_null( $wp_oembed ) ) { $wp_oembed = new WP_oEmbed(); - + } return $wp_oembed; } diff --git a/wp-includes/class-wp-customize-control.php b/wp-includes/class-wp-customize-control.php index 08a53a0b3f..d280596a2e 100644 --- a/wp-includes/class-wp-customize-control.php +++ b/wp-includes/class-wp-customize-control.php @@ -20,6 +20,8 @@ class WP_Customize_Control { * Used when sorting two instances whose priorities are equal. * * @since 4.1.0 + * + * @static * @access protected * @var int */ diff --git a/wp-includes/class-wp-customize-panel.php b/wp-includes/class-wp-customize-panel.php index 96e740dc12..f977f06867 100644 --- a/wp-includes/class-wp-customize-panel.php +++ b/wp-includes/class-wp-customize-panel.php @@ -24,6 +24,8 @@ class WP_Customize_Panel { * Used when sorting two instances whose priorities are equal. * * @since 4.1.0 + * + * @static * @access protected * @var int */ diff --git a/wp-includes/class-wp-customize-section.php b/wp-includes/class-wp-customize-section.php index 5364da7897..f41767c88d 100644 --- a/wp-includes/class-wp-customize-section.php +++ b/wp-includes/class-wp-customize-section.php @@ -24,6 +24,8 @@ class WP_Customize_Section { * Used when sorting two instances whose priorities are equal. * * @since 4.1.0 + * + * @static * @access protected * @var int */ diff --git a/wp-includes/class-wp-customize-widgets.php b/wp-includes/class-wp-customize-widgets.php index d4d30b0ad1..e784c66a10 100644 --- a/wp-includes/class-wp-customize-widgets.php +++ b/wp-includes/class-wp-customize-widgets.php @@ -108,6 +108,8 @@ final class WP_Customize_Widgets { * @since 4.2.0 * @access protected * + * @staticvar array $cache + * * @param $setting_id Setting ID. * @return string|void Setting type. */ @@ -876,7 +878,6 @@ final class WP_Customize_Widgets { * Naturally order available widgets by name. * * @since 3.9.0 - * @static * @access protected * * @param array $widget_a The first widget to compare. diff --git a/wp-includes/class-wp-image-editor-gd.php b/wp-includes/class-wp-image-editor-gd.php index 9f526efe4c..3498bb2827 100644 --- a/wp-includes/class-wp-image-editor-gd.php +++ b/wp-includes/class-wp-image-editor-gd.php @@ -34,10 +34,12 @@ class WP_Image_Editor_GD extends WP_Image_Editor { * Checks to see if current environment supports GD. * * @since 3.5.0 + * + * @static * @access public * * @param array $args - * @return boolean + * @return bool */ public static function test( $args = array() ) { if ( ! extension_loaded('gd') || ! function_exists('gd_info') ) @@ -58,10 +60,12 @@ class WP_Image_Editor_GD extends WP_Image_Editor { * Checks to see if editor supports the mime-type specified. * * @since 3.5.0 + * + * @static * @access public * * @param string $mime_type - * @return boolean + * @return bool */ public static function supports_mime_type( $mime_type ) { $image_types = imagetypes(); diff --git a/wp-includes/class-wp-image-editor-imagick.php b/wp-includes/class-wp-image-editor-imagick.php index 82720c3977..51be2b10b5 100644 --- a/wp-includes/class-wp-image-editor-imagick.php +++ b/wp-includes/class-wp-image-editor-imagick.php @@ -38,6 +38,8 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor { * method can be called statically. * * @since 3.5.0 + * + * @static * @access public * * @param array $args @@ -86,6 +88,8 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor { * Checks to see if editor supports the mime-type specified. * * @since 3.5.0 + * + * @static * @access public * * @param string $mime_type diff --git a/wp-includes/class-wp-image-editor.php b/wp-includes/class-wp-image-editor.php index bfc43793df..9fc619e03e 100644 --- a/wp-includes/class-wp-image-editor.php +++ b/wp-includes/class-wp-image-editor.php @@ -31,6 +31,8 @@ abstract class WP_Image_Editor { * Must be overridden in a sub-class. * * @since 3.5.0 + * + * @static * @access public * @abstract * @@ -46,6 +48,8 @@ abstract class WP_Image_Editor { * Must be overridden in a sub-class. * * @since 3.5.0 + * + * @static * @access public * @abstract * @@ -442,6 +446,8 @@ abstract class WP_Image_Editor { * as mapped from wp_get_mime_types() * * @since 3.5.0 + * + * @static * @access protected * * @param string $extension @@ -468,6 +474,8 @@ abstract class WP_Image_Editor { * as mapped from wp_get_mime_types() * * @since 3.5.0 + * + * @static * @access protected * * @param string $mime_type diff --git a/wp-includes/class-wp-theme.php b/wp-includes/class-wp-theme.php index 6c824d875e..ad70a4bf9e 100644 --- a/wp-includes/class-wp-theme.php +++ b/wp-includes/class-wp-theme.php @@ -687,7 +687,7 @@ final class WP_Theme implements ArrayAccess { * @since 3.4.0 * @access private * - * @stativar string $comma + * @staticvar string $comma * * @param string $header Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status, Tags. * @param string $value Value to mark up. diff --git a/wp-includes/comment.php b/wp-includes/comment.php index 9e0f7db79c..a58bbfe20b 100644 --- a/wp-includes/comment.php +++ b/wp-includes/comment.php @@ -2558,6 +2558,8 @@ function wp_defer_comment_counting($defer=null) { * @since 2.1.0 * @see wp_update_comment_count_now() For what could cause a false return value * + * @staticvar array $_deferred + * * @param int $post_id Post ID * @param bool $do_deferred Whether to process previously deferred post comment counts * @return bool|void True on success, false on failure diff --git a/wp-includes/compat.php b/wp-includes/compat.php index 4317eb689b..ffae3b167a 100644 --- a/wp-includes/compat.php +++ b/wp-includes/compat.php @@ -20,6 +20,8 @@ if ( !function_exists('_') ) { * @since 4.2.2 * @access private * + * @staticvar string $utf8_pcre + * * @param bool $set - Used for testing only * null : default - get PCRE/u capability * false : Used for testing - return false for future calls to this function diff --git a/wp-includes/default-widgets.php b/wp-includes/default-widgets.php index 55a7782d0f..a3f473126e 100644 --- a/wp-includes/default-widgets.php +++ b/wp-includes/default-widgets.php @@ -644,10 +644,14 @@ class WP_Widget_Categories extends WP_Widget { } /** + * @staticvar bool $first_dropdown + * * @param array $args * @param array $instance */ public function widget( $args, $instance ) { + static $first_dropdown = true; + /** This filter is documented in wp-includes/default-widgets.php */ $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title'], $instance, $this->id_base ); @@ -667,8 +671,6 @@ class WP_Widget_Categories extends WP_Widget { ); if ( $d ) { - static $first_dropdown = true; - $dropdown_id = ( $first_dropdown ) ? 'cat' : "{$this->id_base}-dropdown-{$this->number}"; $first_dropdown = false; diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index 34ef7c3e98..7fb0fe2245 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -38,8 +38,13 @@ */ function wptexturize( $text, $reset = false ) { global $wp_cockneyreplace, $shortcode_tags; - static $static_characters, $static_replacements, $dynamic_characters, $dynamic_replacements, - $default_no_texturize_tags, $default_no_texturize_shortcodes, $run_texturize = true; + static $static_characters = null, + $static_replacements = null, + $dynamic_characters = null, + $dynamic_replacements = null, + $default_no_texturize_tags = null, + $default_no_texturize_shortcodes = null, + $run_texturize = true; // If there's nothing to do, just stop. if ( empty( $text ) || false === $run_texturize ) { @@ -630,7 +635,7 @@ function seems_utf8( $str ) { * @since 1.2.2 * @access private * - * @staticvar string|false $_charset + * @staticvar string $_charset * * @param string $string The text which is to be encoded. * @param int $quote_style Optional. Converts double quotes if set to ENT_COMPAT, both single and double if set to ENT_QUOTES or none if set to ENT_NOQUOTES. Also compatible with old values; converting single quotes if set to 'single', double if set to 'double' or both if otherwise set. Default is ENT_NOQUOTES. @@ -656,7 +661,7 @@ function _wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = fals // Store the site charset as a static to avoid multiple calls to wp_load_alloptions() if ( ! $charset ) { - static $_charset; + static $_charset = null; if ( ! isset( $_charset ) ) { $alloptions = wp_load_alloptions(); $_charset = isset( $alloptions['blog_charset'] ) ? $alloptions['blog_charset'] : ''; @@ -790,17 +795,17 @@ function wp_check_invalid_utf8( $string, $strip = false ) { } // Store the site charset as a static to avoid multiple calls to get_option() - static $is_utf8; - if ( !isset( $is_utf8 ) ) { + static $is_utf8 = null; + if ( ! isset( $is_utf8 ) ) { $is_utf8 = in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ); } - if ( !$is_utf8 ) { + if ( ! $is_utf8 ) { return $string; } // Check for support for utf8 in the installed PCRE library once and store the result in a static - static $utf8_pcre; - if ( !isset( $utf8_pcre ) ) { + static $utf8_pcre = null; + if ( ! isset( $utf8_pcre ) ) { $utf8_pcre = @preg_match( '/^./u', 'a' ); } // We can't demand utf8 in the PCRE installation, so just return the string in those cases @@ -3959,13 +3964,13 @@ function capital_P_dangit( $text ) { return str_replace( 'Wordpress', 'WordPress', $text ); // Still here? Use the more judicious replacement static $dblq = false; - if ( false === $dblq ) + if ( false === $dblq ) { $dblq = _x( '“', 'opening curly double quote' ); + } return str_replace( array( ' Wordpress', '‘Wordpress', $dblq . 'Wordpress', '>Wordpress', '(Wordpress' ), array( ' WordPress', '‘WordPress', $dblq . 'WordPress', '>WordPress', '(WordPress' ), $text ); - } /** @@ -4095,7 +4100,7 @@ function get_url_in_content( $content ) { * @return string The spaces regexp. */ function wp_spaces_regexp() { - static $spaces; + static $spaces = ''; if ( empty( $spaces ) ) { /** diff --git a/wp-includes/functions.php b/wp-includes/functions.php index ed75e8e07c..b09ed844af 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -1621,7 +1621,7 @@ function wp_normalize_path( $path ) { * @return string Writable temporary directory. */ function get_temp_dir() { - static $temp; + static $temp = ''; if ( defined('WP_TEMP_DIR') ) return trailingslashit(WP_TEMP_DIR); @@ -4483,7 +4483,7 @@ function send_frame_options_header() { * @return array Array of allowed protocols. */ function wp_allowed_protocols() { - static $protocols; + static $protocols = array(); if ( empty( $protocols ) ) { $protocols = array( 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn', 'tel', 'fax', 'xmpp', 'webcal' ); diff --git a/wp-includes/http.php b/wp-includes/http.php index d867a3a439..4768c7fdd7 100644 --- a/wp-includes/http.php +++ b/wp-includes/http.php @@ -22,11 +22,11 @@ * @return WP_Http HTTP Transport object. */ function _wp_http_get_object() { - static $http; + static $http = null; - if ( is_null($http) ) + if ( is_null( $http ) ) { $http = new WP_Http(); - + } return $http; } diff --git a/wp-includes/ms-functions.php b/wp-includes/ms-functions.php index 86ea6f894a..55aff4a528 100644 --- a/wp-includes/ms-functions.php +++ b/wp-includes/ms-functions.php @@ -2146,11 +2146,11 @@ Thanks! * * @staticvar bool $forced_content * - * @param string|bool $force + * @param bool $force * @return bool True if forced, false if not forced. */ function force_ssl_content( $force = '' ) { - static $forced_content; + static $forced_content = false; if ( '' != $force ) { $old_forced = $forced_content; diff --git a/wp-includes/plugin.php b/wp-includes/plugin.php index 53058f39a8..11ba3f8cf4 100644 --- a/wp-includes/plugin.php +++ b/wp-includes/plugin.php @@ -689,7 +689,7 @@ function wp_register_plugin_realpath( $file ) { global $wp_plugin_paths; // Normalize, but store as static to avoid recalculation of a constant value - static $wp_plugin_path, $wpmu_plugin_path; + static $wp_plugin_path = null, $wpmu_plugin_path = null; if ( ! isset( $wp_plugin_path ) ) { $wp_plugin_path = wp_normalize_path( WP_PLUGIN_DIR ); $wpmu_plugin_path = wp_normalize_path( WPMU_PLUGIN_DIR ); diff --git a/wp-includes/pomo/po.php b/wp-includes/pomo/po.php index 58a420db66..381977c5cf 100644 --- a/wp-includes/pomo/po.php +++ b/wp-includes/pomo/po.php @@ -355,6 +355,7 @@ class PO extends Gettext_Translations { /** * @staticvar string $last_line * @staticvar boolean $use_last_line + * * @param resource $f * @param string $action * @return boolean diff --git a/wp-includes/revision.php b/wp-includes/revision.php index 986bafab6d..ace578e0c3 100644 --- a/wp-includes/revision.php +++ b/wp-includes/revision.php @@ -16,16 +16,16 @@ * @since 2.6.0 * @access private * - * @staticvar array|false $fields + * @staticvar array $fields * * @param array $post Optional. A post array to be processed for insertion as a post revision. * @param bool $autosave Optional. Is the revision an autosave? * @return array Post array ready to be inserted as a post revision or array of fields that can be versioned. */ function _wp_post_revision_fields( $post = null, $autosave = false ) { - static $fields = false; + static $fields = null; - if ( !$fields ) { + if ( is_null( $fields ) ) { // Allow these to be versioned $fields = array( 'post_title' => __( 'Title' ), diff --git a/wp-includes/rewrite.php b/wp-includes/rewrite.php index 3740c14cff..ce3dbf21d6 100644 --- a/wp-includes/rewrite.php +++ b/wp-includes/rewrite.php @@ -2170,7 +2170,7 @@ class WP_Rewrite { * @param bool $hard Whether to update .htaccess (hard flush) or just update rewrite_rules option (soft flush). Default is true (hard). */ public function flush_rules( $hard = true ) { - static $do_hard_later; + static $do_hard_later = null; // Prevent this action from running before everyone has registered their rewrites if ( ! did_action( 'wp_loaded' ) ) { diff --git a/wp-includes/theme.php b/wp-includes/theme.php index 84f591467c..998fbcfabf 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -410,10 +410,11 @@ function register_theme_directory( $directory ) { */ function search_theme_directories( $force = false ) { global $wp_theme_directories; + static $found_themes = null; + if ( empty( $wp_theme_directories ) ) return false; - static $found_themes; if ( ! $force && isset( $found_themes ) ) return $found_themes; @@ -1105,7 +1106,7 @@ function get_header_image() { * @return object */ function _get_random_header_data() { - static $_wp_random_header; + static $_wp_random_header = null; if ( empty( $_wp_random_header ) ) { global $_wp_default_headers; diff --git a/wp-includes/vars.php b/wp-includes/vars.php index da29cb20f0..d58dc4bae6 100644 --- a/wp-includes/vars.php +++ b/wp-includes/vars.php @@ -118,13 +118,16 @@ $is_iis7 = $is_IIS && intval( substr( $_SERVER['SERVER_SOFTWARE'], strpos( $_SER /** * Test if the current browser runs on a mobile device (smart phone, tablet, etc.) * + * @staticvar bool $is_mobile + * * @return bool true|false */ function wp_is_mobile() { - static $is_mobile; + static $is_mobile = null; - if ( isset($is_mobile) ) + if ( isset( $is_mobile ) ) { return $is_mobile; + } if ( empty($_SERVER['HTTP_USER_AGENT']) ) { $is_mobile = false; diff --git a/wp-includes/version.php b/wp-includes/version.php index 5aa632b244..f41c1f9542 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.3-alpha-32649'; +$wp_version = '4.3-alpha-32650'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.