From 7c109ea3f02593f95f6039cf607ea8159ff3cf59 Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Sun, 19 Sep 2010 18:43:52 +0000 Subject: [PATCH] MDL-24276 "static abstract" combination is deprecated since PHP 5.2, replacing with our coding_style exception --- backup/moodle2/backup_activity_task.class.php | 4 +++- backup/moodle2/backup_block_task.class.php | 4 +++- backup/moodle2/restore_activity_task.class.php | 8 ++++++-- backup/moodle2/restore_block_task.class.php | 8 ++++++-- backup/util/ui/base_ui.class.php | 4 +++- lib/completion/data_object.php | 10 +++++++--- lib/ddl/sql_generator.php | 2 +- lib/googleapi.php | 8 +++++--- lib/grade/grade_object.php | 8 ++++++-- lib/portfolio/caller.php | 12 +++++++++--- lib/portfolio/formats.php | 12 +++++++++--- lib/portfolio/plugin.php | 4 +++- 12 files changed, 61 insertions(+), 23 deletions(-) diff --git a/backup/moodle2/backup_activity_task.class.php b/backup/moodle2/backup_activity_task.class.php index 0a9124c92c4..f9a14d4b6c0 100644 --- a/backup/moodle2/backup_activity_task.class.php +++ b/backup/moodle2/backup_activity_task.class.php @@ -274,6 +274,8 @@ abstract class backup_activity_task extends backup_task { * Code the transformations to perform in the activity in * order to get transportable (encoded) links */ - abstract static public function encode_content_links($content); + static public function encode_content_links($content) { + throw new coding_exception('encode_content_links() method needs to be overridden in each subclass of backup_activity_task'); + } } diff --git a/backup/moodle2/backup_block_task.class.php b/backup/moodle2/backup_block_task.class.php index 61f346e6a20..7d3f26e54c7 100644 --- a/backup/moodle2/backup_block_task.class.php +++ b/backup/moodle2/backup_block_task.class.php @@ -210,5 +210,7 @@ abstract class backup_block_task extends backup_task { * Code the transformations to perform in the block in * order to get transportable (encoded) links */ - abstract static public function encode_content_links($content); + static public function encode_content_links($content) { + throw new coding_exception('encode_content_links() method needs to be overridden in each subclass of backup_block_task'); + } } diff --git a/backup/moodle2/restore_activity_task.class.php b/backup/moodle2/restore_activity_task.class.php index 76e6c3b7814..bdddd2e0761 100644 --- a/backup/moodle2/restore_activity_task.class.php +++ b/backup/moodle2/restore_activity_task.class.php @@ -216,13 +216,17 @@ abstract class restore_activity_task extends restore_task { * Define the contents in the activity that must be * processed by the link decoder */ - abstract static public function define_decode_contents(); + static public function define_decode_contents() { + throw new coding_exception('define_decode_contents() method needs to be overridden in each subclass of restore_activity_task'); + } /** * Define the decoding rules for links belonging * to the activity to be executed by the link decoder */ - abstract static public function define_decode_rules(); + static public function define_decode_rules() { + throw new coding_exception('define_decode_rules() method needs to be overridden in each subclass of restore_activity_task'); + } // Protected API starts here diff --git a/backup/moodle2/restore_block_task.class.php b/backup/moodle2/restore_block_task.class.php index 294152be5fd..d4715d7bffa 100644 --- a/backup/moodle2/restore_block_task.class.php +++ b/backup/moodle2/restore_block_task.class.php @@ -152,13 +152,17 @@ abstract class restore_block_task extends restore_task { * Define the contents in the activity that must be * processed by the link decoder */ - abstract static public function define_decode_contents(); + static public function define_decode_contents() { + throw new coding_exception('define_decode_contents() method needs to be overridden in each subclass of restore_block_task'); + } /** * Define the decoding rules for links belonging * to the activity to be executed by the link decoder */ - abstract static public function define_decode_rules(); + static public function define_decode_rules() { + throw new coding_exception('define_decode_rules() method needs to be overridden in each subclass of restore_block_task'); + } // Protected API starts here diff --git a/backup/util/ui/base_ui.class.php b/backup/util/ui/base_ui.class.php index fb38025d96f..fce02a1da53 100644 --- a/backup/util/ui/base_ui.class.php +++ b/backup/util/ui/base_ui.class.php @@ -212,7 +212,9 @@ abstract class base_ui { * Loads the backup controller if we are tracking one * @return backup_controller|false */ - abstract public static function load_controller($uniqueid=false); + public static function load_controller($uniqueid=false) { + throw new coding_exception('load_controller() method needs to be overridden in each subclass of base_ui'); + } /** * Gets an array of progress bar items that can be displayed through the backup renderer. * @return array Array of items for the progress bar diff --git a/lib/completion/data_object.php b/lib/completion/data_object.php index b805939f650..7f7cd422310 100644 --- a/lib/completion/data_object.php +++ b/lib/completion/data_object.php @@ -104,15 +104,19 @@ abstract class data_object { * @param array $params associative arrays varname=>value * @return object data_object instance or false if none found. */ - public static abstract function fetch($params); + public static function fetch($params) { + throw new coding_exception('fetch() method needs to be overridden in each subclass of data_object'); + } /** * Finds and returns all data_object instances based on params. * * @param array $params associative arrays varname=>value - * @return array array of data_object insatnces or false if none found. + * @return array array of data_object instances or false if none found. */ - public static function fetch_all($params) {} + public static function fetch_all($params) { + throw new coding_exception('fetch_all() method needs to be overridden in each subclass of data_object'); + } /** * Factory method - uses the parameters to retrieve matching instance from the DB. diff --git a/lib/ddl/sql_generator.php b/lib/ddl/sql_generator.php index 599d2a48daa..1d400e8699d 100644 --- a/lib/ddl/sql_generator.php +++ b/lib/ddl/sql_generator.php @@ -1188,7 +1188,7 @@ abstract class sql_generator { * @return array of reserved words */ public static function getReservedWords() { - return array(); + throw new coding_exception('getReservedWords() method needs to be overridden in each subclass of sql_generator'); } /** diff --git a/lib/googleapi.php b/lib/googleapi.php index 10c3d9cd2aa..cb09710cb2a 100644 --- a/lib/googleapi.php +++ b/lib/googleapi.php @@ -42,12 +42,14 @@ require_once($CFG->libdir.'/filelib.php'); * @copyright Dan Poltawski * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -abstract class google_auth_request extends curl{ +abstract class google_auth_request extends curl { protected $token = ''; private $persistantheaders = array(); - // Must be overriden with the authorization header name - public abstract static function get_auth_header_name(); + // Must be overridden with the authorization header name + public static function get_auth_header_name() { + throw new coding_exception('get_auth_header_name() method needs to be overridden in each subclass of google_auth_request'); + } protected function request($url, $options = array()){ if($this->token){ diff --git a/lib/grade/grade_object.php b/lib/grade/grade_object.php index 62ea77014f0..dda33ad17d9 100644 --- a/lib/grade/grade_object.php +++ b/lib/grade/grade_object.php @@ -119,7 +119,9 @@ abstract class grade_object { * @param array $params associative arrays varname=>value * @return object grade_object instance or false if none found. */ - public static abstract function fetch($params); + public static function fetch($params) { + throw new coding_exception('fetch() method needs to be overridden in each subclass of grade_object'); + } /** * Finds and returns all grade_object instances based on params. @@ -128,7 +130,9 @@ abstract class grade_object { * @param array $params associative arrays varname=>value * @return array array of grade_object instances or false if none found. */ - public static abstract function fetch_all($params); + public static function fetch_all($params) { + throw new coding_exception('fetch_all() method needs to be overridden in each subclass of grade_object'); + } /** * Factory method - uses the parameters to retrieve matching instance from the DB. diff --git a/lib/portfolio/caller.php b/lib/portfolio/caller.php index 239227b3ec8..7bfeb8252cd 100644 --- a/lib/portfolio/caller.php +++ b/lib/portfolio/caller.php @@ -334,7 +334,9 @@ abstract class portfolio_caller_base { return portfolio_most_specific_formats($specific, $basic); } - public abstract static function base_supported_formats(); + public static function base_supported_formats() { + throw new coding_exception('base_supported_formats() method needs to be overridden in each subclass of portfolio_caller_base'); + } /** * this is the "return to where you were" url @@ -352,7 +354,9 @@ abstract class portfolio_caller_base { /** * nice name to display to the user about this caller location */ - public abstract static function display_name(); + public static function display_name() { + throw new coding_exception('display_name() method needs to be overridden in each subclass of portfolio_caller_base'); + } /** * return a string to put at the header summarising this export @@ -475,7 +479,9 @@ abstract class portfolio_caller_base { * * @return array */ - public static abstract function expected_callbackargs(); + public static function expected_callbackargs() { + throw new coding_exception('expected_callbackargs() method needs to be overridden in each subclass of portfolio_caller_base'); + } /** diff --git a/lib/portfolio/formats.php b/lib/portfolio/formats.php index 17e7873b746..c462daa87c1 100644 --- a/lib/portfolio/formats.php +++ b/lib/portfolio/formats.php @@ -39,14 +39,18 @@ abstract class portfolio_format { /** * array of mimetypes this format supports */ - public static abstract function mimetypes(); + public static function mimetypes() { + throw new coding_exception('mimetypes() method needs to be overridden in each subclass of portfolio_format'); + } /** * for multipart formats, eg html with attachments, * we need to have a directory to place associated files in * inside the zip file. this is the name of that directory */ - public static abstract function get_file_directory(); + public static function get_file_directory() { + throw new coding_exception('get_file_directory() method needs to be overridden in each subclass of portfolio_format'); + } /** * given a file, return a snippet of markup in whatever format @@ -62,7 +66,9 @@ abstract class portfolio_format { * * @return string some html or xml or whatever */ - public static abstract function file_output($file, $options=null); + public static function file_output($file, $options=null) { + throw new coding_exception('file_output() method needs to be overridden in each subclass of portfolio_format'); + } public static function make_tag($file, $path, $attributes) { $srcattr = 'href'; diff --git a/lib/portfolio/plugin.php b/lib/portfolio/plugin.php index 786e272880b..5d8177cead7 100644 --- a/lib/portfolio/plugin.php +++ b/lib/portfolio/plugin.php @@ -153,7 +153,9 @@ abstract class portfolio_plugin_base { * * @return string */ - public static abstract function get_name(); + public static function get_name() { + throw new coding_exception('get_name() method needs to be overridden in each subclass of portfolio_plugin_base'); + } /** * check sanity of plugin