Conditions | 5 |
Paths | 7 |
Total Lines | 80 |
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 |
||
14 | function elgg_solr_init() { |
||
15 | |||
16 | elgg_extend_view('css/admin', 'css/admin/elgg_solr'); |
||
17 | |||
18 | // if the plugin is not configured lets leave search alone |
||
19 | if (!elgg_solr_has_settings()) { |
||
20 | return true; |
||
21 | } |
||
22 | |||
23 | $is_elgg18 = elgg_solr_is_elgg18(); |
||
24 | |||
25 | elgg_register_library('Solarium', dirname(__FILE__) . '/vendor/autoload.php'); |
||
26 | elgg_register_library('elgg_solr:upgrades', dirname(__FILE__) . '/lib/upgrades.php'); |
||
27 | |||
28 | if (elgg_get_plugin_setting('use_solr', 'elgg_solr') != 'no') { |
||
29 | // unregister default search hooks |
||
30 | elgg_unregister_plugin_hook_handler('search', 'object', 'search_objects_hook'); |
||
31 | elgg_unregister_plugin_hook_handler('search', 'user', 'search_users_hook'); |
||
32 | elgg_unregister_plugin_hook_handler('search', 'group', 'search_groups_hook'); |
||
33 | elgg_unregister_plugin_hook_handler('search', 'tags', 'search_tags_hook'); |
||
34 | |||
35 | elgg_register_plugin_hook_handler('search', 'object:file', 'elgg_solr_file_search'); |
||
36 | elgg_register_plugin_hook_handler('search', 'object', 'elgg_solr_object_search'); |
||
37 | elgg_register_plugin_hook_handler('search', 'user', 'elgg_solr_user_search'); |
||
38 | elgg_register_plugin_hook_handler('search', 'group', 'elgg_solr_group_search'); |
||
39 | elgg_register_plugin_hook_handler('search', 'tags', 'elgg_solr_tag_search'); |
||
40 | |||
41 | |||
42 | if ($is_elgg18) { |
||
43 | // this is elgg 1.8 need to handle comments as annotations |
||
44 | elgg_unregister_plugin_hook_handler('search', 'comments', 'search_comments_hook'); |
||
45 | elgg_register_plugin_hook_handler('search', 'comments', 'elgg_solr_comment_search'); |
||
46 | } |
||
47 | } |
||
48 | |||
49 | elgg_register_plugin_hook_handler('cron', 'daily', 'elgg_solr_daily_cron'); |
||
50 | |||
51 | |||
52 | elgg_register_event_handler('create', 'all', 'elgg_solr_add_update_entity', 1000); |
||
53 | elgg_register_event_handler('update', 'all', 'elgg_solr_add_update_entity', 1000); |
||
54 | elgg_register_event_handler('delete', 'all', 'elgg_solr_delete_entity', 1000); |
||
55 | elgg_register_event_handler('create', 'metadata', 'elgg_solr_metadata_update'); |
||
56 | elgg_register_event_handler('update', 'metadata', 'elgg_solr_metadata_update'); |
||
57 | elgg_register_event_handler('upgrade', 'system', 'elgg_solr_upgrades'); |
||
58 | elgg_register_event_handler('disable', 'all', 'elgg_solr_disable_entity'); |
||
59 | elgg_register_event_handler('enable', 'all', 'elgg_solr_enable_entity'); |
||
60 | elgg_register_event_handler('shutdown', 'system', 'elgg_solr_entities_sync'); |
||
61 | |||
62 | if ($is_elgg18) { |
||
63 | elgg_register_event_handler('create', 'all', 'elgg_solr_add_update_annotation', 1000); |
||
64 | elgg_register_event_handler('update', 'all', 'elgg_solr_add_update_annotation', 1000); |
||
65 | elgg_register_event_handler('delete', 'annotations', 'elgg_solr_delete_annotation', 1000); |
||
66 | elgg_register_event_handler('shutdown', 'system', 'elgg_solr_annotations_sync'); |
||
67 | } |
||
68 | |||
69 | elgg_set_config('elgg_solr_sync', array()); |
||
70 | elgg_set_config('elgg_solr_delete', array()); |
||
71 | |||
72 | // when to update the user index |
||
73 | elgg_register_plugin_hook_handler('usersettings:save', 'user', 'elgg_solr_user_settings_save', 1000); |
||
74 | elgg_register_event_handler('profileupdate', 'user', 'elgg_solr_profile_update', 1000); |
||
75 | |||
76 | |||
77 | // register functions for indexing |
||
78 | elgg_solr_register_solr_entity_type('object', 'file', 'elgg_solr_add_update_file'); |
||
79 | elgg_solr_register_solr_entity_type('user', 'default', 'elgg_solr_add_update_user'); |
||
80 | elgg_solr_register_solr_entity_type('object', 'default', 'elgg_solr_add_update_object_default'); |
||
81 | elgg_solr_register_solr_entity_type('group', 'default', 'elgg_solr_add_update_group_default'); |
||
82 | |||
83 | elgg_register_action('elgg_solr/reindex', dirname(__FILE__) . '/actions/reindex.php', 'admin'); |
||
84 | elgg_register_action('elgg_solr/delete_index', dirname(__FILE__) . '/actions/delete_index.php', 'admin'); |
||
85 | elgg_register_action('elgg_solr/reindex_unlock', dirname(__FILE__) . '/actions/reindex_unlock.php', 'admin'); |
||
86 | elgg_register_action('elgg_solr/settings/save', dirname(__FILE__) . '/actions/plugin_settings.php', 'admin'); |
||
87 | elgg_register_action('elgg_solr/restart_reindex', dirname(__FILE__) . '/actions/restart_reindex.php', 'admin'); |
||
88 | elgg_register_action('elgg_solr/stop_reindex', dirname(__FILE__) . '/actions/stop_reindex.php', 'admin'); |
||
89 | |||
90 | elgg_register_admin_menu_item('administer', 'solr_index', 'administer_utilities'); |
||
91 | |||
92 | elgg_register_ajax_view('elgg_solr/ajax/progress'); |
||
93 | } |
||
94 |
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: