WordPress.org

Make WordPress Core

Changeset 32650


Ignore:
Timestamp:
05/29/2015 03:42:40 PM (5 years ago)
Author:
wonderboymusic
Message:

Add @static* annotations where they are missing.
Initialize all static vars that are not, most to null.

See #32444.

Location:
trunk/src
Files:
35 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-filesystem-ftpext.php

    r31815 r32650  
    380380     */
    381381    public function parselisting($line) {
    382         static $is_windows;
     382        static $is_windows = null;
    383383        if ( is_null($is_windows) )
    384384            $is_windows = stripos( ftp_systype($this->link), 'win') !== false;
  • trunk/src/wp-admin/includes/class-wp-list-table.php

    r32644 r32650  
    901901     * @access public
    902902     *
     903     * @staticvar int $cb_counter
     904     *
    903905     * @param bool $with_id Whether to set the id attribute or not
    904906     */
  • trunk/src/wp-admin/includes/class-wp-ms-themes-list-table.php

    r32644 r32650  
    163163     */
    164164    public function _search_callback( $theme ) {
    165         static $term;
     165        static $term = null;
    166166        if ( is_null( $term ) )
    167167            $term = wp_unslash( $_REQUEST['s'] );
  • trunk/src/wp-admin/includes/class-wp-plugins-list-table.php

    r32644 r32650  
    220220     */
    221221    public function _search_callback( $plugin ) {
    222         static $term;
     222        static $term = null;
    223223        if ( is_null( $term ) )
    224224            $term = wp_unslash( $_REQUEST['s'] );
  • trunk/src/wp-admin/includes/class-wp-upgrader.php

    r32642 r32650  
    16591659     *
    16601660     * @since 3.7.0
     1661     *
     1662     * @static
    16611663     */
    16621664    public static function async_upgrade( $upgrader = false ) {
     
    21362138     *
    21372139     * @since 3.7.0
     2140     *
     2141     * @static
    21382142     *
    21392143     * @param string $offered_ver The offered version, of the format x.y.z.
  • trunk/src/wp-admin/includes/deprecated.php

    r31717 r32650  
    733733 * @deprecated Use wp_editor()
    734734 * @see wp_editor()
     735 *
     736 * @staticvar int $num
    735737 */
    736738function wp_tiny_mce( $teeny = false, $settings = false ) {
  • trunk/src/wp-admin/includes/media.php

    r32642 r32650  
    535535 *
    536536 * @global int $post_ID
     537 *
     538 * @staticvar int $instance
    537539 *
    538540 * @param string $editor_id
  • trunk/src/wp-admin/includes/screen.php

    r32643 r32650  
    1111 *
    1212 * @since 2.7.0
     13 *
     14 * @staticvar array $column_headers
    1315 *
    1416 * @param string|WP_Screen $screen The screen you want the headers for
     
    328330    /**
    329331     * Stores old string-based help.
     332     *
     333     * @static
     334     * @access private
     335     *
     336     * @var array
    330337     */
    331338    private static $_old_compat_help = array();
     
    344351     *
    345352     * @since 3.3.0
     353     *
     354     * @static
     355     * @access private
     356     *
    346357     * @var array
    347      * @access private
    348358     */
    349359    private static $_registry = array();
     
    372382     * @since 3.3.0
    373383     * @access public
     384     *
     385     * @static
    374386     *
    375387     * @global string $hook_suffix
     
    588600     *
    589601     * @since 3.3.0
     602     *
     603     * @static
    590604     *
    591605     * @param WP_Screen $screen A screen object.
     
    975989     *
    976990     * @global array $wp_meta_boxes
    977      * 
     991     *
    978992     * @return bool
    979993     */
  • trunk/src/wp-admin/includes/template.php

    r32643 r32650  
    606606 * @since 2.5.0
    607607 *
     608 * @staticvar string $update_nonce
     609 *
    608610 * @param array $entry
    609611 * @param int   $count
     
    611613 */
    612614function _list_meta_row( $entry, &$count ) {
    613     static $update_nonce = false;
     615    static $update_nonce = '';
    614616
    615617    if ( is_protected_meta( $entry['meta_key'], 'post' ) )
    616618        return '';
    617619
    618     if ( !$update_nonce )
     620    if ( ! $update_nonce )
    619621        $update_nonce = wp_create_nonce( 'add-meta' );
    620622
     
    19921994     *     remove_action( 'admin_print_footer_scripts', array( 'WP_Internal_Pointers', 'pointer_wp390_widgets' ) );
    19931995     *
     1996     * @static
     1997     *
    19941998     * @param string $hook_suffix The current admin page.
    19951999     */
     
    20482052     * @since 3.3.0
    20492053     *
     2054     * @static
     2055     *
    20502056     * @param string $pointer_id The pointer ID.
    20512057     * @param string $selector The HTML elements, on which the pointer should be attached.
     
    20952101    public static function pointer_wp360_revisions() {}
    20962102
     2103    /**
     2104     * @static
     2105     */
    20972106    public static function pointer_wp360_locks() {
    20982107        if ( ! is_multi_author() ) {
     
    21092118    }
    21102119
     2120    /**
     2121     * @static
     2122     */
    21112123    public static function pointer_wp390_widgets() {
    21122124        if ( ! current_theme_supports( 'widgets' ) ) {
     
    21652177     *
    21662178     * @since 3.3.0
     2179     *
     2180     * @static
    21672181     *
    21682182     * @param int $user_id User ID.
  • trunk/src/wp-admin/includes/theme.php

    r32643 r32650  
    137137 * @since 3.8.0
    138138 *
     139 * @staticvar object $themes_update
     140 *
    139141 * @param WP_Theme $theme WP_Theme object.
    140142 * @return false|string HTML for the update link, or false if invalid info was passed.
    141143 */
    142144function get_theme_update_available( $theme ) {
    143     static $themes_update;
     145    static $themes_update = null;
    144146
    145147    if ( !current_user_can('update_themes' ) )
  • trunk/src/wp-admin/includes/widgets.php

    r32642 r32650  
    105105 * @global array $wp_registered_widgets
    106106 *
     107 * @staticvar int $i
     108 *
    107109 * @param array $params
    108110 * @return array
  • trunk/src/wp-includes/capabilities.php

    r32568 r32650  
    490490    var $filter = null;
    491491
     492    /**
     493     * @static
     494     * @access private
     495     * @var array
     496     */
    492497    private static $back_compat_keys;
    493498
     
    562567     *
    563568     * @since 3.3.0
     569     *
     570     * @static
    564571     *
    565572     * @global wpdb $wpdb
  • trunk/src/wp-includes/class-http.php

    r32542 r32650  
    342342     *
    343343     * @since 3.2.0
     344     *
     345     * @static
    344346     * @access private
    345347     *
     
    627629     * @link https://core.trac.wordpress.org/ticket/14636 Allow wildcard domains in WP_ACCESSIBLE_HOSTS
    628630     *
     631     * @staticvar array|null $accessible_hosts
     632     * @staticvar array      $wildcard_regex
     633     *
    629634     * @param string $uri URI of url.
    630635     * @return bool True to block, false to allow.
     
    657662            return true;
    658663
    659         static $accessible_hosts;
    660         static $wildcard_regex = false;
    661         if ( null == $accessible_hosts ) {
     664        static $accessible_hosts = null;
     665        static $wildcard_regex = array();
     666        if ( null === $accessible_hosts ) {
    662667            $accessible_hosts = preg_split('|,\s*|', WP_ACCESSIBLE_HOSTS);
    663668
     
    688693     *
    689694     * @since 4.1.0
     695     *
     696     * @static
    690697     * @access protected
    691698     *
     
    726733     * @since 3.4.0
    727734     *
     735     * @static
    728736     * @access public
     737     *
    729738     * @param string $maybe_relative_path The URL which might be relative
    730739     * @param string $url                 The URL which $maybe_relative_path is relative to
     
    796805     *
    797806     * @since 3.7.0
     807     *
     808     * @static
    798809     *
    799810     * @param string $url The URL which was requested.
     
    17991810     * @since 2.8.0
    18001811     *
     1812     * @staticvar array|null $bypass_hosts
     1813     * @staticvar array      $wildcard_regex
     1814     *
    18011815     * @param string $uri URI to check.
    18021816     * @return bool True, to send through the proxy and false if, the proxy should not be used.
     
    18381852            return true;
    18391853
    1840         static $bypass_hosts;
    1841         static $wildcard_regex = false;
    1842         if ( null == $bypass_hosts ) {
     1854        static $bypass_hosts = null;
     1855        static $wildcard_regex = array();
     1856        if ( null === $bypass_hosts ) {
    18431857            $bypass_hosts = preg_split('|,\s*|', WP_PROXY_BYPASS_HOSTS);
    18441858
     
    20882102     * @since 2.8.0
    20892103     *
     2104     * @static
     2105     *
    20902106     * @param string $raw String to compress.
    20912107     * @param int $level Optional, default is 9. Compression level, 9 is highest.
     
    21072123     * @since 2.8.0
    21082124     *
     2125     * @static
     2126     *
    21092127     * @param string $compressed String to decompress.
    21102128     * @param int $length The optional length of the compressed data.
     
    21512169     * @link http://au2.php.net/manual/en/function.gzinflate.php#70875
    21522170     * @link http://au2.php.net/manual/en/function.gzinflate.php#77336
     2171     *
     2172     * @static
    21532173     *
    21542174     * @param string $gzData String to decompress.
     
    21912211     * @since 2.8.0
    21922212     *
     2213     * @static
     2214     *
    21932215     * @param string $url
    21942216     * @param array  $args
     
    22372259     * @since 2.8.0
    22382260     *
     2261     * @static
     2262     *
    22392263     * @return string Content-Encoding string to send in the header.
    22402264     */
     
    22472271     *
    22482272     * @since 2.8.0
     2273     *
     2274     * @static
    22492275     *
    22502276     * @param array|string $headers All of the available headers.
     
    22712297     * @since 2.8.0
    22722298     *
     2299     * @static
     2300     *
    22732301     * @return bool
    22742302     */
  • trunk/src/wp-includes/class-oembed.php

    r32533 r32650  
    2020class WP_oEmbed {
    2121    public $providers = array();
     22    /**
     23     * @static
     24     * @var array
     25     */
    2226    public static $early_providers = array();
    2327
     
    612616 * @access private
    613617 *
    614  * @see WP_oEmbed
     618 * @staticvar WP_oEmbed $wp_oembed
    615619 *
    616620 * @return WP_oEmbed object.
    617621 */
    618622function _wp_oembed_get_object() {
    619     static $wp_oembed;
    620 
    621     if ( is_null($wp_oembed) )
     623    static $wp_oembed = null;
     624
     625    if ( is_null( $wp_oembed ) ) {
    622626        $wp_oembed = new WP_oEmbed();
    623 
     627    }
    624628    return $wp_oembed;
    625629}
  • trunk/src/wp-includes/class-wp-customize-control.php

    r32568 r32650  
    2121     *
    2222     * @since 4.1.0
     23     *
     24     * @static
    2325     * @access protected
    2426     * @var int
  • trunk/src/wp-includes/class-wp-customize-panel.php

    r32649 r32650  
    2525     *
    2626     * @since 4.1.0
     27     *
     28     * @static
    2729     * @access protected
    2830     * @var int
  • trunk/src/wp-includes/class-wp-customize-section.php

    r32649 r32650  
    2525     *
    2626     * @since 4.1.0
     27     *
     28     * @static
    2729     * @access protected
    2830     * @var int
  • trunk/src/wp-includes/class-wp-customize-widgets.php

    r32649 r32650  
    108108     * @since 4.2.0
    109109     * @access protected
     110     *
     111     * @staticvar array $cache
    110112     *
    111113     * @param $setting_id Setting ID.
     
    877879     *
    878880     * @since 3.9.0
    879      * @static
    880881     * @access protected
    881882     *
  • trunk/src/wp-includes/class-wp-image-editor-gd.php

    r32554 r32650  
    3535     *
    3636     * @since 3.5.0
     37     *
     38     * @static
    3739     * @access public
    3840     *
    3941     * @param array $args
    40      * @return boolean
     42     * @return bool
    4143     */
    4244    public static function test( $args = array() ) {
     
    5961     *
    6062     * @since 3.5.0
     63     *
     64     * @static
    6165     * @access public
    6266     *
    6367     * @param string $mime_type
    64      * @return boolean
     68     * @return bool
    6569     */
    6670    public static function supports_mime_type( $mime_type ) {
  • trunk/src/wp-includes/class-wp-image-editor-imagick.php

    r32555 r32650  
    3939     *
    4040     * @since 3.5.0
     41     *
     42     * @static
    4143     * @access public
    4244     *
     
    8789     *
    8890     * @since 3.5.0
     91     *
     92     * @static
    8993     * @access public
    9094     *
  • trunk/src/wp-includes/class-wp-image-editor.php

    r32546 r32650  
    3232     *
    3333     * @since 3.5.0
     34     *
     35     * @static
    3436     * @access public
    3537     * @abstract
     
    4749     *
    4850     * @since 3.5.0
     51     *
     52     * @static
    4953     * @access public
    5054     * @abstract
     
    443447     *
    444448     * @since 3.5.0
     449     *
     450     * @static
    445451     * @access protected
    446452     *
     
    469475     *
    470476     * @since 3.5.0
     477     *
     478     * @static
    471479     * @access protected
    472480     *
  • trunk/src/wp-includes/class-wp-theme.php

    r32568 r32650  
    688688     * @access private
    689689     *
    690      * @stativar string $comma
     690     * @staticvar string $comma
    691691     *
    692692     * @param string $header Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status, Tags.
  • trunk/src/wp-includes/comment.php

    r32587 r32650  
    25592559 * @see wp_update_comment_count_now() For what could cause a false return value
    25602560 *
     2561 * @staticvar array $_deferred
     2562 *
    25612563 * @param int $post_id Post ID
    25622564 * @param bool $do_deferred Whether to process previously deferred post comment counts
  • trunk/src/wp-includes/compat.php

    r32364 r32650  
    2020 * @since 4.2.2
    2121 * @access private
     22 *
     23 * @staticvar string $utf8_pcre
    2224 *
    2325 * @param bool $set - Used for testing only
  • trunk/src/wp-includes/default-widgets.php

    r32600 r32650  
    645645
    646646    /**
     647     * @staticvar bool $first_dropdown
     648     *
    647649     * @param array $args
    648650     * @param array $instance
    649651     */
    650652    public function widget( $args, $instance ) {
     653        static $first_dropdown = true;
     654
    651655        /** This filter is documented in wp-includes/default-widgets.php */
    652656        $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title'], $instance, $this->id_base );
     
    668672
    669673        if ( $d ) {
    670             static $first_dropdown = true;
    671 
    672674            $dropdown_id = ( $first_dropdown ) ? 'cat' : "{$this->id_base}-dropdown-{$this->number}";
    673675            $first_dropdown = false;
  • trunk/src/wp-includes/formatting.php

    r32590 r32650  
    3939function wptexturize( $text, $reset = false ) {
    4040    global $wp_cockneyreplace, $shortcode_tags;
    41     static $static_characters, $static_replacements, $dynamic_characters, $dynamic_replacements,
    42         $default_no_texturize_tags, $default_no_texturize_shortcodes, $run_texturize = true;
     41    static $static_characters = null,
     42        $static_replacements = null,
     43        $dynamic_characters = null,
     44        $dynamic_replacements = null,
     45        $default_no_texturize_tags = null,
     46        $default_no_texturize_shortcodes = null,
     47        $run_texturize = true;
    4348
    4449    // If there's nothing to do, just stop.
     
    631636 * @access private
    632637 *
    633  * @staticvar string|false $_charset
     638 * @staticvar string $_charset
    634639 *
    635640 * @param string $string         The text which is to be encoded.
     
    657662    // Store the site charset as a static to avoid multiple calls to wp_load_alloptions()
    658663    if ( ! $charset ) {
    659         static $_charset;
     664        static $_charset = null;
    660665        if ( ! isset( $_charset ) ) {
    661666            $alloptions = wp_load_alloptions();
     
    791796
    792797    // Store the site charset as a static to avoid multiple calls to get_option()
    793     static $is_utf8;
    794     if ( !isset( $is_utf8 ) ) {
     798    static $is_utf8 = null;
     799    if ( ! isset( $is_utf8 ) ) {
    795800        $is_utf8 = in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) );
    796801    }
    797     if ( !$is_utf8 ) {
     802    if ( ! $is_utf8 ) {
    798803        return $string;
    799804    }
    800805
    801806    // Check for support for utf8 in the installed PCRE library once and store the result in a static
    802     static $utf8_pcre;
    803     if ( !isset( $utf8_pcre ) ) {
     807    static $utf8_pcre = null;
     808    if ( ! isset( $utf8_pcre ) ) {
    804809        $utf8_pcre = @preg_match( '/^./u', 'a' );
    805810    }
     
    39603965    // Still here? Use the more judicious replacement
    39613966    static $dblq = false;
    3962     if ( false === $dblq )
     3967    if ( false === $dblq ) {
    39633968        $dblq = _x( '“', 'opening curly double quote' );
     3969    }
    39643970    return str_replace(
    39653971        array( ' Wordpress', '‘Wordpress', $dblq . 'Wordpress', '>Wordpress', '(Wordpress' ),
    39663972        array( ' WordPress', '‘WordPress', $dblq . 'WordPress', '>WordPress', '(WordPress' ),
    39673973    $text );
    3968 
    39693974}
    39703975
     
    40964101 */
    40974102function wp_spaces_regexp() {
    4098     static $spaces;
     4103    static $spaces = '';
    40994104
    41004105    if ( empty( $spaces ) ) {
  • trunk/src/wp-includes/functions.php

    r32595 r32650  
    16221622 */
    16231623function get_temp_dir() {
    1624     static $temp;
     1624    static $temp = '';
    16251625    if ( defined('WP_TEMP_DIR') )
    16261626        return trailingslashit(WP_TEMP_DIR);
     
    44844484 */
    44854485function wp_allowed_protocols() {
    4486     static $protocols;
     4486    static $protocols = array();
    44874487
    44884488    if ( empty( $protocols ) ) {
  • trunk/src/wp-includes/http.php

    r32599 r32650  
    2323 */
    2424function _wp_http_get_object() {
    25     static $http;
    26 
    27     if ( is_null($http) )
     25    static $http = null;
     26
     27    if ( is_null( $http ) ) {
    2828        $http = new WP_Http();
    29 
     29    }
    3030    return $http;
    3131}
  • trunk/src/wp-includes/ms-functions.php

    r32611 r32650  
    21472147 * @staticvar bool $forced_content
    21482148 *
    2149  * @param string|bool $force
     2149 * @param bool $force
    21502150 * @return bool True if forced, false if not forced.
    21512151 */
    21522152function force_ssl_content( $force = '' ) {
    2153     static $forced_content;
     2153    static $forced_content = false;
    21542154
    21552155    if ( '' != $force ) {
  • trunk/src/wp-includes/plugin.php

    r32615 r32650  
    690690
    691691    // Normalize, but store as static to avoid recalculation of a constant value
    692     static $wp_plugin_path, $wpmu_plugin_path;
     692    static $wp_plugin_path = null, $wpmu_plugin_path = null;
    693693    if ( ! isset( $wp_plugin_path ) ) {
    694694        $wp_plugin_path   = wp_normalize_path( WP_PLUGIN_DIR   );
  • trunk/src/wp-includes/pomo/po.php

    r30663 r32650  
    356356     * @staticvar string   $last_line
    357357     * @staticvar boolean  $use_last_line
     358     *
    358359     * @param     resource $f
    359360     * @param     string   $action
  • trunk/src/wp-includes/revision.php

    r32621 r32650  
    1717 * @access private
    1818 *
    19  * @staticvar array|false $fields
     19 * @staticvar array $fields
    2020 *
    2121 * @param array $post     Optional. A post array to be processed for insertion as a post revision.
     
    2424 */
    2525function _wp_post_revision_fields( $post = null, $autosave = false ) {
    26     static $fields = false;
    27 
    28     if ( !$fields ) {
     26    static $fields = null;
     27
     28    if ( is_null( $fields ) ) {
    2929        // Allow these to be versioned
    3030        $fields = array(
  • trunk/src/wp-includes/rewrite.php

    r32648 r32650  
    21712171     */
    21722172    public function flush_rules( $hard = true ) {
    2173         static $do_hard_later;
     2173        static $do_hard_later = null;
    21742174
    21752175        // Prevent this action from running before everyone has registered their rewrites
  • trunk/src/wp-includes/theme.php

    r32632 r32650  
    411411function search_theme_directories( $force = false ) {
    412412    global $wp_theme_directories;
     413    static $found_themes = null;
     414
    413415    if ( empty( $wp_theme_directories ) )
    414416        return false;
    415417
    416     static $found_themes;
    417418    if ( ! $force && isset( $found_themes ) )
    418419        return $found_themes;
     
    11061107 */
    11071108function _get_random_header_data() {
    1108     static $_wp_random_header;
     1109    static $_wp_random_header = null;
    11091110
    11101111    if ( empty( $_wp_random_header ) ) {
  • trunk/src/wp-includes/vars.php

    r32116 r32650  
    119119 * Test if the current browser runs on a mobile device (smart phone, tablet, etc.)
    120120 *
     121 * @staticvar bool $is_mobile
     122 *
    121123 * @return bool true|false
    122124 */
    123125function wp_is_mobile() {
    124     static $is_mobile;
     126    static $is_mobile = null;
    125127
    126     if ( isset($is_mobile) )
     128    if ( isset( $is_mobile ) ) {
    127129        return $is_mobile;
     130    }
    128131
    129132    if ( empty($_SERVER['HTTP_USER_AGENT']) ) {
Note: See TracChangeset for help on using the changeset viewer.