Commit 6ca33b27 by pupi1985

PHPDoc update in qa-db, util/image, util/sort and util/string

parent a4d750a5
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
More about this license: http://www.question2answer.org/license.php 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 if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../'); header('Location: ../');
exit; exit;
...@@ -42,8 +44,8 @@ function qa_db_allow_connect() ...@@ -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). * 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. * Uses mysqli as of Q2A 1.7.
* @deprecated 1.9.0 Use DbConnection->connect() instead. * @deprecated 1.9.0 Use DbConnection->connect() instead.
* @param null $failhandler * @param string|null $failhandler
* @return mixed|void * @return mixed
*/ */
function qa_db_connect($failhandler = null) function qa_db_connect($failhandler = null)
{ {
...@@ -56,7 +58,7 @@ 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. * 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. * @deprecated 1.9.0 Use DbConnection->failError() instead.
* @param $type * @param string $type
* @param int $errno * @param int $errno
* @param string $error * @param string $error
* @param string $query * @param string $query
...@@ -105,8 +107,8 @@ function qa_db_disconnect() ...@@ -105,8 +107,8 @@ function qa_db_disconnect()
* Run the raw $query, call the global failure handler if necessary, otherwise return the result resource. * 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. * 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. * @deprecated 1.9.0 Use DbConnection->query() instead.
* @param $query * @param string $query
* @return mixed * @return DbResult
*/ */
function qa_db_query_raw($query) function qa_db_query_raw($query)
{ {
...@@ -119,8 +121,8 @@ 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. * 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. * @deprecated 1.9.0 Use DbConnection->query() instead.
* @param $query * @param string $query
* @return mixed * @return DbResult
*/ */
function qa_db_query_execute($query) function qa_db_query_execute($query)
{ {
...@@ -133,8 +135,8 @@ 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). * 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. * @deprecated 1.9.0 No longer needed: parameters passed to DbConnection->query() are automatically escaped.
* @param $string * @param string $string
* @return mixed * @return string
*/ */
function qa_db_escape_string($string) function qa_db_escape_string($string)
{ {
...@@ -151,8 +153,8 @@ 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. * 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. * If $argument is an array, return a comma-separated list of escaped elements, with or without $arraybrackets.
* @deprecated 1.9.0 * @deprecated 1.9.0
* @param $argument * @param mixed|null $argument
* @param $alwaysquote * @param bool $alwaysquote
* @param bool $arraybrackets * @param bool $arraybrackets
* @return mixed|string * @return mixed|string
*/ */
...@@ -184,7 +186,7 @@ function qa_db_argument_to_mysql($argument, $alwaysquote, $arraybrackets = false ...@@ -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. * 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. * @deprecated 1.9.0 Use DbConnection->addTablePrefix() instead.
* @param $rawname * @param string $rawname
* @return string * @return string
*/ */
function qa_db_add_table_prefix($rawname) function qa_db_add_table_prefix($rawname)
...@@ -198,7 +200,7 @@ 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(). * Callback function to add table prefixes, as used in qa_db_apply_sub().
* @deprecated 1.9.0 No longer needed. * @deprecated 1.9.0 No longer needed.
* @param $matches * @param array $matches
* @return string * @return string
*/ */
function qa_db_prefix_callback($matches) function qa_db_prefix_callback($matches)
...@@ -214,8 +216,8 @@ 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. * $ 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. * 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. * @deprecated 1.9.0 Use DbConnection->applyTableSub() instead.
* @param $query * @param string $query
* @param $arguments * @param array $arguments
* @return mixed * @return mixed
*/ */
function qa_db_apply_sub($query, $arguments) function qa_db_apply_sub($query, $arguments)
...@@ -258,7 +260,7 @@ 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). * Run $query after substituting ^, # and $ symbols, and return the result resource (or call fail handler).
* @deprecated 1.9.0 Use DbConnection->query() instead. * @deprecated 1.9.0 Use DbConnection->query() instead.
* @param string $query * @param string $query
* @return mixed * @return DbResult
*/ */
function qa_db_query_sub($query) // arguments for substitution retrieved using func_get_args() 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 ...@@ -266,13 +268,14 @@ function qa_db_query_sub($query) // arguments for substitution retrieved using f
return qa_service('database')->query($query, $params); return qa_service('database')->query($query, $params);
} }
/** /**
* Run $query after substituting ^, # and $ symbols, and return the result resource (or call fail handler). * Run $query after substituting ^, # and $ symbols, and return the result resource (or call fail handler).
* Query parameters are passed as an array. * Query parameters are passed as an array.
* @deprecated 1.9.0 Use DbConnection->query() instead. * @deprecated 1.9.0 Use DbConnection->query() instead.
* @param string $query * @param string $query
* @param array $params * @param array $params
* @return mixed * @return DbResult
*/ */
function qa_db_query_sub_params($query, $params) function qa_db_query_sub_params($query, $params)
{ {
...@@ -283,7 +286,7 @@ 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.) * Return the number of rows in $result. (Simple wrapper for mysqli_result::num_rows.)
* @deprecated 1.9.0 Use DbResult->affectedRows() instead. * @deprecated 1.9.0 Use DbResult->affectedRows() instead.
* @param $result * @param DbResult|mysqli_result $result
* @return int * @return int
*/ */
function qa_db_num_rows($result) function qa_db_num_rows($result)
...@@ -303,6 +306,7 @@ 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. * Return the value of the auto-increment column for the last inserted row.
* @deprecated 1.9.0 Use DbConnection->lastInsertId() instead. * @deprecated 1.9.0 Use DbConnection->lastInsertId() instead.
* @return string
*/ */
function qa_db_last_insert_id() function qa_db_last_insert_id()
{ {
...@@ -313,6 +317,7 @@ 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. * Return the number of rows affected by the last query.
* @deprecated 1.9.0 Use DbResult->affectedRows() instead. * @deprecated 1.9.0 Use DbResult->affectedRows() instead.
* @return int
*/ */
function qa_db_affected_rows() function qa_db_affected_rows()
{ {
...@@ -324,16 +329,18 @@ 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. * For the previous INSERT ... ON DUPLICATE KEY UPDATE query, return whether an insert operation took place.
* @deprecated 1.9.0 Use DbResult->affectedRows() instead. * @deprecated 1.9.0 Use DbResult->affectedRows() instead.
* @return bool
*/ */
function qa_db_insert_on_duplicate_inserted() 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. * 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. * 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() function qa_db_random_bigint()
{ {
...@@ -344,6 +351,7 @@ 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. * 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. * No longer used by Q2A and shouldn't be needed.
* @return array
*/ */
function qa_db_list_tables_lc() function qa_db_list_tables_lc()
{ {
...@@ -423,8 +431,8 @@ function qa_db_list_tables($onlyTablesWithPrefix = false) ...@@ -423,8 +431,8 @@ function qa_db_list_tables($onlyTablesWithPrefix = false)
/** /**
* Return the data specified by a single $selectspec - see long comment above. * Return the data specified by a single $selectspec - see long comment above.
* @deprecated 1.9.0 Use DbConnection->singleSelect() instead. * @deprecated 1.9.0 Use DbConnection->singleSelect() instead.
* @param $selectspec * @param array $selectspec
* @return array|mixed * @return mixed
*/ */
function qa_db_single_select($selectspec) function qa_db_single_select($selectspec)
{ {
...@@ -496,9 +504,9 @@ function qa_db_post_select(&$outresult, $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 $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. * 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. * @deprecated 1.9.0 Use DbResult->fetchAllAssoc() instead.
* @param $result * @param DbResult|mysqli_result $result
* @param string $key * @param string|null $key
* @param mixed $value * @param int|string|null $value
* @return array * @return array
*/ */
function qa_db_read_all_assoc($result, $key = null, $value = null) 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) ...@@ -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]. * 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. * If there's no first row, throw a fatal error unless $allowempty is true.
* @deprecated 1.9.0 Use DbResult->fetchNextAssoc() instead. * @deprecated 1.9.0 Use DbResult->fetchNextAssoc() instead.
* @param $result * @param DbResult|mysqli_result $result
* @param bool $allowempty * @param bool $allowempty
* @return array|null * @return array|null
*/ */
...@@ -539,7 +547,6 @@ function qa_db_read_one_assoc($result, $allowempty = false) ...@@ -539,7 +547,6 @@ function qa_db_read_one_assoc($result, $allowempty = false)
return $allowempty ? $result->fetchNextAssoc() : $result->fetchNextAssocOrFail(); return $allowempty ? $result->fetchNextAssoc() : $result->fetchNextAssocOrFail();
} }
// backwards compatibility // backwards compatibility
if (!($result instanceof mysqli_result)) if (!($result instanceof mysqli_result))
qa_fatal_error('Reading one assoc from invalid result'); qa_fatal_error('Reading one assoc from invalid result');
...@@ -559,7 +566,7 @@ function qa_db_read_one_assoc($result, $allowempty = false) ...@@ -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. * Return a numbered array containing the first (and presumably only) column from the $result resource.
* @deprecated 1.9.0 Use DbResult->fetchAllValues() instead. * @deprecated 1.9.0 Use DbResult->fetchAllValues() instead.
* @param $result * @param DbResult|mysqli_result $result
* @return array * @return array
*/ */
function qa_db_read_all_values($result) function qa_db_read_all_values($result)
...@@ -568,7 +575,6 @@ function qa_db_read_all_values($result) ...@@ -568,7 +575,6 @@ function qa_db_read_all_values($result)
return $result->fetchAllValues(0); return $result->fetchAllValues(0);
} }
// backwards compatibility // backwards compatibility
if (!($result instanceof mysqli_result)) if (!($result instanceof mysqli_result))
qa_fatal_error('Reading column from invalid result'); qa_fatal_error('Reading column from invalid result');
...@@ -586,9 +592,9 @@ function qa_db_read_all_values($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. * 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. * If there's no first row, throw a fatal error unless $allowempty is true.
* @deprecated 1.9.0 Use DbResult->fetchOneValue() instead. * @deprecated 1.9.0 Use DbResult->fetchOneValue() instead.
* @param $result * @param DbResult|mysqli_result $result
* @param bool $allowempty * @param bool $allowempty
* @return mixed|null * @return string|null
*/ */
function qa_db_read_one_value($result, $allowempty = false) function qa_db_read_one_value($result, $allowempty = false)
{ {
...@@ -596,7 +602,6 @@ 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); return $allowempty ? $result->fetchOneValue(0) : $result->fetchOneValueOrFail(0);
} }
// backwards compatibility // backwards compatibility
if (!($result instanceof mysqli_result)) if (!($result instanceof mysqli_result))
qa_fatal_error('Reading one value from invalid result'); qa_fatal_error('Reading one value from invalid result');
......
...@@ -39,8 +39,8 @@ function qa_has_gd_image() ...@@ -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 * 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) * 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 * Returns false if the image will fit fine, otherwise a safe estimate of the factor the image should be sized by
* @param $imagefile * @param string $imagefile
* @param int $size * @param int|null $size
* @return bool|float * @return bool|float
*/ */
function qa_image_file_too_big($imagefile, $size = null) function qa_image_file_too_big($imagefile, $size = null)
...@@ -82,12 +82,12 @@ 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. * 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. * 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. * 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 $width
* @param int $height * @param int $height
* @param int $maxwidth * @param int $maxwidth
* @param int $maxheight * @param int|null $maxheight
* @return null|string * @return string|null
*/ */
function qa_image_constrain_data($imagedata, &$width, &$height, $maxwidth, $maxheight = 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 ...@@ -119,7 +119,7 @@ function qa_image_constrain_data($imagedata, &$width, &$height, $maxwidth, $maxh
* @param int $width * @param int $width
* @param int $height * @param int $height
* @param int $maxwidth * @param int $maxwidth
* @param int $maxheight * @param int|null $maxheight
* @return bool * @return bool
*/ */
function qa_image_constrain(&$width, &$height, $maxwidth, $maxheight = null) function qa_image_constrain(&$width, &$height, $maxwidth, $maxheight = null)
...@@ -141,9 +141,9 @@ 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 * Resize the GD $image to $width and $height, setting it to null if the resize failed
* @param $image * @param resource $image
* @param $width * @param int $width
* @param $height * @param int $height
*/ */
function qa_gd_image_resize(&$image, $width, $height) function qa_gd_image_resize(&$image, $width, $height)
{ {
...@@ -181,6 +181,7 @@ function qa_gd_image_jpeg($image, $output = false) ...@@ -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 an array of strings listing the image formats that are supported
* @return array
*/ */
function qa_gd_image_formats() function qa_gd_image_formats()
{ {
......
...@@ -27,9 +27,9 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly ...@@ -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 * Sort the $array of inner arrays by sub-element $by1 of each inner array, and optionally then by sub-element $by2
* @param $array * @param array $array
* @param $by1 * @param string $by1
* @param null $by2 * @param string|null $by2
*/ */
function qa_sort_by(&$array, $by1, $by2 = null) function qa_sort_by(&$array, $by1, $by2 = null)
{ {
...@@ -44,8 +44,8 @@ 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() * Function used in uasort to implement qa_sort_by()
* @param $a * @param array $a
* @param $b * @param array $b
* @return int * @return int
*/ */
function qa_sort_by_fn($a, $b) function qa_sort_by_fn($a, $b)
...@@ -73,8 +73,8 @@ 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 * General comparison function for two values, textual or numeric
* @deprecated * @deprecated
* @param $a * @param int|float|string $a
* @param $b * @param int|float|string $b
* @return int * @return int
*/ */
function qa_sort_cmp($a, $b) function qa_sort_cmp($a, $b)
...@@ -89,9 +89,9 @@ 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. * 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. * If $beforekey cannot be found, the elements are appended at the end of the array.
* @param $array * @param array $array
* @param $beforekey * @param string $beforekey
* @param $addelements * @param array $addelements
*/ */
function qa_array_insert(&$array, $beforekey, $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 ...@@ -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 * 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. * 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. * If $reorderrelative is true, the relative ordering between the elements will also be set by the order in $keys.
* @param $array * @param array $array
* @param $keys * @param array $keys
* @param mixed $beforekey * @param mixed|null $beforekey
* @param bool $reorderrelative * @param bool $reorderrelative
*/ */
function qa_array_reorder(&$array, $keys, $beforekey = null, $reorderrelative = true) function qa_array_reorder(&$array, $keys, $beforekey = null, $reorderrelative = true)
......
...@@ -421,7 +421,7 @@ function qa_string_initialize() ...@@ -421,7 +421,7 @@ function qa_string_initialize()
* Return the UTF-8 input string converted into an array of words, changed $tolowercase (or not). * 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 * Set $delimiters to true to keep the delimiters after each word and tweak what we used for word
* splitting with $splitideographs and $splithyphens. * splitting with $splitideographs and $splithyphens.
* @param $string * @param string $string
* @param bool $tolowercase * @param bool $tolowercase
* @param bool $delimiters * @param bool $delimiters
* @param bool $splitideographs * @param bool $splitideographs
...@@ -521,8 +521,8 @@ function qa_slugify($string, $asciiOnly = true, $maxLength = null) ...@@ -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 * Convert an array of tags into a string for storage in the database
* @param $tags * @param array $tags
* @return mixed|string * @return string
*/ */
function qa_tags_to_tagstring($tags) function qa_tags_to_tagstring($tags)
{ {
...@@ -534,7 +534,7 @@ 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 * Convert a tag string as stored in the database into an array of tags
* @param $tagstring * @param string $tagstring
* @return array|mixed * @return array|mixed
*/ */
function qa_tagstring_to_tags($tagstring) function qa_tagstring_to_tags($tagstring)
...@@ -548,7 +548,6 @@ 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 * 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 * 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 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 * @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 * ellipsis if it is higher than the maximum allowed length
...@@ -596,7 +595,7 @@ function qa_shorten_string_line($string, $length, $ellipsis = ' ... ') ...@@ -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. * 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 * @return string
*/ */
function qa_remove_utf8mb4($string) function qa_remove_utf8mb4($string)
...@@ -611,8 +610,8 @@ 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 * Return an array of the words within $wordstring, each of which can contain asterisks
* @param $wordstring * @param string $wordstring
* @return array|mixed * @return array
*/ */
function qa_block_words_explode($wordstring) function qa_block_words_explode($wordstring)
{ {
...@@ -624,7 +623,7 @@ 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 * Return a regular expression fragment corresponding to the block words $wordstring
* @param $wordsstring * @param string $wordsstring
* @return mixed|string * @return mixed|string
*/ */
function qa_block_words_to_preg($wordsstring) function qa_block_words_to_preg($wordsstring)
...@@ -652,8 +651,8 @@ 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] * Return an array of matches of the regular expression fragment $wordspreg in $string, [offset] => [length]
* @param $string * @param string $string
* @param $wordspreg * @param string $wordspreg
* @return array * @return array
*/ */
function qa_block_words_match_all($string, $wordspreg) function qa_block_words_match_all($string, $wordspreg)
...@@ -693,7 +692,7 @@ 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 $string
* @param string $wordspreg * @param string $wordspreg
* @param string $character * @param string $character
* @return mixed * @return string
*/ */
function qa_block_words_replace($string, $wordspreg, $character = '*') function qa_block_words_replace($string, $wordspreg, $character = '*')
{ {
...@@ -713,7 +712,7 @@ 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 * Return a random alphanumeric string (base 36) of $length
* @param $length * @param int $length
* @return string * @return string
*/ */
function qa_random_alphanum($length) function qa_random_alphanum($length)
...@@ -729,8 +728,8 @@ 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) * 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 * @param string $email
* @return bool|mixed * @return bool
*/ */
function qa_email_validate($email) function qa_email_validate($email)
{ {
...@@ -742,8 +741,8 @@ 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 * Return the number of characters in $string, preferably using PHP's multibyte string functions
* @param $string * @param string $string
* @return int|mixed * @return int
*/ */
function qa_strlen($string) function qa_strlen($string)
{ {
...@@ -755,8 +754,8 @@ 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 * Return a lower case version of $string, preferably using PHP's multibyte string functions
* @param $string * @param string $string
* @return mixed|string * @return string
*/ */
function qa_strtolower($string) function qa_strtolower($string)
{ {
...@@ -768,10 +767,10 @@ 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 * Return $length characters from $string, starting from $start, preferably using PHP's multibyte string functions
* @param $string * @param string $string
* @param $start * @param int $start
* @param int $length * @param int $length
* @return mixed|string * @return string
*/ */
function qa_substr($string, $start, $length = 2147483647) function qa_substr($string, $start, $length = 2147483647)
{ {
...@@ -783,6 +782,7 @@ 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 whether this version of PHP has been compiled with multibyte string support
* @return bool
*/ */
function qa_has_multibyte() function qa_has_multibyte()
{ {
...@@ -792,8 +792,8 @@ 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. * Return true if at least one of the values in array $matches is a substring of $string. Otherwise, return false.
* @param $string * @param string $string
* @param $matches * @param array $matches
* @return bool * @return bool
*/ */
function qa_string_matches_one($string, $matches) 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