Complex classes like Functions often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Functions, and based on these observations, apply Extract Interface, too.
| 1 | <?php  | 
            ||
| 16 | class Functions { | 
            ||
| 17 | const HTTPS_CHECK_OPTION_PREFIX = 'jetpack_sync_https_history_';  | 
            ||
| 18 | const HTTPS_CHECK_HISTORY = 5;  | 
            ||
| 19 | |||
| 20 | /**  | 
            ||
| 21 | * Return array of Jetpack modules.  | 
            ||
| 22 | *  | 
            ||
| 23 | * @return array  | 
            ||
| 24 | */  | 
            ||
| 25 | 	public static function get_modules() { | 
            ||
| 34 | |||
| 35 | /**  | 
            ||
| 36 | * Return array of taxonomies registered on the site.  | 
            ||
| 37 | *  | 
            ||
| 38 | * @return array  | 
            ||
| 39 | */  | 
            ||
| 40 | 	public static function get_taxonomies() { | 
            ||
| 51 | |||
| 52 | /**  | 
            ||
| 53 | * Return array of registered shortcodes.  | 
            ||
| 54 | *  | 
            ||
| 55 | * @return array  | 
            ||
| 56 | */  | 
            ||
| 57 | 	public static function get_shortcodes() { | 
            ||
| 61 | |||
| 62 | /**  | 
            ||
| 63 | * Removes any callback data since we will not be able to process it on our side anyways.  | 
            ||
| 64 | *  | 
            ||
| 65 | * @param \WP_Taxonomy $taxonomy \WP_Taxonomy item.  | 
            ||
| 66 | *  | 
            ||
| 67 | * @return mixed|null  | 
            ||
| 68 | */  | 
            ||
| 69 | 	public static function sanitize_taxonomy( $taxonomy ) { | 
            ||
| 95 | |||
| 96 | /**  | 
            ||
| 97 | * Return array of registered post types.  | 
            ||
| 98 | *  | 
            ||
| 99 | * @return array  | 
            ||
| 100 | */  | 
            ||
| 101 | 	public static function get_post_types() { | 
            ||
| 113 | |||
| 114 | /**  | 
            ||
| 115 | * Sanitizes by cloning post type object.  | 
            ||
| 116 | *  | 
            ||
| 117 | * @param object $post_type \WP_Post_Type.  | 
            ||
| 118 | *  | 
            ||
| 119 | * @return object  | 
            ||
| 120 | */  | 
            ||
| 121 | 	public static function sanitize_post_type( $post_type ) { | 
            ||
| 131 | |||
| 132 | /**  | 
            ||
| 133 | * Return information about a synced post type.  | 
            ||
| 134 | *  | 
            ||
| 135 | * @param array $sanitized_post_type Array of args used in constructing \WP_Post_Type.  | 
            ||
| 136 | * @param string $post_type Post type name.  | 
            ||
| 137 | *  | 
            ||
| 138 | * @return object \WP_Post_Type  | 
            ||
| 139 | */  | 
            ||
| 140 | 	public static function expand_synced_post_type( $sanitized_post_type, $post_type ) { | 
            ||
| 149 | |||
| 150 | /**  | 
            ||
| 151 | * Returns site's post_type_features.  | 
            ||
| 152 | *  | 
            ||
| 153 | * @return array  | 
            ||
| 154 | */  | 
            ||
| 155 | 	public static function get_post_type_features() { | 
            ||
| 160 | |||
| 161 | /**  | 
            ||
| 162 | * Return hosting provider.  | 
            ||
| 163 | *  | 
            ||
| 164 | * Uses a set of known constants, classes, or functions to help determine the hosting platform.  | 
            ||
| 165 | *  | 
            ||
| 166 | * @return string Hosting provider.  | 
            ||
| 167 | */  | 
            ||
| 168 | 	public static function get_hosting_provider() { | 
            ||
| 185 | |||
| 186 | /**  | 
            ||
| 187 | * Return a hosting provider using a set of known constants.  | 
            ||
| 188 | *  | 
            ||
| 189 | * @return mixed A host identifier string or false.  | 
            ||
| 190 | */  | 
            ||
| 191 | 	public function get_hosting_provider_by_known_constant() { | 
            ||
| 213 | |||
| 214 | /**  | 
            ||
| 215 | * Return a hosting provider using a set of known classes.  | 
            ||
| 216 | *  | 
            ||
| 217 | * @return mixed A host identifier string or false.  | 
            ||
| 218 | */  | 
            ||
| 219 | 	public function get_hosting_provider_by_known_class() { | 
            ||
| 230 | |||
| 231 | /**  | 
            ||
| 232 | * Return a hosting provider using a set of known functions.  | 
            ||
| 233 | *  | 
            ||
| 234 | * @return mixed A host identifier string or false.  | 
            ||
| 235 | */  | 
            ||
| 236 | 	public function get_hosting_provider_by_known_function() { | 
            ||
| 247 | |||
| 248 | /**  | 
            ||
| 249 | * Return array of allowed REST API post types.  | 
            ||
| 250 | *  | 
            ||
| 251 | * @return array Array of allowed post types.  | 
            ||
| 252 | */  | 
            ||
| 253 | 	public static function rest_api_allowed_post_types() { | 
            ||
| 257 | |||
| 258 | /**  | 
            ||
| 259 | * Return array of allowed REST API public metadata.  | 
            ||
| 260 | *  | 
            ||
| 261 | * @return array Array of allowed metadata.  | 
            ||
| 262 | */  | 
            ||
| 263 | 	public static function rest_api_allowed_public_metadata() { | 
            ||
| 277 | |||
| 278 | /**  | 
            ||
| 279 | * Finds out if a site is using a version control system.  | 
            ||
| 280 | *  | 
            ||
| 281 | * @return bool  | 
            ||
| 282 | **/  | 
            ||
| 283 | 	public static function is_version_controlled() { | 
            ||
| 292 | |||
| 293 | /**  | 
            ||
| 294 | * Returns true if the site has file write access false otherwise.  | 
            ||
| 295 | *  | 
            ||
| 296 | * @return bool  | 
            ||
| 297 | **/  | 
            ||
| 298 | 	public static function file_system_write_access() { | 
            ||
| 324 | |||
| 325 | /**  | 
            ||
| 326 | * Helper function that is used when getting home or siteurl values. Decides  | 
            ||
| 327 | * whether to get the raw or filtered value.  | 
            ||
| 328 | *  | 
            ||
| 329 | * @param string $url_type URL to get, home or siteurl.  | 
            ||
| 330 | * @return string  | 
            ||
| 331 | */  | 
            ||
| 332 | 	public static function get_raw_or_filtered_url( $url_type ) { | 
            ||
| 336 | |||
| 337 | /**  | 
            ||
| 338 | * Return the escaped home_url.  | 
            ||
| 339 | *  | 
            ||
| 340 | * @return string  | 
            ||
| 341 | */  | 
            ||
| 342 | 	public static function home_url() { | 
            ||
| 346 | |||
| 347 | /**  | 
            ||
| 348 | * Return the escaped siteurl.  | 
            ||
| 349 | *  | 
            ||
| 350 | * @return string  | 
            ||
| 351 | */  | 
            ||
| 352 | 	public static function site_url() { | 
            ||
| 356 | |||
| 357 | /**  | 
            ||
| 358 | * Return main site URL with a normalized protocol.  | 
            ||
| 359 | *  | 
            ||
| 360 | * @return string  | 
            ||
| 361 | */  | 
            ||
| 362 | 	public static function main_network_site_url() { | 
            ||
| 366 | |||
| 367 | /**  | 
            ||
| 368 | * Return main site WordPress.com site ID.  | 
            ||
| 369 | *  | 
            ||
| 370 | * @return string  | 
            ||
| 371 | */  | 
            ||
| 372 | 	public static function main_network_site_wpcom_id() { | 
            ||
| 389 | |||
| 390 | /**  | 
            ||
| 391 | * Return URL with a normalized protocol.  | 
            ||
| 392 | *  | 
            ||
| 393 | * @param callable $callable Function to retrieve URL option.  | 
            ||
| 394 | * @param string $new_value URL Protocol to set URLs to.  | 
            ||
| 395 | * @return string Normalized URL.  | 
            ||
| 396 | */  | 
            ||
| 397 | 	public static function get_protocol_normalized_url( $callable, $new_value ) { | 
            ||
| 401 | |||
| 402 | /**  | 
            ||
| 403 | * Return URL from option or PHP constant.  | 
            ||
| 404 | *  | 
            ||
| 405 | * @param string $option_name (e.g. 'home').  | 
            ||
| 406 | *  | 
            ||
| 407 | * @return mixed|null URL.  | 
            ||
| 408 | */  | 
            ||
| 409 | 	public static function get_raw_url( $option_name ) { | 
            ||
| 413 | |||
| 414 | /**  | 
            ||
| 415 | * Normalize domains by removing www unless declared in the site's option.  | 
            ||
| 416 | *  | 
            ||
| 417 | * @param string $option Option value from the site.  | 
            ||
| 418 | * @param callable $url_function Function retrieving the URL to normalize.  | 
            ||
| 419 | * @return mixed|string URL.  | 
            ||
| 420 | */  | 
            ||
| 421 | 	public static function normalize_www_in_url( $option, $url_function ) { | 
            ||
| 425 | |||
| 426 | /**  | 
            ||
| 427 | * Return filtered value of get_plugins.  | 
            ||
| 428 | *  | 
            ||
| 429 | * @return mixed|void  | 
            ||
| 430 | */  | 
            ||
| 431 | 	public static function get_plugins() { | 
            ||
| 439 | |||
| 440 | /**  | 
            ||
| 441 | * Get custom action link tags that the plugin is using  | 
            ||
| 442 | * Ref: https://codex.wordpress.org/Plugin_API/Filter_Reference/plugin_action_links_(plugin_file_name)  | 
            ||
| 443 | *  | 
            ||
| 444 | * @param string $plugin_file_singular Particular plugin.  | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 445 | * @return array of plugin action links (key: link name value: url)  | 
            ||
| 446 | */  | 
            ||
| 447 | 	public static function get_plugins_action_links( $plugin_file_singular = null ) { | 
            ||
| 461 | |||
| 462 | /**  | 
            ||
| 463 | * Return the WP version as defined in the $wp_version global.  | 
            ||
| 464 | *  | 
            ||
| 465 | * @return string  | 
            ||
| 466 | */  | 
            ||
| 467 | 	public static function wp_version() { | 
            ||
| 471 | |||
| 472 | /**  | 
            ||
| 473 | * Return site icon url used on the site.  | 
            ||
| 474 | *  | 
            ||
| 475 | * @param int $size Size of requested icon in pixels.  | 
            ||
| 476 | * @return mixed|string|void  | 
            ||
| 477 | */  | 
            ||
| 478 | 	public static function site_icon_url( $size = 512 ) { | 
            ||
| 482 | |||
| 483 | /**  | 
            ||
| 484 | * Return roles registered on the site.  | 
            ||
| 485 | *  | 
            ||
| 486 | * @return array  | 
            ||
| 487 | */  | 
            ||
| 488 | 	public static function roles() { | 
            ||
| 492 | |||
| 493 | /**  | 
            ||
| 494 | * Determine time zone from WordPress' options "timezone_string"  | 
            ||
| 495 | * and "gmt_offset".  | 
            ||
| 496 | *  | 
            ||
| 497 | * 1. Check if `timezone_string` is set and return it.  | 
            ||
| 498 | * 2. Check if `gmt_offset` is set, formats UTC-offset from it and return it.  | 
            ||
| 499 | * 3. Default to "UTC+0" if nothing is set.  | 
            ||
| 500 | *  | 
            ||
| 501 | * Note: This function is specifically not using wp_timezone() to keep consistency with  | 
            ||
| 502 | * the existing formatting of the timezone string.  | 
            ||
| 503 | *  | 
            ||
| 504 | * @return string  | 
            ||
| 505 | */  | 
            ||
| 506 | 	public static function get_timezone() { | 
            ||
| 526 | |||
| 527 | /**  | 
            ||
| 528 | * Return list of paused themes.  | 
            ||
| 529 | *  | 
            ||
| 530 | * @return array|bool Array of paused themes or false if unsupported.  | 
            ||
| 531 | */  | 
            ||
| 532 | 	public static function get_paused_themes() { | 
            ||
| 536 | |||
| 537 | /**  | 
            ||
| 538 | * Return list of paused plugins.  | 
            ||
| 539 | *  | 
            ||
| 540 | * @return array|bool Array of paused plugins or false if unsupported.  | 
            ||
| 541 | */  | 
            ||
| 542 | 	public static function get_paused_plugins() { | 
            ||
| 546 | |||
| 547 | /**  | 
            ||
| 548 | * Return the theme's supported features.  | 
            ||
| 549 | * Used for syncing the supported feature that we care about.  | 
            ||
| 550 | *  | 
            ||
| 551 | * @return array List of features that the theme supports.  | 
            ||
| 552 | */  | 
            ||
| 553 | 	public static function get_theme_support() { | 
            ||
| 566 | |||
| 567 | /**  | 
            ||
| 568 | * Wraps data in a way so that we can distinguish between objects and array and also prevent object recursion.  | 
            ||
| 569 | *  | 
            ||
| 570 | * @since 9.5.0  | 
            ||
| 571 | *  | 
            ||
| 572 | * @param array|obj $any Source data to be cleaned up.  | 
            ||
| 573 | * @param array $seen_nodes Built array of nodes.  | 
            ||
| 574 | *  | 
            ||
| 575 | * @return array  | 
            ||
| 576 | */  | 
            ||
| 577 | 	public static function json_wrap( &$any, $seen_nodes = array() ) { | 
            ||
| 607 | }  | 
            ||
| 608 | 
This check looks for
@paramannotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.