Commit 006e1162 by Scott

Coding style: add missing DocBlocks

parent 57262809
......@@ -57,8 +57,8 @@ function qa_admin_check_privileges(&$qa_content)
/**
* Return a sorted array of available languages, [short code] => [long name]
* @return array
* Return a sorted array of available languages, [short code] => [long name]
* @return array
*/
function qa_admin_language_options()
{
......
......@@ -1289,12 +1289,12 @@ 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
*/
* 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
*/
function convert_to_bytes($unit, $value)
{
$value = (int) $value;
......
......@@ -37,6 +37,7 @@ class Container
/**
* Return an object assigned to the given key. If the key is not found an exception is thrown.
* @throws FatalErrorException
* @param string $key The key to look for
* @return mixed
*/
......
......@@ -173,6 +173,7 @@ class DbConnection
/**
* Prepare and execute a SQL query, handling any failures. In debugging mode, track the queries and resources used.
* @throws SelectSpecException
* @param string $query
* @param array $params
* @return DbResult
......
......@@ -68,10 +68,10 @@ class DbQueryHelper
/**
* Substitute single '?' in a SQL query with multiple '?' for array parameters, and flatten parameter list accordingly.
* @throws SelectSpecException
* @param string $query
* @param array $params
* @return array Query and flattened parameter list
* @throws SelectSpecException
*/
public function expandParameters($query, array $params = [])
{
......@@ -139,6 +139,7 @@ class DbQueryHelper
* INSERT INTO..VALUES query for inserting multiple rows.
* If the first subparam is an array, the rest of the parameter groups should have the same
* amount of elements, i.e. the output should be '(?, ?), (?, ?)' rather than '(?), (?, ?)'.
* @throws SelectSpecException
* @param array $subArray
* @param string $outQuery
* @param array $outParams
......
......@@ -57,9 +57,8 @@ class Router
/**
* Return the route definition that matches the given request. If none is found then null is
* returned.
*
* @throws MethodNotAllowedException
* @param string $request Request that will be looked for a match
*
* @return Route|null
*/
public function match($request)
......@@ -88,9 +87,7 @@ class Router
/**
* Build the final regular expression to match the request. This method replaces all the
* parameters' placeholders with the given regular expression.
*
* @param string $routePath Route that might have placeholders
*
* @return string
*/
private function buildPathRegex($routePath)
......@@ -100,7 +97,6 @@ class Router
/**
* Return the HTTP method of the current request.
*
* @return string
*/
public function getHttpMethod()
......
......@@ -25,10 +25,13 @@ abstract class AbstractFinalStep extends AbstractStep
protected $isFinalStep = true;
/**
* Should not be called.
* @throws Exception
* @return bool
*/
public function doStep()
{
throw new Exception('Do not process the completion step.');
return false;
}
}
......@@ -20,9 +20,16 @@ namespace Q2A\Recalc;
abstract class AbstractStep
{
/** @var string */
protected $state;
/** @var bool */
protected $isFinalStep = false;
/**
* Initialize a step.
* @param State $state
*/
public function __construct(State $state)
{
require_once QA_INCLUDE_DIR . 'app/format.php'; // for qa_format_number()
......@@ -30,13 +37,25 @@ abstract class AbstractStep
$this->state = $state;
}
/**
* Execute the step.
* @return bool
*/
abstract public function doStep();
/**
* Get the current progress.
* @return string
*/
public function getMessage()
{
return '';
}
/**
* Whether to stop processing.
* @return bool
*/
public function isFinalStep()
{
return $this->isFinalStep;
......@@ -45,12 +64,12 @@ abstract class AbstractStep
/**
* Return the translated language ID string replacing the progress and total in it.
*
* @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
* @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
* the formatted progress and total numbers.
*/
protected function progressLang($langId, $progress, $total)
{
......@@ -60,6 +79,11 @@ abstract class AbstractStep
));
}
/**
* Factory method to instantiate the State.
* @param State $state
* @return AbstractStep|null
*/
public static function factory(State $state)
{
$class = $state->getOperationClass();
......
......@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class BlobsMoveComplete extends AbstractFinalStep
{
/**
* Get the current progress.
* @return string
*/
public function getMessage()
{
return qa_lang('admin/blobs_move_complete');
......
......@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class BlobsToDB extends AbstractStep
{
/**
* Perform the recalculation.
* @return bool
*/
public function doStep()
{
$this->state->transition('doblobstodb_move');
......
......@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class BlobsToDBMove extends AbstractStep
{
/**
* Perform the recalculation.
* @return bool
*/
public function doStep()
{
$blob = qa_db_get_next_blob_on_disk($this->state->next);
......@@ -40,6 +44,10 @@ class BlobsToDBMove extends AbstractStep
return true;
}
/**
* Get the current progress.
* @return string
*/
public function getMessage()
{
return $this->progressLang('admin/blobs_move_moved', $this->state->done, $this->state->length);
......
......@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class BlobsToDisk extends AbstractStep
{
/**
* Perform the recalculation.
* @return bool
*/
public function doStep()
{
$this->state->transition('doblobstodisk_move');
......
......@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class BlobsToDiskMove extends AbstractStep
{
/**
* Perform the recalculation.
* @return bool
*/
public function doStep()
{
$blob = qa_db_get_next_blob_in_db($this->state->next);
......@@ -41,6 +45,10 @@ class BlobsToDiskMove extends AbstractStep
return true;
}
/**
* Get the current progress.
* @return string
*/
public function getMessage()
{
return $this->progressLang('admin/blobs_move_moved', $this->state->done, $this->state->length);
......
......@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class CacheClear extends AbstractStep
{
/**
* Perform the recalculation.
* @return bool
*/
public function doStep()
{
$this->state->transition('docacheclear_process');
......
......@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class CacheClearComplete extends AbstractFinalStep
{
/**
* Get the current progress.
* @return string
*/
public function getMessage()
{
return qa_lang('admin/caching_delete_complete');
......
......@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class CacheClearProcess extends AbstractStep
{
/**
* Perform the recalculation.
* @return bool
*/
public function doStep()
{
$cacheDriver = \Q2A\Storage\CacheFactory::getCacheDriver();
......@@ -37,6 +41,10 @@ class CacheClearProcess extends AbstractStep
return true;
}
/**
* Get the current progress.
* @return string
*/
public function getMessage()
{
return $this->progressLang('admin/caching_delete_progress', $this->state->done, $this->state->length);
......
......@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class CacheTrim extends AbstractStep
{
/**
* Perform the recalculation.
* @return bool
*/
public function doStep()
{
$this->state->transition('docachetrim_process');
......
......@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class DeleteHidden extends AbstractStep
{
/**
* Perform the recalculation.
* @return bool
*/
public function doStep()
{
$this->state->transition('dodeletehidden_comments');
......
......@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class DeleteHiddenAnswers extends AbstractStep
{
/**
* Perform the recalculation.
* @return bool
*/
public function doStep()
{
$posts = qa_db_posts_get_for_deleting('A', $this->state->next, 1);
......@@ -39,6 +43,10 @@ class DeleteHiddenAnswers extends AbstractStep
return true;
}
/**
* Get the current progress.
* @return string
*/
public function getMessage()
{
return $this->progressLang('admin/hidden_answers_deleted', $this->state->done, $this->state->length);
......
......@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class DeleteHiddenComments extends AbstractStep
{
/**
* Perform the recalculation.
* @return bool
*/
public function doStep()
{
$posts = qa_db_posts_get_for_deleting('C', $this->state->next, 1);
......@@ -39,6 +43,10 @@ class DeleteHiddenComments extends AbstractStep
return true;
}
/**
* Get the current progress.
* @return string
*/
public function getMessage()
{
return $this->progressLang('admin/hidden_comments_deleted', $this->state->done, $this->state->length);
......
......@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class DeleteHiddenComplete extends AbstractFinalStep
{
/**
* Get the current progress.
* @return string
*/
public function getMessage()
{
return qa_lang('admin/delete_hidden_complete');
......
......@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class DeleteHiddenQuestions extends AbstractStep
{
/**
* Perform the recalculation.
* @return bool
*/
public function doStep()
{
$posts = qa_db_posts_get_for_deleting('Q', $this->state->next, 1);
......@@ -39,6 +43,10 @@ class DeleteHiddenQuestions extends AbstractStep
return true;
}
/**
* Get the current progress.
* @return string
*/
public function getMessage()
{
return $this->progressLang('admin/hidden_questions_deleted', $this->state->done, $this->state->length);
......
......@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class RecalcCategories extends AbstractStep
{
/**
* Perform the recalculation.
* @return bool
*/
public function doStep()
{
$this->state->transition('dorecalccategories_postcount');
......
......@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class RecalcCategoriesBackPaths extends AbstractStep
{
/**
* Perform the recalculation.
* @return bool
*/
public function doStep()
{
$categoryids = qa_db_categories_get_for_recalcs($this->state->next, 10);
......@@ -37,6 +41,10 @@ class RecalcCategoriesBackPaths extends AbstractStep
return true;
}
/**
* Get the current progress.
* @return string
*/
public function getMessage()
{
return $this->progressLang('admin/recalc_categories_backpaths', $this->state->done, $this->state->length);
......
......@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class RecalcCategoriesComplete extends AbstractFinalStep
{
/**
* Get the current progress.
* @return string
*/
public function getMessage()
{
return qa_lang('admin/recalc_categories_complete');
......
......@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class RecalcCategoriesPostCount extends AbstractStep
{
/**
* Perform the recalculation.
* @return bool
*/
public function doStep()
{
qa_db_acount_update();
......
......@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class RecalcCategoriesPostUpdate extends AbstractStep
{
/**
* Perform the recalculation.
* @return bool
*/
public function doStep()
{
$postids = qa_db_posts_get_for_recategorizing($this->state->next, 100);
......@@ -39,6 +43,10 @@ class RecalcCategoriesPostUpdate extends AbstractStep
return true;
}
/**
* Get the current progress.
* @return string
*/
public function getMessage()
{
return $this->progressLang('admin/recalc_categories_updated', $this->state->done, $this->state->length);
......
......@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class RecalcCategoriesRecount extends AbstractStep
{
/**
* Perform the recalculation.
* @return bool
*/
public function doStep()
{
$categoryids = qa_db_categories_get_for_recalcs($this->state->next, 10);
......@@ -39,6 +43,10 @@ class RecalcCategoriesRecount extends AbstractStep
return true;
}
/**
* Get the current progress.
* @return string
*/
public function getMessage()
{
return $this->progressLang('admin/recalc_categories_recounting', $this->state->done, $this->state->length);
......
......@@ -60,6 +60,7 @@ class RecalcMain
/**
* Initialize the counts of resource usage.
* @param string $state
*/
public function __construct($state)
{
......@@ -76,11 +77,19 @@ class RecalcMain
$this->state = new \Q2A\Recalc\State($state);
}
/**
* Get the state.
* @return string
*/
public function getState()
{
return $this->state->getState();
}
/**
* Do the recalculation.
* @return bool
*/
public function performStep()
{
$step = AbstractStep::factory($this->state);
......@@ -99,7 +108,7 @@ class RecalcMain
}
/**
* Return a string which gives a user-viewable version of $state
* Return a string which gives a user-viewable version of $state.
* @return string
*/
public function getMessage()
......
......@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class RecalcPoints extends AbstractStep
{
/**
* Perform the recalculation.
* @return bool
*/
public function doStep()
{
$this->state->transition('dorecalcpoints_usercount');
......
......@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class RecalcPointsComplete extends AbstractFinalStep
{
/**
* Get the current progress.
* @return string
*/
public function getMessage()
{
return qa_lang('admin/recalc_points_complete');
......
......@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class RecalcPointsRecalc extends AbstractStep
{
/**
* Perform the recalculation.
* @return bool
*/
public function doStep()
{
$default_recalccount = 10;
......@@ -46,6 +50,10 @@ class RecalcPointsRecalc extends AbstractStep
}
}
/**
* Get the current progress.
* @return string
*/
public function getMessage()
{
return $this->progressLang('admin/recalc_points_recalced', $this->state->done, $this->state->length);
......
......@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class RecalcPointsUserCount extends AbstractStep
{
/**
* Perform the recalculation.
* @return bool
*/
public function doStep()
{
qa_db_userpointscount_update(); // for progress update - not necessarily accurate
......@@ -28,6 +32,10 @@ class RecalcPointsUserCount extends AbstractStep
return false;
}
/**
* Get the current progress.
* @return string
*/
public function getMessage()
{
return qa_lang('admin/recalc_points_usercount');
......
......@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class RecountPosts extends AbstractStep
{
/**
* Perform the recalculation.
* @return bool
*/
public function doStep()
{
$this->state->transition('dorecountposts_postcount');
......
......@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class RecountPostsACount extends AbstractStep
{
/**
* Perform the recalculation.
* @return bool
*/
public function doStep()
{
$postids = qa_db_posts_get_for_recounting($this->state->next, 1000);
......@@ -39,6 +43,10 @@ class RecountPostsACount extends AbstractStep
return true;
}
/**
* Get the current progress.
* @return string
*/
public function getMessage()
{
return $this->progressLang('admin/recount_posts_as_recounted', $this->state->done, $this->state->length);
......
......@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class RecountPostsComplete extends AbstractFinalStep
{
/**
* Get the current progress.
* @return string
*/
public function getMessage()
{
return qa_lang('admin/recount_posts_complete');
......
......@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class RecountPostsPostCount extends AbstractStep
{
/**
* Perform the recalculation.
* @return bool
*/
public function doStep()
{
qa_db_qcount_update();
......@@ -32,6 +36,10 @@ class RecountPostsPostCount extends AbstractStep
return false;
}
/**
* Get the current progress.
* @return string
*/
public function getMessage()
{
return qa_lang('admin/recalc_posts_count');
......
......@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class RecountPostsVoteCount extends AbstractStep
{
/**
* Perform the recalculation.
* @return bool
*/
public function doStep()
{
$postids = qa_db_posts_get_for_recounting($this->state->next, 1000);
......@@ -38,6 +42,10 @@ class RecountPostsVoteCount extends AbstractStep
return true;
}
/**
* Get the current progress.
* @return string
*/
public function getMessage()
{
return $this->progressLang('admin/recount_posts_votes_recounted', $this->state->done, $this->state->length);
......
......@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class RefillEvents extends AbstractStep
{
/**
* Perform the recalculation.
* @return bool
*/
public function doStep()
{
$this->state->transition('dorefillevents_qcount');
......
......@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class RefillEventsComplete extends AbstractFinalStep
{
/**
* Get the current progress.
* @return string
*/
public function getMessage()
{
return qa_lang('admin/refill_events_complete');
......
......@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class RefillEventsQCount extends AbstractStep
{
/**
* Perform the recalculation.
* @return bool
*/
public function doStep()
{
qa_db_qcount_update();
......@@ -27,6 +31,10 @@ class RefillEventsQCount extends AbstractStep
return false;
}
/**
* Get the current progress.
* @return string
*/
public function getMessage()
{
return qa_lang('admin/recalc_posts_count');
......
......@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class RefillEventsRefill extends AbstractStep
{
/**
* Include some extra files.
* @param State $state
*/
public function __construct(State $state)
{
require_once QA_INCLUDE_DIR . 'app/events.php';
......@@ -29,6 +33,10 @@ class RefillEventsRefill extends AbstractStep
parent::__construct($state);
}
/**
* Perform the recalculation.
* @return bool
*/
public function doStep()
{
$questionids = qa_db_qs_get_for_event_refilling($this->state->next, 1);
......@@ -124,6 +132,10 @@ class RefillEventsRefill extends AbstractStep
return true;
}
/**
* Get the current progress.
* @return string
*/
public function getMessage()
{
return $this->progressLang('admin/refill_events_refilled', $this->state->done, $this->state->length);
......
......@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class ReindexContent extends AbstractStep
{
/**
* Perform the recalculation.
* @return bool
*/
public function doStep()
{
$this->state->transition('doreindexcontent_pagereindex');
......
......@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class ReindexContentPageReindex extends AbstractStep
{
/**
* Perform the recalculation.
* @return bool
*/
public function doStep()
{
$pages = qa_db_pages_get_for_reindexing($this->state->next, 10);
......@@ -56,6 +60,10 @@ class ReindexContentPageReindex extends AbstractStep
return true;
}
/**
* Get the current progress.
* @return string
*/
public function getMessage()
{
return $this->progressLang('admin/reindex_pages_reindexed', $this->state->done, $this->state->length);
......
......@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class ReindexContentPostCount extends AbstractStep
{
/**
* Perform the recalculation.
* @return bool
*/
public function doStep()
{
qa_db_qcount_update();
......@@ -30,6 +34,10 @@ class ReindexContentPostCount extends AbstractStep
return false;
}
/**
* Get the current progress.
* @return string
*/
public function getMessage()
{
return qa_lang('admin/recalc_posts_count');
......
......@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class ReindexContentPostReindex extends AbstractStep
{
/**
* Perform the recalculation.
* @return bool
*/
public function doStep()
{
$posts = qa_db_posts_get_for_reindexing($this->state->next, 10);
......@@ -58,6 +62,10 @@ class ReindexContentPostReindex extends AbstractStep
return true;
}
/**
* Get the current progress.
* @return string
*/
public function getMessage()
{
return $this->progressLang('admin/reindex_posts_reindexed', $this->state->done, $this->state->length);
......
......@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class ReindexPostsComplete extends AbstractFinalStep
{
/**
* Get the current progress.
* @return string
*/
public function getMessage()
{
return qa_lang('admin/reindex_posts_complete');
......
......@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class ReindexPostsWordCount extends AbstractStep
{
/**
* Perform the recalculation.
* @return bool
*/
public function doStep()
{
$wordids = qa_db_words_prepare_for_recounting($this->state->next, 1000);
......@@ -39,6 +43,10 @@ class ReindexPostsWordCount extends AbstractStep
return true;
}
/**
* Get the current progress.
* @return string
*/
public function getMessage()
{
return $this->progressLang('admin/reindex_posts_wordcounted', $this->state->done, $this->state->length);
......
......@@ -73,41 +73,64 @@ class State
/**
* Initialize the counts of resource usage.
* @param string $state
*/
public function __construct($state)
{
$this->setState($state);
}
/**
* Get the state.
* @return string
*/
public function getState()
{
return $this->state;
}
/**
* Set the state.
* @param string $state
* @return void
*/
public function setState($state = '')
{
$this->state = $state;
list($this->operation, $this->length, $this->next, $this->done) = explode("\t", $state . "\t\t\t\t");
}
/**
* Update the state.
* @return void
*/
public function updateState()
{
$this->state = $this->operation . "\t" . $this->length . "\t" . $this->next . "\t" . $this->done;
}
/**
* Get the class that will handle this operation.
* @return string|null
*/
public function getOperationClass()
{
return isset($this->classes[$this->operation]) ? $this->classes[$this->operation] : null;
}
/**
* Whether all steps are completed.
* @return bool
*/
public function allDone()
{
return $this->done >= $this->length;
}
/**
* Change the $state to represent the beginning of a new $operation
* @param $newOperation
* Change the $state to represent the beginning of a new $operation.
* @param string $newOperation
* @return void
*/
public function transition($newOperation)
{
......@@ -120,7 +143,7 @@ class State
}
/**
* Return how many steps there will be in recalculation $operation
* Return how many steps there will be in recalculation operation.
* @return int
*/
private function stageLength()
......
......@@ -30,4 +30,16 @@
</properties>
</rule>
<!-- Not part of normal usage, but kept for testing (default severity = 5) -->
<rule ref="Squiz.Commenting.FunctionComment">
<severity>0</severity>
<exclude name="Squiz.Commenting.FunctionComment.EmptyThrows"/>
<exclude name="Squiz.Commenting.FunctionComment.IncorrectParamVarName"/>
<exclude name="Squiz.Commenting.FunctionComment.InvalidReturn"/>
<exclude name="Squiz.Commenting.FunctionComment.MissingParamComment"/>
<exclude name="Squiz.Commenting.FunctionComment.ScalarTypeHintMissing"/>
<exclude name="Squiz.Commenting.FunctionComment.SpacingAfterParamName"/>
<exclude name="Squiz.Commenting.FunctionComment.SpacingAfterParamType"/>
</rule>
</ruleset>
......@@ -43,4 +43,6 @@
</properties>
</rule>
<rule ref="Squiz.Commenting.DocCommentAlignment"></rule>
</ruleset>
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