Permalink
Browse files

Code Standards/PHP Doc improvements

Improvements to code base to follow coding standards,
and improve phpdoc validation from PHP Codesniffer rules
  • Loading branch information...
1 parent ee1b1c9 commit b78f966e013d494ea27d92bba39d797a1266b7b7 @grangeway grangeway committed Jul 13, 2014
Showing with 1,815 additions and 1,837 deletions.
  1. +19 −13 account_page.php
  2. +6 −6 account_sponsor_page.php
  3. +8 −10 adm_config_report.php
  4. +1 −1 adm_config_set.php
  5. +10 −8 admin/check/check_api.php
  6. +1 −1 admin/check/check_config_inc.php
  7. +8 −10 admin/check/check_database_inc.php
  8. +44 −44 admin/install.php
  9. +14 −14 admin/move_attachments.php
  10. +12 −12 admin/move_attachments_page.php
  11. +260 −261 admin/schema.php
  12. +95 −100 admin/test_langs.php
  13. +13 −13 admin/upgrade_unattended.php
  14. +10 −10 api/soap/mantisconnect.php
  15. +10 −10 api/soap/mc_api.php
  16. +3 −3 api/soap/mc_file_api.php
  17. +56 −56 api/soap/mc_issue_api.php
  18. +28 −28 api/soap/mc_project_api.php
  19. +5 −5 api/soap/mc_tag_api.php
  20. +3 −4 billing_inc.php
  21. +3 −3 bug_actiongroup_page.php
  22. +25 −31 bug_change_status_page.php
  23. +2 −2 bug_relationship_graph.php
  24. +17 −8 bug_report_page.php
  25. +3 −1 bug_revision_view_page.php
  26. +2 −2 bug_update_page.php
  27. +1 −3 bugnote_stats_inc.php
  28. +3 −3 changelog_page.php
  29. +6 −6 core/bug_api.php
  30. +1 −1 core/bugnote_api.php
  31. +1 −1 core/category_api.php
  32. +5 −5 core/cfdefs/cfdef_standard.php
  33. +8 −8 core/columns_api.php
  34. +11 −11 core/config_api.php
  35. +79 −81 core/custom_field_api.php
  36. +10 −10 core/database_api.php
  37. +8 −8 core/date_api.php
  38. +18 −18 core/email_api.php
  39. +5 −5 core/email_queue_api.php
  40. +1 −1 core/error_api.php
  41. +1 −1 core/event_api.php
  42. +13 −15 core/file_api.php
  43. +351 −361 core/filter_api.php
  44. +8 −6 core/helper_api.php
  45. +8 −10 core/history_api.php
  46. +47 −48 core/html_api.php
  47. +1 −1 core/http_api.php
  48. +3 −3 core/icon_api.php
  49. +40 −40 core/install_helper_functions_api.php
  50. +2 −2 core/json_api.php
  51. +19 −19 core/ldap_api.php
  52. +1 −1 core/logging_api.php
  53. +14 −15 core/news_api.php
  54. +5 −5 core/plugin_api.php
  55. +62 −64 core/print_api.php
  56. +19 −19 core/profile_api.php
  57. +32 −33 core/project_api.php
  58. +13 −13 core/project_hierarchy_api.php
  59. +26 −26 core/relationship_api.php
  60. +2 −2 core/relationship_graph_api.php
  61. +3 −3 core/rss_api.php
  62. +11 −11 core/sponsorship_api.php
  63. +76 −76 core/summary_api.php
  64. +43 −43 core/tag_api.php
  65. +11 −12 core/tokens_api.php
  66. +64 −65 core/user_api.php
  67. +7 −9 core/user_pref_api.php
  68. +1 −1 core/utility_api.php
  69. +1 −1 core/version_api.php
  70. +2 −2 file_download.php
  71. +1 −1 login_select_proj_page.php
  72. +43 −43 manage_config_email_page.php
  73. +13 −12 manage_config_work_threshold_page.php
  74. +31 −31 manage_config_workflow_page.php
  75. +1 −1 manage_custom_field_create.php
  76. +1 −1 manage_overview_page.php
  77. +2 −2 manage_plugin_page.php
  78. +2 −2 manage_user_page.php
  79. +6 −6 return_dynamic_filters.php
  80. +1 −1 set_project.php
  81. +13 −13 view_all_inc.php
View
@@ -128,17 +128,23 @@
echo '</ul>';
echo '</div>';
}
+
+$t_force_pw_reset_html = '';
+if( $t_force_pw_reset ) {
+ $t_force_pw_reset_html = ' class="has-required"';
+}
?>
<div id="account-update-div" class="form-container">
<form id="account-update-form" method="post" action="account_update.php">
- <fieldset <?php if( $t_force_pw_reset ) { ?> class="has-required"<?php } ?>>
+ <fieldset <?php echo $t_force_pw_reset_html ?>>
<legend><span><?php echo lang_get( 'edit_account_title' ); ?></span></legend>
<?php echo form_security_field( 'account_update' );
print_account_menu( 'account_page.php' );
- if( !helper_call_custom_function( 'auth_can_change_password', array() ) ) {
- # With LDAP --> ?>
+ if( !helper_call_custom_function( 'auth_can_change_password', array() ) ) {
+ # With LDAP -->
+ ?>
<div class="field-container">
<span class="display-label"><span><?php echo lang_get( 'username' ) ?></span></span>
<span class="input"><span class="field-value"><?php echo string_display_line( $u_username ) ?></span></span>
@@ -149,9 +155,9 @@
<span class="input"><span class="field-value"><?php echo lang_get( 'no_password_change' ) ?></span></span>
<span class="label-style"></span>
</div><?php
- } else {
- # Without LDAP
- $t_show_update_button = true;
+ } else {
+ # Without LDAP
+ $t_show_update_button = true;
?>
<div class="field-container">
<span class="display-label"><span><?php echo lang_get( 'username' ) ?></span></span>
@@ -164,22 +170,22 @@
} else {
?>
<div class="field-container">
- <label for="password" <?php if( $t_force_pw_reset ) { ?> class="required" <?php } ?>><span><?php echo lang_get( 'current_password' ) ?></span></label>
+ <label for="password" <?php echo $t_force_pw_reset_html ?>><span><?php echo lang_get( 'current_password' ) ?></span></label>
<span class="input"><input id="password-current" type="password" name="password_current" size="32" maxlength="<?php echo auth_get_password_max_size(); ?>" /></span>
<span class="label-style"></span>
- </div><?php
- } ?>
+ </div>
+ <?php } ?>
<div class="field-container">
- <label for="password" <?php if( $t_force_pw_reset ) { ?> class="required" <?php } ?>><span><?php echo lang_get( 'password' ) ?></span></label>
+ <label for="password" <?php echo $t_force_pw_reset_html ?>><span><?php echo lang_get( 'password' ) ?></span></label>
<span class="input"><input id="password" type="password" name="password" size="32" maxlength="<?php echo auth_get_password_max_size(); ?>" /></span>
<span class="label-style"></span>
</div>
<div class="field-container">
- <label for="password-confirm" <?php if( $t_force_pw_reset ) { ?> class="required" <?php } ?>><span><?php echo lang_get( 'confirm_password' ) ?></span></label>
+ <label for="password-confirm" <?php echo $t_force_pw_reset_html ?>><span><?php echo lang_get( 'confirm_password' ) ?></span></label>
<span class="input"><input id="password-confirm" type="password" name="password_confirm" size="32" maxlength="<?php echo auth_get_password_max_size(); ?>" /></span>
<span class="label-style"></span>
- </div><?php
- } ?>
+ </div>
+ <?php } ?>
<div class="field-container">
<span class="display-label"><span><?php echo lang_get( 'email' ) ?></span></span>
<span class="input"><?php
View
@@ -230,12 +230,12 @@
</div>
<?php } # end sponsored issues
-$t_query = "SELECT b.id as bug, s.id as sponsor, s.paid, b.project_id, b.fixed_in_version, b.status
- FROM $t_bug_table b, $t_sponsor_table s
- WHERE b.handler_id=" . db_param() . ' AND s.bug_id = b.id ' .
- ( $t_show_all ? '' : 'AND ( b.status < ' . db_param() . ' OR s.paid < ' . SPONSORSHIP_PAID . ')' ) . "
- AND $t_project_clause
- ORDER BY s.paid ASC, b.project_id ASC, b.fixed_in_version ASC, b.status ASC, b.id DESC";
+$t_query = 'SELECT b.id as bug, s.id as sponsor, s.paid, b.project_id, b.fixed_in_version, b.status
+ FROM ' . $t_bug_table . ' b, ' . $t_sponsor_table . ' s
+ WHERE b.handler_id=' . db_param() . ' AND s.bug_id = b.id ' .
+ ( $t_show_all ? '' : 'AND ( b.status < ' . db_param() . ' OR s.paid < ' . SPONSORSHIP_PAID . ')' ) . '
+ AND ' . $t_project_clause . '
+ ORDER BY s.paid ASC, b.project_id ASC, b.fixed_in_version ASC, b.status ASC, b.id DESC';
$t_result = db_query_bound( $t_query, $t_show_all ? array( $t_user ) : array( $t_user , $t_resolved ) );
View
@@ -207,7 +207,7 @@ function print_option_list_from_array( array $p_array, $p_filter_value ) {
$t_project_table = db_get_table( 'project' );
# Get users in db having specific configs
-$t_query = "SELECT DISTINCT user_id FROM $t_config_table WHERE user_id <> " . db_param() ;
+$t_query = 'SELECT DISTINCT user_id FROM ' . $t_config_table . ' WHERE user_id <> ' . db_param() ;
$t_result = db_query_bound( $t_query, array( ALL_USERS ) );
if( $t_filter_user_value != META_FILTER_NONE && $t_filter_user_value != ALL_USERS ) {
# Make sure the filter value exists in the list
@@ -228,11 +228,11 @@ function print_option_list_from_array( array $p_array, $p_filter_value ) {
+ $t_users_list;
# Get projects in db with specific configs
-$t_query = "SELECT DISTINCT project_id, pt.name as project_name
- FROM $t_config_table as ct
- JOIN $t_project_table as pt ON pt.id = ct.project_id
+$t_query = 'SELECT DISTINCT project_id, pt.name as project_name
+ FROM ' . $t_config_table . ' as ct
+ JOIN ' . $t_project_table . ' as pt ON pt.id = ct.project_id
WHERE project_id!=0
- ORDER BY project_name";
+ ORDER BY project_name';
$t_result = db_query_bound( $t_query );
$t_projects_list[META_FILTER_NONE] = '[' . lang_get( 'any' ) . ']';
$t_projects_list[ALL_PROJECTS] = lang_get( 'all_projects' );
@@ -242,7 +242,7 @@ function print_option_list_from_array( array $p_array, $p_filter_value ) {
}
# Get config list used in db
-$t_query = "SELECT DISTINCT config_id FROM $t_config_table ORDER BY config_id";
+$t_query = 'SELECT DISTINCT config_id FROM ' . $t_config_table . ' ORDER BY config_id';
$t_result = db_query_bound( $t_query );
$t_configs_list[META_FILTER_NONE] = '[' . lang_get( 'any' ) . ']';
if( $t_filter_config_value != META_FILTER_NONE ) {
@@ -273,10 +273,8 @@ function print_option_list_from_array( array $p_array, $p_filter_value ) {
$t_where = ' WHERE 1=1 ' . $t_where;
}
-$t_query = "SELECT config_id, user_id, project_id, type, value, access_reqd
- FROM $t_config_table
- $t_where
- ORDER BY user_id, project_id, config_id ";
+$t_query = 'SELECT config_id, user_id, project_id, type, value, access_reqd
+ FROM ' . $t_config_table . $t_where . ' ORDER BY user_id, project_id, config_id ';
$t_result = db_query_bound( $t_query, $t_param );
?>
View
@@ -169,7 +169,7 @@ function process_complex_value( $p_value, $p_trimquotes = false ) {
# It's an array - process each element
$t_processed = array();
- if( preg_match_all( "/$s_regex_element/", $t_match[1], $t_elements ) ) {
+ if( preg_match_all( '/' . $s_regex_element . '/', $t_match[1], $t_elements ) ) {
foreach( $t_elements[0] as $t_key => $t_element ) {
if( !trim( $t_element ) ) {
# Empty element - skip it
View
@@ -124,7 +124,7 @@ function check_print_error_rows() {
$t_error_description = htmlentities( $t_error['error'] );
}
echo "\t<tr>\n\t\t<td colspan=\"2\" class=\"error\">";
- echo "<strong>$t_error_type:</strong> $t_error_description<br />";
+ echo '<strong>' . $t_error_type . ':</strong> ' . $t_error_description . '<br />';
echo '<em>Raised in file ' . htmlentities( $t_error['file'] ) . ' on line ' . htmlentities( $t_error['line'] ) . '</em>';
echo "</td>\n\t</tr>\n";
}
@@ -157,8 +157,10 @@ function check_print_info_row( $p_description, $p_info = null ) {
if( !$g_show_all ) {
return;
}
- echo "\t<tr>\n\t\t<td class=\"description$g_alternate_row\">$p_description</td>\n";
- echo "\t\t<td class=\"info$g_alternate_row\">$p_info</td>\n\t</tr>\n";
+ echo "\t" . '<tr>' . "\n\t\t";
+ echo '<td class="description' . $g_alternate_row . '">' . $p_description . '</td>' . "\n";
+ echo "\t\t" . '<td class="info' . $g_alternate_row . '">' . $p_info . '</td>' . "\n";
+ echo "\t" . '</tr>' . "\n";
$g_alternate_row = $g_alternate_row === 1 ? 2 : 1;
}
@@ -171,14 +173,14 @@ function check_print_test_result( $p_result ) {
global $g_alternate_row, $g_failed_test, $g_passed_test_with_warnings;
switch( $p_result ) {
case BAD:
- echo "\t\t<td class=\"fail$g_alternate_row\">FAIL</td>\n";
+ echo "\t\t" . '<td class="fail' . $g_alternate_row . '">FAIL</td>' . "\n";
$g_failed_test = true;
break;
case GOOD:
- echo "\t\t<td class=\"pass$g_alternate_row\">PASS</td>\n";
+ echo "\t\t" . '<td class="pass' . $g_alternate_row . '">PASS</td>' . "\n";
break;
case WARN:
- echo "\t\t<td class=\"warn$g_alternate_row\">WARN</td>\n";
+ echo "\t\t" . '<td class="warn' . $g_alternate_row . '">WARN</td>' . "\n";
$g_passed_test_with_warnings = true;
break;
}
@@ -198,7 +200,7 @@ function check_print_test_row( $p_description, $p_pass, $p_info = null ) {
return $p_pass;
}
- echo "\t<tr>\n\t\t<td class=\"description$g_alternate_row\">$p_description";
+ echo "\t<tr>\n\t\t<td class=\"description" . $g_alternate_row . '\">' . $p_description;
if( $p_info !== null ) {
if( is_array( $p_info ) && isset( $p_info[$p_pass] ) ) {
echo '<br /><em>' . $p_info[$p_pass] . '</em>';
@@ -238,7 +240,7 @@ function check_print_test_warn_row( $p_description, $p_pass, $p_info = null ) {
if( !$g_show_all && $p_pass && !$t_unhandled ) {
return $p_pass;
}
- echo "\t<tr>\n\t\t<td class=\"description$g_alternate_row\">$p_description";
+ echo "\t<tr>\n\t\t<td class=\"description" . $g_alternate_row . '">' . $p_description;
if( $p_info !== null ) {
if( is_array( $p_info ) && isset( $p_info[$p_pass] ) ) {
echo '<br /><em>' . $p_info[$p_pass] . '</em>';
@@ -92,7 +92,7 @@
check_print_test_warn_row( 'Email debugging should be OFF',
empty( $g_debug_email ),
- array( false => "All notification e-mails will be sent to: $g_debug_email" )
+ array( false => 'All notification e-mails will be sent to: ' . $g_debug_email )
);
@@ -192,7 +192,7 @@
array(
true => 'You are using version ' . htmlentities( $t_db_version ) . '.',
false => 'The database version you are using is ' . htmlentities( $t_db_version )
- . ". The minimum requirement for MantisBT on your database platform is $t_db_min_version."
+ . '. The minimum requirement for MantisBT on your database platform is ' . $t_db_min_version . '.'
)
);
@@ -255,7 +255,7 @@
'MySQL version is within the <a href="' . $t_support_url . '">Extended Support</a> period (GA + 8 years)',
date_create( $t_date_extended_end ) > date_create( 'now' ),
array(
- true => "Extended support for MySQL $t_db_major_version series ends on " . $t_date_extended_end,
+ true => 'Extended support for MySQL ' . $t_db_major_version . ' series ends on ' . $t_date_extended_end,
false => 'Support for the release of MySQL you are using ('
. htmlentities( $t_db_version )
. ') ended on ' . $t_date_extended_end
@@ -267,7 +267,7 @@
'Version of MySQL being used is within the <a href="' . $t_support_url . '">Premier Support</a> period (GA + 5 years)',
date_create( $t_date_premier_end ) > date_create( 'now' ),
array(
- true => "Premier support for MySQL $t_db_major_version series ends on " . $t_date_premier_end,
+ true => 'Premier support for MySQL ' . $t_db_major_version . ' series ends on ' . $t_date_premier_end,
false => 'Premier Support for the release of MySQL you are using ('
. htmlentities( $t_db_version )
. ') ended on ' . $t_date_premier_end
@@ -276,10 +276,8 @@
. '. You should upgrade to a newer version of MySQL which is still within its Premier support period to benefit from bug fixes and security patches.'
) );
}
-}
-
-# PostgreSQL support checking
-elseif( db_is_pgsql() ) {
+} else if( db_is_pgsql() ) {
+ # PostgreSQL support checking
# Version support information
$t_versions = array(
@@ -313,7 +311,7 @@
'PostgreSQL version support information availability',
false,
array(
- false => "Release information for version $t_db_major_version is not available. "
+ false => 'Release information for version ' . $t_db_major_version . ' is not available. '
. vsprintf( 'Since it is %s than %s, we assume it is %s. ', $t_assume )
. 'Please refer to the <a href="' . $t_support_url
. '">PostgreSQL release support policy</a> to make sure.'
@@ -382,7 +380,7 @@
$t_result = db_query_bound( 'SHOW TABLE STATUS' );
while( $t_row = db_fetch_array( $t_result ) ) {
if( $t_row[$t_field_comment] !== 'VIEW' &&
- preg_match( "/^$t_table_prefix_regex_safe.+?$t_table_suffix_regex_safe\$/", $t_row[$t_field_name] )
+ preg_match( '/^' . $t_table_prefix_regex_safe . '.+?' . $t_table_suffix_regex_safe . '$/', $t_row[$t_field_name] )
) {
check_print_test_row(
'Table <em>' . htmlentities( $t_row[$t_field_name] ) . '</em> is using UTF-8 collation',
@@ -394,7 +392,7 @@
}
foreach( db_get_table_list() as $t_table ) {
- if( preg_match( "/^$t_table_prefix_regex_safe.+?$t_table_suffix_regex_safe\$/", $t_table ) ) {
+ if( preg_match( '/^' . $t_table_prefix_regex_safe . '.+?' . $t_table_suffix_regex_safe . '$/', $t_table ) ) {
$t_result = db_query_bound( 'SHOW FULL FIELDS FROM ' . $t_table );
while( $t_row = db_fetch_array( $t_result ) ) {
if( $t_row[$t_field_collation] === null ) {
Oops, something went wrong.

3 comments on commit b78f966

Member

atrol replied Jul 14, 2014

In file filter_api.php function print_filter_plugin_field lines 4056 and 4061 $g_filter has to be used instead of $t_filter

Contributor

grangeway replied Jul 14, 2014

Member

atrol replied Jul 15, 2014

I’d love to know how you spotted that when I struggled whilst doing it ;)

PhpStorm found usage of undefined variable

Please sign in to comment.