From b7f7c3bcf226809bc685f3b351eadd16404429b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0koda?= Date: Sat, 15 Mar 2014 13:17:01 +0800 Subject: [PATCH] MDL-44639 fix some phpdocs issues in tasks classes There is also one extra () to improve code readability. --- lib/classes/task/adhoc_task.php | 4 +-- lib/classes/task/manager.php | 46 ++++++++++++++++------------- lib/classes/task/scheduled_task.php | 4 +-- lib/classes/task/task_base.php | 2 +- 4 files changed, 30 insertions(+), 26 deletions(-) diff --git a/lib/classes/task/adhoc_task.php b/lib/classes/task/adhoc_task.php index 7fc3fa65d2a..916b92b31ea 100644 --- a/lib/classes/task/adhoc_task.php +++ b/lib/classes/task/adhoc_task.php @@ -58,7 +58,7 @@ abstract class adhoc_task extends task_base { /** * Setter for $customdata. - * @param object $customdata (anything that can be handled by json_encode) + * @param mixed $customdata (anything that can be handled by json_encode) */ public function set_custom_data($customdata) { $this->customdata = json_encode($customdata); @@ -66,7 +66,7 @@ abstract class adhoc_task extends task_base { /** * Getter for $customdata. - * @return object (anything that can be handled by json_decode). + * @return mixed (anything that can be handled by json_decode). */ public function get_custom_data() { return json_decode($this->customdata); diff --git a/lib/classes/task/manager.php b/lib/classes/task/manager.php index 16726e86264..ea573c9efa7 100644 --- a/lib/classes/task/manager.php +++ b/lib/classes/task/manager.php @@ -40,7 +40,7 @@ class manager { * Given a component name, will load the list of tasks in the db/tasks.php file for that component. * * @param string $componentname - The name of the component to fetch the tasks for. - * @return array(core\task\scheduled_task) - List of scheduled tasks for this component. + * @return \core\task\scheduled_task[] - List of scheduled tasks for this component. */ public static function load_default_scheduled_tasks_for_component($componentname) { $dir = \core_component::get_component_directory($componentname); @@ -179,7 +179,7 @@ class manager { * Utility method to create a DB record from a scheduled task. * * @param \core\task\scheduled_task $task - * @return stdClass + * @return \stdClass */ public static function record_from_scheduled_task($task) { $record = new \stdClass(); @@ -206,7 +206,7 @@ class manager { * Utility method to create a DB record from an adhoc task. * * @param \core\task\adhoc_task $task - * @return stdClass + * @return \stdClass */ public static function record_from_adhoc_task($task) { $record = new \stdClass(); @@ -227,7 +227,7 @@ class manager { /** * Utility method to create an adhoc task from a DB record. * - * @param stdClass $record + * @param \stdClass $record * @return \core\task\adhoc_task */ public static function adhoc_task_from_record($record) { @@ -262,7 +262,7 @@ class manager { /** * Utility method to create a task from a DB record. * - * @param stdClass $record + * @param \stdClass $record * @return \core\task\scheduled_task */ public static function scheduled_task_from_record($record) { @@ -273,6 +273,7 @@ class manager { if (!class_exists($classname)) { return false; } + /** @var \core\task\scheduled_task $task */ $task = new $classname; if (isset($record->lastruntime)) { $task->set_last_run_time($record->lastruntime); @@ -313,7 +314,7 @@ class manager { * Given a component name, will load the list of tasks from the scheduled_tasks table for that component. * Do not execute tasks loaded from this function - they have not been locked. * @param string $componentname - The name of the component to load the tasks for. - * @return array(core\task\scheduled_task) + * @return \core\task\scheduled_task[] */ public static function load_scheduled_tasks_for_component($componentname) { global $DB; @@ -332,7 +333,8 @@ class manager { /** * This function load the scheduled task details for a given classname. * - * @return core\task\scheduled_task or false + * @param string $classname + * @return \core\task\scheduled_task or false */ public static function get_scheduled_task($classname) { global $DB; @@ -351,7 +353,8 @@ class manager { /** * This function load the default scheduled task details for a given classname. * - * @return core\task\scheduled_task or false + * @param string $classname + * @return \core\task\scheduled_task or false */ public static function get_default_scheduled_task($classname) { $task = self::get_scheduled_task($classname); @@ -370,7 +373,7 @@ class manager { /** * This function will return a list of all the scheduled tasks that exist in the database. * - * @return array(core\task\scheduled_task) or null + * @return \core\task\scheduled_task[] */ public static function get_all_scheduled_tasks() { global $DB; @@ -391,7 +394,8 @@ class manager { * with an open lock - possibly on the entire cron process. Make sure you call either * {@link adhoc_task_failed} or {@link adhoc_task_complete} to release the lock and reschedule the task. * - * @return core\task\adhoc_task or null + * @param int $timestart + * @return \core\task\adhoc_task or null if not found */ public static function get_next_adhoc_task($timestart) { global $DB; @@ -432,7 +436,7 @@ class manager { * {@link scheduled_task_failed} or {@link scheduled_task_complete} to release the lock and reschedule the task. * * @param int $timestart - The start of the cron process - do not repeat any tasks that have been run more recently than this. - * @return core\task\scheduled_task or null + * @return \core\task\scheduled_task or null */ public static function get_next_scheduled_task($timestart) { global $DB; @@ -468,9 +472,9 @@ class manager { } /** - * This function indicates that an adhoc task was not completed succesfully and should be retried. + * This function indicates that an adhoc task was not completed successfully and should be retried. * - * @param core\task\adhoc_task $task + * @param \core\task\adhoc_task $task */ public static function adhoc_task_failed(adhoc_task $task) { global $DB; @@ -505,9 +509,9 @@ class manager { } /** - * This function indicates that an adhoc task was completed succesfully. + * This function indicates that an adhoc task was completed successfully. * - * @param core\task\adhoc_task $task + * @param \core\task\adhoc_task $task */ public static function adhoc_task_complete(adhoc_task $task) { global $DB; @@ -523,9 +527,9 @@ class manager { } /** - * This function indicates that a scheduled task was not completed succesfully and should be retried. + * This function indicates that a scheduled task was not completed successfully and should be retried. * - * @param core\task\scheduled_task $task + * @param \core\task\scheduled_task $task */ public static function scheduled_task_failed(scheduled_task $task) { global $DB; @@ -561,9 +565,9 @@ class manager { } /** - * This function indicates that a scheduled task was completed succesfully and should be rescheduled. + * This function indicates that a scheduled task was completed successfully and should be rescheduled. * - * @param core\task\scheduled_task $task + * @param \core\task\scheduled_task $task */ public static function scheduled_task_complete(scheduled_task $task) { global $DB; @@ -611,11 +615,11 @@ class manager { /** * Return true if the static caches have been cleared since $starttime. * @param int $starttime The time this process started. - * @return boolean True if static caches need reseting. + * @return boolean True if static caches need resetting. */ public static function static_caches_cleared_since($starttime) { global $DB; $record = $DB->get_record('config', array('name'=>'scheduledtaskreset')); - return $record && intval($record->value) > $starttime; + return $record && (intval($record->value) > $starttime); } } diff --git a/lib/classes/task/scheduled_task.php b/lib/classes/task/scheduled_task.php index 9b76d81a967..1c36b07e434 100644 --- a/lib/classes/task/scheduled_task.php +++ b/lib/classes/task/scheduled_task.php @@ -62,7 +62,7 @@ abstract class scheduled_task extends task_base { /** * Set the last run time for this scheduled task. - * @return int + * @param int $lastruntime */ public function set_last_run_time($lastruntime) { $this->lastruntime = $lastruntime; @@ -251,7 +251,7 @@ abstract class scheduled_task extends task_base { * If list is empty, this function will return 0. * * @param int $current The current value - * @param array(int) $list The list of valid items. + * @param int[] $list The list of valid items. * @return int $next. */ private function next_in_list($current, $list) { diff --git a/lib/classes/task/task_base.php b/lib/classes/task/task_base.php index b10107ee80e..2faabe67c64 100644 --- a/lib/classes/task/task_base.php +++ b/lib/classes/task/task_base.php @@ -84,7 +84,7 @@ abstract class task_base { /** * Set the next run time for this task. - * @return int + * @param int $nextruntime */ public function set_next_run_time($nextruntime) { $this->nextruntime = $nextruntime;