Unverified Commit 7763be86 by Scott Committed by GitHub

Merge pull request #734 from pupi1985/patch-122

Add data types to PHPDocs
parents 5669d75e 6ca33b27
......@@ -27,9 +27,9 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
/**
* Return the URL which will output $blobid from the database when requested, $absolute or relative
* @param $blobid
* @param string $blobid
* @param bool $absolute
* @return mixed|string
* @return string
*/
function qa_get_blob_url($blobid, $absolute = false)
{
......@@ -41,8 +41,8 @@ function qa_get_blob_url($blobid, $absolute = false)
/**
* Return the full path to the on-disk directory for blob $blobid (subdirectories are named by the first 3 digits of $blobid)
* @param $blobid
* @return mixed|string
* @param string $blobid
* @return string
*/
function qa_get_blob_directory($blobid)
{
......@@ -54,9 +54,9 @@ function qa_get_blob_directory($blobid)
/**
* Return the full page and filename of blob $blobid which is in $format ($format is used as the file name suffix e.g. .jpg)
* @param $blobid
* @param $format
* @return mixed|string
* @param string $blobid
* @param string $format
* @return string
*/
function qa_get_blob_filename($blobid, $format)
{
......@@ -69,13 +69,13 @@ function qa_get_blob_filename($blobid, $format)
/**
* Create a new blob (storing the content in the database or on disk as appropriate) with $content and $format, returning its blobid.
* Pass the original name of the file uploaded in $sourcefilename and the $userid, $cookieid and $ip of the user creating it
* @param $content
* @param $format
* @param $sourcefilename
* @param $userid
* @param $cookieid
* @param $ip
* @return mixed|null|string
* @param string $content
* @param string $format
* @param string|null $sourcefilename
* @param mixed|null $userid
* @param string|null $cookieid
* @param string $ip
* @return string
*/
function qa_create_blob($content, $format, $sourcefilename = null, $userid = null, $cookieid = null, $ip = null)
{
......@@ -97,10 +97,10 @@ function qa_create_blob($content, $format, $sourcefilename = null, $userid = nul
/**
* Write the on-disk file for blob $blobid with $content and $format. Returns true if the write succeeded, false otherwise.
* @param $blobid
* @param $content
* @param $format
* @return bool|mixed
* @param string $blobid
* @param string $content
* @param string $format
* @return bool
*/
function qa_write_blob_file($blobid, $content, $format)
{
......@@ -130,8 +130,8 @@ function qa_write_blob_file($blobid, $content, $format)
/**
* Retrieve blob $blobid from the database, reading the content from disk if appropriate
* @param $blobid
* @return array|mixed|null
* @param string $blobid
* @return array
*/
function qa_read_blob($blobid)
{
......@@ -150,9 +150,9 @@ function qa_read_blob($blobid)
/**
* Read the content of blob $blobid in $format from disk. On failure, it will return false.
* @param $blobid
* @param $format
* @return mixed|null|string
* @param string $blobid
* @param string $format
* @return false|string|null
*/
function qa_read_blob_file($blobid, $format)
{
......@@ -168,7 +168,7 @@ function qa_read_blob_file($blobid, $format)
/**
* Delete blob $blobid from the database, and remove the on-disk file if appropriate
* @param $blobid
* @param string $blobid
* @return mixed
*/
function qa_delete_blob($blobid)
......@@ -190,8 +190,8 @@ function qa_delete_blob($blobid)
/**
* Delete the on-disk file for blob $blobid in $format
* @param $blobid
* @param $format
* @param string $blobid
* @param string $format
* @return mixed
*/
function qa_delete_blob_file($blobid, $format)
......@@ -204,8 +204,8 @@ function qa_delete_blob_file($blobid, $format)
/**
* Check if blob $blobid exists
* @param $blobid
* @return bool|mixed
* @param string $blobid
* @return bool
*/
function qa_blob_exists($blobid)
{
......
......@@ -38,8 +38,8 @@ function qa_captcha_available()
/**
* Return an HTML string explaining $captchareason (from qa_user_captcha_reason()) to the user about why they are seeing a captcha
* @param $captchareason
* @return mixed|null|string
* @param string $captchareason
* @return string|null
*/
function qa_captcha_reason_note($captchareason)
{
......@@ -66,10 +66,10 @@ function qa_captcha_reason_note($captchareason)
/**
* Prepare $qa_content for showing a captcha, adding the element to $fields, given previous $errors, and a $note to display.
* Returns JavaScript required to load CAPTCHA when field is shown by user (e.g. clicking comment button).
* @param $qa_content
* @param $fields
* @param $errors
* @param $note
* @param array $qa_content
* @param array $fields
* @param array $errors
* @param string $note
* @return string
*/
function qa_set_up_captcha_field(&$qa_content, &$fields, $errors, $note = null)
......@@ -105,7 +105,7 @@ function qa_set_up_captcha_field(&$qa_content, &$fields, $errors, $note = null)
/**
* Check if captcha is submitted correctly, and if not, set $errors['captcha'] to a descriptive string.
* @param $errors
* @param array $errors
* @return bool
*/
function qa_captcha_validate_post(&$errors)
......
......@@ -27,6 +27,7 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
/**
* Return the user identification cookie sent by the browser for this page request, or null if none
* @return string|null
*/
function qa_cookie_get()
{
......@@ -39,6 +40,7 @@ function qa_cookie_get()
/**
* Return user identification cookie sent by browser if valid, or create a new one if not.
* Either way, extend for another year (this is used when an anonymous post is created)
* @return string
*/
function qa_cookie_get_create()
{
......@@ -63,8 +65,8 @@ function qa_cookie_get_create()
/**
* Called after a database write $action performed by a user identified by $cookieid,
* relating to $questionid, $answerid and/or $commentid
* @param $cookieid
* @param $action
* @param string $cookieid
* @param string $action
*/
function qa_cookie_report_action($cookieid, $action)
{
......
......@@ -24,6 +24,7 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
exit;
}
use Q2A\Exceptions\FatalErrorException;
use Q2A\Notifications\Email;
use Q2A\Notifications\Mailer;
use Q2A\Notifications\Status as NotifyStatus;
......@@ -44,21 +45,22 @@ function qa_suspend_notifications($suspend = true)
* Send email to person with $userid and/or $email and/or $handle (null/invalid values are ignored or retrieved from
* user database as appropriate). Email uses $subject and $body, after substituting each key in $subs with its
* corresponding value, plus applying some standard substitutions such as ^site_title, ^site_url, ^handle and ^email.
* @param $userid
* @param $email
* @param $handle
* @param $subject
* @param $body
* @param $subs
* @param bool $html
* @return bool
* If notifications are suspended, then a null value is returned.
* @param mixed $userid
* @param string $email
* @param string $handle
* @param string $subject
* @param string $body
* @param array $subs
* @param bool|false $html
* @return bool|null
*/
function qa_send_notification($userid, $email, $handle, $subject, $body, $subs, $html = false)
{
if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }
if (NotifyStatus::isSuspended()) {
return;
return null;
}
if ($userid) {
......@@ -74,8 +76,9 @@ function qa_send_notification($userid, $email, $handle, $subject, $body, $subs,
/**
* Send the email based on the $params array - the following keys are required (some can be empty): fromemail,
* fromname, toemail, toname, subject, body, html
* @param $params
* @param array $params
* @return bool
* @throws phpmailerException
*/
function qa_send_email($params)
{
......
......@@ -33,12 +33,12 @@ require_once QA_INCLUDE_DIR . 'app/updates.php';
* to $lastpostid whose antecedent question is $questionid, and was caused by $lastuserid. Pass a unix $timestamp for
* the event time or leave as null to use now. This will add an event to $questionid's and $lastuserid's streams. If
* $otheruserid is set, it will also add an notification-style event for that user, unless they are the one who did it.
* @param $questionid
* @param $lastpostid
* @param $updatetype
* @param $lastuserid
* @param $otheruserid
* @param $timestamp
* @param int $questionid
* @param int $lastpostid
* @param string $updatetype
* @param mixed $lastuserid
* @param mixed|null $otheruserid
* @param int|null $timestamp
*/
function qa_create_event_for_q_user($questionid, $lastpostid, $updatetype, $lastuserid, $otheruserid = null, $timestamp = null)
{
......@@ -57,11 +57,11 @@ function qa_create_event_for_q_user($questionid, $lastpostid, $updatetype, $last
* being created with those tags or having one of those tags added afterwards). The event of type $updatetype relates
* to the question $questionid, and was caused by $lastuserid. Pass a unix $timestamp for the event time or leave as
* null to use now.
* @param $tagstring
* @param $questionid
* @param $updatetype
* @param $lastuserid
* @param $timestamp
* @param string $tagstring
* @param int $questionid
* @param string $updatetype
* @param mixed $lastuserid
* @param int $timestamp
*/
function qa_create_event_for_tags($tagstring, $questionid, $updatetype, $lastuserid, $timestamp = null)
{
......@@ -80,11 +80,11 @@ function qa_create_event_for_tags($tagstring, $questionid, $updatetype, $lastuse
* that category or being moved to it later on), along with all of its ancestor categories. The event of type
* $updatetype relates to the question $questionid, and was caused by $lastuserid. Pass a unix $timestamp for the event
* time or leave as null to use now.
* @param $categoryid
* @param $questionid
* @param $updatetype
* @param $lastuserid
* @param $timestamp
* @param int|null $categoryid
* @param int $questionid
* @param string $updatetype
* @param mixed $lastuserid
* @param int|null $timestamp
*/
function qa_create_event_for_category($categoryid, $questionid, $updatetype, $lastuserid, $timestamp = null)
{
......
......@@ -84,8 +84,8 @@ function qa_user_favorite_set($userid, $handle, $cookieid, $entitytype, $entityi
/**
* Returns content to set in $qa_content['q_list'] for a user's favorite $questions. Pre-generated
* user HTML in $usershtml.
* @param $questions
* @param $usershtml
* @param array $questions
* @param array $usershtml
* @return array
*/
function qa_favorite_q_list_view($questions, $usershtml)
......@@ -118,8 +118,8 @@ function qa_favorite_q_list_view($questions, $usershtml)
/**
* Returns content to set in $qa_content['ranking_users'] for a user's favorite $users. Pre-generated
* user HTML in $usershtml.
* @param $users
* @param $usershtml
* @param array $users
* @param array $usershtml
* @return array|null
*/
function qa_favorite_users_view($users, $usershtml)
......@@ -154,7 +154,7 @@ function qa_favorite_users_view($users, $usershtml)
/**
* Returns content to set in $qa_content['ranking_tags'] for a user's favorite $tags.
* @param $tags
* @param array $tags
* @return array
*/
function qa_favorite_tags_view($tags)
......@@ -181,7 +181,7 @@ function qa_favorite_tags_view($tags)
/**
* Returns content to set in $qa_content['nav_list_categories'] for a user's favorite $categories.
* @param $categories
* @param array $categories
* @return array
*/
function qa_favorite_categories_view($categories)
......
......@@ -30,8 +30,8 @@ define('QA_PAGE_FLAGS_NEW_WINDOW', 2);
/**
* Return textual representation of $seconds
* @param $seconds
* @return mixed|string
* @param int $seconds
* @return string
*/
function qa_time_to_string($seconds)
{
......@@ -69,9 +69,9 @@ function qa_time_to_string($seconds)
/**
* Check if $post is by user $userid, or if post is anonymous and $userid not specified, then
* check if $post is by the anonymous user identified by $cookieid
* @param $post
* @param $userid
* @param $cookieid
* @param array $post
* @param mixed $userid
* @param string $cookieid
* @return bool
*/
function qa_post_is_by_user($post, $userid, $cookieid)
......@@ -92,7 +92,6 @@ function qa_post_is_by_user($post, $userid, $cookieid)
/**
* Return array which maps the 'userid' and/or 'lastuserid' of each user to its HTML representation.
* For internal user management, corresponding 'handle' and/or 'lasthandle' are required in each element.
*
* @param array $useridhandles User IDs or usernames.
* @param bool $microdata Whether to include microdata.
* @return array The HTML.
......@@ -143,6 +142,7 @@ function qa_userids_handles_html($useridhandles, $microdata = false)
* users tend to favorite many more questions than other things.) The top-level array can contain three keys - 'user' for favorited
* users, 'tag' for tags, 'category' for categories. The next level down has the identifier for each favorited entity in the *key*
* of the array, and true for its value. If no user is logged in the empty array is returned. The result is cached for future calls.
* @return array
*/
function qa_get_favorite_non_qs_map()
{
......@@ -182,7 +182,6 @@ function qa_get_favorite_non_qs_map()
/**
* Convert textual tag to HTML representation, linked to its tag page.
*
* @param string $tag The tag.
* @param bool $microdata Whether to include microdata.
* @param bool $favorited Show the tag as favorited.
......@@ -203,8 +202,8 @@ function qa_tag_html($tag, $microdata = false, $favorited = false)
/**
* Given $navcategories retrieved for $categoryid from the database (using qa_db_category_nav_selectspec(...)),
* return an array of elements from $navcategories for the hierarchy down to $categoryid.
* @param $navcategories
* @param $categoryid
* @param array $navcategories
* @param int $categoryid
* @return array
*/
function qa_category_path($navcategories, $categoryid)
......@@ -221,8 +220,8 @@ function qa_category_path($navcategories, $categoryid)
/**
* Given $navcategories retrieved for $categoryid from the database (using qa_db_category_nav_selectspec(...)),
* return some HTML that shows the category hierarchy down to $categoryid.
* @param $navcategories
* @param $categoryid
* @param array $navcategories
* @param int $categoryid
* @return string
*/
function qa_category_path_html($navcategories, $categoryid)
......@@ -240,8 +239,8 @@ function qa_category_path_html($navcategories, $categoryid)
/**
* Given $navcategories retrieved for $categoryid from the database (using qa_db_category_nav_selectspec(...)),
* return a Q2A request string that represents the category hierarchy down to $categoryid.
* @param $navcategories
* @param $categoryid
* @param array $navcategories
* @param int $categoryid
* @return string
*/
function qa_category_path_request($navcategories, $categoryid)
......@@ -258,8 +257,8 @@ function qa_category_path_request($navcategories, $categoryid)
/**
* Return HTML to use for $ip address, which links to appropriate page with $anchorhtml
* @param $ip
* @param null $anchorhtml
* @param string $ip
* @param string|null $anchorhtml
* @return mixed|string
*/
function qa_ip_anchor_html($ip, $anchorhtml = null)
......@@ -280,11 +279,11 @@ function qa_ip_anchor_html($ip, $anchorhtml = null)
* $dummy is a placeholder (used to be $categories parameter but that's no longer needed)
* $options is an array which sets what is displayed (see qa_post_html_defaults() in /qa-include/app/options.php)
* If something is missing from $post (e.g. ['content']), correponding HTML also omitted.
* @param $post
* @param $userid
* @param $cookieid
* @param $usershtml
* @param $dummy
* @param array $post
* @param mixed $userid
* @param string $cookieid
* @param array $usershtml
* @param null $dummy
* @param array $options
* @return array
*/
......@@ -683,7 +682,6 @@ function qa_post_html_fields($post, $userid, $cookieid, $usershtml, $dummy, $opt
/**
* Generate array of mostly HTML representing a message, to be passed to theme layer.
*
* @param array $message The message object (as retrieved from database).
* @param array $options Viewing options (see qa_message_html_defaults() in /qa-include/app/options.php).
* @return array The HTML.
......@@ -738,9 +736,8 @@ function qa_message_html_fields($message, $options = array())
/**
* Generate array of split HTML (prefix, data, suffix) to represent author of post.
*
* @param bool $isbyuser True if the current user made the post.
* @param int $postuserid The post user's ID.
* @param int|null $postuserid The post user's ID.
* @param array $usershtml Array of HTML representing usernames.
* @param string $ip The post user's IP.
* @param bool|string $microdata Whether to include microdata.
......@@ -776,9 +773,8 @@ function qa_who_to_html($isbyuser, $postuserid, $usershtml, $ip = null, $microda
/**
* Generate array of split HTML (prefix, data, suffix) to represent a timestamp, optionally with the full date.
*
* @param int $timestamp Unix timestamp.
* @param int $fulldatedays Number of days after which to show the full date.
* @param int|null $fulldatedays Number of days after which to show the full date.
* @return array The HTML.
*/
function qa_when_to_html($timestamp, $fulldatedays)
......@@ -815,12 +811,12 @@ function qa_when_to_html($timestamp, $fulldatedays)
* $question, as retrieved from database, with fields prefixed 'o' for the answer, comment or edit.
* $userid, $cookieid, $usershtml, $options are passed through to qa_post_html_fields(). If $question['opersonal']
* is set and true then the item is displayed with its personal relevance to the user (for user updates page).
* @param $question
* @param $userid
* @param $cookieid
* @param $usershtml
* @param $dummy
* @param $options
* @param array $question
* @param mixed $userid
* @param string $cookieid
* @param array $usershtml
* @param null $dummy
* @param array $options
* @return array
*/
function qa_other_to_q_html_fields($question, $userid, $cookieid, $usershtml, $dummy, $options)
......@@ -979,12 +975,12 @@ function qa_other_to_q_html_fields($question, $userid, $cookieid, $usershtml, $d
/**
* Based on the elements in $question, return HTML to be passed to theme layer to link
* to the question, or to an associated answer, comment or edit.
* @param $question
* @param $userid
* @param $cookieid
* @param $usershtml
* @param $dummy
* @param $options
* @param array $question
* @param mixed $userid
* @param string $cookieid
* @param array $usershtml
* @param null $dummy
* @param array $options
* @return array
*/
function qa_any_to_q_html_fields($question, $userid, $cookieid, $usershtml, $dummy, $options)
......@@ -1001,8 +997,8 @@ function qa_any_to_q_html_fields($question, $userid, $cookieid, $usershtml, $dum
/**
* Each element in $questions represents a question and optional associated answer, comment or edit, as retrieved from database.
* Return it sorted by the date appropriate for each element, without removing duplicate references to the same question.
* @param $questions
* @return mixed
* @param array $questions
* @return array
*/
function qa_any_sort_by_date($questions)
{
......@@ -1022,7 +1018,7 @@ function qa_any_sort_by_date($questions)
/**
* Each element in $questions represents a question and optional associated answer, comment or edit, as retrieved from database.
* Return it sorted by the date appropriate for each element, and keep only the first item related to each question.
* @param $questions
* @param array $questions
* @return array
*/
function qa_any_sort_and_dedupe($questions)
......@@ -1079,7 +1075,7 @@ function qa_any_sort_and_dedupe($questions)
/**
* Each element in $questions represents a question and optional associated answer, comment or edit, as retrieved from database.
* Return an array of elements (userid,handle) for the appropriate user for each element.
* @param $questions
* @param array $questions
* @return array
*/
function qa_any_get_userids_handles($questions)
......@@ -1108,7 +1104,7 @@ function qa_any_get_userids_handles($questions)
* Return $html with any URLs converted into links (with nofollow and in a new window if $newwindow).
* Closing parentheses/brackets are removed from the link if they don't have a matching opening one. This avoids creating
* incorrect URLs from (http://www.question2answer.org) but allow URLs such as http://www.wikipedia.org/Computers_(Software)
* @param $html
* @param string $html
* @param bool $newwindow
* @return mixed
*/
......@@ -1160,7 +1156,7 @@ function qa_html_convert_urls($html, $newwindow = false)
/**
* Return HTML representation of $url (if it appears to be an URL), linked with nofollow and in a new window if $newwindow
* @param $url
* @param string $url
* @param bool $newwindow
* @return mixed|string
*/
......@@ -1182,9 +1178,9 @@ function qa_url_to_html_link($url, $newwindow = false)
/**
* Return $htmlmessage with ^1...^6 substituted for links to log in or register or confirm email and come back to $topage with $params
* @param $htmlmessage
* @param null $topage
* @param null $params
* @param string $htmlmessage
* @param string|null $topage
* @param string|null $params
* @return string
*/
function qa_insert_login_links($htmlmessage, $topage = null, $params = null)
......@@ -1214,14 +1210,14 @@ function qa_insert_login_links($htmlmessage, $topage = null, $params = null)
* $start is current offset, there are $pagesize items per page and $count items in total
* (unless $hasmore is true in which case there are at least $count items).
* Show links to $prevnext pages before and after this one and include $params in the URLs.
* @param $request
* @param $start
* @param $pagesize
* @param $count
* @param $prevnext
* @param string $request
* @param int $start
* @param int $pagesize
* @param int $count
* @param int $prevnext
* @param array $params
* @param bool $hasmore
* @param null $anchor
* @param string|null $anchor
* @return array|null
*/
function qa_html_page_links($request, $start, $pagesize, $count, $prevnext, $params = array(), $hasmore = false, $anchor = null)
......@@ -1286,8 +1282,8 @@ function qa_html_page_links($request, $start, $pagesize, $count, $prevnext, $par
* Return HTML that suggests browsing all questions (in the category specified by $categoryrequest, if
* it's not null) and also popular tags if $usingtags is true
* @param bool $usingtags
* @param null $categoryrequest
* @return mixed|string
* @param string|null $categoryrequest
* @return string
*/
function qa_html_suggest_qs_tags($usingtags = false, $categoryrequest = null)
{
......@@ -1313,8 +1309,8 @@ function qa_html_suggest_qs_tags($usingtags = false, $categoryrequest = null)
/**
* Return HTML that suggest getting things started by asking a question, in $categoryid if not null
* @param null $categoryid
* @return mixed|string
* @param int|null $categoryid
* @return string
*/
function qa_html_suggest_ask($categoryid = null)
{
......@@ -1336,12 +1332,12 @@ function qa_html_suggest_ask($categoryid = null)
/**
* Return the navigation structure for the category hierarchical menu, with $selectedid selected,
* and links beginning with $pathprefix, and showing question counts if $showqcount
* @param $categories
* @param null $selectedid
* @param array $categories
* @param int|null $selectedid
* @param string $pathprefix
* @param bool $showqcount
* @param null $pathparams
* @return array|mixed
* @param array|null $pathparams
* @return array
*/
function qa_category_navigation($categories, $selectedid = null, $pathprefix = '', $showqcount = true, $pathparams = null)
{
......@@ -1361,14 +1357,14 @@ function qa_category_navigation($categories, $selectedid = null, $pathprefix = '
/**
* Recursion function used by qa_category_navigation(...) to build hierarchical category menu.
* @param $parentcategories
* @param $parentid
* @param $selecteds
* @param $pathprefix
* @param $showqcount
* @param $pathparams
* @param null $favoritemap
* @return array|mixed
* @param array $parentcategories
* @param int|null $parentid
* @param array $selecteds
* @param string $pathprefix
* @param bool $showqcount
* @param array $pathparams
* @param array|null $favoritemap
* @return array
*/
function qa_category_navigation_sub($parentcategories, $parentid, $selecteds, $pathprefix, $showqcount, $pathparams, $favoritemap = null)
{
......@@ -1407,6 +1403,7 @@ function qa_category_navigation_sub($parentcategories, $parentid, $selecteds, $p
/**
* Return the sub navigation structure for user listing pages
* @return array|null
*/
function qa_users_sub_navigation()
{
......@@ -1455,8 +1452,8 @@ function qa_users_sub_navigation()
/**
* Return the sub navigation structure for navigating between the different pages relating to a user
* @param $handle
* @param $selected
* @param string $handle
* @param string $selected
* @param bool $ismyuser
* @return array
*/
......@@ -1526,7 +1523,7 @@ function qa_user_sub_navigation($handle, $selected, $ismyuser = false)
/**
* Return the sub navigation structure for private message pages
* @deprecated 1.8.0 This menu is no longer used.
* @param null $selected
* @param string|null $selected
* @return array
*/
function qa_messages_sub_navigation($selected = null)
......@@ -1552,7 +1549,6 @@ function qa_messages_sub_navigation($selected = null)
/**
* Return the sub navigation structure for user account pages.
*
* @deprecated Deprecated from 1.6.3; use `qa_user_sub_navigation()` instead.
*/
function qa_account_sub_navigation()
......@@ -1573,7 +1569,7 @@ function qa_account_sub_navigation()
/**
* Return the url for $page retrieved from the database
* @param $page
* @param array $page
* @return string
*/
function qa_custom_page_url($page)
......@@ -1586,8 +1582,8 @@ function qa_custom_page_url($page)
/**
* Add an element to the $navigation array corresponding to $page retrieved from the database
* @param $navigation
* @param $page
* @param array $navigation
* @param array $page
*/
function qa_navigation_add_page(&$navigation, $page)
{
......@@ -1607,7 +1603,7 @@ function qa_navigation_add_page(&$navigation, $page)
/**
* Convert an admin option for matching into a threshold for the score given by database search
* @param $match
* @param int $match
* @return int
*/
function qa_match_to_min_score($match)
......@@ -1618,7 +1614,6 @@ function qa_match_to_min_score($match)
/**
* Adds JavaScript to the page to handle toggling of form fields based on other fields.
*
* @param array $qa_content Page content array.
* @param array $effects List of rules for element toggling, with the structure:
* array('target1' => 'source1', 'target2' => 'source2', ...)
......@@ -1676,13 +1671,13 @@ function qa_set_display_rules(&$qa_content, $effects)
/**
* Set up $qa_content and $field (with HTML name $fieldname) for tag auto-completion, where
* $exampletags are suggestions and $completetags are simply the most popular ones. Show up to $maxtags.
* @param $qa_content
* @param $field
* @param $fieldname
* @param $tags
* @param $exampletags
* @param $completetags
* @param $maxtags
* @param array $qa_content
* @param array $field
* @param string $fieldname
* @param array $tags
* @param array $exampletags
* @param array $completetags
* @param int $maxtags
*/
function qa_set_up_tag_field(&$qa_content, &$field, $fieldname, $tags, $exampletags, $completetags, $maxtags)
{
......@@ -1716,7 +1711,7 @@ function qa_set_up_tag_field(&$qa_content, &$field, $fieldname, $tags, $examplet
/**
* Get a list of user-entered tags submitted from a field that was created with qa_set_up_tag_field(...)
* @param $fieldname
* @param string $fieldname
* @return array
*/
function qa_get_tags_field_value($fieldname)
......@@ -1738,15 +1733,15 @@ function qa_get_tags_field_value($fieldname)
* If $allownone is true, it will allow selection of no category. If $allownosub is true, it will allow a category to be
* selected without selecting a subcategory within. Set $maxdepth to the maximum depth of category that can be selected
* (or null for no maximum) and $excludecategoryid to a category that should not be included.
* @param $qa_content
* @param $field
* @param $fieldname
* @param $navcategories
* @param $categoryid
* @param $allownone
* @param $allownosub
* @param null $maxdepth
* @param null $excludecategoryid
* @param array $qa_content
* @param array $field
* @param string $fieldname
* @param array $navcategories
* @param int $categoryid
* @param int $allownone
* @param int $allownosub
* @param int|null $maxdepth
* @param int|null $excludecategoryid
*/
function qa_set_up_category_field(&$qa_content, &$field, $fieldname, $navcategories, $categoryid, $allownone, $allownosub, $maxdepth = null, $excludecategoryid = null)
{
......@@ -1834,8 +1829,8 @@ function qa_set_up_category_field(&$qa_content, &$field, $fieldname, $navcategor
/**
* Get the user-entered category id submitted from a field that was created with qa_set_up_category_field(...)
* @param $fieldname
* @return mixed|null
* @param string $fieldname
* @return string|null
*/
function qa_get_category_field_value($fieldname)
{
......@@ -1858,9 +1853,9 @@ function qa_get_category_field_value($fieldname)
/**
* Set up $qa_content and add to $fields to allow the user to enter their name for a post if they are not logged in
* $inname is from previous submission/validation. Pass $fieldprefix to add a prefix to the form field name used.
* @param $qa_content
* @param $fields
* @param $inname
* @param array $qa_content
* @param array $fields
* @param string $inname
* @param string $fieldprefix
*/
function qa_set_up_name_field(&$qa_content, &$fields, $inname, $fieldprefix = '')
......@@ -1878,13 +1873,13 @@ function qa_set_up_name_field(&$qa_content, &$fields, $inname, $fieldprefix = ''
* $basetype is 'Q', 'A' or 'C' for question, answer or comment. $login_email is the email of logged in user,
* or null if this is an anonymous post. $innotify, $inemail and $errors_email are from previous submission/validation.
* Pass $fieldprefix to add a prefix to the form field names and IDs used.
* @param $qa_content
* @param $fields
* @param $basetype
* @param $login_email
* @param $innotify
* @param $inemail
* @param $errors_email
* @param array $qa_content
* @param array $fields
* @param string $basetype
* @param string|null $login_email
* @param string $innotify
* @param string $inemail
* @param string $errors_email
* @param string $fieldprefix
*/
function qa_set_up_notify_fields(&$qa_content, &$fields, $basetype, $login_email, $innotify, $inemail, $errors_email, $fieldprefix = '')
......@@ -1959,10 +1954,10 @@ function qa_get_site_theme()
/**
* Return the initialized class for $theme (or the default if it's gone), passing $template, $content and $request.
* Also applies any registered plugin layers.
* @param $theme
* @param $template
* @param $content
* @param $request
* @param string $theme
* @param string $template
* @param array $content
* @param string $request
* @return qa_html_theme_base
*/
function qa_load_theme_class($theme, $template, $content, $request)
......@@ -2055,9 +2050,9 @@ function qa_load_theme_class($theme, $template, $content, $request)
/**
* Return an instantiation of the appropriate editor module class, given $content in $format
* Pass the preferred module name in $editorname, on return it will contain the name of the module used.
* @param $content string
* @param $format string
* @param $editorname string
* @param string $content
* @param string $format
* @param string $editorname
* @return object
*/
function qa_load_editor($content, $format, &$editorname)
......@@ -2092,7 +2087,7 @@ function qa_load_editor($content, $format, &$editorname)
* $content, $format, $fieldname, $rows and $focusnow are passed through to the module's get_field() method. ($focusnow
* is deprecated as a parameter to get_field() but it's still passed through for old editor modules.) Based on
* $focusnow and $loadnow, also add the editor's load and/or focus scripts to $qa_content's onload handlers.
* @param $editor object
* @param object $editor
* @param array $qa_content
* @param string $content
* @param string $format
......@@ -2100,7 +2095,7 @@ function qa_load_editor($content, $format, &$editorname)
* @param int $rows
* @param bool $focusnow
* @param bool $loadnow
* @return string|array
* @return array
*/
function qa_editor_load_field($editor, &$qa_content, $content, $format, $fieldname, $rows, $focusnow = false, $loadnow = true)
{
......@@ -2192,12 +2187,12 @@ function qa_get_post_title($fieldname)
/**
* Retrieve the POST from an editor module's HTML field named $contentfield, where the editor's name was in HTML field $editorfield
* Assigns the module's output to $incontent and $informat, editor's name in $ineditor, text rendering of content in $intext
* @param $editorfield
* @param $contentfield
* @param $ineditor
* @param $incontent
* @param $informat
* @param $intext
* @param string $editorfield
* @param string $contentfield
* @param string $ineditor
* @param string $incontent
* @param string $informat
* @param string $intext
*/
function qa_get_post_content($editorfield, $contentfield, &$ineditor, &$incontent, &$informat, &$intext)
{
......@@ -2217,8 +2212,8 @@ function qa_get_post_content($editorfield, $contentfield, &$ineditor, &$inconten
/**
* Check if any of the 'content', 'format' or 'text' elements have changed between $oldfields and $fields
* If so, recalculate $fields['text'] based on $fields['content'] and $fields['format']
* @param $fields
* @param $oldfields
* @param array $fields
* @param array $oldfields
*/
function qa_update_post_text(&$fields, $oldfields)
{
......@@ -2234,12 +2229,12 @@ function qa_update_post_text(&$fields, $oldfields)
/**
* Return the <img...> HTML to display avatar $blobid whose stored size is $width and $height
* Constrain the image to $size (width AND height) and pad it to that size if $padding is true
* @param $blobId
* @param $width
* @param $height
* @param $size
* @param string $blobId
* @param int $width
* @param int $height
* @param int $size
* @param bool $padding
* @return null|string
* @return string|null
*/
function qa_get_avatar_blob_html($blobId, $width, $height, $size, $padding = false)
{
......@@ -2277,9 +2272,9 @@ function qa_get_avatar_blob_html($blobId, $width, $height, $size, $padding = fal
/**
* Return the <img...> HTML to display the Gravatar for $email, constrained to $size
* @param $email
* @param $size
* @return mixed|null|string
* @param string $email
* @param int|null $size
* @return string|null
*/
function qa_get_gravatar_html($email, $size)
{
......@@ -2300,9 +2295,9 @@ function qa_get_gravatar_html($email, $size)
/**
* Retrieve the appropriate user title from $pointstitle for a user with $userpoints points, or null if none
* @param $userpoints
* @param $pointstitle
* @return null
* @param int $userpoints
* @param array $pointstitle
* @return string|null
*/
function qa_get_points_title_html($userpoints, $pointstitle)
{
......@@ -2318,9 +2313,9 @@ function qa_get_points_title_html($userpoints, $pointstitle)
/**
* Return an form to add to the $qa_content['notices'] array for displaying a user notice with id $noticeid
* and $content. Pass the raw database information for the notice in $rawnotice.
* @param $noticeid
* @param $content
* @param null $rawnotice
* @param string $noticeid
* @param string $content
* @param array|null $rawnotice
* @return array
*/
function qa_notice_form($noticeid, $content, $rawnotice = null)
......@@ -2341,10 +2336,10 @@ function qa_notice_form($noticeid, $content, $rawnotice = null)
/**
* Return a form to set in $qa_content['favorite'] for the favoriting button for entity $entitytype with $entityid.
* Set $favorite to whether the entity is currently a favorite and a description title for the button in $title.
* @param $entitytype
* @param $entityid
* @param $favorite
* @param $title
* @param string $entitytype
* @param mixed $entityid
* @param bool $favorite
* @param string $title
* @return array
*/
function qa_favorite_form($entitytype, $entityid, $favorite, $title)
......
......@@ -167,7 +167,7 @@ function qa_is_ip_blocked()
/**
* Return an array of the clauses within $blockipstring, each of which can contain hyphens or asterisks
* @param $blockipstring
* @param string $blockipstring
* @return array
*/
function qa_block_ips_explode($blockipstring)
......@@ -216,9 +216,9 @@ function qa_block_ip_match($ip, $blockipclause)
/**
* Check if IP falls between two others.
* @param $ip
* @param $startip
* @param $endip
* @param string $ip
* @param string $startip
* @param string $endip
* @return bool
*/
function qa_ip_between($ip, $startip, $endip)
......@@ -294,7 +294,7 @@ function qa_report_write_action($userid, $cookieid, $action, $questionid, $answe
/**
* Take note for rate limits that a user and/or the requesting IP just performed an action.
* @param int $userid User performing the action.
* @param int|null $userid User performing the action.
* @param string $action One of the QA_LIMIT_* constants defined above.
* @return mixed
*/
......
......@@ -120,10 +120,10 @@ function qa_mailing_perform_step()
/**
* Send a single message from the mailing, to $userid with $handle and $email.
* Pass the user's existing $emailcode if there is one, otherwise a new one will be set up
* @param $userid
* @param $handle
* @param $email
* @param $emailcode
* @param mixed $userid
* @param string $handle
* @param string $email
* @param string $emailcode
* @return bool
*/
function qa_mailing_send_one($userid, $handle, $email, $emailcode)
......@@ -152,6 +152,7 @@ function qa_mailing_send_one($userid, $handle, $email, $emailcode)
/**
* Return a message describing current progress in the mailing
* @return string|null
*/
function qa_mailing_progress_message()
{
......
......@@ -28,10 +28,10 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
/**
* Returns an HTML string describing the reason why user $fromuserid cannot post on the wall of $touserid who has
* user flags $touserflags. If there is no such reason the function returns false.
* @param $fromuserid
* @param $touserid
* @param $touserflags
* @return bool|mixed|string
* @param mixed $fromuserid
* @param mixed $touserid
* @param int $touserflags
* @return bool|string
*/
function qa_wall_error_html($fromuserid, $touserid, $touserflags)
{
......@@ -78,13 +78,13 @@ function qa_wall_error_html($fromuserid, $touserid, $touserflags)
/**
* Adds a post to the wall of user $touserid with handle $tohandle, containing $content in $format (e.g. '' for text or 'html')
* The post is by user $userid with handle $handle, and $cookieid is the user's current cookie (used for reporting the event).
* @param $userid
* @param $handle
* @param $cookieid
* @param $touserid
* @param $tohandle
* @param $content
* @param $format
* @param mixed $userid
* @param string $handle
* @param string $cookieid
* @param mixed $touserid
* @param string $tohandle
* @param string $content
* @param string $format
* @return mixed
*/
function qa_wall_add_post($userid, $handle, $cookieid, $touserid, $tohandle, $content, $format)
......@@ -113,10 +113,10 @@ function qa_wall_add_post($userid, $handle, $cookieid, $touserid, $tohandle, $co
/**
* Deletes the wall post described in $message (as obtained via qa_db_recent_messages_selectspec()). The deletion was performed
* by user $userid with handle $handle, and $cookieid is the user's current cookie (all used for reporting the event).
* @param $userid
* @param $handle
* @param $cookieid
* @param $message
* @param mixed $userid
* @param string $handle
* @param string $cookieid
* @param array $message
*/
function qa_wall_delete_post($userid, $handle, $cookieid, $message)
{
......@@ -136,9 +136,9 @@ function qa_wall_delete_post($userid, $handle, $cookieid, $message)
* Return the list of messages in $usermessages (as obtained via qa_db_recent_messages_selectspec()) with additional
* fields indicating what actions can be performed on them by the current user. The messages were retrieved beginning
* at offset $start in the database. Currently only 'deleteable' is relevant.
* @param $usermessages
* @param $start
* @return mixed
* @param array $usermessages
* @param int $start
* @return array
*/
function qa_wall_posts_add_rules($usermessages, $start)
{
......@@ -166,7 +166,7 @@ function qa_wall_posts_add_rules($usermessages, $start)
/**
* Returns an element to add to $qa_content['message_list']['messages'] for $message (as obtained via
* qa_db_recent_messages_selectspec() and then qa_wall_posts_add_rules()).
* @param $message
* @param array $message
* @return array
*/
function qa_wall_post_view($message)
......@@ -197,8 +197,8 @@ function qa_wall_post_view($message)
/**
* Returns an element to add to $qa_content['message_list']['messages'] with a link to view all wall posts
* @param $handle
* @param $start
* @param string $handle
* @param int $start
* @return array
*/
function qa_wall_view_more_link($handle, $start)
......@@ -214,11 +214,11 @@ function qa_wall_view_more_link($handle, $start)
* Hides the private message described in $message (as obtained via qa_db_messages_inbox_selectspec() or qa_db_messages_outbox_selectspec()).
* If both sender and receiver have hidden the message, it gets deleted from the database.
* Note: currently no event is reported here, so $handle/$cookieid are unused.
* @param $userid
* @param $handle
* @param $cookieid
* @param $message
* @param $box
* @param mixed $userid
* @param string $handle
* @param string $cookieid
* @param array $message
* @param string $box
*/
function qa_pm_delete($userid, $handle, $cookieid, $message, $box)
{
......
......@@ -43,7 +43,7 @@ define('QA_PERMIT_SUPERS', 0);
/**
* Return an array [name] => [value] of settings for each option in $names.
* If any options are missing from the database, set them to their defaults
* @param $names
* @param array $names
* @return array
*/
function qa_get_options($names)
......@@ -96,8 +96,8 @@ function qa_get_options($names)
/**
* Return the value of option $name if it has already been loaded, otherwise return null
* (used to prevent a database query if it's not essential for us to know the option value)
* @param $name
* @return
* @param string $name
* @return string
*/
function qa_opt_if_loaded($name)
{
......@@ -139,7 +139,7 @@ function qa_preload_options()
/**
* Load the options from the $results of the database selectspecs defined in qa_preload_options()
* @param $results
* @param array $results
* @return mixed
*/
function qa_load_options_results($results)
......@@ -161,8 +161,8 @@ function qa_load_options_results($results)
/**
* Set an option $name to $value (application level) in both cache and database, unless
* $todatabase=false, in which case set it in the cache only
* @param $name
* @param $value
* @param string $name
* @param mixed|null $value
* @param bool $todatabase
* @return mixed
*/
......@@ -181,7 +181,7 @@ function qa_set_option($name, $value, $todatabase = true)
/**
* Reset the options in $names to their defaults
* @param $names
* @param array $names
* @return mixed
*/
function qa_reset_options($names)
......@@ -196,7 +196,7 @@ function qa_reset_options($names)
/**
* Return the default value for option $name
* @param $name
* @param string $name
* @return bool|mixed|string
*/
function qa_default_option($name)
......@@ -561,7 +561,7 @@ function qa_default_site_title()
/**
* Return an array of defaults for the $options parameter passed to qa_post_html_fields() and its ilk for posts of $basetype='Q'/'A'/'C'
* Set $full to true if these posts will be viewed in full, i.e. on a question page rather than a question listing
* @param $basetype
* @param string $basetype
* @param bool $full
* @return array|mixed
*/
......@@ -601,8 +601,8 @@ function qa_post_html_defaults($basetype, $full = false)
* Return an array of options for post $post to pass in the $options parameter to qa_post_html_fields() and its ilk. Preferably,
* call qa_post_html_defaults() previously and pass its output in $defaults, to save excessive recalculation for each item in a
* list. Set $full to true if these posts will be viewed in full, i.e. on a question page rather than a question listing.
* @param $post
* @param $defaults
* @param array $post
* @param array|null $defaults
* @param bool $full
* @return array|mixed|null
*/
......
......@@ -227,8 +227,8 @@ function qa_get_request_content()
/**
* Output the $qa_content via the theme class after doing some pre-processing, mainly relating to Javascript
* @param $qa_content
* Output the $qa_content via the theme class after doing some pre-processing, mainly relating to Javascript
* @param array $qa_content
* @return mixed
*/
function qa_output_content($qa_content)
......@@ -382,7 +382,7 @@ function qa_output_content($qa_content)
/**
* Update any statistics required by the fields in $qa_content, and return true if something was done
* @param $qa_content
* @param array $qa_content
* @return bool
*/
function qa_do_content_stats($qa_content)
......@@ -487,7 +487,7 @@ function qa_controller_routing()
/**
* Sets the template which should be passed to the theme class, telling it which type of page it's displaying
* @param $template
* @param string $template
*/
function qa_set_template($template)
{
......
......@@ -33,10 +33,10 @@ require_once QA_INCLUDE_DIR . 'util/string.php';
/**
* Return value to store in database combining $notify and $email values entered by user $userid (or null for anonymous)
* @param $userid
* @param $notify
* @param $email
* @return null|string
* @param mixed $userid
* @param bool $notify
* @param string $email
* @return string|null
*/
function qa_combine_notify_email($userid, $notify, $email)
{
......@@ -48,22 +48,22 @@ function qa_combine_notify_email($userid, $notify, $email)
* Add a question (application level) - create record, update appropriate counts, index it, send notifications.
* If question is follow-on from an answer, $followanswer should contain answer database record, otherwise null.
* See /qa-include/app/posts.php for a higher-level function which is easier to use.
* @param $followanswer
* @param $userid
* @param $handle
* @param $cookieid
* @param $title
* @param $content
* @param $format
* @param $text
* @param $tagstring
* @param $notify
* @param $email
* @param $categoryid
* @param $extravalue
* @param array $followanswer
* @param mixed $userid
* @param string $handle
* @param string $cookieid
* @param string $title
* @param string $content
* @param string $format
* @param string $text
* @param string $tagstring
* @param bool $notify
* @param string $email
* @param int|null $categoryid
* @param string|null $extravalue
* @param bool $queued
* @param $name
* @return mixed
* @param string|null $name
* @return int
*/
function qa_question_create($followanswer, $userid, $handle, $cookieid, $title, $content, $format, $text, $tagstring, $notify, $email,
$categoryid = null, $extravalue = null, $queued = false, $name = null)
......@@ -113,7 +113,7 @@ function qa_question_create($followanswer, $userid, $handle, $cookieid, $title,
/**
* Perform various common cached count updating operations to reflect changes in the question whose id is $postid
* @param $postid
* @param int|null $postid
*/
function qa_update_counts_for_q($postid)
{
......@@ -130,8 +130,8 @@ function qa_update_counts_for_q($postid)
/**
* Return an array containing the elements of $inarray whose key is in $keys
* @param $inarray
* @param $keys
* @param array $inarray
* @param array $keys
* @return array
*/
function qa_array_filter_by_keys($inarray, $keys)
......@@ -163,16 +163,16 @@ function qa_suspend_post_indexing($suspend = true)
/**
* Add post $postid (which comes under $questionid) of $type (Q/A/C) to the database index, with $title, $text,
* $tagstring and $categoryid. Calls through to all installed search modules.
* @param $postid
* @param $type
* @param $questionid
* @param $parentid
* @param $title
* @param $content
* @param $format
* @param $text
* @param $tagstring
* @param $categoryid
* @param int $postid
* @param string $type
* @param int $questionid
* @param int $parentid
* @param string $title
* @param string $content
* @param string $format
* @param string $text
* @param string $tagstring
* @param int $categoryid
*/
function qa_post_index($postid, $type, $questionid, $parentid, $title, $content, $format, $text, $tagstring, $categoryid)
{
......@@ -193,18 +193,18 @@ function qa_post_index($postid, $type, $questionid, $parentid, $title, $content,
* Add an answer (application level) - create record, update appropriate counts, index it, send notifications.
* $question should contain database record for the question this is an answer to.
* See /qa-include/app/posts.php for a higher-level function which is easier to use.
* @param $userid
* @param $handle
* @param $cookieid
* @param $content
* @param $format
* @param $text
* @param $notify
* @param $email
* @param $question
* @param mixed $userid
* @param string $handle
* @param string $cookieid
* @param string $content
* @param string $format
* @param string $text
* @param bool $notify
* @param string $email
* @param array $question
* @param bool $queued
* @param $name
* @return mixed
* @param string|null $name
* @return int
*/
function qa_answer_create($userid, $handle, $cookieid, $content, $format, $text, $notify, $email, $question, $queued = false, $name = null)
{
......@@ -244,7 +244,7 @@ function qa_answer_create($userid, $handle, $cookieid, $content, $format, $text,
/**
* Perform various common cached count updating operations to reflect changes in an answer of question $questionid
* @param $questionid
* @param int $questionid
*/
function qa_update_q_counts_for_a($questionid)
{
......@@ -263,20 +263,20 @@ function qa_update_q_counts_for_a($questionid)
* $commentsfollows should contain database records for all previous comments on the same question or answer,
* but it can also contain other records that are ignored.
* See /qa-include/app/posts.php for a higher-level function which is easier to use.
* @param $userid
* @param $handle
* @param $cookieid
* @param $content
* @param $format
* @param $text
* @param $notify
* @param $email
* @param $question
* @param $parent
* @param $commentsfollows
* @param mixed $userid
* @param string $handle
* @param string $cookieid
* @param string $content
* @param string $format
* @param string $text
* @param bool $notify
* @param string $email
* @param array $question
* @param array $parent
* @param array $commentsfollows
* @param bool $queued
* @param $name
* @return mixed
* @param string|null $name
* @return int
*/
function qa_comment_create($userid, $handle, $cookieid, $content, $format, $text, $notify, $email, $question, $parent, $commentsfollows, $queued = false, $name = null)
{
......
......@@ -44,18 +44,18 @@ define('QA_POST_STATUS_QUEUED', 2);
* $userid, $handle and $cookieid. Set $remoderate to true if the question should be requeued for moderation if
* modified. Set $silent to true to not mark the question as edited. Reports event as appropriate. See /qa-include/app/posts.php
* for a higher-level function which is easier to use.
* @param $oldquestion
* @param $title
* @param $content
* @param $format
* @param $text
* @param $tagstring
* @param $notify
* @param $userid
* @param $handle
* @param $cookieid
* @param $extravalue
* @param $name
* @param array $oldquestion
* @param string $title
* @param string $content
* @param string $format
* @param string $text
* @param string $tagstring
* @param bool $notify
* @param mixed $userid
* @param string $handle
* @param string $cookieid
* @param string|null $extravalue
* @param string|null $name
* @param bool $remoderate
* @param bool $silent
*/
......@@ -144,12 +144,12 @@ function qa_question_set_content($oldquestion, $title, $content, $format, $text,
* in $userid, $handle and $cookieid, and the database records for the selected and deselected answers in $answers.
* Handles user points values and notifications.
* See /qa-include/app/posts.php for a higher-level function which is easier to use.
* @param $userid
* @param $handle
* @param $cookieid
* @param $oldquestion
* @param $selchildid
* @param $answers
* @param mixed $userid
* @param string $handle
* @param string $cookieid
* @param array $oldquestion
* @param int|null $selchildid
* @param array $answers
*/
function qa_question_set_selchildid($userid, $handle, $cookieid, $oldquestion, $selchildid, $answers)
{
......@@ -209,11 +209,11 @@ function qa_question_set_selchildid($userid, $handle, $cookieid, $oldquestion, $
* Reopen $oldquestion if it was closed. Pass details of the user doing this in $userid, $handle and $cookieid, and the
* $oldclosepost (to match $oldquestion['closedbyid']) if any.
* See /qa-include/app/posts.php for a higher-level function which is easier to use.
* @param $oldquestion
* @param $oldclosepost
* @param $userid
* @param $handle
* @param $cookieid
* @param array $oldquestion
* @param array|null $oldclosepost
* @param mixed $userid
* @param string $handle
* @param string $cookieid
*/
function qa_question_close_clear($oldquestion, $oldclosepost, $userid, $handle, $cookieid)
{
......@@ -237,12 +237,12 @@ function qa_question_close_clear($oldquestion, $oldclosepost, $userid, $handle,
* Close $oldquestion as a duplicate of the question with id $originalpostid. Pass details of the user doing this in
* $userid, $handle and $cookieid, and the $oldclosepost (to match $oldquestion['closedbyid']) if any. See
* /qa-include/app/posts.php for a higher-level function which is easier to use.
* @param $oldquestion
* @param $oldclosepost
* @param $originalpostid
* @param $userid
* @param $handle
* @param $cookieid
* @param array $oldquestion
* @param array $oldclosepost
* @param int $originalpostid
* @param mixed $userid
* @param string $handle
* @param string $cookieid
*/
function qa_question_close_duplicate($oldquestion, $oldclosepost, $originalpostid, $userid, $handle, $cookieid)
{
......@@ -263,12 +263,12 @@ function qa_question_close_duplicate($oldquestion, $oldclosepost, $originalposti
* Close $oldquestion with the reason given in $note. Pass details of the user doing this in $userid, $handle and
* $cookieid, and the $oldclosepost (to match $oldquestion['closedbyid']) if any.
* See /qa-include/app/posts.php for a higher-level function which is easier to use.
* @param $oldquestion
* @param $oldclosepost
* @param $note
* @param $userid
* @param $handle
* @param $cookieid
* @param array $oldquestion
* @param array $oldclosepost
* @param string $note
* @param mixed $userid
* @param string $handle
* @param string $cookieid
*/
function qa_question_close_other($oldquestion, $oldclosepost, $note, $userid, $handle, $cookieid)
{
......@@ -294,16 +294,17 @@ function qa_question_close_other($oldquestion, $oldclosepost, $note, $userid, $h
/**
* Set $oldquestion to hidden if $hidden is true, visible/normal if otherwise. All other parameters are as for qa_question_set_status(...)
* Set $oldquestion to hidden if $hidden is true, visible/normal if otherwise. All other parameters are as for
* qa_question_set_status(...)
* @deprecated Replaced by qa_question_set_status.
* @param $oldquestion
* @param $hidden
* @param $userid
* @param $handle
* @param $cookieid
* @param $answers
* @param $commentsfollows
* @param $closepost
* @param array $oldquestion
* @param bool $hidden
* @param mixed $userid
* @param string $handle
* @param string $cookieid
* @param array $answers
* @param array $commentsfollows
* @param int|null $closepost
*/
function qa_question_set_hidden($oldquestion, $hidden, $userid, $handle, $cookieid, $answers, $commentsfollows, $closepost = null)
{
......@@ -318,14 +319,14 @@ function qa_question_set_hidden($oldquestion, $hidden, $userid, $handle, $cookie
* $commentsfollows ($commentsfollows can also contain records for follow-on questions which are ignored), and
* $closepost to match $oldquestion['closedbyid'] (if any). Handles indexing, user points, cached counts and event
* reports. See /qa-include/app/posts.php for a higher-level function which is easier to use.
* @param $oldquestion
* @param $status
* @param $userid
* @param $handle
* @param $cookieid
* @param $answers
* @param $commentsfollows
* @param $closepost
* @param array $oldquestion
* @param int $status
* @param mixed $userid
* @param string $handle
* @param string $cookieid
* @param array $answers
* @param array $commentsfollows
* @param array|null $closepost
*/
function qa_question_set_status($oldquestion, $status, $userid, $handle, $cookieid, $answers, $commentsfollows, $closepost = null)
{
......@@ -472,14 +473,14 @@ function qa_question_set_status($oldquestion, $status, $userid, $handle, $cookie
* contain records for follow-on questions which are ignored), and $closepost to match $oldquestion['closedbyid'] (if any).
* Set $silent to true to not mark the question as edited. Handles cached counts and event reports and will reset category
* IDs and paths for all answers and comments. See /qa-include/app/posts.php for a higher-level function which is easier to use.
* @param $oldquestion
* @param $categoryid
* @param $userid
* @param $handle
* @param $cookieid
* @param $answers
* @param $commentsfollows
* @param $closepost
* @param array $oldquestion
* @param int $categoryid
* @param mixed $userid
* @param string $handle
* @param string $cookieid
* @param array $answers
* @param array $commentsfollows
* @param int|null $closepost
* @param bool $silent
*/
function qa_question_set_category($oldquestion, $categoryid, $userid, $handle, $cookieid, $answers, $commentsfollows, $closepost = null, $silent = false)
......@@ -531,11 +532,11 @@ function qa_question_set_category($oldquestion, $categoryid, $userid, $handle, $
* comments on it. Pass details of the user doing this in $userid, $handle and $cookieid, and $closepost to match
* $oldquestion['closedbyid'] (if any). Handles unindexing, votes, points, cached counts and event reports.
* See /qa-include/app/posts.php for a higher-level function which is easier to use.
* @param $oldquestion
* @param $userid
* @param $handle
* @param $cookieid
* @param $oldclosepost
* @param array $oldquestion
* @param mixed $userid
* @param string $handle
* @param string $cookieid
* @param array|null $oldclosepost
*/
function qa_question_delete($oldquestion, $userid, $handle, $cookieid, $oldclosepost = null)
{
......@@ -579,10 +580,10 @@ function qa_question_delete($oldquestion, $userid, $handle, $cookieid, $oldclose
/**
* Set the author (application level) of $oldquestion to $userid and also pass $handle and $cookieid
* of user. Updates points and reports events as appropriate.
* @param $oldquestion
* @param $userid
* @param $handle
* @param $cookieid
* @param array $oldquestion
* @param mixed $userid
* @param string $handle
* @param string $cookieid
*/
function qa_question_set_userid($oldquestion, $userid, $handle, $cookieid)
{
......@@ -606,7 +607,7 @@ function qa_question_set_userid($oldquestion, $userid, $handle, $cookieid)
/**
* Remove post $postid from our index and update appropriate word counts. Calls through to all search modules.
* @param $postid
* @param int $postid
*/
function qa_post_unindex($postid)
{
......@@ -643,16 +644,16 @@ function qa_question_uncache($questionId)
* $handle and $cookieid. Set $remoderate to true if the question should be requeued for moderation if modified. Set
* $silent to true to not mark the question as edited. Handle indexing and event reports as appropriate. See
* /qa-include/app/posts.php for a higher-level function which is easier to use.
* @param $oldanswer
* @param $content
* @param $format
* @param $text
* @param $notify
* @param $userid
* @param $handle
* @param $cookieid
* @param $question
* @param $name
* @param array $oldanswer
* @param string $content
* @param string $format
* @param string $text
* @param bool $notify
* @param mixed $userid
* @param string $handle
* @param string $cookieid
* @param array $question
* @param string|null $name
* @param bool $remoderate
* @param bool $silent
*/
......@@ -715,13 +716,13 @@ function qa_answer_set_content($oldanswer, $content, $format, $text, $notify, $u
/**
* Set $oldanswer to hidden if $hidden is true, visible/normal if otherwise. All other parameters are as for qa_answer_set_status(...)
* @deprecated Replaced by qa_answer_set_status.
* @param $oldanswer
* @param $hidden
* @param $userid
* @param $handle
* @param $cookieid
* @param $question
* @param $commentsfollows
* @param array $oldanswer
* @param bool $hidden
* @param mixed $userid
* @param string $handle
* @param string $cookieid
* @param array $question
* @param array $commentsfollows
*/
function qa_answer_set_hidden($oldanswer, $hidden, $userid, $handle, $cookieid, $question, $commentsfollows)
{
......@@ -735,13 +736,13 @@ function qa_answer_set_hidden($oldanswer, $hidden, $userid, $handle, $cookieid,
* and the database records for all comments on the answer in $commentsfollows ($commentsfollows can also contain other
* records which are ignored). Handles indexing, user points, cached counts and event reports. See /qa-include/app/posts.php for
* a higher-level function which is easier to use.
* @param $oldanswer
* @param $status
* @param $userid
* @param $handle
* @param $cookieid
* @param $question
* @param $commentsfollows
* @param array $oldanswer
* @param int $status
* @param mixed $userid
* @param string $handle
* @param string $cookieid
* @param array $question
* @param array $commentsfollows
*/
function qa_answer_set_status($oldanswer, $status, $userid, $handle, $cookieid, $question, $commentsfollows)
{
......@@ -860,11 +861,11 @@ function qa_answer_set_status($oldanswer, $status, $userid, $handle, $cookieid,
* follow-on questions. Pass the database record for the question in $question and details of the user doing this
* in $userid, $handle and $cookieid. Handles unindexing, votes, points, cached counts and event reports.
* See /qa-include/app/posts.php for a higher-level function which is easier to use.
* @param $oldanswer
* @param $question
* @param $userid
* @param $handle
* @param $cookieid
* @param array $oldanswer
* @param array $question
* @param mixed $userid
* @param string $handle
* @param string $cookieid
*/
function qa_answer_delete($oldanswer, $question, $userid, $handle, $cookieid)
{
......@@ -908,10 +909,10 @@ function qa_answer_delete($oldanswer, $question, $userid, $handle, $cookieid)
/**
* Set the author (application level) of $oldanswer to $userid and also pass $handle and $cookieid
* of user. Updates points and reports events as appropriate.
* @param $oldanswer
* @param $userid
* @param $handle
* @param $cookieid
* @param array $oldanswer
* @param mixed $userid
* @param string $handle
* @param string $cookieid
*/
function qa_answer_set_userid($oldanswer, $userid, $handle, $cookieid)
{
......@@ -942,17 +943,17 @@ function qa_answer_set_userid($oldanswer, $userid, $handle, $cookieid)
* otherwise null. Set $remoderate to true if the question should be requeued for moderation if modified. Set $silent
* to true to not mark the question as edited. Handles unindexing and event reports. See /qa-include/app/posts.php for a
* higher-level function which is easier to use.
* @param $oldcomment
* @param $content
* @param $format
* @param $text
* @param $notify
* @param $userid
* @param $handle
* @param $cookieid
* @param $question
* @param $parent
* @param $name
* @param array $oldcomment
* @param string $content
* @param string $format
* @param string $text
* @param bool $notify
* @param mixed $userid
* @param string $handle
* @param string $cookieid
* @param array $question
* @param array $parent
* @param string|null $name
* @param bool $remoderate
* @param bool $silent
*/
......@@ -1018,19 +1019,19 @@ function qa_comment_set_content($oldcomment, $content, $format, $text, $notify,
* $commentsfollows ($commentsfollows can also contain other records which are ignored). Set $remoderate to true if the
* question should be requeued for moderation if modified. Set $silent to true to not mark the question as edited.
* Handles indexing (based on $text), user points, cached counts and event reports.
* @param $oldanswer
* @param $parentid
* @param $content
* @param $format
* @param $text
* @param $notify
* @param $userid
* @param $handle
* @param $cookieid
* @param $question
* @param $answers
* @param $commentsfollows
* @param $name
* @param array $oldanswer
* @param int $parentid
* @param string $content
* @param string $format
* @param string $text
* @param bool $notify
* @param mixed $userid
* @param string $handle
* @param string $cookieid
* @param array $question
* @param array $answers
* @param array $commentsfollows
* @param string|null $name
* @param bool $remoderate
* @param bool $silent
*/
......@@ -1116,13 +1117,13 @@ function qa_answer_to_comment($oldanswer, $parentid, $content, $format, $text, $
/**
* Set $oldcomment to hidden if $hidden is true, visible/normal if otherwise. All other parameters are as for qa_comment_set_status(...)
* @deprecated Replaced by qa_comment_set_status.
* @param $oldcomment
* @param $hidden
* @param $userid
* @param $handle
* @param $cookieid
* @param $question
* @param $parent
* @param array $oldcomment
* @param bool $hidden
* @param mixed $userid
* @param string $handle
* @param string $cookieid
* @param array $question
* @param array $parent
*/
function qa_comment_set_hidden($oldcomment, $hidden, $userid, $handle, $cookieid, $question, $parent)
{
......@@ -1135,13 +1136,13 @@ function qa_comment_set_hidden($oldcomment, $hidden, $userid, $handle, $cookieid
* antecedent question's record in $question, details of the user doing this in $userid, $handle and $cookieid, and the
* answer's database record in $answer if this is a comment on an answer, otherwise null. Handles indexing, user
* points, cached counts and event reports. See /qa-include/app/posts.php for a higher-level function which is easier to use.
* @param $oldcomment
* @param $status
* @param $userid
* @param $handle
* @param $cookieid
* @param $question
* @param $parent
* @param array $oldcomment
* @param int $status
* @param mixed $userid
* @param string $handle
* @param string $cookieid
* @param array $question
* @param array $parent
*/
function qa_comment_set_status($oldcomment, $status, $userid, $handle, $cookieid, $question, $parent)
{
......@@ -1261,12 +1262,12 @@ function qa_comment_set_status($oldcomment, $status, $userid, $handle, $cookieid
* and the answer's database record in $answer if this is a comment on an answer, otherwise null. Pass details of the user
* doing this in $userid, $handle and $cookieid. Handles unindexing, points, cached counts and event reports.
* See /qa-include/app/posts.php for a higher-level function which is easier to use.
* @param $oldcomment
* @param $question
* @param $parent
* @param $userid
* @param $handle
* @param $cookieid
* @param array $oldcomment
* @param array $question
* @param array $parent
* @param mixed $userid
* @param string $handle
* @param string $cookieid
*/
function qa_comment_delete($oldcomment, $question, $parent, $userid, $handle, $cookieid)
{
......@@ -1299,10 +1300,10 @@ function qa_comment_delete($oldcomment, $question, $parent, $userid, $handle, $c
/**
* Set the author (application level) of $oldcomment to $userid and also pass $handle and $cookieid
* of user. Updates points and reports events as appropriate.
* @param $oldcomment
* @param $userid
* @param $handle
* @param $cookieid
* @param array $oldcomment
* @param mixed $userid
* @param string $handle
* @param string $cookieid
*/
function qa_comment_set_userid($oldcomment, $userid, $handle, $cookieid)
{
......
......@@ -49,18 +49,18 @@ require_once QA_INCLUDE_DIR . 'util/string.php';
* post - either to $email if it is specified and valid, or to the current email address of $userid if $email is '@'.
* If you're creating a question, the $extravalue parameter will be set as the custom extra field, if not null. For all
* post types you can specify the $name of the post's author, which is relevant if the $userid is null.
* @param $type
* @param $parentid
* @param $title
* @param $content
* @param string $type
* @param int|null $parentid
* @param string $title
* @param string $content
* @param string $format
* @param $categoryid
* @param $tags
* @param $userid
* @param $notify
* @param $email
* @param $extravalue
* @param $name
* @param int|null $categoryid
* @param array|null $tags
* @param mixed|null $userid
* @param string|null $notify
* @param string|null $email
* @param string|null $extravalue
* @param string|null $name
* @return mixed
*/
function qa_post_create($type, $parentid, $title, $content, $format = '', $categoryid = null, $tags = null, $userid = null,
......@@ -105,16 +105,16 @@ function qa_post_create($type, $parentid, $title, $content, $format = '', $categ
* Change the data stored for post $postid based on any of the $title, $content, $format, $tags, $notify, $email,
* $extravalue and $name parameters passed which are not null. The meaning of these parameters is the same as for
* qa_post_create() above. Pass the identify of the user making this change in $byuserid (or null for silent).
* @param $postid
* @param $title
* @param $content
* @param $format
* @param $tags
* @param $notify
* @param $email
* @param $byuserid
* @param $extravalue
* @param $name
* @param int $postid
* @param string|null $title
* @param string|null $content
* @param string $format
* @param array|null $tags
* @param string|null $notify
* @param string|null $email
* @param mixed|null $byuserid
* @param string|null $extravalue
* @param string $name
*/
function qa_post_set_content($postid, $title, $content, $format = null, $tags = null, $notify = null, $email = null, $byuserid = null, $extravalue = null, $name = null)
{
......@@ -166,9 +166,9 @@ function qa_post_set_content($postid, $title, $content, $format = null, $tags =
* Change the category of $postid to $categoryid. The category of all related posts (shown together on the same
* question page) will also be changed. Pass the identify of the user making this change in $byuserid (or null for an
* anonymous change).
* @param $postid
* @param $categoryid
* @param $byuserid
* @param int $postid
* @param int $categoryid
* @param mixed|null $byuserid
*/
function qa_post_set_category($postid, $categoryid, $byuserid = null)
{
......@@ -189,9 +189,9 @@ function qa_post_set_category($postid, $categoryid, $byuserid = null)
/**
* Set the selected best answer of $questionid to $answerid (or to none if $answerid is null). Pass the identify of the
* user in $byuserid (or null for an anonymous change).
* @param $questionid
* @param $answerid
* @param $byuserid
* @param int $questionid
* @param int|null $answerid
* @param mixed|null $byuserid
*/
function qa_post_set_selchildid($questionid, $answerid, $byuserid = null)
{
......@@ -210,11 +210,11 @@ function qa_post_set_selchildid($questionid, $answerid, $byuserid = null)
* Close $questionid if $closed is true, otherwise reopen it. If $closed is true, pass either the $originalpostid of
* the question that it is a duplicate of, or a $note to explain why it's closed. Pass the identifier of the user in
* $byuserid (or null for an anonymous change).
* @param $questionid
* @param int $questionid
* @param bool $closed
* @param $originalpostid
* @param $note
* @param $byuserid
* @param int|null $originalpostid
* @param string|null $note
* @param mixed|null $byuserid
*/
function qa_post_set_closed($questionid, $closed = true, $originalpostid = null, $note = null, $byuserid = null)
{
......@@ -251,9 +251,9 @@ function qa_post_is_closed(array $question)
* Hide $postid if $hidden is true, otherwise show the post. Pass the identify of the user making this change in
* $byuserid (or null for a silent change).
* @deprecated Replaced by qa_post_set_status.
* @param $postid
* @param int $postid
* @param bool $hidden
* @param $byuserid
* @param mixed|null $byuserid
*/
function qa_post_set_hidden($postid, $hidden = true, $byuserid = null)
{
......@@ -264,9 +264,9 @@ function qa_post_set_hidden($postid, $hidden = true, $byuserid = null)
/**
* Change the status of $postid to $status, which should be one of the QA_POST_STATUS_* constants defined in
* /qa-include/app/post-update.php. Pass the identify of the user making this change in $byuserid (or null for a silent change).
* @param $postid
* @param $status
* @param $byuserid
* @param int $postid
* @param int $status
* @param mixed|null $byuserid
*/
function qa_post_set_status($postid, $status, $byuserid = null)
{
......@@ -298,8 +298,8 @@ function qa_post_set_status($postid, $status, $byuserid = null)
/**
* Set the created date of $postid to $created, which is a unix timestamp.
* @param $postid
* @param $created
* @param int $postid
* @param int $created
*/
function qa_post_set_created($postid, $created)
{
......@@ -321,7 +321,7 @@ function qa_post_set_created($postid, $created)
/**
* Delete $postid from the database, hiding it first if appropriate.
* @param $postid
* @param int $postid
*/
function qa_post_delete($postid)
{
......@@ -365,9 +365,9 @@ function qa_post_delete($postid)
/**
* Return the full information from the database for $postid in an array.
* @param $postid
* @param $requiredbasetypes
* @return array|mixed
* @param int $postid
* @param string|null $requiredbasetypes
* @return array
*/
function qa_post_get_full($postid, $requiredbasetypes = null)
{
......@@ -387,8 +387,8 @@ function qa_post_get_full($postid, $requiredbasetypes = null)
* Return the handle corresponding to $userid, unless it is null in which case return null.
*
* @deprecated Deprecated from 1.7; use `qa_userid_to_handle($userid)` instead.
* @param $userid
* @return mixed|null
* @param mixed $userid
* @return string|null
*/
function qa_post_userid_to_handle($userid)
{
......@@ -398,8 +398,8 @@ function qa_post_userid_to_handle($userid)
/**
* Return the textual rendition of $content in $format (used for indexing).
* @param $content
* @param $format
* @param string $content
* @param string $format
* @return string
*/
function qa_post_content_to_text($content, $format)
......@@ -415,8 +415,8 @@ function qa_post_content_to_text($content, $format)
/**
* Return tagstring to store in the database based on $tags as an array or a comma-separated string.
* @param $tags
* @return mixed|string
* @param array|string $tags
* @return string
*/
function qa_post_tags_to_tagstring($tags)
{
......@@ -429,7 +429,7 @@ function qa_post_tags_to_tagstring($tags)
/**
* Return the full database records for all answers to question $questionid
* @param $questionid
* @param int $questionid
* @return array
*/
function qa_post_get_question_answers($questionid)
......@@ -449,7 +449,7 @@ function qa_post_get_question_answers($questionid)
/**
* Return the full database records for all comments or follow-on questions for question $questionid or its answers
* @param $questionid
* @param int $questionid
* @return array
*/
function qa_post_get_question_commentsfollows($questionid)
......@@ -477,8 +477,8 @@ function qa_post_get_question_commentsfollows($questionid)
/**
* Return the full database record for the post which closed $questionid, if there is any
* @param $questionid
* @return array|mixed
* @param int $questionid
* @return array|null
*/
function qa_post_get_question_closepost($questionid)
{
......@@ -488,7 +488,7 @@ function qa_post_get_question_closepost($questionid)
/**
* Return the full database records for all comments or follow-on questions for answer $answerid
* @param $answerid
* @param int $answerid
* @return array
*/
function qa_post_get_answer_commentsfollows($answerid)
......@@ -508,8 +508,8 @@ function qa_post_get_answer_commentsfollows($answerid)
/**
* Return $parent if it's the database record for a question, otherwise return the database record for its parent
* @param $parent
* @return array|mixed
* @param array $parent
* @return array
*/
function qa_post_parent_to_question($parent)
{
......
......@@ -37,21 +37,21 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
* page has an RSS feed whose URL uses that prefix. If there are no links to other pages, $suggest
* is used to suggest what the user should do. The $pagelinkparams are passed through to
* qa_html_page_links(...) which creates links for page 2, 3, etc..
* @param $questions
* @param $pagesize
* @param $start
* @param $count
* @param $sometitle
* @param $nonetitle
* @param $navcategories
* @param $categoryid
* @param $categoryqcount
* @param $categorypathprefix
* @param $feedpathprefix
* @param $suggest
* @param $pagelinkparams
* @param $categoryparams
* @param $dummy
* @param array $questions
* @param int|null $pagesize
* @param int $start
* @param int|null $count
* @param string $sometitle
* @param string $nonetitle
* @param array $navcategories
* @param int|null $categoryid
* @param bool $categoryqcount
* @param string|null $categorypathprefix
* @param string|null $feedpathprefix
* @param string $suggest
* @param array|null $pagelinkparams
* @param array|null$categoryparams
* @param null $dummy
* @return array
*/
function qa_q_list_page_content($questions, $pagesize, $start, $count, $sometitle, $nonetitle,
......@@ -153,8 +153,8 @@ function qa_q_list_page_content($questions, $pagesize, $start, $count, $sometitl
/**
* Return the sub navigation structure common to question listing pages
* @param $sort
* @param $categoryslugs
* @param string $sort
* @param array|null $categoryslugs
* @return array
*/
function qa_qs_sub_navigation($sort, $categoryslugs)
......@@ -210,8 +210,8 @@ function qa_qs_sub_navigation($sort, $categoryslugs)
/**
* Return the sub navigation structure common to unanswered pages
* @param $by
* @param $categoryslugs
* @param string $by
* @param array|null $categoryslugs
* @return array
*/
function qa_unanswered_sub_navigation($by, $categoryslugs)
......
......@@ -78,7 +78,7 @@ require_once QA_INCLUDE_DIR . 'app/post-update.php';
/**
* Advance the recalculation operation represented by $state by a single step.
* $state can also be the name of a recalculation operation on its own.
* @param $state
* @param string $state
* @return bool
*/
function qa_recalc_perform_step(&$state)
......@@ -574,8 +574,8 @@ function qa_recalc_perform_step(&$state)
/**
* Change the $state to represent the beginning of a new $operation
* @param $state
* @param $operation
* @param string $state
* @param string $operation
*/
function qa_recalc_transition(&$state, $operation)
{
......@@ -589,7 +589,7 @@ function qa_recalc_transition(&$state, $operation)
/**
* Return how many steps there will be in recalculation $operation
* @param $operation
* @param string $operation
* @return int
*/
function qa_recalc_stage_length($operation)
......@@ -664,11 +664,9 @@ function qa_recalc_stage_length($operation)
/**
* Return the translated language ID string replacing the progress and total in it.
* @access private
* @param string $langId Language string ID that contains 2 placeholders (^1 and ^2)
* @param int $progress Amount of processed elements
* @param int $total Total amount of elements
*
* @return string Returns the language string ID with their placeholders replaced with
* the formatted progress and total numbers
*/
......@@ -683,7 +681,7 @@ function qa_recalc_progress_lang($langId, $progress, $total)
/**
* Return a string which gives a user-viewable version of $state
* @param $state
* @param string $state
* @return string
*/
function qa_recalc_get_message($state)
......
......@@ -30,13 +30,13 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
* to get absolute URLs for the results and $fullcontent if the results should include full post content. This calls
* through to the chosen search module, and performs all the necessary post-processing to supplement the results for
* display online or in an RSS feed.
* @param $query
* @param $start
* @param $count
* @param $userid
* @param $absoluteurls
* @param $fullcontent
* @return
* @param string $query
* @param int $start
* @param int $count
* @param mixed $userid
* @param bool $absoluteurls
* @param bool $fullcontent
* @return array
*/
function qa_get_search_results($query, $start, $count, $userid, $absoluteurls, $fullcontent)
{
......
......@@ -55,12 +55,12 @@ function qa_get_max_upload_size()
* 'height' => if an image, the height in pixels of the blob created (after possible scaling)
* 'blobid' => the blobid that was created (if there was no error)
* 'bloburl' => the url that can be used to view/download the created blob (if there was no error)
* @param $localfilename
* @param $sourcefilename
* @param $maxfilesize
* @param string $localfilename
* @param string $sourcefilename
* @param int|null $maxfilesize
* @param bool $onlyimage
* @param $imagemaxwidth
* @param $imagemaxheight
* @param int|null $imagemaxwidth
* @param int|null $imagemaxheight
* @return array
*/
function qa_upload_file($localfilename, $sourcefilename, $maxfilesize = null, $onlyimage = false, $imagemaxwidth = null, $imagemaxheight = null)
......@@ -197,10 +197,10 @@ function qa_upload_file($localfilename, $sourcefilename, $maxfilesize = null, $o
/**
* In response to a file upload, move the first uploaded file into blob storage. Other parameters are as for qa_upload_file(...)
* @param $maxfilesize
* @param int|null $maxfilesize
* @param bool $onlyimage
* @param $imagemaxwidth
* @param $imagemaxheight
* @param int|null $imagemaxwidth
* @param int|null $imagemaxheight
* @return array
*/
function qa_upload_file_one($maxfilesize = null, $onlyimage = false, $imagemaxwidth = null, $imagemaxheight = null)
......
......@@ -19,6 +19,8 @@
More about this license: http://www.question2answer.org/license.php
*/
use Q2A\Exceptions\FatalErrorException;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
......@@ -39,9 +41,9 @@ if (!defined('QA_NEW_PASSWORD_LEN')){
/**
* Return $errors fields for any invalid aspect of user-entered $handle (username) and $email. Works by calling through
* to all filter modules and also rejects existing values in database unless they belongs to $olduser (if set).
* @param $handle
* @param $email
* @param $olduser
* @param string $handle
* @param string $email
* @param array $olduser
* @return array
*/
function qa_handle_email_filter(&$handle, &$email, $olduser = null)
......@@ -93,7 +95,7 @@ function qa_handle_email_filter(&$handle, &$email, $olduser = null)
/**
* Make $handle valid and unique in the database - if $allowuserid is set, allow it to match that user only
* @param $handle
* @param string $handle
* @return string
*/
function qa_handle_make_valid($handle)
......@@ -139,8 +141,8 @@ function qa_handle_make_valid($handle)
/**
* Return an array with a single element (key 'password') if user-entered $password is valid, otherwise an empty array.
* Works by calling through to all filter modules.
* @param $password
* @param $olduser
* @param string $password
* @param array $olduser
* @return array
*/
function qa_password_validate($password, $olduser = null)
......@@ -171,9 +173,9 @@ function qa_password_validate($password, $olduser = null)
* Create a new user (application level) with $email, $password, $handle and $level.
* Set $confirmed to true if the email address has been confirmed elsewhere.
* Handles user points, notification and optional email confirmation.
* @param $email
* @param $password
* @param $handle
* @param string $email
* @param string|null $password
* @param string $handle
* @param int $level
* @param bool $confirmed
* @return mixed
......@@ -232,7 +234,7 @@ function qa_create_new_user($email, $password, $handle, $level = QA_USER_LEVEL_B
/**
* Delete $userid and all their votes and flags. Their posts will become anonymous.
* Handles recalculations of votes and flags for posts this user has affected.
* @param $userid
* @param mixed $userid
* @return mixed
*/
function qa_delete_user($userid)
......@@ -265,7 +267,7 @@ function qa_delete_user($userid)
/**
* Set a new email confirmation code for the user and send it out
* @param $userid
* @param mixed $userid
* @return mixed
*/
function qa_send_new_confirm($userid)
......@@ -292,10 +294,10 @@ function qa_send_new_confirm($userid)
/**
* Set a new email confirmation code for the user and return the corresponding link. If the email code is also sent then that value
* is used. Otherwise, a new email code is generated
* @param $userid
* @param $handle
* @param $emailcode
* @return mixed|string
* @param mixed $userid
* @param string $handle
* @param string $emailcode
* @return string
*/
function qa_get_new_confirm_url($userid, $handle, $emailcode = null)
{
......@@ -314,9 +316,9 @@ function qa_get_new_confirm_url($userid, $handle, $emailcode = null)
/**
* Complete the email confirmation process for the user
* @param $userid
* @param $email
* @param $handle
* @param mixed $userid
* @param string $email
* @param string $handle
* @return mixed
*/
function qa_complete_confirm($userid, $email, $handle)
......@@ -339,10 +341,10 @@ function qa_complete_confirm($userid, $email, $handle)
/**
* Set the user level of user $userid with $handle to $level (one of the QA_USER_LEVEL_* constraints in /qa-include/app/users.php)
* Pass the previous user level in $oldlevel. Reports the appropriate event, assumes change performed by the logged in user.
* @param $userid
* @param $handle
* @param $level
* @param $oldlevel
* @param mixed $userid
* @param string $handle
* @param int $level
* @param int $oldlevel
*/
function qa_set_user_level($userid, $handle, $level, $oldlevel)
{
......@@ -368,9 +370,9 @@ function qa_set_user_level($userid, $handle, $level, $oldlevel)
/**
* Set the status of user $userid with $handle to blocked if $blocked is true, otherwise to unblocked. Reports the appropriate
* event, assumes change performed by the logged in user.
* @param $userid
* @param $handle
* @param $blocked
* @param mixed $userid
* @param string $handle
* @param string $blocked
*/
function qa_set_user_blocked($userid, $handle, $blocked)
{
......@@ -388,7 +390,7 @@ function qa_set_user_blocked($userid, $handle, $blocked)
/**
* Start the 'I forgot my password' process for $userid, sending reset code
* @param $userid
* @param mixed $userid
* @return mixed
*/
function qa_start_reset_user($userid)
......@@ -415,9 +417,8 @@ function qa_start_reset_user($userid)
/**
* Successfully finish the 'I forgot my password' process for $userid, sending new password
*
* @deprecated This function has been replaced by qa_finish_reset_user since Q2A 1.8
* @param $userid
* @param mixed $userid
* @return mixed
*/
function qa_complete_reset_user($userid)
......@@ -454,7 +455,7 @@ function qa_complete_reset_user($userid)
* Successfully finish the 'I forgot my password' process for $userid, cleaning the emailcode field and logging in the user
* @param mixed $userId The userid identifiying the user who will have the password reset
* @param string $newPassword The new password for the user
* @return void
* @return mixed
*/
function qa_finish_reset_user($userId, $newPassword)
{
......@@ -501,9 +502,9 @@ function qa_logged_in_user_flush()
/**
* Set the avatar of $userid to the image in $imagedata, and remove $oldblobid from the database if not null
* @param $userid
* @param $imagedata
* @param $oldblobid
* @param mixed $userid
* @param string $imagedata
* @param string $oldblobid
* @return bool
*/
function qa_set_user_avatar($userid, $imagedata, $oldblobid = null)
......
......@@ -92,8 +92,8 @@ if (QA_FINAL_EXTERNAL_USERS) {
/**
* Return $field of the currently logged in user, or null if not available
* @param $field
* @return null
* @param string $field
* @return string|null
*/
function qa_get_logged_in_user_field($field)
{
......@@ -131,10 +131,10 @@ if (QA_FINAL_EXTERNAL_USERS) {
/**
* Return HTML to display for the avatar of $userid, constrained to $size pixels, with optional $padding to that size
* @param $userid
* @param $size
* @param mixed $userid
* @param int|null $size
* @param bool $padding
* @return mixed|null|string
* @return string|null
*/
function qa_get_external_avatar_html($userid, $size, $padding = false)
{
......@@ -183,8 +183,8 @@ if (QA_FINAL_EXTERNAL_USERS) {
/**
* Returns a verification code used to ensure that a user session can't be generated by another PHP script running on the same server
* @param $userid
* @return mixed|string
* @param int $userid
* @return string
*/
function qa_session_verify_code($userid)
{
......@@ -197,9 +197,9 @@ if (QA_FINAL_EXTERNAL_USERS) {
/**
* Set cookie in browser for username $handle with $sessioncode (in database).
* Pass true if user checked 'Remember me' (either now or previously, as learned from cookie).
* @param $handle
* @param $sessioncode
* @param $remember
* @param string $handle
* @param string $sessioncode
* @param bool $remember
* @return mixed
*/
function qa_set_session_cookie($handle, $sessioncode, $remember)
......@@ -224,8 +224,8 @@ if (QA_FINAL_EXTERNAL_USERS) {
/**
* Set the session variables to indicate that $userid is logged in from $source
* @param $userid
* @param $source
* @param int $userid
* @param string|null $source
* @return mixed
*/
function qa_set_session_user($userid, $source)
......@@ -259,10 +259,10 @@ if (QA_FINAL_EXTERNAL_USERS) {
/**
* Call for successful log in by $userid and $handle or successful log out with $userid=null.
* $remember states if 'Remember me' was checked in the login form.
* @param $userid
* @param int|null $userid
* @param string $handle
* @param bool $remember
* @param $source
* @param string|null $source
* @return mixed
*/
function qa_set_logged_in_user($userid, $handle = '', $remember = false, $source = null)
......@@ -316,9 +316,9 @@ if (QA_FINAL_EXTERNAL_USERS) {
/**
* Call to log in a user based on an external identity provider $source with external $identifier
* A new user is created based on $fields if it's a new combination of $source and $identifier
* @param $source
* @param $identifier
* @param $fields
* @param string $source
* @param string $identifier
* @param array $fields
* @return mixed
*/
function qa_log_in_external_user($source, $identifier, $fields)
......@@ -483,8 +483,8 @@ if (QA_FINAL_EXTERNAL_USERS) {
/**
* Return $field of the currently logged in user
* @param $field
* @return mixed|null
* @param string $field
* @return string|null
*/
function qa_get_logged_in_user_field($field)
{
......@@ -533,7 +533,7 @@ if (QA_FINAL_EXTERNAL_USERS) {
require_once QA_INCLUDE_DIR . 'util/image.php';
if (strlen($blobId) == 0 || (isset($size) && (int)$size <= 0)) {
if (strlen($blobId) == 0 || (isset($size) && $size <= 0)) {
return null;
}
......@@ -550,7 +550,6 @@ if (QA_FINAL_EXTERNAL_USERS) {
/**
* Get HTML to display a username, linked to their user page.
*
* @param string $handle The username.
* @param bool $microdata Whether to include microdata.
* @param bool $favorited Show the user as favorited.
......@@ -609,13 +608,12 @@ if (QA_FINAL_EXTERNAL_USERS) {
/**
* Return the avatar URL, either Gravatar or from a blob ID, constrained to $size pixels.
*
* @param int $flags The user's flags
* @param string $email The user's email. Only needed to return the Gravatar link
* @param string $blobId The blob ID. Only needed to return the locally stored avatar
* @param int $size The size to constrain the final image
* @param int|null $size The size to constrain the final image
* @param bool $absolute Whether the link returned should be absolute or relative
* @return null|string The URL to the user's avatar or null if none could be found (not even as a default site avatar)
* @return string|null The URL to the user's avatar or null if none could be found (not even as a default site avatar)
*/
function qa_get_user_avatar_url($flags, $email, $blobId, $size = null, $absolute = false)
{
......@@ -638,7 +636,6 @@ if (QA_FINAL_EXTERNAL_USERS) {
/**
* Return HTML to display for the user's avatar, constrained to $size pixels, with optional $padding to that size
*
* @param int $flags The user's flags
* @param string $email The user's email. Only needed to return the Gravatar HTML
* @param string $blobId The blob ID. Only needed to return the locally stored avatar HTML
......@@ -680,7 +677,7 @@ if (QA_FINAL_EXTERNAL_USERS) {
/**
* Return email address for user $userid (if not using single sign-on integration)
* @param $userid
* @param int $userid
* @return string
*/
function qa_get_user_email($userid)
......@@ -693,8 +690,8 @@ if (QA_FINAL_EXTERNAL_USERS) {
/**
* Called after a database write $action performed by a user $userid
* @param $userid
* @param $action
* @param int $userid
* @param string $action
* @return mixed
*/
function qa_user_report_action($userid, $action)
......@@ -709,8 +706,8 @@ if (QA_FINAL_EXTERNAL_USERS) {
/**
* Return textual representation of the user $level
* @param $level
* @return mixed|string
* @param int $level
* @return string
*/
function qa_user_level_string($level)
{
......@@ -737,8 +734,8 @@ if (QA_FINAL_EXTERNAL_USERS) {
/**
* Return an array of links to login, register, email confirm and logout pages (if not using single sign-on integration)
* @param $rooturl
* @param $tourl
* @param string $rooturl
* @param string|null $tourl
* @return array
*/
function qa_get_login_links($rooturl, $tourl)
......@@ -756,6 +753,7 @@ if (QA_FINAL_EXTERNAL_USERS) {
/**
* Return whether someone is logged in at the moment
* @return bool
*/
function qa_is_logged_in()
{
......@@ -766,6 +764,7 @@ function qa_is_logged_in()
/**
* Return displayable handle/username of currently logged in user, or null if none
* @return string
*/
function qa_get_logged_in_handle()
{
......@@ -775,6 +774,7 @@ function qa_get_logged_in_handle()
/**
* Return email of currently logged in user, or null if none
* @return string
*/
function qa_get_logged_in_email()
{
......@@ -784,6 +784,7 @@ function qa_get_logged_in_email()
/**
* Return level of currently logged in user, or null if none
* @return string
*/
function qa_get_logged_in_level()
{
......@@ -793,6 +794,7 @@ function qa_get_logged_in_level()
/**
* Return flags (see QA_USER_FLAGS_*) of currently logged in user, or null if none
* @return string
*/
function qa_get_logged_in_flags()
{
......@@ -805,6 +807,7 @@ function qa_get_logged_in_flags()
/**
* Return an array of all the specific (e.g. per category) level privileges for the logged in user, retrieving from the database if necessary
* @return array
*/
function qa_get_logged_in_levels()
{
......@@ -816,7 +819,7 @@ function qa_get_logged_in_levels()
/**
* Return an array mapping each userid in $userids to that user's handle (public username), or to null if not found
* @param $userids
* @param array $userids
* @return array
*/
function qa_userids_to_handles($userids)
......@@ -839,7 +842,7 @@ function qa_userids_to_handles($userids)
/**
* Return an string mapping the received userid to that user's handle (public username), or to null if not found
* @param $userid
* @param array $userid
* @return mixed|null
*/
function qa_userid_to_handle($userid)
......@@ -853,7 +856,7 @@ function qa_userid_to_handle($userid)
* Return an array mapping each handle in $handles the user's userid, or null if not found. If $exactonly is true then
* $handles must have the correct case and accents. Otherwise, handles are case- and accent-insensitive, and the keys
* of the returned array will match the $handles provided, not necessary those in the DB.
* @param $handles
* @param array $handles
* @param bool $exactonly
* @return array
*/
......@@ -890,7 +893,7 @@ function qa_handles_to_userids($handles, $exactonly = false)
/**
* Return the userid corresponding to $handle (not case- or accent-sensitive)
* @param $handle
* @param string $handle
* @return mixed|null
*/
function qa_handle_to_userid($handle)
......@@ -912,7 +915,7 @@ function qa_handle_to_userid($handle)
/**
* Return the level of the logged in user for a post with $categoryids (expressing the full hierarchy to the final category)
* @param $categoryids
* @param array $categoryids
* @return mixed|null
*/
function qa_user_level_for_categories($categoryids)
......@@ -943,8 +946,8 @@ function qa_user_level_for_categories($categoryids)
/**
* Return the level of the logged in user for $post, as retrieved from the database
* @param $post
* @return mixed|null
* @param array $post
* @return int|null
*/
function qa_user_level_for_post($post)
{
......@@ -959,6 +962,7 @@ function qa_user_level_for_post($post)
/**
* Return the maximum possible level of the logged in user in any context (i.e. for any category)
* @return int
*/
function qa_user_level_maximum()
{
......@@ -978,9 +982,9 @@ function qa_user_level_maximum()
/**
* Check whether the logged in user has permission to perform $permitoption on post $post (from the database)
* Other parameters and the return value are as for qa_user_permit_error(...)
* @param $permitoption
* @param $post
* @param $limitaction
* @param string $permitoption
* @param array $post
* @param string|null $limitaction
* @param bool $checkblocks
* @return bool|string
*/
......@@ -993,8 +997,8 @@ function qa_user_post_permit_error($permitoption, $post, $limitaction = null, $c
/**
* Check whether the logged in user would have permittion to perform $permitoption in any context (i.e. for any category)
* Other parameters and the return value are as for qa_user_permit_error(...)
* @param $permitoption
* @param $limitaction
* @param string $permitoption
* @param string|null $limitaction
* @param bool $checkblocks
* @return bool|string
*/
......@@ -1006,14 +1010,12 @@ function qa_user_maximum_permit_error($permitoption, $limitaction = null, $check
/**
* Check whether the logged in user has permission to perform an action.
*
* @param string $permitoption The permission to check (if null, this simply checks whether the user is blocked).
* @param string $limitaction Constant from /qa-include/app/limits.php to check against user or IP rate limits.
* @param int $userlevel A QA_USER_LEVEL_* constant to consider the user at a different level to usual (e.g. if
* @param string|null $permitoption The permission to check (if null, this simply checks whether the user is blocked).
* @param string|null $limitaction Constant from /qa-include/app/limits.php to check against user or IP rate limits.
* @param int|null $userlevel A QA_USER_LEVEL_* constant to consider the user at a different level to usual (e.g. if
* they are performing this action in a category for which they have elevated privileges).
* @param bool $checkblocks Whether to check the user's blocked status.
* @param array $userfields Cache for logged in user, containing keys 'userid', 'level' (optional), 'flags'.
*
* @param array|null $userfields Cache for logged in user, containing keys 'userid', 'level' (optional), 'flags'.
* @return bool|string The permission error, or false if no error. Possible errors, in order of priority:
* 'login' => the user should login or register
* 'level' => a special privilege level (e.g. expert) or minimum number of points is required
......@@ -1061,13 +1063,11 @@ function qa_user_permit_error($permitoption = null, $limitaction = null, $userle
/**
* Check whether user can perform $permitoption. Result as for qa_user_permit_error(...).
*
* @param string $permitoption Permission option name (from database) for action.
* @param int $userid ID of user (null for no user).
* @param int $userlevel Level to check against.
* @param int $userflags Flags for this user.
* @param int $userpoints User's points: if $userid is currently logged in, you can set $userpoints=null to retrieve them only if necessary.
*
* @param string|null $permitoption Permission option name (from database) for action.
* @param int|null $userid ID of user (null for no user).
* @param int|null $userlevel Level to check against.
* @param int|null $userflags Flags for this user.
* @param int|null $userpoints User's points: if $userid is currently logged in, you can set $userpoints=null to retrieve them only if necessary.
* @return string|bool Reason the user is not permitted, or false if the operation can go ahead.
*/
function qa_permit_error($permitoption, $userid, $userlevel, $userflags, $userpoints = null)
......@@ -1096,12 +1096,10 @@ function qa_permit_error($permitoption, $userid, $userlevel, $userflags, $userpo
/**
* Check whether user can reach the permission level. Result as for qa_user_permit_error(...).
*
* @param int $permit Permission constant.
* @param int $userid ID of user (null for no user).
* @param int $userlevel Level to check against.
* @param int $userflags Flags for this user.
*
* @param int|null $userid ID of user (null for no user).
* @param int|null $userlevel Level to check against.
* @param int|null $userflags Flags for this user.
* @return string|bool Reason the user is not permitted, or false if the operation can go ahead
*/
function qa_permit_value_error($permit, $userid, $userlevel, $userflags)
......@@ -1154,8 +1152,8 @@ function qa_permit_value_error($permit, $userid, $userlevel, $userflags)
* 'approve' => captcha required because the user has not been approved
* 'confirm' => captcha required because the user has not confirmed their email address
* false => captcha is not required
* @param $userlevel
* @return bool|mixed|string
* @param int|null $userlevel
* @return bool|string
*/
function qa_user_captcha_reason($userlevel = null)
{
......@@ -1183,8 +1181,8 @@ function qa_user_captcha_reason($userlevel = null)
/**
* Return whether a captcha should be presented to the logged in user for writing posts. You can pass in a
* QA_USER_LEVEL_* constant in $userlevel to consider the user at a different level to usual.
* @param $userlevel
* @return bool|mixed
* @param int|null $userlevel
* @return bool|string
*/
function qa_user_use_captcha($userlevel = null)
{
......@@ -1205,7 +1203,7 @@ function qa_user_use_captcha($userlevel = null)
* 'confirm' => moderation required because the user has not confirmed their email address
* 'points' => moderation required because the user has insufficient points
* false => moderation is not required
* @param $userlevel
* @param int|null $userlevel
* @return bool|string
*/
function qa_user_moderation_reason($userlevel = null)
......@@ -1238,7 +1236,7 @@ function qa_user_moderation_reason($userlevel = null)
/**
* Return the label to display for $userfield as retrieved from the database, using default if no name set
* @param $userfield
* @param array $userfield
* @return string
*/
function qa_user_userfield_label($userfield)
......@@ -1264,6 +1262,7 @@ function qa_user_userfield_label($userfield)
/**
* Set or extend the cookie in browser of non logged-in users which identifies them for the purposes of form security (anti-CSRF protection)
* @return mixed
*/
function qa_set_form_security_key()
{
......@@ -1287,9 +1286,9 @@ function qa_set_form_security_key()
/**
* Return the form security (anti-CSRF protection) hash for an $action (any string), that can be performed within
* QA_FORM_EXPIRY_SECS of $timestamp (in unix seconds) by the current user.
* @param $action
* @param $timestamp
* @return mixed|string
* @param string $action
* @param int $timestamp
* @return string
*/
function qa_calc_form_security_hash($action, $timestamp)
{
......@@ -1307,8 +1306,8 @@ function qa_calc_form_security_hash($action, $timestamp)
/**
* Return the full form security (anti-CSRF protection) code for an $action (any string) performed within
* QA_FORM_EXPIRY_SECS of now by the current user.
* @param $action
* @return mixed|string
* @param string $action
* @return string
*/
function qa_get_form_security_code($action)
{
......@@ -1325,8 +1324,8 @@ function qa_get_form_security_code($action)
/**
* Return whether $value matches the expected form security (anti-CSRF protection) code for $action (any string) and
* that the code has not expired (if more than QA_FORM_EXPIRY_SECS have passed). Logs causes for suspicion.
* @param $action
* @param $value
* @param string $action
* @param string|null $value
* @return bool
*/
function qa_check_form_security_code($action, $value)
......
......@@ -28,11 +28,11 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
/**
* Check if $userid can vote on $post, on the page $topage.
* Return an HTML error to display if there was a problem, or false if it's OK.
* @param $post
* @param $vote
* @param $userid
* @param $topage
* @return bool|mixed|string
* @param array $post
* @param int $vote
* @param mixed $userid
* @param string $topage
* @return bool|string
*/
function qa_vote_error_html($post, $vote, $userid, $topage)
{
......@@ -106,12 +106,12 @@ function qa_vote_error_html($post, $vote, $userid, $topage)
/**
* Actually set (application level) the $vote (-1/0/1) by $userid (with $handle and $cookieid) on $postid.
* Handles user points, recounting and event reports as appropriate.
* @param $post
* @param $userid
* @param $handle
* @param $cookieid
* @param $vote
* @return void
* @param array $post
* @param mixed $userid
* @param string $handle
* @param string $cookieid
* @param int $vote
* @return mixed
*/
function qa_vote_set($post, $userid, $handle, $cookieid, $vote)
{
......@@ -178,10 +178,10 @@ function qa_vote_set($post, $userid, $handle, $cookieid, $vote)
/**
* Check if $userid can flag $post, on the page $topage.
* Return an HTML error to display if there was a problem, or false if it's OK.
* @param $post
* @param $userid
* @param $topage
* @return bool|mixed|string
* @param array $post
* @param mixed $userid
* @param string $topage
* @return bool|string|array
*/
function qa_flag_error_html($post, $userid, $topage)
{
......@@ -228,11 +228,11 @@ function qa_flag_error_html($post, $userid, $topage)
* Set (application level) a flag by $userid (with $handle and $cookieid) on $oldpost which belongs to $question.
* Handles recounting, admin notifications and event reports as appropriate.
* Returns true if the post should now be hidden because it has accumulated enough flags.
* @param $oldpost
* @param $userid
* @param $handle
* @param $cookieid
* @param $question
* @param array $oldpost
* @param mixed $userid
* @param string $handle
* @param string $cookieid
* @param array $question
* @return bool
*/
function qa_flag_set_tohide($oldpost, $userid, $handle, $cookieid, $question)
......@@ -278,10 +278,10 @@ function qa_flag_set_tohide($oldpost, $userid, $handle, $cookieid, $question)
/**
* Clear (application level) a flag on $oldpost by $userid (with $handle and $cookieid).
* Handles recounting and event reports as appropriate.
* @param $oldpost
* @param $userid
* @param $handle
* @param $cookieid
* @param array $oldpost
* @param mixed $userid
* @param string $handle
* @param string $cookieid
* @return mixed
*/
function qa_flag_clear($oldpost, $userid, $handle, $cookieid)
......@@ -320,10 +320,10 @@ function qa_flag_clear($oldpost, $userid, $handle, $cookieid)
/**
* Clear (application level) all flags on $oldpost by $userid (with $handle and $cookieid).
* Handles recounting and event reports as appropriate.
* @param $oldpost
* @param $userid
* @param $handle
* @param $cookieid
* @param array $oldpost
* @param mixed $userid
* @param string $handle
* @param string $cookieid
* @return mixed
*/
function qa_flags_clear_all($oldpost, $userid, $handle, $cookieid)
......
......@@ -27,6 +27,7 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
/**
* Return the current version of MySQL
* @return string
*/
function qa_db_mysql_version()
{
......@@ -36,6 +37,7 @@ function qa_db_mysql_version()
/**
* Return the total size in bytes of all relevant tables in the Q2A database
* @return float
*/
function qa_db_table_size()
{
......@@ -67,9 +69,9 @@ function qa_db_table_size()
/**
* Return a count of the number of posts of $type in database.
* Set $fromuser to true to only count non-anonymous posts, false to only count anonymous posts
* @param $type
* @param $fromuser
* @return mixed|null
* @param string|null $type
* @param mixed|null $fromuser
* @return string
*/
function qa_db_count_posts($type = null, $fromuser = null)
{
......@@ -89,6 +91,7 @@ function qa_db_count_posts($type = null, $fromuser = null)
/**
* Return number of registered users in database.
* @return string
*/
function qa_db_count_users()
{
......@@ -100,8 +103,8 @@ function qa_db_count_users()
/**
* Return number of active users in database $table
* @param $table
* @return mixed|null
* @param string $table
* @return string
*/
function qa_db_count_active_users($table)
{
......@@ -124,6 +127,7 @@ function qa_db_count_active_users($table)
/**
* Return number of categories in the database
* @return string
*/
function qa_db_count_categories()
{
......@@ -135,8 +139,8 @@ function qa_db_count_categories()
/**
* Return number of questions in the database in $categoryid exactly, and not one of its subcategories
* @param $categoryid
* @return mixed|null
* @param int $categoryid
* @return string
*/
function qa_db_count_categoryid_qs($categoryid)
{
......@@ -149,7 +153,7 @@ function qa_db_count_categoryid_qs($categoryid)
/**
* Return list of postids of visible or queued posts by $userid
* @param $userid
* @param mixed $userid
* @return array
*/
function qa_db_get_user_visible_postids($userid)
......@@ -163,7 +167,7 @@ function qa_db_get_user_visible_postids($userid)
/**
* Return list of postids of visible or queued posts from $ip address
* @param $ip
* @param string $ip
* @return array
*/
function qa_db_get_ip_visible_postids($ip)
......@@ -177,12 +181,12 @@ function qa_db_get_ip_visible_postids($ip)
/**
* Return an array whose keys contain the $postids which exist, and whose elements contain the number of other posts depending on each one
* @param $postids
* @param array $postids
* @return array
*/
function qa_db_postids_count_dependents($postids)
{
if (count($postids))
if (!empty($postids))
return qa_db_read_all_assoc(qa_db_query_sub(
"SELECT postid, COALESCE(childcount, 0) AS count FROM ^posts LEFT JOIN (SELECT parentid, COUNT(*) AS childcount FROM ^posts WHERE parentid IN (#) AND LEFT(type, 1) IN ('A', 'C') GROUP BY parentid) x ON postid=x.parentid WHERE postid IN (#)",
$postids, $postids
......@@ -195,7 +199,7 @@ function qa_db_postids_count_dependents($postids)
/**
* Return an array of the (up to) $count most recently created users who are awaiting approval and have not been blocked.
* The array element for each user includes a 'profile' key whose value is an array of non-empty profile fields of the user.
* @param $count
* @param int $count
* @return array
*/
function qa_db_get_unapproved_users($count)
......@@ -227,6 +231,7 @@ function qa_db_get_unapproved_users($count)
/**
* Return whether there are any blobs whose content has been stored as a file on disk
* @return bool
*/
function qa_db_has_blobs_on_disk()
{
......@@ -236,6 +241,7 @@ function qa_db_has_blobs_on_disk()
/**
* Return whether there are any blobs whose content has been stored in the database
* @return bool
*/
function qa_db_has_blobs_in_db()
{
......@@ -245,8 +251,8 @@ function qa_db_has_blobs_in_db()
/**
* Return the maximum position of the categories with $parentid
* @param $parentid
* @return mixed|null
* @param int $parentid
* @return string
*/
function qa_db_category_last_pos($parentid)
{
......@@ -259,7 +265,7 @@ function qa_db_category_last_pos($parentid)
/**
* Return how many levels of subcategory there are below $categoryid
* @param $categoryid
* @param int $categoryid
* @return int
*/
function qa_db_category_child_depth($categoryid)
......@@ -283,18 +289,18 @@ function qa_db_category_child_depth($categoryid)
/**
* Create a new category with $parentid, $title (=name) and $tags (=slug) in the database
* @param $parentid
* @param $title
* @param $tags
* @return mixed
* @param int $parentid
* @param string $title
* @param string $tags
* @return int
*/
function qa_db_category_create($parentid, $title, $tags)
{
$lastpos = qa_db_category_last_pos($parentid);
$lastpos = (int)qa_db_category_last_pos($parentid);
qa_db_query_sub(
'INSERT INTO ^categories (parentid, title, tags, position) VALUES (#, $, $, #)',
$parentid, $title, $tags, 1 + $lastpos
$parentid, $title, $tags, $lastpos + 1
);
$categoryid = qa_db_last_insert_id();
......@@ -307,8 +313,8 @@ function qa_db_category_create($parentid, $title, $tags)
/**
* Recalculate the backpath columns for all categories from $firstcategoryid to $lastcategoryid (if specified)
* @param $firstcategoryid
* @param $lastcategoryid
* @param int $firstcategoryid
* @param int|null $lastcategoryid
*/
function qa_db_categories_recalc_backpaths($firstcategoryid, $lastcategoryid = null)
{
......@@ -324,9 +330,9 @@ function qa_db_categories_recalc_backpaths($firstcategoryid, $lastcategoryid = n
/**
* Set the name of $categoryid to $title and its slug to $tags in the database
* @param $categoryid
* @param $title
* @param $tags
* @param int $categoryid
* @param string $title
* @param string $tags
*/
function qa_db_category_rename($categoryid, $title, $tags)
{
......@@ -341,8 +347,8 @@ function qa_db_category_rename($categoryid, $title, $tags)
/**
* Set the content (=description) of $categoryid to $content
* @param $categoryid
* @param $content
* @param int $categoryid
* @param string $content
*/
function qa_db_category_set_content($categoryid, $content)
{
......@@ -355,8 +361,8 @@ function qa_db_category_set_content($categoryid, $content)
/**
* Return the parentid of $categoryid
* @param $categoryid
* @return mixed|null
* @param int $categoryid
* @return string
*/
function qa_db_category_get_parent($categoryid)
{
......@@ -369,8 +375,8 @@ function qa_db_category_get_parent($categoryid)
/**
* Move the category $categoryid into position $newposition under its parent
* @param $categoryid
* @param $newposition
* @param int $categoryid
* @param int $newposition
*/
function qa_db_category_set_position($categoryid, $newposition)
{
......@@ -381,8 +387,8 @@ function qa_db_category_set_position($categoryid, $newposition)
/**
* Set the parent of $categoryid to $newparentid, placing it in last position (doesn't do necessary recalculations)
* @param $categoryid
* @param $newparentid
* @param int $categoryid
* @param string $newparentid
*/
function qa_db_category_set_parent($categoryid, $newparentid)
{
......@@ -393,11 +399,11 @@ function qa_db_category_set_parent($categoryid, $newparentid)
qa_db_ordered_move('categories', 'categoryid', $categoryid, $lastpos, qa_db_apply_sub('parentid<=>#', array($oldparentid)));
$lastpos = qa_db_category_last_pos($newparentid);
$lastpos = (int)qa_db_category_last_pos($newparentid);
qa_db_query_sub(
'UPDATE ^categories SET parentid=#, position=# WHERE categoryid=#',
$newparentid, 1 + $lastpos, $categoryid
$newparentid, $lastpos + 1, $categoryid
);
}
}
......@@ -405,8 +411,8 @@ function qa_db_category_set_parent($categoryid, $newparentid)
/**
* Change the categoryid of any posts with (exact) $categoryid to $reassignid
* @param $categoryid
* @param $reassignid
* @param int $categoryid
* @param int $reassignid
*/
function qa_db_category_reassign($categoryid, $reassignid)
{
......@@ -416,7 +422,7 @@ function qa_db_category_reassign($categoryid, $reassignid)
/**
* Delete the category $categoryid in the database
* @param $categoryid
* @param int $categoryid
*/
function qa_db_category_delete($categoryid)
{
......@@ -427,9 +433,9 @@ function qa_db_category_delete($categoryid)
/**
* Return the categoryid for the category with parent $parentid and $slug
* @param $parentid
* @param $slug
* @return mixed|null
* @param int $parentid
* @param string $slug
* @return string|null
*/
function qa_db_category_slug_to_id($parentid, $slug)
{
......@@ -442,13 +448,13 @@ function qa_db_category_slug_to_id($parentid, $slug)
/**
* Create a new custom page (or link) in the database
* @param $title
* @param $flags
* @param $tags
* @param $heading
* @param $content
* @param $permit
* @return mixed
* @param string $title
* @param int $flags
* @param string $tags
* @param string $heading
* @param string $content
* @param int|null $permit
* @return string
*/
function qa_db_page_create($title, $flags, $tags, $heading, $content, $permit = null)
{
......@@ -465,13 +471,13 @@ function qa_db_page_create($title, $flags, $tags, $heading, $content, $permit =
/**
* Set the fields of $pageid to the values provided in the database
* @param $pageid
* @param $title
* @param $flags
* @param $tags
* @param $heading
* @param $content
* @param $permit
* @param int $pageid
* @param string $title
* @param int $flags
* @param string $tags
* @param string $heading
* @param string $content
* @param int|null $permit
*/
function qa_db_page_set_fields($pageid, $title, $flags, $tags, $heading, $content, $permit = null)
{
......@@ -484,9 +490,9 @@ function qa_db_page_set_fields($pageid, $title, $flags, $tags, $heading, $conten
/**
* Move the page $pageid into navigation menu $nav and position $newposition in the database
* @param $pageid
* @param $nav
* @param $newposition
* @param int $pageid
* @param string $nav
* @param int $newposition
*/
function qa_db_page_move($pageid, $nav, $newposition)
{
......@@ -501,7 +507,7 @@ function qa_db_page_move($pageid, $nav, $newposition)
/**
* Delete the page $pageid in the database
* @param $pageid
* @param int $pageid
*/
function qa_db_page_delete($pageid)
{
......@@ -511,11 +517,11 @@ function qa_db_page_delete($pageid)
/**
* Move the entity identified by $idcolumn=$id into position $newposition (within optional $conditionsql) in $table in the database
* @param $table
* @param $idcolumn
* @param $id
* @param $newposition
* @param $conditionsql
* @param string $table
* @param string $idcolumn
* @param string $id
* @param int $newposition
* @param string|null $conditionsql
*/
function qa_db_ordered_move($table, $idcolumn, $id, $newposition, $conditionsql = null)
{
......@@ -547,10 +553,10 @@ function qa_db_ordered_move($table, $idcolumn, $id, $newposition, $conditionsql
/**
* Delete the entity identified by $idcolumn=$id (and optional $conditionsql) in $table in the database
* @param $table
* @param $idcolumn
* @param $id
* @param $conditionsql
* @param string $table
* @param string $idcolumn
* @param string $id
* @param string|null $conditionsql
*/
function qa_db_ordered_delete($table, $idcolumn, $id, $conditionsql = null)
{
......@@ -570,11 +576,11 @@ function qa_db_ordered_delete($table, $idcolumn, $id, $conditionsql = null)
/**
* Create a new user field with (internal) tag $title, label $content, $flags and $permit in the database.
* @param $title
* @param $content
* @param $flags
* @param $permit
* @return mixed
* @param string $title
* @param string $content
* @param int $flags
* @param int|null $permit
* @return string
*/
function qa_db_userfield_create($title, $content, $flags, $permit = null)
{
......@@ -591,10 +597,10 @@ function qa_db_userfield_create($title, $content, $flags, $permit = null)
/**
* Change the user field $fieldid to have label $content, $flags and $permit in the database (the title column cannot be changed once set)
* @param $fieldid
* @param $content
* @param $flags
* @param $permit
* @param string $fieldid
* @param string $content
* @param int $flags
* @param int|null $permit
*/
function qa_db_userfield_set_fields($fieldid, $content, $flags, $permit = null)
{
......@@ -607,8 +613,8 @@ function qa_db_userfield_set_fields($fieldid, $content, $flags, $permit = null)
/**
* Move the user field $fieldid into position $newposition in the database
* @param $fieldid
* @param $newposition
* @param string $fieldid
* @param int $newposition
*/
function qa_db_userfield_move($fieldid, $newposition)
{
......@@ -618,7 +624,7 @@ function qa_db_userfield_move($fieldid, $newposition)
/**
* Delete the user field $fieldid in the database
* @param $fieldid
* @param string $fieldid
*/
function qa_db_userfield_delete($fieldid)
{
......@@ -628,9 +634,9 @@ function qa_db_userfield_delete($fieldid)
/**
* Return the ID of a new widget, to be displayed by the widget module named $title on templates within $tags (comma-separated list)
* @param $title
* @param $tags
* @return mixed
* @param string $title
* @param string $tags
* @return string
*/
function qa_db_widget_create($title, $tags)
{
......@@ -647,8 +653,8 @@ function qa_db_widget_create($title, $tags)
/**
* Set the comma-separated list of templates for $widgetid to $tags
* @param $widgetid
* @param $tags
* @param int $widgetid
* @param string $tags
*/
function qa_db_widget_set_fields($widgetid, $tags)
{
......@@ -661,9 +667,9 @@ function qa_db_widget_set_fields($widgetid, $tags)
/**
* Move the widget $widgetit into position $position in the database's order, and show it in $place on the page
* @param $widgetid
* @param $place
* @param $newposition
* @param int $widgetid
* @param string $place
* @param int $newposition
*/
function qa_db_widget_move($widgetid, $place, $newposition)
{
......@@ -678,7 +684,7 @@ function qa_db_widget_move($widgetid, $place, $newposition)
/**
* Delete the widget $widgetid in the database
* @param $widgetid
* @param int $widgetid
*/
function qa_db_widget_delete($widgetid)
{
......
......@@ -27,13 +27,13 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
/**
* Create a new blob in the database with $content and $format, other fields as provided
* @param $content
* @param $format
* @param $sourcefilename
* @param $userid
* @param $cookieid
* @param $ip
* @return mixed|null|string
* @param string $content
* @param string $format
* @param string|null $sourcefilename
* @param mixed|null $userid
* @param string|null $cookieid
* @param string|null $ip
* @return mixed|string|null
*/
function qa_db_blob_create($content, $format, $sourcefilename = null, $userid = null, $cookieid = null, $ip = null)
{
......@@ -59,8 +59,8 @@ function qa_db_blob_create($content, $format, $sourcefilename = null, $userid =
/**
* Get the information about blob $blobid from the database
* @param $blobid
* @return array|mixed|null
* @param string $blobid
* @return array|null
*/
function qa_db_blob_read($blobid)
{
......@@ -75,8 +75,8 @@ function qa_db_blob_read($blobid)
/**
* Change the content of blob $blobid in the database to $content (can also be null)
* @param $blobid
* @param $content
* @param string $blobid
* @param string $content
*/
function qa_db_blob_set_content($blobid, $content)
{
......@@ -89,7 +89,7 @@ function qa_db_blob_set_content($blobid, $content)
/**
* Delete blob $blobid in the database
* @param $blobid
* @param string $blobid
* @return mixed
*/
function qa_db_blob_delete($blobid)
......@@ -105,8 +105,8 @@ function qa_db_blob_delete($blobid)
/**
* Check if blob $blobid exists in the database
* @param $blobid
* @return bool|mixed
* @param string $blobid
* @return bool
*/
function qa_db_blob_exists($blobid)
{
......
......@@ -29,9 +29,9 @@ require_once QA_INCLUDE_DIR . 'db/maxima.php';
/**
* Create (or replace) the item ($type, $cacheid) in the database cache table with $content
* @param $type
* @param $cacheid
* @param $content
* @param string $type
* @param string $cacheid
* @param string $content
* @return mixed
*/
function qa_db_cache_set($type, $cacheid, $content)
......@@ -53,8 +53,8 @@ function qa_db_cache_set($type, $cacheid, $content)
/**
* Retrieve the item ($type, $cacheid) from the database cache table
* @param $type
* @param $cacheid
* @param string $type
* @param string $cacheid
* @return mixed|null
*/
function qa_db_cache_get($type, $cacheid)
......
......@@ -27,8 +27,8 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
/**
* Create a new random cookie for $ipaddress and insert into database, returning it
* @param $ipaddress
* @return null|string
* @param string $ipaddress
* @return string|null
*/
function qa_db_cookie_create($ipaddress)
{
......@@ -53,8 +53,8 @@ function qa_db_cookie_create($ipaddress)
/**
* Note in database that a write operation has been done by user identified by $cookieid and from $ipaddress
* @param $cookieid
* @param $ipaddress
* @param string $cookieid
* @param string $ipaddress
*/
function qa_db_cookie_written($cookieid, $ipaddress)
{
......@@ -67,7 +67,7 @@ function qa_db_cookie_written($cookieid, $ipaddress)
/**
* Return whether $cookieid exists in database
* @param $cookieid
* @param string $cookieid
* @return bool
*/
function qa_db_cookie_exists($cookieid)
......
......@@ -31,13 +31,13 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
* event time or leave as null to use now. This will add the event both to the entity's shared stream, and the
* individual user streams for any users following the entity not via its shared stream (See long comment in
* /qa-include/db/favorites.php). Also handles truncation.
* @param $entitytype
* @param $entityid
* @param $questionid
* @param $lastpostid
* @param $updatetype
* @param $lastuserid
* @param $timestamp
* @param string $entitytype
* @param int $entityid
* @param int $questionid
* @param int $lastpostid
* @param string $updatetype
* @param mixed $lastuserid
* @param int|null $timestamp
*/
function qa_db_event_create_for_entity($entitytype, $entityid, $questionid, $lastpostid, $updatetype, $lastuserid, $timestamp = null)
{
......@@ -116,12 +116,12 @@ function qa_db_event_create_for_entity($entitytype, $entityid, $questionid, $las
* notification which is relevant for them, e.g. if someone answers their question). The event of type $updatetype
* relates to $lastpostid whose antecedent question is $questionid, and was caused by $lastuserid. Pass a unix
* $timestamp for the event time or leave as null to use now. Also handles truncation of event streams.
* @param $userid
* @param $questionid
* @param $lastpostid
* @param $updatetype
* @param $lastuserid
* @param $timestamp
* @param mixed $userid
* @param int $questionid
* @param int $lastpostid
* @param string $updatetype
* @param mixed $lastuserid
* @param int|null $timestamp
*/
function qa_db_event_create_not_entity($userid, $questionid, $lastpostid, $updatetype, $lastuserid, $timestamp = null)
{
......@@ -142,8 +142,8 @@ function qa_db_event_create_not_entity($userid, $questionid, $lastpostid, $updat
/**
* Trim the number of events in the event stream for $userid. If an event was just added for a particular question,
* pass the question's id in $questionid (to help focus the truncation).
* @param $userid
* @param $questionid
* @param mixed $userid
* @param int|null $questionid
*/
function qa_db_user_events_truncate($userid, $questionid = null)
{
......
......@@ -106,9 +106,9 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
* Add the entity $entitytype with $entityid to the favorites list of $userid. Handles switching streams across from
* per-user to per-entity based on how many other users have favorited the entity (see long explanation above). If
* appropriate, it also adds recent events from that entity to the user's event stream.
* @param $userid
* @param $entitytype
* @param $entityid
* @param mixed $userid
* @param string $entitytype
* @param int $entityid
*/
function qa_db_favorite_create($userid, $entitytype, $entityid)
{
......@@ -186,9 +186,9 @@ function qa_db_favorite_create($userid, $entitytype, $entityid)
/**
* Delete the entity $entitytype with $entityid from the favorites list of $userid, removing any corresponding events
* from the user's stream.
* @param $userid
* @param $entitytype
* @param $entityid
* @param mixed $userid
* @param string $entitytype
* @param int $entityid
*/
function qa_db_favorite_delete($userid, $entitytype, $entityid)
{
......
......@@ -46,9 +46,9 @@ function qa_db_increment_views($postid)
*
* @param int $firstpostid First post to recalculate (or only post if $lastpostid is null).
* @param int $lastpostid Last post in the range to recalculate.
* @param bool $viewincrement Deprecated - view counter is now incremented separately. Previously, would increment the post's
* views and include that in the hotness calculation.
* @return void
* @param bool $viewincrement Deprecated - view counter is now incremented separately. Previously, would increment the
* post's views and include that in the hotness calculation.
* @return mixed
*/
function qa_db_hotness_update($firstpostid, $lastpostid = null, $viewincrement = false)
{
......
......@@ -29,6 +29,7 @@ define('QA_DB_VERSION_CURRENT', 67);
/**
* Return the column type for user ids after verifying it is one of the legal options
* @return string
*/
function qa_db_user_column_type_verify()
{
......@@ -59,6 +60,7 @@ function qa_db_user_column_type_verify()
/**
* Return an array of table definitions. For each element of the array, the key is the table name (without prefix)
* and the value is an array of column definitions, [column name] => [definition]. The column name is omitted for indexes.
* @return array
*/
function qa_db_table_definitions()
{
......@@ -539,7 +541,7 @@ function qa_db_table_definitions()
/**
* Return array with all values from $array as keys
* @param $array
* @param array $array
* @return array
*/
function qa_array_to_keys($array)
......@@ -550,7 +552,7 @@ function qa_array_to_keys($array)
/**
* Return a list of tables missing from the database, [table name] => [column/index definitions]
* @param $definitions
* @param array $definitions
* @return array
*/
function qa_db_missing_tables($definitions)
......@@ -569,8 +571,8 @@ function qa_db_missing_tables($definitions)
/**
* Return a list of columns missing from $table in the database, given the full definition set in $definition
* @param $table
* @param $definition
* @param string $table
* @param array $definition
* @return array
*/
function qa_db_missing_columns($table, $definition)
......@@ -589,6 +591,7 @@ function qa_db_missing_columns($table, $definition)
/**
* Return the current version of the Q2A database, to determine need for DB upgrades
* @return int|null
*/
function qa_db_get_db_version()
{
......@@ -607,7 +610,7 @@ function qa_db_get_db_version()
/**
* Set the current version in the database
* @param $version
* @param int $version
*/
function qa_db_set_db_version($version)
{
......@@ -619,6 +622,7 @@ function qa_db_set_db_version($version)
/**
* Return a string describing what is wrong with the database, or false if everything is just fine
* @return false|string
*/
function qa_db_check_tables()
{
......@@ -703,8 +707,8 @@ function qa_db_install_tables()
/**
* Return the SQL command to create a table with $rawname and $definition obtained from qa_db_table_definitions()
* @param $rawname
* @param $definition
* @param string $rawname
* @param array $definition
* @return string
*/
function qa_db_create_table_sql($rawname, $definition)
......@@ -720,6 +724,7 @@ function qa_db_create_table_sql($rawname, $definition)
/**
* Return the SQL to create the default entries in the userfields table (before 1.3 these were hard-coded in PHP)
* @return string
*/
function qa_db_default_userfields_sql()
{
......@@ -1629,9 +1634,9 @@ function qa_db_upgrade_tables()
/**
* Reset the definitions of $columns in $table according to the $definitions array
* @param $definitions
* @param $table
* @param $columns
* @param array $definitions
* @param string $table
* @param array $columns
*/
function qa_db_upgrade_table_columns($definitions, $table, $columns)
{
......@@ -1646,7 +1651,7 @@ function qa_db_upgrade_table_columns($definitions, $table, $columns)
/**
* Perform upgrade $query and output progress to the browser
* @param $query
* @param string $query
*/
function qa_db_upgrade_query($query)
{
......@@ -1657,7 +1662,7 @@ function qa_db_upgrade_query($query)
/**
* Output $text to the browser (after converting to HTML) and do all we can to get it displayed
* @param $text
* @param string $text
*/
function qa_db_upgrade_progress($text)
{
......
......@@ -28,9 +28,9 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
/**
* Get rate limit information for $action from the database for user $userid and/or IP address $ip, if they're set.
* Return as an array with the limit type in the key, and a labelled array of the period and count.
* @param $userid
* @param $ip
* @param $action
* @param mixed $userid
* @param string|null $ip
* @param string $action
* @return array
*/
function qa_db_limits_get($userid, $ip, $action)
......@@ -50,7 +50,7 @@ function qa_db_limits_get($userid, $ip, $action)
$arguments[] = $action;
}
if (count($selects)) {
if (!empty($selects)) {
$query = qa_db_apply_sub(implode(' UNION ALL ', $selects), $arguments);
return qa_db_read_all_assoc(qa_db_query_raw($query), 'limitkey');
......@@ -61,10 +61,10 @@ function qa_db_limits_get($userid, $ip, $action)
/**
* Increment the database rate limit count for user $userid and $action by $count within $period
* @param $userid
* @param $action
* @param $period
* @param $count
* @param mixed $userid
* @param string $action
* @param int $period
* @param int $count
*/
function qa_db_limits_user_add($userid, $action, $period, $count)
{
......@@ -78,10 +78,10 @@ function qa_db_limits_user_add($userid, $action, $period, $count)
/**
* Increment the database rate limit count for IP address $ip and $action by $count within $period
* @param $ip
* @param $action
* @param $period
* @param $count
* @param string $ip
* @param string $action
* @param int $period
* @param int $count
*/
function qa_db_limits_ip_add($ip, $action, $period, $count)
{
......
......@@ -28,12 +28,12 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
/**
* Record a message sent from $fromuserid to $touserid with $content in $format in the database. $public sets whether
* public (on wall) or private. Return the messageid of the row created.
* @param $fromuserid
* @param $touserid
* @param $content
* @param $format
* @param mixed $fromuserid
* @param mixed $touserid
* @param string $content
* @param string $format
* @param bool $public
* @return mixed
* @return string
*/
function qa_db_message_create($fromuserid, $touserid, $content, $format, $public = false)
{
......@@ -48,8 +48,8 @@ function qa_db_message_create($fromuserid, $touserid, $content, $format, $public
/**
* Hide the message with $messageid, in $box (inbox|outbox) from the user.
* @param $messageid
* @param $box
* @param int $messageid
* @param string $box
*/
function qa_db_message_user_hide($messageid, $box)
{
......@@ -64,7 +64,7 @@ function qa_db_message_user_hide($messageid, $box)
/**
* Delete the message with $messageid from the database.
* @param $messageid
* @param int $messageid
* @param bool $public
*/
function qa_db_message_delete($messageid, $public = true)
......@@ -81,7 +81,7 @@ function qa_db_message_delete($messageid, $public = true)
/**
* Recalculate the cached count of wall posts for user $userid in the database
* @param $userid
* @param mixed $userid
*/
function qa_db_user_recount_posts($userid)
{
......
......@@ -27,9 +27,9 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
/**
* Set the metadata for user $userid with $key to $value. Keys beginning qa_ are reserved for the Q2A core.
* @param $userid
* @param $key
* @param $value
* @param mixed $userid
* @param string $key
* @param string $value
*/
function qa_db_usermeta_set($userid, $key, $value)
{
......@@ -39,8 +39,8 @@ function qa_db_usermeta_set($userid, $key, $value)
/**
* Clear the metadata for user $userid with $key ($key can also be an array of keys)
* @param $userid
* @param $key
* @param mixed $userid
* @param string $key
*/
function qa_db_usermeta_clear($userid, $key)
{
......@@ -51,8 +51,8 @@ function qa_db_usermeta_clear($userid, $key)
/**
* Return the metadata value for user $userid with $key ($key can also be an array of keys in which case this
* returns an array of metadata key => value).
* @param $userid
* @param $key
* @param mixed $userid
* @param string $key
* @return array|mixed|null
*/
function qa_db_usermeta_get($userid, $key)
......@@ -63,9 +63,9 @@ function qa_db_usermeta_get($userid, $key)
/**
* Set the metadata for post $postid with $key to $value. Keys beginning qa_ are reserved for the Q2A core.
* @param $postid
* @param $key
* @param $value
* @param int $postid
* @param string $key
* @param string $value
*/
function qa_db_postmeta_set($postid, $key, $value)
{
......@@ -75,8 +75,8 @@ function qa_db_postmeta_set($postid, $key, $value)
/**
* Clear the metadata for post $postid with $key ($key can also be an array of keys)
* @param $postid
* @param $key
* @param int $postid
* @param string $key
*/
function qa_db_postmeta_clear($postid, $key)
{
......@@ -87,8 +87,8 @@ function qa_db_postmeta_clear($postid, $key)
/**
* Return the metadata value for post $postid with $key ($key can also be an array of keys in which case this
* returns an array of metadata key => value).
* @param $postid
* @param $key
* @param int $postid
* @param string $key
* @return array|mixed|null
*/
function qa_db_postmeta_get($postid, $key)
......@@ -99,9 +99,9 @@ function qa_db_postmeta_get($postid, $key)
/**
* Set the metadata for category $categoryid with $key to $value. Keys beginning qa_ are reserved for the Q2A core.
* @param $categoryid
* @param $key
* @param $value
* @param int $categoryid
* @param string $key
* @param string $value
*/
function qa_db_categorymeta_set($categoryid, $key, $value)
{
......@@ -111,8 +111,8 @@ function qa_db_categorymeta_set($categoryid, $key, $value)
/**
* Clear the metadata for category $categoryid with $key ($key can also be an array of keys)
* @param $categoryid
* @param $key
* @param int $categoryid
* @param string $key
*/
function qa_db_categorymeta_clear($categoryid, $key)
{
......@@ -123,8 +123,8 @@ function qa_db_categorymeta_clear($categoryid, $key)
/**
* Return the metadata value for category $categoryid with $key ($key can also be an array of keys in which
* case this returns an array of metadata key => value).
* @param $categoryid
* @param $key
* @param int $categoryid
* @param string $key
* @return array|mixed|null
*/
function qa_db_categorymeta_get($categoryid, $key)
......@@ -135,9 +135,9 @@ function qa_db_categorymeta_get($categoryid, $key)
/**
* Set the metadata for tag $tag with $key to $value. Keys beginning qa_ are reserved for the Q2A core.
* @param $tag
* @param $key
* @param $value
* @param string $tag
* @param string $key
* @param string $value
*/
function qa_db_tagmeta_set($tag, $key, $value)
{
......@@ -147,8 +147,8 @@ function qa_db_tagmeta_set($tag, $key, $value)
/**
* Clear the metadata for tag $tag with $key ($key can also be an array of keys)
* @param $tag
* @param $key
* @param string $tag
* @param string $key
*/
function qa_db_tagmeta_clear($tag, $key)
{
......@@ -159,9 +159,9 @@ function qa_db_tagmeta_clear($tag, $key)
/**
* Return the metadata value for tag $tag with $key ($key can also be an array of keys in which case this
* returns an array of metadata key => value).
* @param $tag
* @param $key
* @return array|mixed|null
* @param string $tag
* @param string $key
* @return mixed
*/
function qa_db_tagmeta_get($tag, $key)
{
......@@ -171,11 +171,11 @@ function qa_db_tagmeta_get($tag, $key)
/**
* Internal general function to set metadata
* @param $metatable
* @param $idcolumn
* @param $idvalue
* @param $title
* @param $content
* @param string $metatable
* @param string $idcolumn
* @param string $idvalue
* @param string $title
* @param string $content
*/
function qa_db_meta_set($metatable, $idcolumn, $idvalue, $title, $content)
{
......@@ -189,10 +189,10 @@ function qa_db_meta_set($metatable, $idcolumn, $idvalue, $title, $content)
/**
* Internal general function to clear metadata
* @param $metatable
* @param $idcolumn
* @param $idvalue
* @param $title
* @param string $metatable
* @param string $idcolumn
* @param string $idvalue
* @param string|array $title
*/
function qa_db_meta_clear($metatable, $idcolumn, $idvalue, $title)
{
......@@ -214,11 +214,11 @@ function qa_db_meta_clear($metatable, $idcolumn, $idvalue, $title)
/**
* Internal general function to return metadata
* @param $metatable
* @param $idcolumn
* @param $idvalue
* @param $title
* @return array|mixed|null
* @param string $metatable
* @param string $idcolumn
* @param string $idvalue
* @param string|array $title
* @return mixed
*/
function qa_db_meta_get($metatable, $idcolumn, $idvalue, $title)
{
......
......@@ -27,10 +27,10 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
/**
* Create a notice for $userid with $content in $format and optional $tags (not displayed) and return its noticeid
* @param $userid
* @param $content
* @param mixed $userid
* @param string $content
* @param string $format
* @param $tags
* @param string|null $tags
* @return mixed
*/
function qa_db_usernotice_create($userid, $content, $format = '', $tags = null)
......@@ -46,8 +46,8 @@ function qa_db_usernotice_create($userid, $content, $format = '', $tags = null)
/**
* Delete the notice $notice which belongs to $userid
* @param $userid
* @param $noticeid
* @param mixed $userid
* @param int $noticeid
*/
function qa_db_usernotice_delete($userid, $noticeid)
{
......@@ -60,7 +60,7 @@ function qa_db_usernotice_delete($userid, $noticeid)
/**
* Return an array summarizing the notices to be displayed for $userid, including the tags (not displayed)
* @param $userid
* @param mixed $userid
* @return array
*/
function qa_db_usernotices_list($userid)
......
......@@ -27,8 +27,8 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
/**
* Set option $name to $value in the database
* @param $name
* @param $value
* @param string $name
* @param string $value
*/
function qa_db_set_option($name, $value)
{
......
......@@ -27,6 +27,7 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
/**
* Returns an array of option names required to perform calculations in userpoints table
* @return mixed
*/
function qa_db_points_option_names()
{
......@@ -49,6 +50,7 @@ function qa_db_points_option_names()
* The element 'formula' contains the SQL fragment that calculates the columns value for one or more users,
* where the ~ symbol within the fragment is substituted for a constraint on which users we are interested in.
* The element 'multiple' specifies what to multiply each column by to create the final sum in the points column.
* @return mixed
*/
function qa_db_points_calculations()
{
......@@ -156,10 +158,10 @@ function qa_db_points_calculations()
/**
* Update the userpoints table in the database for $userid and $columns, plus the summary points column.
* Set $columns to true for all, empty for none, an array for several, or a single value for one.
* Set $columns to true for all, false for none, an array for several, or a single value for one.
* This dynamically builds some fairly crazy looking SQL, but it works, and saves repeat calculations.
* @param $userid
* @param $columns
* @param mixed $userid
* @param bool|string|array $columns
* @return mixed
*/
function qa_db_points_update_ifuser($userid, $columns)
......@@ -217,8 +219,8 @@ function qa_db_points_update_ifuser($userid, $columns)
/**
* Set the number of explicit bonus points for $userid to $bonus
* @param $userid
* @param $bonus
* @param mixed $userid
* @param int $bonus
*/
function qa_db_points_set_bonus($userid, $bonus)
{
......
......@@ -27,19 +27,19 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
/**
* Create a new post in the database and return its ID (based on auto-incrementing)
* @param $type
* @param $parentid
* @param $userid
* @param $cookieid
* @param $ip
* @param $title
* @param $content
* @param $format
* @param $tagstring
* @param $notify
* @param $categoryid
* @param $name
* @return mixed
* @param string $type
* @param int $parentid
* @param mixed $userid
* @param string $cookieid
* @param string $ip
* @param string $title
* @param string $content
* @param string $format
* @param string $tagstring
* @param bool $notify
* @param int|null $categoryid
* @param string|null $name
* @return string
*/
function qa_db_post_create($type, $parentid, $userid, $cookieid, $ip, $title, $content, $format, $tagstring, $notify, $categoryid = null, $name = null)
{
......@@ -55,8 +55,8 @@ function qa_db_post_create($type, $parentid, $userid, $cookieid, $ip, $title, $c
/**
* Recalculate the full category path (i.e. columns catidpath1/2/3) for posts from $firstpostid to $lastpostid (if specified)
* @param $firstpostid
* @param $lastpostid
* @param int $firstpostid
* @param int|null $lastpostid
*/
function qa_db_posts_calc_category_path($firstpostid, $lastpostid = null)
{
......@@ -76,8 +76,8 @@ function qa_db_posts_calc_category_path($firstpostid, $lastpostid = null)
/**
* Get the full category path (including categoryid) for $postid
* @param $postid
* @return array|null
* @param int $postid
* @return array
*/
function qa_db_post_get_category_path($postid)
{
......@@ -90,7 +90,7 @@ function qa_db_post_get_category_path($postid)
/**
* Update the cached number of answers for $questionid in the database, along with the highest netvotes of any of its answers
* @param $questionid
* @param int $questionid
*/
function qa_db_post_acount_update($questionid)
{
......@@ -105,7 +105,7 @@ function qa_db_post_acount_update($questionid)
/**
* Recalculate the number of questions for each category in $path retrieved via qa_db_post_get_category_path()
* @param $path
* @param array $path
*/
function qa_db_category_path_qcount_update($path)
{
......@@ -118,7 +118,7 @@ function qa_db_category_path_qcount_update($path)
/**
* Update the cached number of questions for category $categoryid in the database, including its subcategories
* @param $categoryid
* @param int|null $categoryid
*/
function qa_db_ifcategory_qcount_update($categoryid)
{
......@@ -136,12 +136,12 @@ function qa_db_ifcategory_qcount_update($categoryid)
/**
* Add rows into the database title index, where $postid contains the words $wordids - this does the same sort
* of thing as qa_db_posttags_add_post_wordids() in a different way, for no particularly good reason.
* @param $postid
* @param $wordids
* @param int $postid
* @param array $wordids
*/
function qa_db_titlewords_add_post_wordids($postid, $wordids)
{
if (count($wordids)) {
if (!empty($wordids)) {
$rowstoadd = array();
foreach ($wordids as $wordid)
$rowstoadd[] = array($postid, $wordid);
......@@ -157,14 +157,14 @@ function qa_db_titlewords_add_post_wordids($postid, $wordids)
/**
* Add rows into the database content index, where $postid (of $type, with the antecedent $questionid)
* has words as per the keys of $wordidcounts, and the corresponding number of those words in the values.
* @param $postid
* @param $type
* @param $questionid
* @param $wordidcounts
* @param int $postid
* @param string $type
* @param int $questionid
* @param array $wordidcounts
*/
function qa_db_contentwords_add_post_wordidcounts($postid, $type, $questionid, $wordidcounts)
{
if (count($wordidcounts)) {
if (!empty($wordidcounts)) {
$rowstoadd = array();
foreach ($wordidcounts as $wordid => $count)
$rowstoadd[] = array($postid, $wordid, $count, $type, $questionid);
......@@ -179,12 +179,12 @@ function qa_db_contentwords_add_post_wordidcounts($postid, $type, $questionid, $
/**
* Add rows into the database index of individual tag words, where $postid contains the words $wordids
* @param $postid
* @param $wordids
* @param int $postid
* @param array $wordids
*/
function qa_db_tagwords_add_post_wordids($postid, $wordids)
{
if (count($wordids)) {
if (!empty($wordids)) {
$rowstoadd = array();
foreach ($wordids as $wordid)
$rowstoadd[] = array($postid, $wordid);
......@@ -199,12 +199,12 @@ function qa_db_tagwords_add_post_wordids($postid, $wordids)
/**
* Add rows into the database index of whole tags, where $postid contains the tags $wordids
* @param $postid
* @param $wordids
* @param int $postid
* @param array $wordids
*/
function qa_db_posttags_add_post_wordids($postid, $wordids)
{
if (count($wordids)) {
if (!empty($wordids)) {
qa_db_query_sub(
'INSERT INTO ^posttags (postid, wordid, postcreated) SELECT postid, wordid, created FROM ^words, ^posts WHERE postid=# AND wordid IN ($)',
$postid, $wordids
......@@ -215,12 +215,12 @@ function qa_db_posttags_add_post_wordids($postid, $wordids)
/**
* Return an array mapping each word in $words to its corresponding wordid in the database
* @param $words
* @param array $words
* @return array
*/
function qa_db_word_mapto_ids($words)
{
if (count($words)) {
if (!empty($words)) {
return qa_db_read_all_assoc(qa_db_query_sub(
'SELECT wordid, word FROM ^words WHERE word IN ($)', $words
), 'word', 'wordid');
......@@ -232,7 +232,7 @@ function qa_db_word_mapto_ids($words)
/**
* Return an array mapping each word in $words to its corresponding wordid in the database, adding any that are missing
* @param $words
* @param array $words
* @return array
*/
function qa_db_word_mapto_ids_add($words)
......@@ -245,7 +245,7 @@ function qa_db_word_mapto_ids_add($words)
$wordstoadd[] = $word;
}
if (count($wordstoadd)) {
if (!empty($wordstoadd)) {
qa_db_query_sub('LOCK TABLES ^words WRITE'); // to prevent two requests adding the same word
$wordtoid = qa_db_word_mapto_ids($words); // map it again in case table content changed before it was locked
......@@ -269,7 +269,7 @@ function qa_db_word_mapto_ids_add($words)
/**
* Update the titlecount column in the database for the words in $wordids, based on how many posts they appear in the title of
* @param $wordids
* @param array $wordids
*/
function qa_db_word_titlecount_update($wordids)
{
......@@ -284,7 +284,7 @@ function qa_db_word_titlecount_update($wordids)
/**
* Update the contentcount column in the database for the words in $wordids, based on how many posts they appear in the content of
* @param $wordids
* @param array $wordids
*/
function qa_db_word_contentcount_update($wordids)
{
......@@ -299,7 +299,7 @@ function qa_db_word_contentcount_update($wordids)
/**
* Update the tagwordcount column in the database for the individual tag words in $wordids, based on how many posts they appear in the tags of
* @param $wordids
* @param array $wordids
*/
function qa_db_word_tagwordcount_update($wordids)
{
......@@ -314,7 +314,7 @@ function qa_db_word_tagwordcount_update($wordids)
/**
* Update the tagcount column in the database for the whole tags in $wordids, based on how many posts they appear as tags of
* @param $wordids
* @param array $wordids
*/
function qa_db_word_tagcount_update($wordids)
{
......
......@@ -30,10 +30,10 @@ require_once QA_INCLUDE_DIR . 'app/updates.php';
/**
* Update the selected answer in the database for $questionid to $selchildid, and optionally record that $lastuserid did it from $lastip
* @param $questionid
* @param $selchildid
* @param $lastuserid
* @param $lastip
* @param int $questionid
* @param int|null $selchildid
* @param mixed|null $lastuserid
* @param string|null $lastip
*/
function qa_db_post_set_selchildid($questionid, $selchildid, $lastuserid = null, $lastip = null)
{
......@@ -61,10 +61,10 @@ function qa_db_post_set_selchildid($questionid, $selchildid, $lastuserid = null,
/**
* Set $questionid to be closed by post $closedbyid (null if not closed) in the database, and optionally record that
* $lastuserid did it from $lastip
* @param $questionid
* @param $closedbyid
* @param $lastuserid
* @param $lastip
* @param int $questionid
* @param int $closedbyid
* @param mixed|null $lastuserid
* @param string|null $lastip
*/
function qa_db_post_set_closed($questionid, $closedbyid, $lastuserid = null, $lastip = null)
{
......@@ -84,10 +84,10 @@ function qa_db_post_set_closed($questionid, $closedbyid, $lastuserid = null, $la
/**
* Set the type in the database of $postid to $type, and optionally record that $lastuserid did it from $lastip
* @param $postid
* @param $type
* @param $lastuserid
* @param $lastip
* @param int $postid
* @param string $type
* @param mixed|null $lastuserid
* @param string|null $lastip
* @param string $updatetype
*/
function qa_db_post_set_type($postid, $type, $lastuserid = null, $lastip = null, $updatetype = QA_UPDATE_TYPE)
......@@ -109,10 +109,10 @@ function qa_db_post_set_type($postid, $type, $lastuserid = null, $lastip = null,
/**
* Set the parent in the database of $postid to $parentid, and optionally record that $lastuserid did it from $lastip
* (if at least one is specified)
* @param $postid
* @param $parentid
* @param $lastuserid
* @param $lastip
* @param int $postid
* @param int $parentid
* @param mixed|null $lastuserid
* @param string|null $lastip
*/
function qa_db_post_set_parent($postid, $parentid, $lastuserid = null, $lastip = null)
{
......@@ -134,16 +134,16 @@ function qa_db_post_set_parent($postid, $parentid, $lastuserid = null, $lastip =
* Set the text fields in the database of $postid to $title, $content, $tagstring, $notify and $name, and record that
* $lastuserid did it from $lastip (if at least one is specified) with $updatetype. For backwards compatibility if $name
* is null then the name will not be changed.
* @param $postid
* @param $title
* @param $content
* @param $format
* @param $tagstring
* @param $notify
* @param $lastuserid
* @param $lastip
* @param int $postid
* @param string $title
* @param string $content
* @param string $format
* @param string $tagstring
* @param bool $notify
* @param mixed|null $lastuserid
* @param string|null $lastip
* @param string $updatetype
* @param $name
* @param string|null $name
*/
function qa_db_post_set_content($postid, $title, $content, $format, $tagstring, $notify, $lastuserid = null, $lastip = null, $updatetype = QA_UPDATE_CONTENT, $name = null)
{
......@@ -164,8 +164,8 @@ function qa_db_post_set_content($postid, $title, $content, $format, $tagstring,
/**
* Set the author in the database of $postid to $userid, and set the lastuserid to $userid as well if appropriate
* @param $postid
* @param $userid
* @param int $postid
* @param mixed $userid
*/
function qa_db_post_set_userid($postid, $userid)
{
......@@ -179,10 +179,10 @@ function qa_db_post_set_userid($postid, $userid)
/**
* Set the (exact) category in the database of $postid to $categoryid, and optionally record that $lastuserid did it from
* $lastip (if at least one is specified)
* @param $postid
* @param $categoryid
* @param $lastuserid
* @param $lastip
* @param int $postid
* @param int $categoryid
* @param mixed|null $lastuserid
* @param string|null $lastip
*/
function qa_db_post_set_category($postid, $categoryid, $lastuserid = null, $lastip = null)
{
......@@ -202,12 +202,12 @@ function qa_db_post_set_category($postid, $categoryid, $lastuserid = null, $last
/**
* Set the category path in the database of each of $postids to $path retrieved via qa_db_post_get_category_path()
* @param $postids
* @param $path
* @param array $postids
* @param array $path
*/
function qa_db_posts_set_category_path($postids, $path)
{
if (count($postids)) {
if (!empty($postids)) {
// requires QA_CATEGORY_DEPTH=4
qa_db_query_sub(
'UPDATE ^posts SET categoryid=#, catidpath1=#, catidpath2=#, catidpath3=# WHERE postid IN (#)',
......@@ -219,8 +219,8 @@ function qa_db_posts_set_category_path($postids, $path)
/**
* Set the created date of $postid to $created, which is a unix timestamp. If created is null, set to now.
* @param $postid
* @param $created
* @param int $postid
* @param int|null $created
*/
function qa_db_post_set_created($postid, $created)
{
......@@ -240,8 +240,8 @@ function qa_db_post_set_created($postid, $created)
/**
* Set the last updated date of $postid to $updated, which is a unix timestamp. If updated is null, set to now.
* @param $postid
* @param $updated
* @param int $postid
* @param int|null $updated
*/
function qa_db_post_set_updated($postid, $updated)
{
......@@ -261,7 +261,7 @@ function qa_db_post_set_updated($postid, $updated)
/**
* Deletes post $postid from the database (will also delete any votes on the post due to foreign key cascading)
* @param $postid
* @param int $postid
*/
function qa_db_post_delete($postid)
{
......@@ -274,7 +274,7 @@ function qa_db_post_delete($postid)
/**
* Return an array of wordids that were indexed in the database for the title of $postid
* @param $postid
* @param int $postid
* @return array
*/
function qa_db_titlewords_get_post_wordids($postid)
......@@ -288,7 +288,7 @@ function qa_db_titlewords_get_post_wordids($postid)
/**
* Remove all entries in the database index of title words for $postid
* @param $postid
* @param int $postid
*/
function qa_db_titlewords_delete_post($postid)
{
......@@ -301,7 +301,7 @@ function qa_db_titlewords_delete_post($postid)
/**
* Return an array of wordids that were indexed in the database for the content of $postid
* @param $postid
* @param int $postid
* @return array
*/
function qa_db_contentwords_get_post_wordids($postid)
......@@ -315,7 +315,7 @@ function qa_db_contentwords_get_post_wordids($postid)
/**
* Remove all entries in the database index of content words for $postid
* @param $postid
* @param int $postid
*/
function qa_db_contentwords_delete_post($postid)
{
......@@ -328,7 +328,7 @@ function qa_db_contentwords_delete_post($postid)
/**
* Return an array of wordids that were indexed in the database for the individual words in tags of $postid
* @param $postid
* @param int $postid
* @return array
*/
function qa_db_tagwords_get_post_wordids($postid)
......@@ -342,7 +342,7 @@ function qa_db_tagwords_get_post_wordids($postid)
/**
* Remove all entries in the database index of individual words in tags of $postid
* @param $postid
* @param int $postid
*/
function qa_db_tagwords_delete_post($postid)
{
......@@ -355,7 +355,7 @@ function qa_db_tagwords_delete_post($postid)
/**
* Return an array of wordids that were indexed in the database for the whole tags of $postid
* @param $postid
* @param int $postid
* @return array
*/
function qa_db_posttags_get_post_wordids($postid)
......@@ -369,7 +369,7 @@ function qa_db_posttags_get_post_wordids($postid)
/**
* Remove all entries in the database index of whole tags for $postid
* @param $postid
* @param int $postid
*/
function qa_db_posttags_delete_post($postid)
{
......@@ -382,12 +382,12 @@ function qa_db_posttags_delete_post($postid)
/**
* Return the array $postids containing only those elements which are the postid of a question in the database
* @param $postids
* @param array $postids
* @return array
*/
function qa_db_posts_filter_q_postids($postids)
{
if (count($postids)) {
if (!empty($postids)) {
return qa_db_read_all_values(qa_db_query_sub(
"SELECT postid FROM ^posts WHERE type='Q' AND postid IN (#)",
$postids
......@@ -400,12 +400,12 @@ function qa_db_posts_filter_q_postids($postids)
/**
* Return an array of all the userids of authors of posts in the array $postids
* @param $postids
* @param array $postids
* @return array
*/
function qa_db_posts_get_userids($postids)
{
if (count($postids)) {
if (!empty($postids)) {
return qa_db_read_all_values(qa_db_query_sub(
"SELECT DISTINCT userid FROM ^posts WHERE postid IN (#) AND userid IS NOT NULL",
$postids
......
......@@ -31,6 +31,7 @@ require_once QA_INCLUDE_DIR . 'db/post-create.php';
/**
* Return the number of custom pages currently in the database
* @return string
*/
function qa_db_count_pages()
{
......@@ -42,8 +43,8 @@ function qa_db_count_pages()
/**
* Return the information to reindex up to $count pages starting from $startpageid in the database
* @param $startpageid
* @param $count
* @param int $startpageid
* @param int $count
* @return array
*/
function qa_db_pages_get_for_reindexing($startpageid, $count)
......@@ -59,8 +60,8 @@ function qa_db_pages_get_for_reindexing($startpageid, $count)
/**
* Return the information required to reindex up to $count posts starting from $startpostid in the database
* @param $startpostid
* @param $count
* @param int $startpostid
* @param int $count
* @return array
*/
function qa_db_posts_get_for_reindexing($startpostid, $count)
......@@ -74,8 +75,8 @@ function qa_db_posts_get_for_reindexing($startpostid, $count)
/**
* Prepare posts $firstpostid to $lastpostid for reindexing in the database by removing their prior index entries
* @param $firstpostid
* @param $lastpostid
* @param int $firstpostid
* @param int $lastpostid
*/
function qa_db_prepare_for_reindexing($firstpostid, $lastpostid)
{
......@@ -103,7 +104,7 @@ function qa_db_prepare_for_reindexing($firstpostid, $lastpostid)
/**
* Remove any rows in the database word indexes with postid from $firstpostid upwards
* @param $firstpostid
* @param int $firstpostid
*/
function qa_db_truncate_indexes($firstpostid)
{
......@@ -131,6 +132,7 @@ function qa_db_truncate_indexes($firstpostid)
/**
* Return the number of words currently referenced in the database
* @return string
*/
function qa_db_count_words()
{
......@@ -142,8 +144,8 @@ function qa_db_count_words()
/**
* Return the ids of up to $count words in the database starting from $startwordid
* @param $startwordid
* @param $count
* @param int $startwordid
* @param int $count
* @return array
*/
function qa_db_words_prepare_for_recounting($startwordid, $count)
......@@ -157,8 +159,8 @@ function qa_db_words_prepare_for_recounting($startwordid, $count)
/**
* Recalculate the cached counts for words $firstwordid to $lastwordid in the database
* @param $firstwordid
* @param $lastwordid
* @param int $firstwordid
* @param int $lastwordid
*/
function qa_db_words_recount($firstwordid, $lastwordid)
{
......@@ -193,8 +195,8 @@ function qa_db_words_recount($firstwordid, $lastwordid)
/**
* Return the ids of up to $count posts in the database starting from $startpostid
* @param $startpostid
* @param $count
* @param int $startpostid
* @param int $count
* @return array
*/
function qa_db_posts_get_for_recounting($startpostid, $count)
......@@ -208,8 +210,8 @@ function qa_db_posts_get_for_recounting($startpostid, $count)
/**
* Recalculate the cached vote counts for posts $firstpostid to $lastpostid in the database
* @param $firstpostid
* @param $lastpostid
* @param int $firstpostid
* @param int $lastpostid
*/
function qa_db_posts_votes_recount($firstpostid, $lastpostid)
{
......@@ -223,9 +225,10 @@ function qa_db_posts_votes_recount($firstpostid, $lastpostid)
/**
* Recalculate the cached answer counts for posts $firstpostid to $lastpostid in the database, along with the highest netvotes of any of their answers
* @param $firstpostid
* @param $lastpostid
* Recalculate the cached answer counts for posts $firstpostid to $lastpostid in the database, along with the highest
* netvotes of any of their answers
* @param int $firstpostid
* @param int $lastpostid
*/
function qa_db_posts_answers_recount($firstpostid, $lastpostid)
{
......@@ -243,10 +246,10 @@ function qa_db_posts_answers_recount($firstpostid, $lastpostid)
// For recalculating user points...
/**
* Return the ids of up to $count users in the database starting from $startuserid
* Return the ids of up to $count users in the database starting from $startuserid.
* If using single sign-on integration, base this on user activity rather than the users table which we don't have
* @param $startuserid
* @param $count
* @param int $startuserid
* @param int $count
* @return array
*/
function qa_db_users_get_for_recalc_points($startuserid, $count)
......@@ -267,8 +270,8 @@ function qa_db_users_get_for_recalc_points($startuserid, $count)
/**
* Recalculate all userpoints columns for users $firstuserid to $lastuserid in the database
* @param $firstuserid
* @param $lastuserid
* @param mixed $firstuserid
* @param mixed $lastuserid
*/
function qa_db_users_recalc_points($firstuserid, $lastuserid)
{
......@@ -324,7 +327,7 @@ function qa_db_users_recalc_points($firstuserid, $lastuserid)
/**
* Remove any rows in the userpoints table where userid is greater than $lastuserid
* @param $lastuserid
* @param mixed $lastuserid
*/
function qa_db_truncate_userpoints($lastuserid)
{
......@@ -339,8 +342,8 @@ function qa_db_truncate_userpoints($lastuserid)
/**
* Return the ids of up to $count questions in the database starting from $startpostid
* @param $startpostid
* @param $count
* @param int $startpostid
* @param int $count
* @return array
*/
function qa_db_qs_get_for_event_refilling($startpostid, $count)
......@@ -356,8 +359,8 @@ function qa_db_qs_get_for_event_refilling($startpostid, $count)
/**
* Return the ids of up to $count posts (including queued/hidden) in the database starting from $startpostid
* @param $startpostid
* @param $count
* @param int $startpostid
* @param int $count
* @return array
*/
function qa_db_posts_get_for_recategorizing($startpostid, $count)
......@@ -372,8 +375,8 @@ function qa_db_posts_get_for_recategorizing($startpostid, $count)
/**
* Recalculate the (exact) categoryid for the posts (including queued/hidden) between $firstpostid and $lastpostid
* in the database, where the category of comments and answers is set by the category of the antecedent question
* @param $firstpostid
* @param $lastpostid
* @param int $firstpostid
* @param int $lastpostid
*/
function qa_db_posts_recalc_categoryid($firstpostid, $lastpostid)
{
......@@ -386,8 +389,8 @@ function qa_db_posts_recalc_categoryid($firstpostid, $lastpostid)
/**
* Return the ids of up to $count categories in the database starting from $startcategoryid
* @param $startcategoryid
* @param $count
* @param int $startcategoryid
* @param int $count
* @return array
*/
function qa_db_categories_get_for_recalcs($startcategoryid, $count)
......@@ -403,9 +406,9 @@ function qa_db_categories_get_for_recalcs($startcategoryid, $count)
/**
* Return the ids of up to $limit posts of $type that can be deleted from the database (i.e. have no dependents)
* @param $type
* @param string $type
* @param int $startpostid
* @param $limit
* @param int|null $limit
* @return array
*/
function qa_db_posts_get_for_deleting($type, $startpostid = 0, $limit = null)
......@@ -423,6 +426,7 @@ function qa_db_posts_get_for_deleting($type, $startpostid = 0, $limit = null)
/**
* Return the number of blobs whose content is stored in the database, rather than on disk
* @return string
*/
function qa_db_count_blobs_in_db()
{
......@@ -432,7 +436,7 @@ function qa_db_count_blobs_in_db()
/**
* Return the id, content and format of the first blob whose content is stored in the database starting from $startblobid
* @param $startblobid
* @param int $startblobid
* @return array|null
*/
function qa_db_get_next_blob_in_db($startblobid)
......@@ -446,6 +450,7 @@ function qa_db_get_next_blob_in_db($startblobid)
/**
* Return the number of blobs whose content is stored on disk, rather than in the database
* @return string
*/
function qa_db_count_blobs_on_disk()
{
......@@ -455,7 +460,7 @@ function qa_db_count_blobs_on_disk()
/**
* Return the id and format of the first blob whose content is stored on disk starting from $startblobid
* @param $startblobid
* @param int $startblobid
* @return array|null
*/
function qa_db_get_next_blob_on_disk($startblobid)
......
......@@ -31,6 +31,7 @@ require_once QA_INCLUDE_DIR.'db/maxima.php';
* Return the results of all the SELECT operations specified by the supplied selectspec parameters, while also
* performing all pending selects that have not yet been executed. If only one parameter is supplied, return its
* result, otherwise return an array of results indexed as per the parameters.
* @return mixed
*/
function qa_db_select_with_pending() // any number of parameters read via func_get_args()
{
......@@ -74,8 +75,8 @@ function qa_db_select_with_pending() // any number of parameters read via func_g
/**
* Queue a $selectspec for running later, with $pendingid (used for retrieval)
* @param $pendingid
* @param $selectspec
* @param string $pendingid
* @param array $selectspec
*/
function qa_db_queue_pending_select($pendingid, $selectspec)
{
......@@ -88,9 +89,9 @@ function qa_db_queue_pending_select($pendingid, $selectspec)
/**
* Get the result of the queued SELECT query identified by $pendingid. Run the query if it hasn't run already. If
* $selectspec is supplied, it doesn't matter if this hasn't been queued before - it will be queued and run now.
* @param $pendingid
* @param $selectspec
* @return
* @param string $pendingid
* @param array|null $selectspec
* @return mixed
*/
function qa_db_get_pending_result($pendingid, $selectspec = null)
{
......@@ -113,7 +114,7 @@ function qa_db_get_pending_result($pendingid, $selectspec = null)
/**
* Remove the results of queued SELECT query identified by $pendingid if it has already been run. This means it will
* run again if its results are requested via qa_db_get_pending_result()
* @param $pendingid
* @param string $pendingid
*/
function qa_db_flush_pending_result($pendingid)
{
......@@ -125,16 +126,16 @@ function qa_db_flush_pending_result($pendingid)
/**
* Modify a selectspec to count the number of items. This assumes the original selectspec does not have a LIMIT clause.
* Currently works with message inbox/outbox functions and user-flags function.
* @param $selectSpec
* @return mixed
* @param array $selectspec
* @return array
*/
function qa_db_selectspec_count($selectSpec)
function qa_db_selectspec_count($selectspec)
{
$selectSpec['columns'] = array('count' => 'COUNT(*)');
$selectSpec['single'] = true;
unset($selectSpec['arraykey']);
$selectspec['columns'] = array('count' => 'COUNT(*)');
$selectspec['single'] = true;
unset($selectspec['arraykey']);
return $selectSpec;
return $selectspec;
}
......@@ -143,7 +144,7 @@ function qa_db_selectspec_count($selectSpec)
* If $voteuserid is set, retrieve the vote made by a particular that user on each post.
* If $full is true, get full information on the posts, instead of just information for listing pages.
* If $user is true, get information about the user who wrote the post (or cookie if anonymous).
* @param $voteuserid
* @param mixed|null $voteuserid
* @param bool $full
* @param bool $user
* @return array
......@@ -224,8 +225,8 @@ function qa_db_posts_basic_selectspec($voteuserid = null, $full = false, $user =
* comment) which is related to the main post (question) retrieved. Pass the name of table which will contain the other
* post in $poststable. Set $fromupdated to true to get information about when this other post was edited, rather than
* created. If $full is true, get full information on this other post.
* @param $selectspec
* @param $poststable
* @param array $selectspec
* @param string $poststable
* @param bool $fromupdated
* @param bool $full
*/
......@@ -263,9 +264,9 @@ function qa_db_add_selectspec_opost(&$selectspec, $poststable, $fromupdated = fa
* post (answer or comment) which is related to the main post (question) retrieved. Pass the name of table which will
* contain the other user's details in $userstable and the name of the table which will contain the other user's points
* in $pointstable.
* @param $selectspec
* @param $userstable
* @param $pointstable
* @param array $selectspec
* @param string $userstable
* @param string $pointstable
*/
function qa_db_add_selectspec_ousers(&$selectspec, $userstable, $pointstable)
{
......@@ -285,7 +286,7 @@ function qa_db_add_selectspec_ousers(&$selectspec, $userstable, $pointstable)
/**
* Given $categoryslugs in order of the hierarchiy, return the equivalent value for the backpath column in the categories table
* @param $categoryslugs
* @param array $categoryslugs
* @return string
*/
function qa_db_slugs_to_backpath($categoryslugs)
......@@ -301,8 +302,8 @@ function qa_db_slugs_to_backpath($categoryslugs)
/**
* Return SQL code that represents the constraint of a post being in the category with $categoryslugs, or any of its subcategories
* @param $categoryslugs
* @param $arguments
* @param array $categoryslugs
* @param array $arguments
* @return string
*/
function qa_db_categoryslugs_sql_args($categoryslugs, &$arguments)
......@@ -328,14 +329,14 @@ function qa_db_categoryslugs_sql_args($categoryslugs, &$arguments)
* restricted to $createip (if not null) and the category for $categoryslugs (if not null), with the corresponding vote
* made by $voteuserid (if not null) and including $full content or not. Return $count (if null, a default is used)
* questions starting from offset $start.
* @param $voteuserid
* @param $sort
* @param $start
* @param $categoryslugs
* @param $createip
* @param mixed $voteuserid
* @param string $sort
* @param int $start
* @param array|null $categoryslugs
* @param string|null $createip
* @param bool $specialtype
* @param bool $full
* @param $count
* @param int|null $count
* @return array
*/
function qa_db_qs_selectspec($voteuserid, $sort, $start, $categoryslugs = null, $createip = null, $specialtype = false, $full = false, $count = null)
......@@ -392,13 +393,13 @@ function qa_db_qs_selectspec($voteuserid, $sort, $start, $categoryslugs = null,
* questions are restricted to the category for $categoryslugs (if not null), and will have the corresponding vote made
* by $voteuserid (if not null) and will include $full content or not. Return $count (if null, a default is used)
* questions starting from offset $start.
* @param $voteuserid
* @param $by
* @param $start
* @param $categoryslugs
* @param mixed $voteuserid
* @param string $by
* @param int $start
* @param array|null $categoryslugs
* @param bool $specialtype
* @param bool $full
* @param $count
* @param int|null $count
* @return array
*/
function qa_db_unanswered_qs_selectspec($voteuserid, $by, $start, $categoryslugs = null, $specialtype = false, $full = false, $count = null)
......@@ -443,13 +444,13 @@ function qa_db_unanswered_qs_selectspec($voteuserid, $by, $start, $categoryslugs
* corresponding vote on those questions made by $voteuserid (if not null). Return $count (if null, a default is used)
* questions starting from offset $start. The selectspec will also retrieve some information about the answers
* themselves (including the content if $fullanswers is true), in columns named with the prefix 'o'.
* @param $voteuserid
* @param $start
* @param $categoryslugs
* @param $createip
* @param mixed $voteuserid
* @param int $start
* @param array|null $categoryslugs
* @param string|null $createip
* @param bool $specialtype
* @param bool $fullanswers
* @param $count
* @param int|null $count
* @return array
*/
function qa_db_recent_a_qs_selectspec($voteuserid, $start, $categoryslugs = null, $createip = null, $specialtype = false, $fullanswers = false, $count = null)
......@@ -495,13 +496,13 @@ function qa_db_recent_a_qs_selectspec($voteuserid, $start, $categoryslugs = null
* corresponding vote on those questions made by $voteuserid (if not null). Return $count (if null, a default is used)
* questions starting from offset $start. The selectspec will also retrieve some information about the comments
* themselves (including the content if $fullcomments is true), in columns named with the prefix 'o'.
* @param $voteuserid
* @param $start
* @param $categoryslugs
* @param $createip
* @param mixed $voteuserid
* @param int $start
* @param array|null $categoryslugs
* @param string|null $createip
* @param bool $specialtype
* @param bool $fullcomments
* @param $count
* @param int|null $count
* @return array
*/
function qa_db_recent_c_qs_selectspec($voteuserid, $start, $categoryslugs = null, $createip = null, $specialtype = false, $fullcomments = false, $count = null)
......@@ -549,13 +550,13 @@ function qa_db_recent_c_qs_selectspec($voteuserid, $start, $categoryslugs = null
* corresponding vote on those questions made by $voteuserid (if not null). Return $count (if null, a default is used)
* questions starting from offset $start. The selectspec will also retrieve some information about the edited posts
* themselves (including the content if $fulledited is true), in columns named with the prefix 'o'.
* @param $voteuserid
* @param $start
* @param $categoryslugs
* @param $lastip
* @param mixed $voteuserid
* @param int $start
* @param array|null $categoryslugs
* @param string|null $lastip
* @param bool $onlyvisible
* @param bool $fulledited
* @param $count
* @param int|null $count
* @return array
*/
function qa_db_recent_edit_qs_selectspec($voteuserid, $start, $categoryslugs = null, $lastip = null, $onlyvisible = true, $fulledited = false, $count = null)
......@@ -597,10 +598,10 @@ function qa_db_recent_edit_qs_selectspec($voteuserid, $start, $categoryslugs = n
* on those questions made by $voteuserid (if not null). Return $count (if null, a default is used) questions starting
* from offset $start. The selectspec will also retrieve some information about the flagged posts themselves (including
* the content if $fullflagged is true).
* @param $voteuserid
* @param $start
* @param mixed $voteuserid
* @param int $start
* @param bool $fullflagged
* @param $count
* @param int|null $count
* @return array
*/
function qa_db_flagged_post_qs_selectspec($voteuserid, $start, $fullflagged = false, $count = null)
......@@ -632,8 +633,8 @@ function qa_db_flagged_post_qs_selectspec($voteuserid, $start, $fullflagged = fa
/**
* Return the selectspec to retrieve the posts in $postids, with the corresponding vote on those posts made by
* $voteuserid (if not null). Returns full information if $full is true.
* @param $voteuserid
* @param $postids
* @param mixed $voteuserid
* @param array $postids
* @param bool $full
* @return array
*/
......@@ -650,7 +651,7 @@ function qa_db_posts_selectspec($voteuserid, $postids, $full = false)
/**
* Return the selectspec to retrieve the basetype for the posts in $postids, as an array mapping postid => basetype
* @param $postids
* @param array $postids
* @return array
*/
function qa_db_posts_basetype_selectspec($postids)
......@@ -667,8 +668,8 @@ function qa_db_posts_basetype_selectspec($postids)
/**
* Return the selectspec to retrieve the basetype for the posts in $postids, as an array mapping postid => basetype
* @param $voteuserid
* @param $postids
* @param mixed $voteuserid
* @param array $postids
* @param bool $full
* @return array
*/
......@@ -694,8 +695,8 @@ function qa_db_posts_to_qs_selectspec($voteuserid, $postids, $full = false)
/**
* Return the selectspec to retrieve the full information for $postid, with the corresponding vote made by $voteuserid (if not null)
* @param $voteuserid
* @param $postid
* @param mixed $voteuserid
* @param int $postid
* @return array
*/
function qa_db_full_post_selectspec($voteuserid, $postid)
......@@ -713,8 +714,8 @@ function qa_db_full_post_selectspec($voteuserid, $postid)
/**
* Return the selectspec to retrieve the full information for all posts whose parent is $parentid, with the
* corresponding vote made by $voteuserid (if not null)
* @param $voteuserid
* @param $parentid
* @param mixed $voteuserid
* @param int $parentid
* @return array
*/
function qa_db_full_child_posts_selectspec($voteuserid, $parentid)
......@@ -731,8 +732,8 @@ function qa_db_full_child_posts_selectspec($voteuserid, $parentid)
/**
* Return the selectspec to retrieve the full information for all posts whose parent is an answer which
* has $questionid as its parent, with the corresponding vote made by $voteuserid (if not null)
* @param $voteuserid
* @param $questionid
* @param mixed $voteuserid
* @param int $questionid
* @return array
*/
function qa_db_full_a_child_posts_selectspec($voteuserid, $questionid)
......@@ -749,7 +750,7 @@ function qa_db_full_a_child_posts_selectspec($voteuserid, $questionid)
/**
* Return the selectspec to retrieve the question for the parent of $postid (where $postid is of a follow-on question or comment),
* i.e. the parent of $questionid's parent if $questionid's parent is an answer, otherwise $questionid's parent itself.
* @param $postid
* @param int $postid
* @return array
*/
function qa_db_post_parent_q_selectspec($postid)
......@@ -766,7 +767,7 @@ function qa_db_post_parent_q_selectspec($postid)
/**
* Return the selectspec to retrieve the post (either duplicate question or explanatory note) which has closed $questionid, if any
* @param $questionid
* @param int $questionid
* @return array
*/
function qa_db_post_close_post_selectspec($questionid)
......@@ -783,7 +784,7 @@ function qa_db_post_close_post_selectspec($questionid)
/**
* Return the selectspec to retrieve the posts that have been closed as a duplicate of this question, if any
* @param $questionid int The canonical question.
* @param int $questionid int The canonical question.
* @return array
*/
function qa_db_post_duplicates_selectspec($questionid)
......@@ -798,9 +799,10 @@ function qa_db_post_duplicates_selectspec($questionid)
/**
* Return the selectspec to retrieve the metadata value for $postid with key $title
* @param $postid
* @param $title
* Return the selectspec to retrieve the metadata value for $postid with key $title. If $title is an array then the
* selectspec will return an array of the matched titles.
* @param int $postid
* @param string|array $title
* @return array
*/
function qa_db_post_meta_selectspec($postid, $title)
......@@ -826,9 +828,9 @@ function qa_db_post_meta_selectspec($postid, $title)
* Return the selectspec to retrieve the most closely related questions to $questionid, with the corresponding vote
* made by $voteuserid (if not null). Return $count (if null, a default is used) questions. This works by looking for
* other questions which have title words, tag words or an (exact) category in common.
* @param $voteuserid
* @param $questionid
* @param $count
* @param mixed $voteuserid
* @param int $questionid
* @param int|null $count
* @return array
*/
function qa_db_related_qs_selectspec($voteuserid, $questionid, $count = null)
......@@ -869,15 +871,15 @@ function qa_db_related_qs_selectspec($voteuserid, $questionid, $count = null)
* where the score came from (since a question could get weight from a match in the question itself, and/or weight from
* a match in its answers, comments, or comments on answers). The 'matchparts' is a comma-separated list of tuples
* matchtype:matchpostid:matchscore to be used with qa_search_set_max_match().
* @param $voteuserid
* @param $titlewords
* @param $contentwords
* @param $tagwords
* @param $handlewords
* @param $handle
* @param $start
* @param mixed $voteuserid
* @param string $titlewords
* @param string $contentwords
* @param array $tagwords
* @param string $handlewords
* @param string $handle
* @param int $start
* @param bool $full
* @param $count
* @param int|null $count
* @return array
*/
function qa_db_search_posts_selectspec($voteuserid, $titlewords, $contentwords, $tagwords, $handlewords, $handle, $start, $full = false, $count = null)
......@@ -985,10 +987,9 @@ function qa_db_search_posts_selectspec($voteuserid, $titlewords, $contentwords,
/**
* Processes the matchparts column in $question which was returned from a search performed via qa_db_search_posts_selectspec()
* Returns the id of the strongest matching answer or comment, or null if the question itself was the strongest match
* @param $question
* @param $type
* @param $postid
* @return null
* @param array $question
* @param string $type
* @param int $postid
*/
function qa_search_set_max_match($question, &$type, &$postid)
{
......@@ -1006,16 +1007,14 @@ function qa_search_set_max_match($question, &$type, &$postid)
}
}
}
return null;
}
/**
* Return a selectspec to retrieve the full information on the category whose id is $slugsorid (if $isid is true),
* otherwise whose backpath matches $slugsorid
* @param $slugsorid
* @param $isid
* @param int|array $slugsorid
* @param bool $isid
* @return array
*/
function qa_db_full_category_selectspec($slugsorid, $isid)
......@@ -1042,8 +1041,8 @@ function qa_db_full_category_selectspec($slugsorid, $isid)
* top level, any ancestors (at any level) of the category, the category's siblings and sub-categories (to one level).
* The central category is specified as follows. If $isid AND $ispostid then $slugsorid is the ID of a post with the category.
* Otherwise if $isid then $slugsorid is the category's own id. Otherwise $slugsorid is the full backpath of the category.
* @param $slugsorid
* @param $isid
* @param int|array $slugsorid
* @param bool $isid
* @param bool $ispostid
* @param bool $full
* @return array
......@@ -1106,7 +1105,7 @@ function qa_db_category_nav_selectspec($slugsorid, $isid, $ispostid = false, $fu
/**
* Return the selectspec to retrieve information on all subcategories of $categoryid (used for Ajax navigation of hierarchy)
* @param $categoryid
* @param int $categoryid
* @return array
*/
function qa_db_category_sub_selectspec($categoryid)
......@@ -1123,7 +1122,7 @@ function qa_db_category_sub_selectspec($categoryid)
/**
* Return the selectspec to retrieve a single category as specified by its $slugs (in order of hierarchy)
* @param $slugs
* @param array $slugs
* @return array
*/
function qa_db_slugs_to_category_id_selectspec($slugs)
......@@ -1140,8 +1139,8 @@ function qa_db_slugs_to_category_id_selectspec($slugs)
/**
* Return the selectspec to retrieve the list of custom pages or links, ordered for display
* @param $onlynavin
* @param $onlypageids
* @param array $onlynavin
* @param array $onlypageids
* @return array
*/
function qa_db_pages_selectspec($onlynavin = null, $onlypageids = null)
......@@ -1169,6 +1168,7 @@ function qa_db_pages_selectspec($onlynavin = null, $onlypageids = null)
/**
* Return the selectspec to retrieve the list of widgets, ordered for display
* @return array
*/
function qa_db_widgets_selectspec()
{
......@@ -1182,8 +1182,8 @@ function qa_db_widgets_selectspec()
/**
* Return the selectspec to retrieve the full information about a custom page
* @param $slugorpageid
* @param $ispageid
* @param int|array $slugorpageid
* @param bool $ispageid
* @return array
*/
function qa_db_page_full_selectspec($slugorpageid, $ispageid)
......@@ -1201,11 +1201,11 @@ function qa_db_page_full_selectspec($slugorpageid, $ispageid)
* Return the selectspec to retrieve the most recent questions with $tag, with the corresponding vote on those
* questions made by $voteuserid (if not null) and including $full content or not. Return $count (if null, a default is
* used) questions starting from $start.
* @param $voteuserid
* @param $tag
* @param $start
* @param mixed $voteuserid
* @param string $tag
* @param int $start
* @param bool $full
* @param $count
* @param int|null $count
* @return array
*/
function qa_db_tag_recent_qs_selectspec($voteuserid, $tag, $start, $full = false, $count = null)
......@@ -1227,7 +1227,7 @@ function qa_db_tag_recent_qs_selectspec($voteuserid, $tag, $start, $full = false
/**
* Return the selectspec to retrieve the number of questions tagged with $tag (single value)
* @param $tag
* @param string $tag
* @return array
*/
function qa_db_tag_word_selectspec($tag)
......@@ -1246,9 +1246,9 @@ function qa_db_tag_word_selectspec($tag)
* handle if we're using internal user management, or a userid if we're using external users. Also include the
* corresponding vote on those questions made by $voteuserid (if not null). Return $count (if null, a default is used)
* questions.
* @param $voteuserid
* @param $identifier
* @param $count
* @param mixed $voteuserid
* @param mixed $identifier
* @param int|null $count
* @param int $start
* @return array
*/
......@@ -1271,9 +1271,9 @@ function qa_db_user_recent_qs_selectspec($voteuserid, $identifier, $count = null
* (see qa_db_user_recent_qs_selectspec() comment), with the corresponding vote on those questions made by $voteuserid
* (if not null). Return $count (if null, a default is used) questions. The selectspec will also retrieve some
* information about the answers themselves, in columns named with the prefix 'o'.
* @param $voteuserid
* @param $identifier
* @param $count
* @param mixed $voteuserid
* @param mixed $identifier
* @param int|null $count
* @param int $start
* @return array
*/
......@@ -1307,9 +1307,9 @@ function qa_db_user_recent_a_qs_selectspec($voteuserid, $identifier, $count = nu
* (see qa_db_user_recent_qs_selectspec() comment), with the corresponding vote on those questions made by $voteuserid
* (if not null). Return $count (if null, a default is used) questions. The selectspec will also retrieve some
* information about the comments themselves, in columns named with the prefix 'o'.
* @param $voteuserid
* @param $identifier
* @param $count
* @param mixed $voteuserid
* @param mixed $identifier
* @param int $count
* @return array
*/
function qa_db_user_recent_c_qs_selectspec($voteuserid, $identifier, $count = null)
......@@ -1340,9 +1340,9 @@ function qa_db_user_recent_c_qs_selectspec($voteuserid, $identifier, $count = nu
* $identifier (see qa_db_user_recent_qs_selectspec() comment), with the corresponding vote on those questions made by
* $voteuserid (if not null). Return $count (if null, a default is used) questions. The selectspec will also retrieve
* some information about the edited posts themselves, in columns named with the prefix 'o'.
* @param $voteuserid
* @param $identifier
* @param $count
* @param mixed $voteuserid
* @param mixed $identifier
* @param int $count
* @return array
*/
function qa_db_user_recent_edit_qs_selectspec($voteuserid, $identifier, $count = null)
......@@ -1372,8 +1372,8 @@ function qa_db_user_recent_edit_qs_selectspec($voteuserid, $identifier, $count =
/**
* Return the selectspec to retrieve the most popular tags. Return $count (if null, a default is used) tags, starting
* from offset $start. The selectspec will produce a sorted array with tags in the key, and counts in the values.
* @param $start
* @param $count
* @param int $start
* @param int $count
* @return array
*/
function qa_db_popular_tags_selectspec($start, $count = null)
......@@ -1408,8 +1408,8 @@ function qa_db_userfields_selectspec()
/**
* Return the selecspec to retrieve a single array with details of the account of the user identified by
* $useridhandle, which should be a userid if $isuserid is true, otherwise $useridhandle should be a handle.
* @param $useridhandle
* @param $isuserid
* @param mixed $useridhandle
* @param bool $isuserid
* @return array
*/
function qa_db_user_account_selectspec($useridhandle, $isuserid)
......@@ -1433,8 +1433,8 @@ function qa_db_user_account_selectspec($useridhandle, $isuserid)
/**
* Return the selectspec to retrieve all user profile information of the user identified by
* $useridhandle (see qa_db_user_account_selectspec() comment), as an array of [field] => [value]
* @param $useridhandle
* @param $isuserid
* @param mixed $useridhandle
* @param bool $isuserid
* @return array
*/
function qa_db_user_profile_selectspec($useridhandle, $isuserid)
......@@ -1451,7 +1451,7 @@ function qa_db_user_profile_selectspec($useridhandle, $isuserid)
/**
* Return the selectspec to retrieve all notices for the user $userid
* @param $userid
* @param mixed $userid
* @return array
*/
function qa_db_user_notices_selectspec($userid)
......@@ -1468,7 +1468,7 @@ function qa_db_user_notices_selectspec($userid)
/**
* Return the selectspec to retrieve all columns from the userpoints table for the user identified by $identifier
* (see qa_db_user_recent_qs_selectspec() comment), as a single array
* @param $identifier
* @param mixed $identifier
* @param bool $isuserid
* @return array
*/
......@@ -1486,7 +1486,7 @@ function qa_db_user_points_selectspec($identifier, $isuserid = QA_FINAL_EXTERNAL
/**
* Return the selectspec to calculate the rank in points of the user identified by $identifier
* (see qa_db_user_recent_qs_selectspec() comment), as a single value
* @param $identifier
* @param mixed $identifier
* @param bool $isuserid
* @return array
*/
......@@ -1505,8 +1505,8 @@ function qa_db_user_rank_selectspec($identifier, $isuserid = QA_FINAL_EXTERNAL_U
/**
* Return the selectspec to get the top scoring users, with handles if we're using internal user management. Return
* $count (if null, a default is used) users starting from the offset $start.
* @param $start
* @param $count
* @param int $start
* @param int|null $count
* @return array
*/
function qa_db_top_users_selectspec($start, $count = null)
......@@ -1544,8 +1544,8 @@ function qa_db_top_users_selectspec($start, $count = null)
/**
* Return the selectspec to get the newest users. Return $count (if null, a default is used) users starting from the
* offset $start. This query must not be run when using external users
* @param $start
* @param $count
* @param int $start
* @param int|null $count
* @return array
*/
function qa_db_newest_users_selectspec($start, $count = null)
......@@ -1564,7 +1564,7 @@ function qa_db_newest_users_selectspec($start, $count = null)
/**
* Return the selectspec to get information about users at a certain privilege level or higher
* @param $level
* @param int $level
* @return array
*/
function qa_db_users_from_level_selectspec($level)
......@@ -1580,9 +1580,9 @@ function qa_db_users_from_level_selectspec($level)
/**
* Return the selectspec to get information about users with the $flag bit set (unindexed query)
* @param $flag
* @param int $flag
* @param int $start
* @param $limit
* @param int|null $limit
* @return array
*/
function qa_db_users_with_flag_selectspec($flag, $start = 0, $limit = null)
......@@ -1606,6 +1606,7 @@ function qa_db_users_with_flag_selectspec($flag, $start = 0, $limit = null)
/**
* Return columns for standard messages selectspec
* @return array
*/
function qa_db_messages_columns()
{
......@@ -1631,11 +1632,11 @@ function qa_db_messages_columns()
* the user identified by $fromidentifier+$fromisuserid to the user identified by $toidentifier+$toisuserid (see
* qa_db_user_recent_qs_selectspec() comment). If $fromidentifier is null, then get recent wall posts
* for the user identified by $toidentifier+$toisuserid. Return $count (if null, a default is used) messages.
* @param $fromidentifier
* @param $fromisuserid
* @param $toidentifier
* @param $toisuserid
* @param $count
* @param mixed $fromidentifier
* @param bool $fromisuserid
* @param mixed $toidentifier
* @param bool $toisuserid
* @param int|null $count
* @param int $start
* @return array
*/
......@@ -1669,11 +1670,11 @@ function qa_db_recent_messages_selectspec($fromidentifier, $fromisuserid, $toide
* Get selectspec for messages *to* specified user. $type is either 'public' or 'private'.
* $toidentifier is a handle or userid depending on the value of $toisuserid.
* Returns $limit messages, or all of them if $limit is null (used in qa_db_selectspec_count).
* @param $type
* @param $toidentifier
* @param $toisuserid
* @param string $type
* @param mixed $toidentifier
* @param mixed $toisuserid
* @param int $start
* @param $limit
* @param int|null $limit
* @return array
*/
function qa_db_messages_inbox_selectspec($type, $toidentifier, $toisuserid, $start = 0, $limit = null)
......@@ -1705,11 +1706,11 @@ function qa_db_messages_inbox_selectspec($type, $toidentifier, $toisuserid, $sta
* Get selectspec for messages *from* specified user. $type is either 'public' or 'private'.
* $fromidentifier is a handle or userid depending on the value of $fromisuserid.
* Returns $limit messages, or all of them if $limit is null (used in qa_db_selectspec_count).
* @param $type
* @param $fromidentifier
* @param $fromisuserid
* @param string $type
* @param mixed $fromidentifier
* @param bool $fromisuserid
* @param int $start
* @param $limit
* @param int|null $limit
* @return array
*/
function qa_db_messages_outbox_selectspec($type, $fromidentifier, $fromisuserid, $start = 0, $limit = null)
......@@ -1740,9 +1741,9 @@ function qa_db_messages_outbox_selectspec($type, $fromidentifier, $fromisuserid,
/**
* Return the selectspec to retrieve whether or not $userid has favorited entity $entitytype identifier by $identifier.
* The $identifier should be a handle, word, backpath or postid for users, tags, categories and questions respectively.
* @param $userid
* @param $entitytype
* @param $identifier
* @param mixed $userid
* @param string $entitytype
* @param mixed $identifier
* @return array
*/
function qa_db_is_favorite_selectspec($userid, $entitytype, $identifier)
......@@ -1784,8 +1785,8 @@ function qa_db_is_favorite_selectspec($userid, $entitytype, $identifier)
/**
* Return the selectspec to retrieve an array of $userid's favorited questions, with the usual information.
* Returns $limit questions, or all of them if $limit is null (used in qa_db_selectspec_count).
* @param $userid
* @param $limit
* @param mixed $userid
* @param int|null $limit
* @param int $start
* @return array
*/
......@@ -1815,8 +1816,8 @@ function qa_db_user_favorite_qs_selectspec($userid, $limit = null, $start = 0)
/**
* Return the selectspec to retrieve an array of $userid's favorited users, with information about those users' accounts.
* Returns $limit users, or all of them if $limit is null (used in qa_db_selectspec_count).
* @param $userid
* @param $limit
* @param mixed $userid
* @param int|null $limit
* @param int $start
* @return array
*/
......@@ -1846,8 +1847,8 @@ function qa_db_user_favorite_users_selectspec($userid, $limit = null, $start = 0
/**
* Return the selectspec to retrieve an array of $userid's favorited tags, with information about those tags.
* Returns $limit tags, or all of them if $limit is null (used in qa_db_selectspec_count).
* @param $userid
* @param $limit
* @param mixed $userid
* @param int|null $limit
* @param int $start
* @return array
*/
......@@ -1876,7 +1877,7 @@ function qa_db_user_favorite_tags_selectspec($userid, $limit = null, $start = 0)
/**
* Return the selectspec to retrieve an array of $userid's favorited categories, with information about those categories.
* @param $userid
* @param mixed $userid
* @return array
*/
function qa_db_user_favorite_categories_selectspec($userid)
......@@ -1895,7 +1896,7 @@ function qa_db_user_favorite_categories_selectspec($userid)
/**
* Return the selectspec to retrieve information about all a user's favorited items except the questions. Depending on
* the type of item, the array for each item will contain a userid, category backpath or tag word.
* @param $userid
* @param mixed $userid
* @return array
*/
function qa_db_user_favorite_non_qs_selectspec($userid)
......@@ -1915,7 +1916,7 @@ function qa_db_user_favorite_non_qs_selectspec($userid)
* include updates on the user's favorites and $forcontent to whether it should include responses to user's content.
* This combines events from both the user's stream and the the shared stream for any entities which the user has
* favorited and which no longer post to user streams (see long comment in /qa-include/db/favorites.php).
* @param $userid
* @param mixed $userid
* @param bool $forfavorites
* @param bool $forcontent
* @return array
......@@ -1970,7 +1971,7 @@ function qa_db_user_updates_selectspec($userid, $forfavorites = true, $forconten
/**
* Return the selectspec to retrieve all of the per-hour activity limits for user $userid
* @param $userid
* @param mixed $userid
* @return array
*/
function qa_db_user_limits_selectspec($userid)
......@@ -1986,7 +1987,7 @@ function qa_db_user_limits_selectspec($userid)
/**
* Return the selectspec to retrieve all of the per-hour activity limits for ip address $ip
* @param $ip
* @param string $ip
* @return array
*/
function qa_db_ip_limits_selectspec($ip)
......@@ -2004,7 +2005,7 @@ function qa_db_ip_limits_selectspec($ip)
* Return the selectspec to retrieve all of the context specific (currently per-categpry) levels for the user identified by
* $identifier, which is treated as a userid if $isuserid is true, otherwise as a handle. Set $full to true to obtain extra
* information about these contexts (currently, categories).
* @param $identifier
* @param mixed $identifier
* @param bool $isuserid
* @param bool $full
* @return array
......
......@@ -27,9 +27,9 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
/**
* Return the expected value for the passcheck column given the $password and password $salt
* @param $password
* @param $salt
* @return mixed|string
* @param string $password
* @param string $salt
* @return string
*/
function qa_db_calc_passcheck($password, $salt)
{
......@@ -41,12 +41,12 @@ function qa_db_calc_passcheck($password, $salt)
/**
* Create a new user in the database with $email, $password, $handle, privilege $level, and $ip address
* @param $email
* @param $password
* @param $handle
* @param $level
* @param $ip
* @return mixed
* @param string $email
* @param string|null $password
* @param string $handle
* @param int $level
* @param string $ip
* @return string
*/
function qa_db_user_create($email, $password, $handle, $level, $ip)
{
......@@ -77,7 +77,7 @@ function qa_db_user_create($email, $password, $handle, $level, $ip)
/**
* Delete user $userid from the database, along with everything they have ever done (to the extent that it's possible)
* @param $userid
* @param mixed $userid
*/
function qa_db_user_delete($userid)
{
......@@ -101,7 +101,7 @@ function qa_db_user_delete($userid)
/**
* Return the ids of all users in the database which match $email (should be one or none)
* @param $email
* @param string $email
* @return array
*/
function qa_db_user_find_by_email($email)
......@@ -115,7 +115,7 @@ function qa_db_user_find_by_email($email)
/**
* Return the ids of all users in the database which match $handle (=username), should be one or none
* @param $handle
* @param string $handle
* @return array
*/
function qa_db_user_find_by_handle($handle)
......@@ -129,12 +129,12 @@ function qa_db_user_find_by_handle($handle)
/**
* Return an array mapping each userid in $userids that can be found to that user's handle
* @param $userids
* @param array $userids
* @return array
*/
function qa_db_user_get_userid_handles($userids)
{
if (count($userids)) {
if (!empty($userids)) {
return qa_db_read_all_assoc(qa_db_query_sub(
'SELECT userid, handle FROM ^users WHERE userid IN (#)',
$userids
......@@ -147,12 +147,12 @@ function qa_db_user_get_userid_handles($userids)
/**
* Return an array mapping mapping each handle in $handle that can be found to that user's userid
* @param $handles
* @param array $handles
* @return array
*/
function qa_db_user_get_handle_userids($handles)
{
if (count($handles)) {
if (!empty($handles)) {
return qa_db_read_all_assoc(qa_db_query_sub(
'SELECT handle, userid FROM ^users WHERE handle IN ($)',
$handles
......@@ -193,8 +193,8 @@ function qa_db_user_set($userid, $fields, $value = null)
/**
* Set the password of $userid to $password, and reset their salt at the same time
* @param $userid
* @param $password
* @param mixed $userid
* @param string $password
* @return mixed
*/
function qa_db_user_set_password($userid, $password)
......@@ -221,9 +221,9 @@ function qa_db_user_set_password($userid, $password)
/**
* Switch on the $flag bit of the flags column for $userid if $set is true, or switch off otherwise
* @param $userid
* @param $flag
* @param $set
* @param mixed $userid
* @param int $flag
* @param bool $set
*/
function qa_db_user_set_flag($userid, $flag, $set)
{
......@@ -236,6 +236,7 @@ function qa_db_user_set_flag($userid, $flag, $set)
/**
* Return a random string to be used for a user's emailcode column
* @return string
*/
function qa_db_user_rand_emailcode()
{
......@@ -249,6 +250,7 @@ function qa_db_user_rand_emailcode()
/**
* Return a random string to be used for a user's sessioncode column (for browser session cookies)
* @return string
*/
function qa_db_user_rand_sessioncode()
{
......@@ -262,9 +264,9 @@ function qa_db_user_rand_sessioncode()
/**
* Set a row in the database user profile table to store $value for $field for $userid
* @param $userid
* @param $field
* @param $value
* @param mixed $userid
* @param string $field
* @param string $value
*/
function qa_db_user_profile_set($userid, $field, $value)
{
......@@ -278,8 +280,8 @@ function qa_db_user_profile_set($userid, $field, $value)
/**
* Note in the database that $userid just logged in from $ip address
* @param $userid
* @param $ip
* @param mixed $userid
* @param string $ip
*/
function qa_db_user_logged_in($userid, $ip)
{
......@@ -292,8 +294,8 @@ function qa_db_user_logged_in($userid, $ip)
/**
* Note in the database that $userid just performed a write operation from $ip address
* @param $userid
* @param $ip
* @param mixed $userid
* @param string $ip
*/
function qa_db_user_written($userid, $ip)
{
......@@ -306,9 +308,9 @@ function qa_db_user_written($userid, $ip)
/**
* Add an external login in the database for $source and $identifier for user $userid
* @param $userid
* @param $source
* @param $identifier
* @param mixed $userid
* @param string $source
* @param string $identifier
*/
function qa_db_user_login_add($userid, $source, $identifier)
{
......@@ -322,8 +324,8 @@ function qa_db_user_login_add($userid, $source, $identifier)
/**
* Return some information about the user with external login $source and $identifier in the database, if a match is found
* @param $source
* @param $identifier
* @param string $source
* @param string $identifier
* @return array
*/
function qa_db_user_login_find($source, $identifier)
......@@ -338,7 +340,7 @@ function qa_db_user_login_find($source, $identifier)
/**
* Lock all tables if $sync is true, otherwise unlock them. Used to synchronize creation of external login mappings.
* @param $sync
* @param bool $sync
*/
function qa_db_user_login_sync($sync)
{
......@@ -360,8 +362,8 @@ function qa_db_user_login_sync($sync)
/**
* Reset the full set of context-specific (currently, per category) user levels for user $userid to $userlevels, where
* $userlevels is an array of arrays, the inner arrays containing items 'entitytype', 'entityid' and 'level'.
* @param $userid
* @param $userlevels
* @param mixed $userid
* @param array $userlevels
*/
function qa_db_user_levels_set($userid, $userlevels)
{
......@@ -382,8 +384,8 @@ function qa_db_user_levels_set($userid, $userlevels)
/**
* Get the information required for sending a mailing to the next $count users with userids greater than $lastuserid
* @param $lastuserid
* @param $count
* @param mixed $lastuserid
* @param int $count
* @return array
*/
function qa_db_users_get_mailing_next($lastuserid, $count)
......
......@@ -27,9 +27,9 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
/**
* Set the vote for $userid on $postid to $vote in the database
* @param $postid
* @param $userid
* @param $vote
* @param int $postid
* @param mixed $userid
* @param int $vote
*/
function qa_db_uservote_set($postid, $userid, $vote)
{
......@@ -44,9 +44,9 @@ function qa_db_uservote_set($postid, $userid, $vote)
/**
* Get the vote for $userid on $postid from the database (or NULL if none)
* @param $postid
* @param $userid
* @return mixed|null
* @param int $postid
* @param mixed $userid
* @return string|null
*/
function qa_db_uservote_get($postid, $userid)
{
......@@ -59,13 +59,13 @@ function qa_db_uservote_get($postid, $userid)
/**
* Set the flag for $userid on $postid to $flag (true or false) in the database
* @param $postid
* @param $userid
* @param $flag
* @param int $postid
* @param mixed $userid
* @param bool $flag
*/
function qa_db_userflag_set($postid, $userid, $flag)
{
$flag = $flag ? 1 : 0;
$flag = (int)$flag;
qa_db_query_sub(
'INSERT INTO ^uservotes (postid, userid, vote, flag) VALUES (#, #, 0, #) ON DUPLICATE KEY UPDATE flag=#',
......@@ -76,7 +76,7 @@ function qa_db_userflag_set($postid, $userid, $flag)
/**
* Clear all flags for $postid in the database
* @param $postid
* @param int $postid
*/
function qa_db_userflags_clear_all($postid)
{
......@@ -89,7 +89,7 @@ function qa_db_userflags_clear_all($postid)
/**
* Recalculate the cached count of upvotes, downvotes and netvotes for $postid in the database
* @param $postid
* @param int $postid
*/
function qa_db_post_recount_votes($postid)
{
......@@ -104,7 +104,7 @@ function qa_db_post_recount_votes($postid)
/**
* Recalculate the cached count of flags for $postid in the database
* @param $postid
* @param int $postid
*/
function qa_db_post_recount_flags($postid)
{
......@@ -119,7 +119,7 @@ function qa_db_post_recount_flags($postid)
/**
* Returns all non-zero votes on post $postid from the database as an array of [userid] => [vote]
* @param $postid
* @param int $postid
* @return array
*/
function qa_db_uservote_post_get($postid)
......@@ -133,7 +133,7 @@ function qa_db_uservote_post_get($postid)
/**
* Returns all the postids from the database for posts that $userid has voted on or flagged
* @param $userid
* @param mixed $userid
* @return array
*/
function qa_db_uservoteflag_user_get($userid)
......@@ -147,7 +147,7 @@ function qa_db_uservoteflag_user_get($userid)
/**
* Return information about all the non-zero votes and/or flags on the posts in postids, including user handles for internal user management
* @param $postids
* @param array $postids
* @return array
*/
function qa_db_uservoteflag_posts_get($postids)
......@@ -168,7 +168,6 @@ function qa_db_uservoteflag_posts_get($postids)
/**
* Remove all votes assigned to a post that had been cast by the owner of the post.
*
* @param int $postid The post ID from which the owner's votes will be removed.
*/
function qa_db_uservote_remove_own($postid)
......
......@@ -33,11 +33,11 @@ require_once QA_INCLUDE_DIR . 'app/post-update.php';
* Checks for a POSTed click on $question by the current user and returns true if it was permitted and processed. Pass
* in the question's $answers, all $commentsfollows from it or its answers, and its closing $closepost (or null if
* none). If there is an error to display, it will be passed out in $error.
* @param $question
* @param $answers
* @param $commentsfollows
* @param $closepost
* @param $error
* @param array $question
* @param array $answers
* @param array $commentsfollows
* @param array $closepost
* @param string $error
* @return bool
*/
function qa_page_q_single_click_q($question, $answers, $commentsfollows, $closepost, &$error)
......@@ -127,12 +127,12 @@ function qa_page_q_single_click_q($question, $answers, $commentsfollows, $closep
* the $question, all of its $answers, and all $commentsfollows from it or its answers. Set $allowselectmove to whether
* it is legitimate to change the selected answer for the question from one to another (this can't be done via Ajax).
* If there is an error to display, it will be passed out in $error.
* @param $answer
* @param $question
* @param $answers
* @param $commentsfollows
* @param $allowselectmove
* @param $error
* @param array $answer
* @param array $question
* @param array $answers
* @param array $commentsfollows
* @param bool $allowselectmove
* @param string $error
* @return bool
*/
function qa_page_q_single_click_a($answer, $question, $answers, $commentsfollows, $allowselectmove, &$error)
......@@ -231,10 +231,10 @@ function qa_page_q_single_click_a($answer, $question, $answers, $commentsfollows
* Checks for a POSTed click on $comment by the current user and returns true if it was permitted and processed. Pass
* in the antecedent $question and the comment's $parent post. If there is an error to display, it will be passed out
* in $error.
* @param $comment
* @param $question
* @param $parent
* @param $error
* @param array $comment
* @param array $question
* @param array $parent
* @param string $error
* @return bool
*/
function qa_page_q_single_click_c($comment, $question, $parent, &$error)
......@@ -322,8 +322,8 @@ function qa_page_q_single_click_c($comment, $question, $parent, &$error)
/**
* Check the form security (anti-CSRF protection) for one of the buttons shown for post $post. Return true if the
* security passed, otherwise return false and set an error message in $error
* @param $post
* @param $error
* @param array $post
* @param string $error
* @return bool
*/
function qa_page_q_click_check_form_code($post, &$error)
......@@ -341,12 +341,12 @@ function qa_page_q_click_check_form_code($post, &$error)
* Processes a POSTed form to add an answer to $question, returning the postid if successful, otherwise null. Pass in
* other $answers to the question and whether a $usecaptcha is required. The form fields submitted will be passed out
* as an array in $in, as well as any $errors on those fields.
* @param $question
* @param $answers
* @param $usecaptcha
* @param $in
* @param $errors
* @return mixed|null
* @param array $question
* @param array $answers
* @param bool $usecaptcha
* @param array $in
* @param array $errors
* @return int|null
*/
function qa_page_q_add_a_submit($question, $answers, $usecaptcha, &$in, &$errors)
{
......@@ -424,13 +424,13 @@ function qa_page_q_add_a_submit($question, $answers, $usecaptcha, &$in, &$errors
* $question and the comment's $parent post. Set $usecaptcha to whether a captcha is required. Pass an array which
* includes the other comments with the same parent in $commentsfollows (it can contain other posts which are ignored).
* The form fields submitted will be passed out as an array in $in, as well as any $errors on those fields.
* @param $question
* @param $parent
* @param $commentsfollows
* @param $usecaptcha
* @param $in
* @param $errors
* @return mixed|null
* @param array $question
* @param array $parent
* @param array $commentsfollows
* @param bool $usecaptcha
* @param array $in
* @param array $errors
* @return int|null
*/
function qa_page_q_add_c_submit($question, $parent, $commentsfollows, $usecaptcha, &$in, &$errors)
{
......@@ -494,7 +494,7 @@ function qa_page_q_add_c_submit($question, $parent, $commentsfollows, $usecaptch
/**
* Return the array of information to be passed to filter modules for the post in $post (from the database)
* @param $post
* @param array $post
* @return array
*/
function qa_page_q_prepare_post_for_filters($post)
......
......@@ -27,8 +27,8 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
/**
* Given a $question and its $childposts from the database, return a list of that question's answers
* @param $question
* @param $childposts
* @param array $question
* @param array $childposts
* @return array
*/
function qa_page_q_load_as($question, $childposts)
......@@ -53,9 +53,9 @@ function qa_page_q_load_as($question, $childposts)
* Given a $question, its $childposts and its answers $achildposts from the database,
* return a list of comments or follow-on questions for that question or its answers.
* Follow-on and duplicate questions are now returned, with their visibility determined in qa_page_q_comment_follow_list()
* @param $question
* @param $childposts
* @param $achildposts
* @param array $question
* @param array $childposts
* @param array $achildposts
* @param array $duplicateposts
* @return array
*/
......@@ -93,11 +93,10 @@ function qa_page_q_load_c_follows($question, $childposts, $achildposts, $duplica
* Calculates which operations the current user may perform on a post. This function is a key part of Q2A's logic
* and is ripe for overriding by plugins. The latter two arrays can contain additional posts retrieved from the
* database, and these will be ignored.
*
* @param array $post The question/answer/comment to check.
* @param array $parentpost The post's parent if there is one.
* @param array $siblingposts The post's siblings (i.e. those with the same type and parent as the post).
* @param array $childposts The post's children (e.g. comments on answers).
* @param array|null $parentpost The post's parent if there is one.
* @param array|null $siblingposts The post's siblings (i.e. those with the same type and parent as the post).
* @param array|null $childposts The post's children (e.g. comments on answers).
* @return array List of elements that can be added to the post.
*/
function qa_page_q_post_rules($post, $parentpost = null, $siblingposts = null, $childposts = null)
......@@ -257,11 +256,11 @@ function qa_page_q_post_rules($post, $parentpost = null, $siblingposts = null, $
* is closed, pass the post used to close this question in $closepost, otherwise null. $usershtml should be an array
* which maps userids to HTML user representations, including the question's author and (if present) last editor. If a
* form has been explicitly requested for the page, set $formrequested to true - this will hide the buttons.
* @param $question
* @param $parentquestion
* @param $closepost
* @param $usershtml
* @param $formrequested
* @param array $question
* @param array|null $parentquestion
* @param int|null $closepost
* @param array $usershtml
* @param bool $formrequested
* @return array
*/
function qa_page_q_question_view($question, $parentquestion, $closepost, $usershtml, $formrequested)
......@@ -492,11 +491,11 @@ function qa_page_q_question_view($question, $parentquestion, $closepost, $usersh
* answer's $question and whether it $isselected. $usershtml should be an array which maps userids to HTML user
* representations, including the answer's author and (if present) last editor. If a form has been explicitly requested
* for the page, set $formrequested to true - this will hide the buttons.
* @param $question
* @param $answer
* @param $isselected
* @param $usershtml
* @param $formrequested
* @param array $question
* @param array $answer
* @param bool $isselected
* @param array $usershtml
* @param bool $formrequested
* @return array
*/
function qa_page_q_answer_view($question, $answer, $isselected, $usershtml, $formrequested)
......@@ -643,18 +642,17 @@ function qa_page_q_answer_view($question, $answer, $isselected, $usershtml, $for
* current user. Pass the comment's $parent post and antecedent $question. $usershtml should be an array which maps
* userids to HTML user representations, including the comments's author and (if present) last editor. If a form has
* been explicitly requested for the page, set $formrequested to true - this will hide the buttons.
* @param $question
* @param $parent
* @param $comment
* @param $usershtml
* @param $formrequested
* @param array $question
* @param array $parent
* @param array $comment
* @param array $usershtml
* @param bool $formrequested
* @return array
*/
function qa_page_q_comment_view($question, $parent, $comment, $usershtml, $formrequested)
{
$commentid = $comment['postid'];
$questionid = ($parent['basetype'] == 'Q') ? $parent['postid'] : $parent['parentid'];
$answerid = ($parent['basetype'] == 'Q') ? null : $parent['postid'];
$userid = qa_get_logged_in_userid();
$cookieid = qa_cookie_get();
......@@ -784,13 +782,13 @@ function qa_page_q_comment_view($question, $parent, $comment, $usershtml, $formr
* comments' and follow on questions' authors and (if present) last editors. If a form has been explicitly requested
* for the page, set $formrequested to true and pass the postid of the post for the form in $formpostid - this will
* hide the buttons and remove the $formpostid comment from the list.
* @param $question
* @param $parent
* @param $commentsfollows
* @param $alwaysfull
* @param $usershtml
* @param $formrequested
* @param $formpostid
* @param array $question
* @param array $parent
* @param array $commentsfollows
* @param bool $alwaysfull
* @param array $usershtml
* @param bool $formrequested
* @param int $formpostid
* @return array
*/
function qa_page_q_comment_follow_list($question, $parent, $commentsfollows, $alwaysfull, $usershtml, $formrequested, $formpostid)
......@@ -865,7 +863,7 @@ function qa_page_q_comment_follow_list($question, $parent, $commentsfollows, $al
}
}
if (!count($commentlist['cs']))
if (empty($commentlist['cs']))
$commentlist['hidden'] = true;
return $commentlist;
......@@ -877,14 +875,14 @@ function qa_page_q_comment_follow_list($question, $parent, $commentsfollows, $al
* and the result of qa_user_captcha_reason() in $captchareason. Pass previous inputs from a submitted version of this
* form in the array $in and resulting errors in $errors. If $loadnow is true, the form will be loaded immediately. Set
* $formrequested to true if the user explicitly requested it, as opposed being shown automatically.
* @param $qa_content
* @param $formid
* @param $captchareason
* @param $question
* @param $in
* @param $errors
* @param $loadnow
* @param $formrequested
* @param array $qa_content
* @param string $formid
* @param string $captchareason
* @param array $question
* @param array $in
* @param array $errors
* @param bool $loadnow
* @param bool $formrequested
* @return array
*/
function qa_page_q_add_a_form(&$qa_content, $formid, $captchareason, $question, $in, $errors, $loadnow, $formrequested)
......@@ -1026,14 +1024,14 @@ function qa_page_q_add_a_form(&$qa_content, $formid, $captchareason, $question,
* to use for the form in $formid and the result of qa_user_captcha_reason() in $captchareason. Pass previous inputs
* from a submitted version of this form in the array $in and resulting errors in $errors. If $loadfocusnow is true,
* the form will be loaded and focused immediately.
* @param $qa_content
* @param $question
* @param $parent
* @param $formid
* @param $captchareason
* @param $in
* @param $errors
* @param $loadfocusnow
* @param array $qa_content
* @param array $question
* @param array $parent
* @param string $formid
* @param string $captchareason
* @param array $in
* @param array $errors
* @param bool $loadfocusnow
* @return array
*/
function qa_page_q_add_c_form(&$qa_content, $question, $parent, $formid, $captchareason, $in, $errors, $loadfocusnow)
......
......@@ -35,7 +35,7 @@ define('QA_BUILD_DATE', '2019-01-12');
* Classes are mapped to PHP files with the underscores converted to directory separators. The Q2A_Util_Debug class is in
* the file qa-include/Q2A/Util/Debug.php. A class named Q2A_Db_User_Messages would be in a file qa-include/Q2A/Db/User/Messages.php.
*
* @param $class
* @param string $class
*/
function qa_autoload($class)
{
......@@ -86,7 +86,7 @@ if (!isset($qa_autoconnect) || $qa_autoconnect !== false) {
* Converts the $version string (e.g. 1.6.2.2) to a floating point that can be used for greater/lesser comparisons
* (PHP's version_compare() function is not quite suitable for our needs)
* @deprecated 1.8.2 no longer used
* @param $version
* @param string $version
* @return float
*/
function qa_version_to_float($version)
......@@ -109,7 +109,7 @@ function qa_version_to_float($version)
/**
* Returns true if the current Q2A version is lower than $version
* @param $version
* @param string $version
* @return bool
*/
function qa_qa_version_below($version)
......@@ -120,7 +120,7 @@ function qa_qa_version_below($version)
/**
* Returns true if the current PHP version is lower than $version
* @param $version
* @param string $version
* @return bool
*/
function qa_php_version_below($version)
......@@ -350,7 +350,7 @@ function qa_initialize_modularity()
/**
* Set up output buffering. Use gzip compression if option set and it's not an admin page (since some of these contain lengthy processes).
* @param $request
* @param string $request
* @return bool whether buffering was used
*/
function qa_initialize_buffering($request = '')
......@@ -418,10 +418,10 @@ function qa_initialize_postdb_plugins()
/**
* Standard database failure handler function which bring up the install/repair/upgrade page
* @param $type
* @param int $errno
* @param string $error
* @param string $query
* @param string $type
* @param int|null $errno
* @param string|null $error
* @param string|null $query
* @return mixed
*/
function qa_page_db_fail_handler($type, $errno = null, $error = null, $query = null)
......@@ -445,9 +445,9 @@ function qa_page_db_fail_handler($type, $errno = null, $error = null, $query = n
* Name, Description, Min Q2A & Min PHP are not currently used by themes.
*
* @deprecated Deprecated from 1.7; Q2A_Util_Metadata class and metadata.json files should be used instead
* @param $contents
* @param $type
* @param bool $versiononly
* @param string $contents
* @param string $type
* @param bool|null $versiononly
* @return array
*/
function qa_addon_metadata($contents, $type, $versiononly = false)
......@@ -538,12 +538,12 @@ function qa_load_override_files()
/**
* Register a module of $type named $name, whose class named $class is defined in file $include (or null if no include necessary)
* If this module comes from a plugin, pass in the local plugin $directory and the $urltoroot relative url for that directory
* @param $type
* @param $include
* @param $class
* @param $name
* @param string $type
* @param string $include
* @param string $class
* @param string $name
* @param string $directory
* @param string $urltoroot
* @param string|null $urltoroot
*/
function qa_register_module($type, $include, $class, $name, $directory = QA_INCLUDE_DIR, $urltoroot = null)
{
......@@ -568,10 +568,10 @@ function qa_register_module($type, $include, $class, $name, $directory = QA_INCL
/**
* Register a layer named $name, defined in file $include. If this layer comes from a plugin (as all currently do),
* pass in the local plugin $directory and the $urltoroot relative url for that directory
* @param $include
* @param $name
* @param string $include
* @param string $name
* @param string $directory
* @param string $urltoroot
* @param string|null $urltoroot
*/
function qa_register_layer($include, $name, $directory = QA_INCLUDE_DIR, $urltoroot = null)
{
......@@ -595,9 +595,9 @@ function qa_register_layer($include, $name, $directory = QA_INCLUDE_DIR, $urltor
/**
* Register a file $include containing override functions. If this file comes from a plugin (as all currently do),
* pass in the local plugin $directory and the $urltoroot relative url for that directory
* @param $include
* @param string $include
* @param string $directory
* @param string $urltoroot
* @param string|null $urltoroot
*/
function qa_register_overrides($include, $directory = QA_INCLUDE_DIR, $urltoroot = null)
{
......@@ -615,8 +615,8 @@ function qa_register_overrides($include, $directory = QA_INCLUDE_DIR, $urltoroot
* Register a set of language phrases, which should be accessed by the prefix $name/ in the qa_lang_*() functions.
* Pass in the $pattern representing the PHP files that define these phrases, where * in the pattern is replaced with
* the language code (e.g. 'fr') and/or 'default'. These files should be formatted like Q2A's qa-lang-*.php files.
* @param $pattern
* @param $name
* @param string $pattern
* @param string $name
*/
function qa_register_phrases($pattern, $name)
{
......@@ -640,10 +640,10 @@ function qa_register_phrases($pattern, $name)
/**
* Register a plugin module of $type named $name, whose class named $class is defined in file $include (or null if no include necessary)
* This function relies on some global variable values and can only be called from a plugin's qa-plugin.php file
* @param $type
* @param $include
* @param $class
* @param $name
* @param string $type
* @param string $include
* @param string $class
* @param string $name
*/
function qa_register_plugin_module($type, $include, $class, $name)
{
......@@ -659,8 +659,8 @@ function qa_register_plugin_module($type, $include, $class, $name)
/**
* Register a plugin layer named $name, defined in file $include. Can only be called from a plugin's qa-plugin.php file
* @param $include
* @param $name
* @param string $include
* @param string $name
*/
function qa_register_plugin_layer($include, $name)
{
......@@ -676,7 +676,7 @@ function qa_register_plugin_layer($include, $name)
/**
* Register a plugin file $include containing override functions. Can only be called from a plugin's qa-plugin.php file
* @param $include
* @param string $include
*/
function qa_register_plugin_overrides($include)
{
......@@ -692,8 +692,8 @@ function qa_register_plugin_overrides($include)
/**
* Register a file name $pattern within a plugin directory containing language phrases accessed by the prefix $name
* @param $pattern
* @param $name
* @param string $pattern
* @param string $name
*/
function qa_register_plugin_phrases($pattern, $name)
{
......@@ -712,8 +712,8 @@ function qa_register_plugin_phrases($pattern, $name)
/**
* Calls eval() on the PHP code in $eval which came from the file $filename. It supplements PHP's regular error reporting by
* displaying/logging (as appropriate) the original source filename, if an error occurred when evaluating the code.
* @param $eval
* @param $filename
* @param string $eval
* @param string $filename
*/
function qa_eval_from_file($eval, $filename)
{
......@@ -747,8 +747,8 @@ function qa_eval_from_file($eval, $filename)
/**
* Call $function with the arguments in the $args array (doesn't work with call-by-reference functions)
* @param $function
* @param $args
* @param string $function
* @param array $args
* @return mixed
*/
function qa_call($function, $args)
......@@ -776,7 +776,6 @@ function qa_call($function, $args)
/**
* Determines whether a function is to be overridden by a plugin. But if the function is being called with
* the _base suffix, any override will be bypassed due to $qa_direct.
*
* @param string $function The function to override
* @return string|null The name of the overriding function (of the form `qa_functionname_override_1_in_filename`)
*/
......@@ -804,8 +803,8 @@ function qa_to_override($function)
/**
* Call the function which immediately overrides $function with the arguments in the $args array
* @param $function
* @param $args
* @param string $function
* @param array $args
* @return mixed
*/
function qa_call_override($function, $args)
......@@ -827,7 +826,7 @@ function qa_call_override($function, $args)
/**
* Exit PHP immediately after reporting a shutdown with $reason to any installed process modules
* @param string $reason
* @param string|null $reason
*/
function qa_exit($reason = null)
{
......@@ -840,7 +839,7 @@ function qa_exit($reason = null)
/**
* Display $message in the browser, write it to server error log, and then stop abruptly
* @param $message
* @param string $message
* @return mixed
*/
function qa_fatal_error($message)
......@@ -885,7 +884,7 @@ function qa_list_module_types()
/**
* Return a list of names of registered modules of $type
* @param $type
* @param string $type
* @return array
*/
function qa_list_modules($type)
......@@ -896,8 +895,8 @@ function qa_list_modules($type)
/**
* Return an array containing information about the module of $type named $name
* @param $type
* @param $name
* @param string $type
* @param string $name
* @return array
*/
function qa_get_module_info($type, $name)
......@@ -908,8 +907,8 @@ function qa_get_module_info($type, $name)
/**
* Return an instantiated class for module of $type named $name, whose functions can be called, or null if it doesn't exist
* @param $type
* @param $name
* @param string $type
* @param string $name
* @return mixed|null
*/
function qa_load_module($type, $name)
......@@ -942,7 +941,7 @@ function qa_load_module($type, $name)
/**
* Return an array of instantiated clases for modules which have defined $method
* (all modules are loaded but not included in the returned array)
* @param $method
* @param string $method
* @return array
*/
function qa_load_all_modules_with($method)
......@@ -966,8 +965,8 @@ function qa_load_all_modules_with($method)
/**
* Return an array of instantiated clases for modules of $type which have defined $method
* (other modules of that type are also loaded but not included in the returned array)
* @param $type
* @param $method
* @param string $type
* @param string $method
* @return array
*/
function qa_load_modules_with($type, $method)
......@@ -991,13 +990,13 @@ function qa_load_modules_with($type, $method)
/**
* Return HTML representation of $string, work well with blocks of text if $multiline is true
* @param $string
* @param string $string
* @param bool $multiline
* @return mixed|string
* @return string
*/
function qa_html($string, $multiline = false)
{
$html = htmlspecialchars((string)$string);
$html = htmlspecialchars($string);
if ($multiline) {
$html = preg_replace('/\r\n?/', "\n", $html);
......@@ -1014,10 +1013,10 @@ function qa_html($string, $multiline = false)
* Return $html after ensuring it is safe, i.e. removing Javascripts and the like - uses htmLawed library
* Links open in a new window if $linksnewwindow is true. Set $storage to true if sanitization is for
* storing in the database, rather than immediate display to user - some think this should be less strict.
* @param $html
* @param string $html
* @param bool $linksnewwindow
* @param bool $storage
* @return mixed|string
* @return string
*/
function qa_sanitize_html($html, $linksnewwindow = false, $storage = false)
{
......@@ -1044,7 +1043,7 @@ function qa_sanitize_html($html, $linksnewwindow = false, $storage = false)
/**
* htmLawed hook function used to process tags in qa_sanitize_html(...)
* @param $element
* @param string $element
* @param array $attributes
* @return string
*/
......@@ -1074,19 +1073,19 @@ function qa_sanitize_html_hook_tag($element, $attributes = null)
/**
* Return XML representation of $string, which is similar to HTML but ASCII control characters are also disallowed
* @param $string
* @param string $string
* @return string
*/
function qa_xml($string)
{
return htmlspecialchars(preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F]/', '', (string)$string));
return htmlspecialchars(preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F]/', '', $string));
}
/**
* Return JavaScript representation of $value, putting in quotes if non-numeric or if $forcequotes is true. In the
* case of boolean values they are returned as the appropriate true or false string
* @param $value
* @param mixed $value
* @param bool $forcequotes
* @return string
*/
......@@ -1113,9 +1112,9 @@ function qa_js($value, $forcequotes = false)
/**
* Inform Q2A that the current request is $request (slash-separated, independent of the url scheme chosen),
* that the relative path to the Q2A root apperas to be $relativeroot, and the url scheme appears to be $usedformat
* @param $request
* @param $relativeroot
* @param $usedformat
* @param string $request
* @param string $relativeroot
* @param int|null $usedformat
* @return mixed
*/
function qa_set_request($request, $relativeroot, $usedformat = null)
......@@ -1132,6 +1131,7 @@ function qa_set_request($request, $relativeroot, $usedformat = null)
/**
* Returns the current Q2A request (slash-separated, independent of the url scheme chosen)
* @return string
*/
function qa_request()
{
......@@ -1144,8 +1144,8 @@ function qa_request()
/**
* Returns the indexed $part (as separated by slashes) of the current Q2A request, or null if it doesn't exist
* @param $part
* @return
* @param int $part
* @return string
*/
function qa_request_part($part)
{
......@@ -1167,8 +1167,8 @@ function qa_request_parts($start = 0)
/**
* Return string for incoming GET/POST/COOKIE value, stripping slashes if appropriate
* @param $string
* @return mixed|string
* @param string $string
* @return string
*/
function qa_gpc_to_string($string)
{
......@@ -1180,8 +1180,8 @@ function qa_gpc_to_string($string)
/**
* Return string with slashes added, if appropriate for later removal by qa_gpc_to_string()
* @param $string
* @return mixed|string
* @param string $string
* @return string
*/
function qa_string_to_gpc($string)
{
......@@ -1193,8 +1193,8 @@ function qa_string_to_gpc($string)
/**
* Return string for incoming GET field, or null if it's not defined
* @param $field
* @return mixed|null|string
* @param string $field
* @return mixed|null
*/
function qa_get($field)
{
......@@ -1207,7 +1207,7 @@ function qa_get($field)
/**
* Return string for incoming POST field, or null if it's not defined.
* While we're at it, trim() surrounding white space and converted to Unix line endings.
* @param $field
* @param string $field
* @return mixed|null
*/
function qa_post_text($field)
......@@ -1220,8 +1220,8 @@ function qa_post_text($field)
/**
* Return an array for incoming POST field, or null if it's not an array or not defined.
* While we're at it, trim() surrounding white space for each value and convert them to Unix line endings.
* @param $field
* @return array|mixed|null
* @param string $field
* @return mixed|null
*/
function qa_post_array($field)
{
......@@ -1242,8 +1242,8 @@ function qa_post_array($field)
/**
* Return true if form button $name was clicked (as type=submit/image) to create this page request, or if a
* simulated click was sent for the button (via 'qa_click' POST field)
* @param $name
* @return bool|mixed
* @param string $name
* @return bool
*/
function qa_clicked($name)
{
......@@ -1255,7 +1255,7 @@ function qa_clicked($name)
/**
* Determine the remote IP address of the user accessing the site.
* @return mixed String representing IP if it's available, or null otherwise.
* @return string|null String representing IP if it's available, or null otherwise.
*/
function qa_remote_ip_address()
{
......@@ -1270,6 +1270,7 @@ function qa_remote_ip_address()
* is too big to be properly processed by PHP, usually because there is an attachment in the HTTP request. A warning
* is added to the server's log displaying the size of the file that triggered this situation. It is important to note
* that whenever this happens the $_POST and $_FILES superglobals are empty.
* @return bool
*/
function qa_post_limit_exceeded()
{
......@@ -1283,6 +1284,8 @@ function qa_post_limit_exceeded()
$postmaxsize = convert_to_bytes($unit, $postmaxsize);
return $_SERVER['CONTENT_LENGTH'] > $postmaxsize;
}
return false;
}
......@@ -1290,8 +1293,8 @@ function qa_post_limit_exceeded()
* Turns a numeric value and a unit (g/m/k) into bytes
* @param string $unit One of 'g', 'm', 'k'. It is case insensitive
* @param int $value The value to turn into bytes
* @return int The amount of bytes the unit and the value represent. If the unit is not one of 'g', 'm' or 'k' then
* the original value is returned
* @return int The amount of bytes the unit and the value represent. If the unit is not one of 'g', 'm' or 'k' then the
* original value is returned
*/
function convert_to_bytes($unit, $value)
{
......@@ -1311,7 +1314,7 @@ function convert_to_bytes($unit, $value)
/**
* Whether we are responding to an HTTP GET request
* Return true if we are responding to an HTTP GET request
* @return bool True if the request is GET
*/
function qa_is_http_get()
......@@ -1323,6 +1326,7 @@ function qa_is_http_get()
/**
* Return true if we are responding to an HTTP POST request
* @return bool True if the request is POST
*/
function qa_is_http_post()
{
......@@ -1334,6 +1338,7 @@ function qa_is_http_post()
/**
* Return true if we appear to be responding to a secure HTTP request (but hard to be sure)
* @return bool
*/
function qa_is_https_probably()
{
......@@ -1346,6 +1351,7 @@ function qa_is_https_probably()
/**
* Return true if it appears the page request is coming from a human using a web browser, rather than a search engine
* or other bot. Based on a whitelist of terms in user agents, this can easily be tricked by a scraper or bad bot.
* @return bool
*/
function qa_is_human_probably()
{
......@@ -1363,7 +1369,9 @@ function qa_is_human_probably()
/**
* Return true if it appears that the page request is coming from a mobile client rather than a desktop/laptop web browser
* Return true if it appears that the page request is coming from a mobile client rather than a desktop/laptop web
* browser
* @return bool
*/
function qa_is_mobile_probably()
{
......@@ -1405,7 +1413,7 @@ function qa_is_mobile_probably()
* loading an option now will cause a problem (see issue in qa_default_option()). The part of
* $identifier before the slash (/) replaces the * in the qa-lang-*.php file references, and the
* part after the / is the key of the array element to be taken from that file's returned result.
* @param $identifier
* @param string $identifier
* @return string
*/
function qa_lang($identifier)
......@@ -1455,8 +1463,8 @@ function qa_lang($identifier)
/**
* Return the translated string for $identifier, with $symbol substituted for $textparam
* @param $identifier
* @param $textparam
* @param string $identifier
* @param string $textparam
* @param string $symbol
* @return mixed
*/
......@@ -1468,8 +1476,8 @@ function qa_lang_sub($identifier, $textparam, $symbol = '^')
/**
* Return the translated string for $identifier, converted to HTML
* @param $identifier
* @return mixed|string
* @param string $identifier
* @return string
*/
function qa_lang_html($identifier)
{
......@@ -1479,8 +1487,8 @@ function qa_lang_html($identifier)
/**
* Return the translated string for $identifier converted to HTML, with $symbol *then* substituted for $htmlparam
* @param $identifier
* @param $htmlparam
* @param string $identifier
* @param string $htmlparam
* @param string $symbol
* @return mixed
*/
......@@ -1493,8 +1501,8 @@ function qa_lang_html_sub($identifier, $htmlparam, $symbol = '^')
/**
* Return an array containing the translated string for $identifier converted to HTML, then split into three,
* with $symbol substituted for $htmlparam in the 'data' element, and obvious 'prefix' and 'suffix' elements
* @param $identifier
* @param $htmlparam
* @param string $identifier
* @param string $htmlparam
* @param string $symbol
* @return array
*/
......@@ -1518,6 +1526,7 @@ function qa_lang_html_sub_split($identifier, $htmlparam, $symbol = '^')
/**
* Return the relative path to the Q2A root (if it was previously set by qa_set_request())
* @return string
*/
function qa_path_to_root()
{
......@@ -1530,6 +1539,7 @@ function qa_path_to_root()
/**
* Return an array of mappings of Q2A requests, as defined in the qa-config.php file
* @return array
*/
function qa_get_request_map()
{
......@@ -1545,11 +1555,11 @@ function qa_get_request_map()
* Slashes in $request will not be urlencoded, but any other characters will.
* If $neaturls is set, use that, otherwise retrieve the option. If $rooturl is set, take
* that as the root of the Q2A site, otherwise use path to root which was set elsewhere.
* @param $request
* @param array $params
* @param string $rooturl
* @param int $neaturls
* @param string $anchor
* @param string $request
* @param array|null $params
* @param string|null $rooturl
* @param int|null $neaturls
* @param string|null $anchor
* @return string
*/
function qa_path($request, $params = null, $rooturl = null, $neaturls = null, $anchor = null)
......@@ -1623,11 +1633,11 @@ function qa_path($request, $params = null, $rooturl = null, $neaturls = null, $a
/**
* Return HTML representation of relative URI path for $request - see qa_path() for other parameters
* @param $request
* @param array $params
* @param string $rooturl
* @param int $neaturls
* @param string $anchor
* @param string $request
* @param array|null $params
* @param string|null $rooturl
* @param int|null $neaturls
* @param string|null $anchor
* @return mixed|string
*/
function qa_path_html($request, $params = null, $rooturl = null, $neaturls = null, $anchor = null)
......@@ -1638,9 +1648,9 @@ function qa_path_html($request, $params = null, $rooturl = null, $neaturls = nul
/**
* Return the absolute URI for $request - see qa_path() for other parameters
* @param $request
* @param array $params
* @param string $anchor
* @param string $request
* @param array|null $params
* @param string|null $anchor
* @return string
*/
function qa_path_absolute($request, $params = null, $anchor = null)
......@@ -1672,9 +1682,9 @@ function qa_q_request($questionid, $title)
/**
* Return the HTML anchor that should be used for post $postid with $basetype (Q/A/C)
* @param $basetype
* @param $postid
* @return mixed|string
* @param string $basetype
* @param int $postid
* @return string
*/
function qa_anchor($basetype, $postid)
{
......@@ -1687,12 +1697,12 @@ function qa_anchor($basetype, $postid)
/**
* Return the URL for question $questionid with $title, possibly using $absolute URLs.
* To link to a specific answer or comment in a question, set $showtype and $showid accordingly.
* @param $questionid
* @param $title
* @param int $questionid
* @param string $title
* @param bool $absolute
* @param string $showtype
* @param int $showid
* @return mixed|string
* @param string|null $showtype
* @param int|null $showid
* @return string
*/
function qa_q_path($questionid, $title, $absolute = false, $showtype = null, $showid = null)
{
......@@ -1713,11 +1723,11 @@ function qa_q_path($questionid, $title, $absolute = false, $showtype = null, $sh
/**
* Return the HTML representation of the URL for $questionid - other parameters as for qa_q_path()
* @param $questionid
* @param $title
* @param bool $absolute
* @param string $showtype
* @param int $showid
* @param int $questionid
* @param string $title
* @param bool|null $absolute
* @param string|null $showtype
* @param int|null $showid
* @return mixed|string
*/
function qa_q_path_html($questionid, $title, $absolute = false, $showtype = null, $showid = null)
......@@ -1728,8 +1738,8 @@ function qa_q_path_html($questionid, $title, $absolute = false, $showtype = null
/**
* Return the request for the specified $feed
* @param $feed
* @return mixed|string
* @param string $feed
* @return string
*/
function qa_feed_request($feed)
{
......@@ -1741,6 +1751,7 @@ function qa_feed_request($feed)
/**
* Return an HTML-ready relative URL for the current page, preserving GET parameters - this is useful for action="..." in HTML forms
* @return string
*/
function qa_self_html()
{
......@@ -1755,12 +1766,12 @@ function qa_self_html()
/**
* Return HTML for hidden fields to insert into a <form method="get"...> on the page.
* This is needed because any parameters on the URL will be lost when the form is submitted.
* @param $request
* @param array $params
* @param string $rooturl
* @param int $neaturls
* @param string $anchor
* @return mixed|string
* @param string $request
* @param array|null $params
* @param string|null $rooturl
* @param int|null $neaturls
* @param string|null $anchor
* @return string
*/
function qa_path_form_html($request, $params = null, $rooturl = null, $neaturls = null, $anchor = null)
{
......@@ -1784,11 +1795,11 @@ function qa_path_form_html($request, $params = null, $rooturl = null, $neaturls
/**
* Redirect the user's web browser to $request and then we're done - see qa_path() for other parameters
* @param $request
* @param array $params
* @param string $rooturl
* @param int $neaturls
* @param string $anchor
* @param string $request
* @param array|null $params
* @param string|null $rooturl
* @param int|null $neaturls
* @param string|null $anchor
* @return mixed
*/
function qa_redirect($request, $params = null, $rooturl = null, $neaturls = null, $anchor = null)
......@@ -1801,7 +1812,7 @@ function qa_redirect($request, $params = null, $rooturl = null, $neaturls = null
/**
* Redirect the user's web browser to page $path which is already a URL
* @param $url
* @param string $url
* @return mixed
*/
function qa_redirect_raw($url)
......@@ -1817,8 +1828,8 @@ function qa_redirect_raw($url)
/**
* Return the contents of remote $url, using file_get_contents() if possible, otherwise curl functions
* @param $url
* @return mixed|string
* @param string $url
* @return bool|string
*/
function qa_retrieve_url($url)
{
......@@ -1875,9 +1886,9 @@ function qa_service($key, $object = null)
/**
* Shortcut to get or set an option value without specifying database
* @param $name
* @param mixed $value
* @return
* @param string $name
* @param mixed|null $value
* @return string
*/
function qa_opt($name, $value = null)
{
......@@ -1898,7 +1909,7 @@ function qa_opt($name, $value = null)
/**
* Simple method to output a preformatted variable
* @param $var
* @param mixed $var
*/
function qa_debug($var)
{
......@@ -1925,12 +1936,12 @@ function qa_suspend_event_reports($suspend = true)
/**
* Send a notification of event $event by $userid, $handle and $cookieid to all event modules, with extra $params
* @param $event
* @param $userid
* @param $handle
* @param $cookieid
* @param string $event
* @param mixed $userid
* @param string $handle
* @param string $cookieid
* @param array $params
* @return mixed|void
* @return mixed
*/
function qa_report_event($event, $userid, $handle, $cookieid, $params = array())
{
......@@ -1946,7 +1957,10 @@ function qa_report_event($event, $userid, $handle, $cookieid, $params = array())
$eventmodule->process_event($event, $userid, $handle, $cookieid, $params);
}
/**
* Execute the given $method in all process modules. Parameters can be sent as arguments.
* @param string $method
*/
function qa_report_process_stage($method) // can have extra params
{
global $qa_process_reports_suspended;
......
......@@ -19,6 +19,8 @@
More about this license: http://www.question2answer.org/license.php
*/
use Q2A\Database\DbResult;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../');
exit;
......@@ -42,8 +44,8 @@ function qa_db_allow_connect()
* Connect to the Q2A database, select the right database, optionally install the $failhandler (and call it if necessary).
* Uses mysqli as of Q2A 1.7.
* @deprecated 1.9.0 Use DbConnection->connect() instead.
* @param null $failhandler
* @return mixed|void
* @param string|null $failhandler
* @return mixed
*/
function qa_db_connect($failhandler = null)
{
......@@ -56,7 +58,7 @@ function qa_db_connect($failhandler = null)
/**
* If a DB error occurs, call the installed fail handler (if any) otherwise report error and exit immediately.
* @deprecated 1.9.0 Use DbConnection->failError() instead.
* @param $type
* @param string $type
* @param int $errno
* @param string $error
* @param string $query
......@@ -105,8 +107,8 @@ function qa_db_disconnect()
* Run the raw $query, call the global failure handler if necessary, otherwise return the result resource.
* If appropriate, also track the resources used by database queries, and the queries themselves, for performance debugging.
* @deprecated 1.9.0 Use DbConnection->query() instead.
* @param $query
* @return mixed
* @param string $query
* @return DbResult
*/
function qa_db_query_raw($query)
{
......@@ -119,8 +121,8 @@ function qa_db_query_raw($query)
/**
* Lower-level function to execute a query, which automatically retries if there is a MySQL deadlock error.
* @deprecated 1.9.0 Use DbConnection->query() instead.
* @param $query
* @return mixed
* @param string $query
* @return DbResult
*/
function qa_db_query_execute($query)
{
......@@ -133,8 +135,8 @@ function qa_db_query_execute($query)
/**
* Return $string escaped for use in queries to the Q2A database (to which a connection must have been made).
* @deprecated 1.9.0 No longer needed: parameters passed to DbConnection->query() are automatically escaped.
* @param $string
* @return mixed
* @param string $string
* @return string
*/
function qa_db_escape_string($string)
{
......@@ -151,8 +153,8 @@ function qa_db_escape_string($string)
* Return $argument escaped for MySQL. Add quotes around it if $alwaysquote is true or it's not numeric.
* If $argument is an array, return a comma-separated list of escaped elements, with or without $arraybrackets.
* @deprecated 1.9.0
* @param $argument
* @param $alwaysquote
* @param mixed|null $argument
* @param bool $alwaysquote
* @param bool $arraybrackets
* @return mixed|string
*/
......@@ -184,7 +186,7 @@ function qa_db_argument_to_mysql($argument, $alwaysquote, $arraybrackets = false
/**
* Return the full name (with prefix) of database table $rawname, usually if it used after a ^ symbol.
* @deprecated 1.9.0 Use DbConnection->addTablePrefix() instead.
* @param $rawname
* @param string $rawname
* @return string
*/
function qa_db_add_table_prefix($rawname)
......@@ -198,7 +200,7 @@ function qa_db_add_table_prefix($rawname)
/**
* Callback function to add table prefixes, as used in qa_db_apply_sub().
* @deprecated 1.9.0 No longer needed.
* @param $matches
* @param array $matches
* @return string
*/
function qa_db_prefix_callback($matches)
......@@ -214,8 +216,8 @@ function qa_db_prefix_callback($matches)
* $ is replaced by the argument in quotes (even if it's a number), # only adds quotes if the argument is non-numeric.
* It's important to use $ when matching a textual column since MySQL won't use indexes to compare text against numbers.
* @deprecated 1.9.0 Use DbConnection->applyTableSub() instead.
* @param $query
* @param $arguments
* @param string $query
* @param array $arguments
* @return mixed
*/
function qa_db_apply_sub($query, $arguments)
......@@ -258,7 +260,7 @@ function qa_db_apply_sub($query, $arguments)
* Run $query after substituting ^, # and $ symbols, and return the result resource (or call fail handler).
* @deprecated 1.9.0 Use DbConnection->query() instead.
* @param string $query
* @return mixed
* @return DbResult
*/
function qa_db_query_sub($query) // arguments for substitution retrieved using func_get_args()
{
......@@ -266,13 +268,14 @@ function qa_db_query_sub($query) // arguments for substitution retrieved using f
return qa_service('database')->query($query, $params);
}
/**
* Run $query after substituting ^, # and $ symbols, and return the result resource (or call fail handler).
* Query parameters are passed as an array.
* @deprecated 1.9.0 Use DbConnection->query() instead.
* @param string $query
* @param array $params
* @return mixed
* @return DbResult
*/
function qa_db_query_sub_params($query, $params)
{
......@@ -283,7 +286,7 @@ function qa_db_query_sub_params($query, $params)
/**
* Return the number of rows in $result. (Simple wrapper for mysqli_result::num_rows.)
* @deprecated 1.9.0 Use DbResult->affectedRows() instead.
* @param $result
* @param DbResult|mysqli_result $result
* @return int
*/
function qa_db_num_rows($result)
......@@ -303,6 +306,7 @@ function qa_db_num_rows($result)
/**
* Return the value of the auto-increment column for the last inserted row.
* @deprecated 1.9.0 Use DbConnection->lastInsertId() instead.
* @return string
*/
function qa_db_last_insert_id()
{
......@@ -313,6 +317,7 @@ function qa_db_last_insert_id()
/**
* Return the number of rows affected by the last query.
* @deprecated 1.9.0 Use DbResult->affectedRows() instead.
* @return int
*/
function qa_db_affected_rows()
{
......@@ -324,16 +329,18 @@ function qa_db_affected_rows()
/**
* For the previous INSERT ... ON DUPLICATE KEY UPDATE query, return whether an insert operation took place.
* @deprecated 1.9.0 Use DbResult->affectedRows() instead.
* @return bool
*/
function qa_db_insert_on_duplicate_inserted()
{
return (qa_db_affected_rows() == 1);
return false;
}
/**
* Return a random integer (as a string) for use in a BIGINT column.
* Actual limit is 18,446,744,073,709,551,615 - we aim for 18,446,743,999,999,999,999.
* @return string
*/
function qa_db_random_bigint()
{
......@@ -344,6 +351,7 @@ function qa_db_random_bigint()
/**
* Return an array of the names of all tables in the Q2A database, converted to lower case.
* No longer used by Q2A and shouldn't be needed.
* @return array
*/
function qa_db_list_tables_lc()
{
......@@ -423,8 +431,8 @@ function qa_db_list_tables($onlyTablesWithPrefix = false)
/**
* Return the data specified by a single $selectspec - see long comment above.
* @deprecated 1.9.0 Use DbConnection->singleSelect() instead.
* @param $selectspec
* @return array|mixed
* @param array $selectspec
* @return mixed
*/
function qa_db_single_select($selectspec)
{
......@@ -496,9 +504,9 @@ function qa_db_post_select(&$outresult, $selectspec)
* is from column $key if specified, otherwise it's integer. The value of each element in the returned array
* is from column $value if specified, otherwise it's a named array of all columns, given an array of arrays.
* @deprecated 1.9.0 Use DbResult->fetchAllAssoc() instead.
* @param $result
* @param string $key
* @param mixed $value
* @param DbResult|mysqli_result $result
* @param string|null $key
* @param int|string|null $value
* @return array
*/
function qa_db_read_all_assoc($result, $key = null, $value = null)
......@@ -529,7 +537,7 @@ function qa_db_read_all_assoc($result, $key = null, $value = null)
* Return the first row from the $result resource as an array of [column name] => [column value].
* If there's no first row, throw a fatal error unless $allowempty is true.
* @deprecated 1.9.0 Use DbResult->fetchNextAssoc() instead.
* @param $result
* @param DbResult|mysqli_result $result
* @param bool $allowempty
* @return array|null
*/
......@@ -539,7 +547,6 @@ function qa_db_read_one_assoc($result, $allowempty = false)
return $allowempty ? $result->fetchNextAssoc() : $result->fetchNextAssocOrFail();
}
// backwards compatibility
if (!($result instanceof mysqli_result))
qa_fatal_error('Reading one assoc from invalid result');
......@@ -559,7 +566,7 @@ function qa_db_read_one_assoc($result, $allowempty = false)
/**
* Return a numbered array containing the first (and presumably only) column from the $result resource.
* @deprecated 1.9.0 Use DbResult->fetchAllValues() instead.
* @param $result
* @param DbResult|mysqli_result $result
* @return array
*/
function qa_db_read_all_values($result)
......@@ -568,7 +575,6 @@ function qa_db_read_all_values($result)
return $result->fetchAllValues(0);
}
// backwards compatibility
if (!($result instanceof mysqli_result))
qa_fatal_error('Reading column from invalid result');
......@@ -586,9 +592,9 @@ function qa_db_read_all_values($result)
* Return the first column of the first row (and presumably only cell) from the $result resource.
* If there's no first row, throw a fatal error unless $allowempty is true.
* @deprecated 1.9.0 Use DbResult->fetchOneValue() instead.
* @param $result
* @param DbResult|mysqli_result $result
* @param bool $allowempty
* @return mixed|null
* @return string|null
*/
function qa_db_read_one_value($result, $allowempty = false)
{
......@@ -596,7 +602,6 @@ function qa_db_read_one_value($result, $allowempty = false)
return $allowempty ? $result->fetchOneValue(0) : $result->fetchOneValueOrFail(0);
}
// backwards compatibility
if (!($result instanceof mysqli_result))
qa_fatal_error('Reading one value from invalid result');
......
......@@ -35,7 +35,7 @@ require_once QA_INCLUDE_DIR . 'app/options.php';
/**
* Database failure handler function for RSS feeds - outputs HTTP and text errors
* @param $type
* @param string $type
* @param int $errno
* @param string $error
* @param string $query
......@@ -62,8 +62,8 @@ function qa_feed_not_found()
/**
* Common function to load appropriate set of questions for requested feed, check category exists, and set up page title
* @param array $categoryslugs
* @param string $allkey
* @param string $catkey
* @param string|null $allkey
* @param string|null $catkey
* @param string $title
* @param array $questionselectspec1
* @param array $questionselectspec2
......
......@@ -34,7 +34,7 @@ qa_report_process_stage('init_install');
if (!function_exists('qa_install_db_fail_handler')) {
/**
* Handler function for database failures during the installation process
* @param $type
* @param string $type
* @param int $errno
* @param string $error
* @param string $query
......
......@@ -38,29 +38,60 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
class qa_html_theme_base
{
/** @var string */
public $template;
/** @var array */
public $content;
/** @var string */
public $rooturl;
/** @var string */
public $request;
public $isRTL; // (boolean) whether text direction is Right-To-Left
protected $minifyHtml; // (boolean) whether to indent the HTML
/**
* Whether text direction is Right-To-Left
*
* @var bool
*/
public $isRTL;
/**
* Whether to indent the HTML
*
* @var bool
*/
protected $minifyHtml;
/** @var int */
protected $indent = 0;
/** @var int */
protected $lines = 0;
/** @var array */
protected $context = array();
// whether to use new block layout in rankings (true) or fall back to tables (false)
/**
* Whether to use new block layout in rankings (true) or fall back to tables (false)
* @var bool
*/
protected $ranking_block_layout = false;
// theme 'slug' to use as CSS class
/**
* Theme 'slug' to use as CSS class
* @var string
*/
protected $theme;
/**
* Initialize the object and assign local variables.
* @param $template
* @param $content
* @param $rooturl
* @param $request
* @param string $template
* @param string $content
* @param string $rooturl
* @param string $request
*/
public function __construct($template, $content, $rooturl, $request)
{
......@@ -75,10 +106,10 @@ class qa_html_theme_base
/**
* @deprecated PHP4-style constructor deprecated from 1.7; please use proper `__construct`
* function instead.
* @param $template
* @param $content
* @param $rooturl
* @param $request
* @param string $template
* @param string $content
* @param string $rooturl
* @param string $request
*/
public function qa_html_theme_base($template, $content, $rooturl, $request)
{
......@@ -90,7 +121,7 @@ class qa_html_theme_base
* Output each element in $elements on a separate line, with automatic HTML indenting.
* This should be passed markup which uses the <tag/> form for unpaired tags, to help keep
* track of indenting, although its actual output converts these to <tag> for W3C validation.
* @param $elements
* @param array $elements
*/
public function output_array($elements)
{
......@@ -132,7 +163,7 @@ class qa_html_theme_base
/**
* Output $html at the current indent level, but don't change indent level based on the markup within.
* Useful for user-entered HTML which is unlikely to follow the rules we need to track indenting.
* @param $html
* @param string $html
*/
public function output_raw($html)
{
......@@ -144,8 +175,8 @@ class qa_html_theme_base
/**
* Output the three elements ['prefix'], ['data'] and ['suffix'] of $parts (if they're defined),
* with appropriate CSS classes based on $class, using $outertag and $innertag in the markup.
* @param $parts
* @param $class
* @param array $parts
* @param string $class
* @param string $outertag
* @param string $innertag
* @param string $extraclass
......@@ -167,8 +198,8 @@ class qa_html_theme_base
/**
* Set some context, which be accessed via $this->context for a function to know where it's being used on the page.
* @param $key
* @param $value
* @param string $key
* @param string $value
*/
public function set_context($key, $value)
{
......@@ -178,7 +209,7 @@ class qa_html_theme_base
/**
* Clear some context (used at the end of the appropriate loop).
* @param $key
* @param string $key
*/
public function clear_context($key)
{
......@@ -189,8 +220,8 @@ class qa_html_theme_base
/**
* Reorder the parts of the page according to the $parts array which contains part keys in their new order. Call this
* before main_parts(). See the docs for qa_array_reorder() in util/sort.php for the other parameters.
* @param $parts
* @param string $beforekey
* @param array $parts
* @param string|null $beforekey
* @param bool $reorderrelative
*/
public function reorder_parts($parts, $beforekey = null, $reorderrelative = true)
......@@ -203,8 +234,8 @@ class qa_html_theme_base
/**
* Output the widgets (as provided in $this->content['widgets']) for $region and $place.
* @param $region
* @param $place
* @param string $region
* @param string $place
*/
public function widgets($region, $place)
{
......@@ -1017,8 +1048,8 @@ class qa_html_theme_base
/**
* Reorder the fields of $form according to the $keys array which contains the field keys in their new order. Call
* before any fields are output. See the docs for qa_array_reorder() in util/sort.php for the other parameters.
* @param $form
* @param $keys
* @param array
* @param array $keys
* @param mixed $beforekey
* @param bool $reorderrelative
*/
......@@ -1205,8 +1236,8 @@ class qa_html_theme_base
/**
* Reorder the buttons of $form according to the $keys array which contains the button keys in their new order. Call
* before any buttons are output. See the docs for qa_array_reorder() in util/sort.php for the other parameters.
* @param $form
* @param $keys
* @param array $form
* @param array $keys
* @param mixed $beforekey
* @param bool $reorderrelative
*/
......@@ -1477,7 +1508,7 @@ class qa_html_theme_base
* removed in a future version. Themes can switch to the new layout by setting the member
* variable $ranking_block_layout to false.
* @param $ranking
* @param $class
* @param string $class
*/
public function ranking_table($ranking, $class)
{
......@@ -1507,7 +1538,7 @@ class qa_html_theme_base
/**
* @deprecated See ranking_table above.
* @param $item
* @param $class
* @param string $class
* @param $spacer
*/
public function ranking_table_item($item, $class, $spacer)
......@@ -1535,7 +1566,7 @@ class qa_html_theme_base
/**
* @deprecated See ranking_table above.
* @param $class
* @param string $class
*/
public function ranking_spacer($class)
{
......@@ -1897,8 +1928,8 @@ class qa_html_theme_base
/**
* @deprecated Deprecated from 1.7; please use avatar() instead.
* @param $post
* @param $class
* @param array $post
* @param string $class
* @param string $prefix
*/
public function post_avatar($post, $class, $prefix = null)
......
......@@ -39,8 +39,8 @@ function qa_has_gd_image()
* Check if the image in $imagefile will be too big for PHP/GD to process given memory usage and limits
* Pass the width and height limit beyond which the image will require scaling in $size (if any)
* Returns false if the image will fit fine, otherwise a safe estimate of the factor the image should be sized by
* @param $imagefile
* @param int $size
* @param string $imagefile
* @param int|null $size
* @return bool|float
*/
function qa_image_file_too_big($imagefile, $size = null)
......@@ -82,12 +82,12 @@ function qa_image_file_too_big($imagefile, $size = null)
* Given $imagedata containing JPEG/GIF/PNG data, constrain it proportionally to fit in $maxwidth x $maxheight.
* Return the new image data (will always be a JPEG), and set the $width and $height variables.
* If $maxheight is omitted or set to null, assume it to be the same as $maxwidth.
* @param $imagedata
* @param string $imagedata
* @param int $width
* @param int $height
* @param int $maxwidth
* @param int $maxheight
* @return null|string
* @param int|null $maxheight
* @return string|null
*/
function qa_image_constrain_data($imagedata, &$width, &$height, $maxwidth, $maxheight = null)
{
......@@ -119,7 +119,7 @@ function qa_image_constrain_data($imagedata, &$width, &$height, $maxwidth, $maxh
* @param int $width
* @param int $height
* @param int $maxwidth
* @param int $maxheight
* @param int|null $maxheight
* @return bool
*/
function qa_image_constrain(&$width, &$height, $maxwidth, $maxheight = null)
......@@ -141,9 +141,9 @@ function qa_image_constrain(&$width, &$height, $maxwidth, $maxheight = null)
/**
* Resize the GD $image to $width and $height, setting it to null if the resize failed
* @param $image
* @param $width
* @param $height
* @param resource $image
* @param int $width
* @param int $height
*/
function qa_gd_image_resize(&$image, $width, $height)
{
......@@ -181,6 +181,7 @@ function qa_gd_image_jpeg($image, $output = false)
/**
* Return an array of strings listing the image formats that are supported
* @return array
*/
function qa_gd_image_formats()
{
......
......@@ -27,9 +27,9 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
/**
* Sort the $array of inner arrays by sub-element $by1 of each inner array, and optionally then by sub-element $by2
* @param $array
* @param $by1
* @param null $by2
* @param array $array
* @param string $by1
* @param string|null $by2
*/
function qa_sort_by(&$array, $by1, $by2 = null)
{
......@@ -44,8 +44,8 @@ function qa_sort_by(&$array, $by1, $by2 = null)
/**
* Function used in uasort to implement qa_sort_by()
* @param $a
* @param $b
* @param array $a
* @param array $b
* @return int
*/
function qa_sort_by_fn($a, $b)
......@@ -73,8 +73,8 @@ function qa_sort_by_fn($a, $b)
/**
* General comparison function for two values, textual or numeric
* @deprecated
* @param $a
* @param $b
* @param int|float|string $a
* @param int|float|string $b
* @return int
*/
function qa_sort_cmp($a, $b)
......@@ -89,9 +89,9 @@ function qa_sort_cmp($a, $b)
/**
* Inserts $addelements into $array, preserving their keys, before $beforekey in that array.
* If $beforekey cannot be found, the elements are appended at the end of the array.
* @param $array
* @param $beforekey
* @param $addelements
* @param array $array
* @param string $beforekey
* @param array $addelements
*/
function qa_array_insert(&$array, $beforekey, $addelements)
{
......@@ -130,9 +130,9 @@ define('QA_ARRAY_AT_END', 0.9); // place all the elements at the end of the arra
* element by passing the key of that element in $beforekey (if $beforekey is not found, the elements are moved to the
* end of the array). Any of the QA_ARRAY_* values defined above can also be passed in the $beforekey parameter.
* If $reorderrelative is true, the relative ordering between the elements will also be set by the order in $keys.
* @param $array
* @param $keys
* @param mixed $beforekey
* @param array $array
* @param array $keys
* @param mixed|null $beforekey
* @param bool $reorderrelative
*/
function qa_array_reorder(&$array, $keys, $beforekey = null, $reorderrelative = true)
......
......@@ -421,7 +421,7 @@ function qa_string_initialize()
* Return the UTF-8 input string converted into an array of words, changed $tolowercase (or not).
* Set $delimiters to true to keep the delimiters after each word and tweak what we used for word
* splitting with $splitideographs and $splithyphens.
* @param $string
* @param string $string
* @param bool $tolowercase
* @param bool $delimiters
* @param bool $splitideographs
......@@ -521,8 +521,8 @@ function qa_slugify($string, $asciiOnly = true, $maxLength = null)
/**
* Convert an array of tags into a string for storage in the database
* @param $tags
* @return mixed|string
* @param array $tags
* @return string
*/
function qa_tags_to_tagstring($tags)
{
......@@ -534,7 +534,7 @@ function qa_tags_to_tagstring($tags)
/**
* Convert a tag string as stored in the database into an array of tags
* @param $tagstring
* @param string $tagstring
* @return array|mixed
*/
function qa_tagstring_to_tags($tagstring)
......@@ -548,7 +548,6 @@ function qa_tagstring_to_tags($tagstring)
/**
* Converts a string to a single line and removes words from it until it fits in the given length. Words are removed
* from a position around two thirds of the string and are replaced by the given ellipsis string
*
* @param string $string Text that will be turned into a single line and cut, if necessary
* @param int $length Maximum allowed length of the returned string. This value can be overriden by the length of the
* ellipsis if it is higher than the maximum allowed length
......@@ -596,7 +595,7 @@ function qa_shorten_string_line($string, $length, $ellipsis = ' ... ')
/**
* Removes 4-byte Unicode characters (e.g. emoji) from a string due to missing support in MySQL < 5.5.3.
* @param string $string
* @param string $string
* @return string
*/
function qa_remove_utf8mb4($string)
......@@ -611,8 +610,8 @@ function qa_remove_utf8mb4($string)
/**
* Return an array of the words within $wordstring, each of which can contain asterisks
* @param $wordstring
* @return array|mixed
* @param string $wordstring
* @return array
*/
function qa_block_words_explode($wordstring)
{
......@@ -624,7 +623,7 @@ function qa_block_words_explode($wordstring)
/**
* Return a regular expression fragment corresponding to the block words $wordstring
* @param $wordsstring
* @param string $wordsstring
* @return mixed|string
*/
function qa_block_words_to_preg($wordsstring)
......@@ -652,8 +651,8 @@ function qa_block_words_to_preg($wordsstring)
/**
* Return an array of matches of the regular expression fragment $wordspreg in $string, [offset] => [length]
* @param $string
* @param $wordspreg
* @param string $string
* @param string $wordspreg
* @return array
*/
function qa_block_words_match_all($string, $wordspreg)
......@@ -693,7 +692,7 @@ function qa_block_words_match_all($string, $wordspreg)
* @param string $string
* @param string $wordspreg
* @param string $character
* @return mixed
* @return string
*/
function qa_block_words_replace($string, $wordspreg, $character = '*')
{
......@@ -713,7 +712,7 @@ function qa_block_words_replace($string, $wordspreg, $character = '*')
/**
* Return a random alphanumeric string (base 36) of $length
* @param $length
* @param int $length
* @return string
*/
function qa_random_alphanum($length)
......@@ -729,8 +728,8 @@ function qa_random_alphanum($length)
/**
* Return true or false to indicate whether $email is a valid email (this is pretty flexible compared to most real emails out there)
* @param $email
* @return bool|mixed
* @param string $email
* @return bool
*/
function qa_email_validate($email)
{
......@@ -742,8 +741,8 @@ function qa_email_validate($email)
/**
* Return the number of characters in $string, preferably using PHP's multibyte string functions
* @param $string
* @return int|mixed
* @param string $string
* @return int
*/
function qa_strlen($string)
{
......@@ -755,8 +754,8 @@ function qa_strlen($string)
/**
* Return a lower case version of $string, preferably using PHP's multibyte string functions
* @param $string
* @return mixed|string
* @param string $string
* @return string
*/
function qa_strtolower($string)
{
......@@ -768,10 +767,10 @@ function qa_strtolower($string)
/**
* Return $length characters from $string, starting from $start, preferably using PHP's multibyte string functions
* @param $string
* @param $start
* @param string $string
* @param int $start
* @param int $length
* @return mixed|string
* @return string
*/
function qa_substr($string, $start, $length = 2147483647)
{
......@@ -783,6 +782,7 @@ function qa_substr($string, $start, $length = 2147483647)
/**
* Return whether this version of PHP has been compiled with multibyte string support
* @return bool
*/
function qa_has_multibyte()
{
......@@ -792,8 +792,8 @@ function qa_has_multibyte()
/**
* Return true if at least one of the values in array $matches is a substring of $string. Otherwise, return false.
* @param $string
* @param $matches
* @param string $string
* @param array $matches
* @return bool
*/
function qa_string_matches_one($string, $matches)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment