From: Happy-melon Date: Sun, 13 Mar 2011 15:12:54 +0000 (+0000) Subject: Implement __toString() magic method for Message objects X-Git-Tag: 1.31.0-rc.0~31467 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=522628555a422fe7bebf9189cf3f0db930bea39a;p=lhc%2Fweb%2Fwiklou.git Implement __toString() magic method for Message objects --- 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