diff --git a/lib/deprecatedlib.php b/lib/deprecatedlib.php index 9462e870b45..dec20d5c5b9 100644 --- a/lib/deprecatedlib.php +++ b/lib/deprecatedlib.php @@ -4021,3 +4021,19 @@ function moodle_strtolower($string, $encoding='') { //Use text services return textlib::strtolower($string, $encoding); } + +/** + * Original singleton helper function, please use static methods instead, + * ex: textlib::convert() + * + * @deprecated since Moodle 2.1 use textlib::xxxx() instead + * @see textlib + * @return textlib instance + */ +function textlib_get_instance() { + + debugging('textlib_get_instance() is deprecated. Please use static calling textlib::functioname() instead.', DEBUG_DEVELOPER); + + return new textlib(); +} + diff --git a/lib/simpletest/testtextlib.php b/lib/simpletest/testtextlib.php index 2b86475b1d5..60306895d5d 100644 --- a/lib/simpletest/testtextlib.php +++ b/lib/simpletest/testtextlib.php @@ -275,6 +275,11 @@ class textlib_test extends UnitTestCase { } public function test_deprecated_textlib_get_instance() { + global $CFG; + + $debugging = $CFG->debug; + $CFG->debug = DEBUG_NORMAL; + $textlib = textlib_get_instance(); $this->assertIdentical($textlib->substr('abc', 1, 1), 'b'); $this->assertIdentical($textlib->strlen('abc'), 3); @@ -285,6 +290,8 @@ class textlib_test extends UnitTestCase { $this->assertIdentical($textlib->strrpos('abcabc', 'a'), 3); $this->assertIdentical($textlib->specialtoascii('ábc'), 'abc'); $this->assertIdentical($textlib->strtotitle('abc ABC'), 'Abc Abc'); + + $CFG->debug = $debugging; } } diff --git a/lib/textlib.class.php b/lib/textlib.class.php index 6403504e51b..9f95a489507 100644 --- a/lib/textlib.class.php +++ b/lib/textlib.class.php @@ -24,20 +24,6 @@ defined('MOODLE_INTERNAL') || die(); -/** - * Original singleton helper function, please use static methods instead, - * ex: textlib::convert() - * - * @deprecated since Moodle 2.1 MDL-29027 textlib contains static functions - * @todo MDL-31301 calling of textlib functions should be static. - * @see textlib - * @return textlib instance - */ -function textlib_get_instance() { - return new textlib(); -} - - /** * defines string api's for manipulating strings *