| Conditions | 19 |
| Paths | 12 |
| Total Lines | 59 |
| Code Lines | 34 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 32 | function cmb_do_meta_boxes( $screen, $context, $object ) { |
||
| 33 | |||
| 34 | global $wp_meta_boxes; |
||
| 35 | |||
| 36 | static $already_sorted = false; |
||
| 37 | |||
| 38 | if ( empty( $screen ) ) |
||
| 39 | $screen = get_current_screen(); |
||
|
|
|||
| 40 | |||
| 41 | elseif ( is_string( $screen ) ) |
||
| 42 | $screen = convert_to_screen( $screen ); |
||
| 43 | |||
| 44 | $page = $screen->id; |
||
| 45 | |||
| 46 | $hidden = get_hidden_meta_boxes( $screen ); |
||
| 47 | |||
| 48 | $i = 0; |
||
| 49 | |||
| 50 | do { |
||
| 51 | // Grab the ones the user has manually sorted. Pull them out of their previous context/priority and into the one the user chose |
||
| 52 | |||
| 53 | if ( ! $already_sorted && $sorted = get_user_option( "meta-box-order_$page" ) ) |
||
| 54 | foreach ( $sorted as $box_context => $ids ) |
||
| 55 | foreach ( explode(',', $ids ) as $id ) |
||
| 56 | if ( $id && 'dashboard_browser_nag' !== $id ) |
||
| 57 | add_meta_box( $id, null, null, $screen, $box_context, 'sorted' ); |
||
| 58 | |||
| 59 | $already_sorted = true; |
||
| 60 | |||
| 61 | if ( ! isset( $wp_meta_boxes ) || ! isset( $wp_meta_boxes[$page] ) || ! isset( $wp_meta_boxes[$page][$context] ) ) |
||
| 62 | break; |
||
| 63 | |||
| 64 | foreach ( array( 'high', 'sorted', 'core', 'default', 'low' ) as $priority ) { |
||
| 65 | |||
| 66 | if ( isset( $wp_meta_boxes[$page][$context][$priority] ) ) { |
||
| 67 | |||
| 68 | foreach ( (array) $wp_meta_boxes[$page][$context][$priority] as $box ) { |
||
| 69 | |||
| 70 | if ( false == $box || ! $box['title'] ) |
||
| 71 | continue; |
||
| 72 | |||
| 73 | $i++; |
||
| 74 | |||
| 75 | $hidden_class = in_array($box['id'], $hidden) ? ' hide-if-js' : ''; ?> |
||
| 76 | |||
| 77 | <div id="<?php esc_attr_e( $box['id'] ); ?>" class="<?php esc_attr_e( postbox_classes( $box['id'], $page ) . $hidden_class ); ?>"> |
||
| 78 | |||
| 79 | <?php call_user_func( $box['callback'], $object, $box ); ?> |
||
| 80 | |||
| 81 | </div> |
||
| 82 | |||
| 83 | <?php } |
||
| 84 | |||
| 85 | } |
||
| 86 | |||
| 87 | } |
||
| 88 | } while( 0 ); |
||
| 89 | |||
| 90 | return $i; |
||
| 91 | |||
| 92 | } |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.