From 92a951c5cd0bc332827f4a3c812d4f446064bc76 Mon Sep 17 00:00:00 2001 From: Ankit Agarwal Date: Mon, 27 Mar 2017 14:37:09 +0530 Subject: [PATCH] MDL-58398 core_files: Fix phpdoc and other minor issues --- files/classes/conversion.php | 19 ++++++++++++------- files/classes/converter.php | 10 +++++----- .../classes/task/conversion_cleanup_task.php | 1 - files/converter/unoconv/classes/converter.php | 10 +++++----- .../unoconv/tests/converter_test.php | 1 - 5 files changed, 22 insertions(+), 19 deletions(-) diff --git a/files/classes/conversion.php b/files/classes/conversion.php index 07872ce40a2b5..d207d6cab0fe6 100644 --- a/files/classes/conversion.php +++ b/files/classes/conversion.php @@ -61,6 +61,11 @@ class conversion extends \core\persistent { */ const TABLE = 'file_conversion'; + /** + * Define properties. + * + * @return array + */ protected static function define_properties() { return array( 'sourcefileid' => [ @@ -209,7 +214,7 @@ public function set_sourcefile(stored_file $file) { /** * Fetch the source file. * - * @return stored_file|false + * @return stored_file|false The source file */ public function get_sourcefile() { $fs = get_file_storage(); @@ -276,7 +281,7 @@ public function store_destfile_from_string($content) { /** * Get the destination file. * - * @return stored_file|this + * @return stored_file|bool Destination file */ public function get_destfile() { $fs = get_file_storage(); @@ -287,7 +292,7 @@ public function get_destfile() { /** * Helper to ensure that the returned status is always an int. * - * @return int + * @return int status */ protected function get_status() { return (int) $this->raw_get('status'); @@ -296,7 +301,7 @@ protected function get_status() { /** * Get an instance of the current converter. * - * @return converter_interface|false + * @return converter_interface|false current converter instance */ public function get_converter_instance() { $currentconverter = $this->get('converter'); @@ -311,7 +316,7 @@ public function get_converter_instance() { /** * Transform data into a storable format. * - * @param stdClass $data The data to be stored + * @param \stdClass $data The data to be stored * @return $this */ protected function set_data($data) { @@ -323,7 +328,7 @@ protected function set_data($data) { /** * Transform data into a storable format. * - * @return stdClass The stored data + * @return \stdClass The stored data */ protected function get_data() { $data = $this->raw_get('data'); @@ -338,7 +343,7 @@ protected function get_data() { /** * Return the file record base for use in the files table. * - * @return array + * @return array|bool */ protected function get_file_record() { $file = $this->get_sourcefile(); diff --git a/files/classes/converter.php b/files/classes/converter.php index d39d84f0733d6..7923908ca3c85 100644 --- a/files/classes/converter.php +++ b/files/classes/converter.php @@ -39,7 +39,7 @@ class converter { /** * Get a list of enabled plugins and classes. * - * @return array + * @return array List of enabled plugins */ protected function get_enabled_plugins() { $plugins = \core\plugininfo\fileconverter::get_enabled_plugins(); @@ -57,7 +57,7 @@ protected function get_enabled_plugins() { * * This allows for mocking of the file_storage API. * - * @return file_storage + * @return \file_storage */ protected function get_file_storage() { return get_file_storage(); @@ -69,7 +69,7 @@ protected function get_file_storage() { * @param stored_file $file The file to convert * @param string $format The desired target file format (file extension) * @param boolean $forcerefresh If true, the file will be converted every time (not cached). - * @return conversion + * @return conversion conversion object */ public function start_conversion(stored_file $file, $format, $forcerefresh = false) { $conversions = conversion::get_conversions_for_file($file, $format); @@ -160,7 +160,7 @@ public function poll_conversion(conversion $conversion) { * * @param array $converters The list of converters to try * @param string|null $currentconverter The converter currently in use - * @return string|false + * @return string|false Name of next converter if present */ protected function get_next_converter($converters, $currentconverter = null) { if ($currentconverter) { @@ -226,7 +226,7 @@ public function can_convert_storedfile_to(stored_file $file, $to) { $from = \core_filetypes::get_file_extension($file->get_mimetype()); if (!$from) { - // No mimetype could be found. Unable to determine converter. + // No mime type could be found. Unable to determine converter. return false; } diff --git a/files/classes/task/conversion_cleanup_task.php b/files/classes/task/conversion_cleanup_task.php index 1353b5b0967e7..4f774f1eac140 100644 --- a/files/classes/task/conversion_cleanup_task.php +++ b/files/classes/task/conversion_cleanup_task.php @@ -1,5 +1,4 @@ libdir . '/filelib.php'); -use stored_file; +use stored_file; use \core_files\conversion; /** @@ -118,9 +118,9 @@ public function start_document_conversion(\core_files\conversion $conversion) { try { // This function can either return false, or throw an exception so we need to handle both. if ($file->copy_content_to($filename) === false) { - throw new file_exception('storedfileproblem', 'Could not copy file contents to temp file.'); + throw new \file_exception('storedfileproblem', 'Could not copy file contents to temp file.'); } - } catch (file_exception $fe) { + } catch (\file_exception $fe) { throw $fe; } @@ -169,7 +169,7 @@ public function poll_conversion_status(conversion $conversion) { /** * Generate and serve the test document. * - * @return stored_file + * @return void */ public function serve_test_document() { global $CFG; @@ -267,7 +267,7 @@ protected static function is_minimum_version_met() { /** * Whether the plugin is fully configured. * - * @return bool + * @return \stdClass */ public static function test_unoconv_path() { global $CFG; diff --git a/files/converter/unoconv/tests/converter_test.php b/files/converter/unoconv/tests/converter_test.php index 78cf8cb552797..455289f9cef8b 100644 --- a/files/converter/unoconv/tests/converter_test.php +++ b/files/converter/unoconv/tests/converter_test.php @@ -24,7 +24,6 @@ defined('MOODLE_INTERNAL') || die(); - /** * A set of tests for some of the unoconv functionality within Moodle. *