| Conditions | 1 |
| Paths | 1 |
| Total Lines | 65 |
| 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 |
||
| 44 | private function preconnection_default_rules() { |
||
| 45 | |||
| 46 | return array( |
||
| 47 | ( new Message( 'jpsetup-posts', 'pre-connect' ) ) |
||
| 48 | ->user_is( 'administrator' ) |
||
| 49 | ->with_icon() |
||
| 50 | ->message_path( '/wp:edit-post:admin_notices/' ) |
||
| 51 | ->show( |
||
| 52 | __( 'Do you know which of these posts gets the most traffic?', 'jetpack' ), |
||
| 53 | __( 'Setup Jetpack to get in-depth stats about your content and visitors.', 'jetpack' ) |
||
| 54 | ) |
||
| 55 | ->priority( 100 ) |
||
| 56 | ->with_cta( |
||
| 57 | __( 'Setup Jetpack', 'jetpack' ), |
||
| 58 | '', |
||
| 59 | function() { |
||
|
|
|||
| 60 | return esc_url( \Jetpack::init()->build_connect_url( true, false, 'pre-connection-jitm-posts' ) ); |
||
| 61 | } |
||
| 62 | ) |
||
| 63 | ->open_cta_in_same_window() |
||
| 64 | ->is_dismissible( true ) |
||
| 65 | ->priority( 1000 ) |
||
| 66 | ->is_hosted_with_partner( 'bluehost' ), |
||
| 67 | ( new Message( 'jpsetup-upload', 'pre-connect' ) ) |
||
| 68 | ->user_is( 'administrator' ) |
||
| 69 | ->with_icon() |
||
| 70 | ->message_path( '/wp:upload:admin_notices/' ) |
||
| 71 | ->show( |
||
| 72 | __( 'Do you want lightning-fast images?', 'jetpack' ), |
||
| 73 | __( 'Setup Jetpack, enable Site Accelerator, and start serving your images lightning fast, for free.', 'jetpack' ) |
||
| 74 | ) |
||
| 75 | ->priority( 100 ) |
||
| 76 | ->with_cta( |
||
| 77 | __( 'Setup Jetpack', 'jetpack' ), |
||
| 78 | '', |
||
| 79 | function() { |
||
| 80 | return esc_url( \Jetpack::init()->build_connect_url( true, false, 'pre-connection-jitm-upload' ) ); |
||
| 81 | } |
||
| 82 | ) |
||
| 83 | ->open_cta_in_same_window() |
||
| 84 | ->is_dismissible( true ) |
||
| 85 | ->priority( 1000 ) |
||
| 86 | ->is_hosted_with_partner( 'bluehost' ), |
||
| 87 | ( new Message( 'jpsetup-widgets', 'pre-connect' ) ) |
||
| 88 | ->user_is( 'administrator' ) |
||
| 89 | ->with_icon() |
||
| 90 | ->message_path( '/wp:widgets:admin_notices/' ) |
||
| 91 | ->show( |
||
| 92 | __( 'Looking for even more widgets?', 'jetpack' ), |
||
| 93 | __( 'Setup Jetpack for great additional widgets like business hours and maps.', 'jetpack' ) |
||
| 94 | ) |
||
| 95 | ->priority( 100 ) |
||
| 96 | ->with_cta( |
||
| 97 | __( 'Setup Jetpack', 'jetpack' ), |
||
| 98 | '', |
||
| 99 | function() { |
||
| 100 | return esc_url( \Jetpack::init()->build_connect_url( true, false, 'pre-connection-jitm-widgets' ) ); |
||
| 101 | } |
||
| 102 | ) |
||
| 103 | ->open_cta_in_same_window() |
||
| 104 | ->is_dismissible( true ) |
||
| 105 | ->priority( 1000 ) |
||
| 106 | ->is_hosted_with_partner( 'bluehost' ), |
||
| 107 | ); |
||
| 108 | } |
||
| 109 | |||
| 188 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: