From 522628555a422fe7bebf9189cf3f0db930bea39a Mon Sep 17 00:00:00 2001 From: Happy-melon Date: Sun, 13 Mar 2011 15:12:54 +0000 Subject: [PATCH] Implement __toString() magic method for Message objects --- includes/Message.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/includes/Message.php b/includes/Message.php index 4dd1a655c2..61f561513b 100644 --- a/includes/Message.php +++ b/includes/Message.php @@ -256,12 +256,6 @@ class Message { /** * Returns the message parsed from wikitext to HTML. - * TODO: in PHP >= 5.2.0, we can make this a magic method, - * and then we can do, eg: - * $foo = Message::get($key); - * $string = "$foo"; - * But we shouldn't implement that while MediaWiki still supports - * PHP < 5.2; or people will start using it... * @return String: HTML */ public function toString() { @@ -292,6 +286,16 @@ class Message { return $string; } + + /** + * Magic method implementation of the above (for PHP >= 5.2.0), so we can do, eg: + * $foo = Message::get($key); + * $string = "$foo"; + * @return String + */ + public function __toString() { + return $this->toString(); + } /** * Fully parse the text from wikitext to HTML -- 2.20.1