r83826 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83825‎ | r83826 | r83827 >
Date:15:12, 13 March 2011
Author:happy-melon
Status:ok
Tags:
Comment:
Implement __toString() magic method for Message objects
Modified paths:
  • /trunk/phase3/includes/Message.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Message.php
@@ -256,12 +256,6 @@
257257
258258 /**
259259 * Returns the message parsed from wikitext to HTML.
260 - * TODO: in PHP >= 5.2.0, we can make this a magic method,
261 - * and then we can do, eg:
262 - * $foo = Message::get($key);
263 - * $string = "<abbr>$foo</abbr>";
264 - * But we shouldn't implement that while MediaWiki still supports
265 - * PHP < 5.2; or people will start using it...
266260 * @return String: HTML
267261 */
268262 public function toString() {
@@ -292,6 +286,16 @@
293287
294288 return $string;
295289 }
 290+
 291+ /**
 292+ * Magic method implementation of the above (for PHP >= 5.2.0), so we can do, eg:
 293+ * $foo = Message::get($key);
 294+ * $string = "<abbr>$foo</abbr>";
 295+ * @return String
 296+ */
 297+ public function __toString() {
 298+ return $this->toString();
 299+ }
296300
297301 /**
298302 * Fully parse the text from wikitext to HTML

Status & tagging log