From e65f93f827188b1dc4b4b0c53009a649ee4ef3cd Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Mon, 12 Sep 2016 21:24:50 -0700 Subject: [PATCH] Use late static binding in Article::newFromID() Address the FIXME and remove subclass implementations by using late static binding. Change-Id: I4f1793c87dfe08f768a283128d14ee2226a9e275 --- includes/page/Article.php | 4 +--- includes/page/CategoryPage.php | 12 ------------ includes/page/ImagePage.php | 12 ------------ 3 files changed, 1 insertion(+), 27 deletions(-) diff --git a/includes/page/Article.php b/includes/page/Article.php index 449c9ffe58..ea920f12e6 100644 --- a/includes/page/Article.php +++ b/includes/page/Article.php @@ -99,9 +99,7 @@ class Article implements Page { */ public static function newFromID( $id ) { $t = Title::newFromID( $id ); - # @todo FIXME: Doesn't inherit right - return $t == null ? null : new self( $t ); - # return $t == null ? null : new static( $t ); // PHP 5.3 + return $t == null ? null : new static( $t ); } /** diff --git a/includes/page/CategoryPage.php b/includes/page/CategoryPage.php index d493002684..865471c33d 100644 --- a/includes/page/CategoryPage.php +++ b/includes/page/CategoryPage.php @@ -43,18 +43,6 @@ class CategoryPage extends Article { return new WikiCategoryPage( $title ); } - /** - * Constructor from a page id - * @param int $id Article ID to load - * @return CategoryPage|null - */ - public static function newFromID( $id ) { - $t = Title::newFromID( $id ); - # @todo FIXME: Doesn't inherit right - return $t == null ? null : new self( $t ); - # return $t == null ? null : new static( $t ); // PHP 5.3 - } - function view() { $request = $this->getContext()->getRequest(); $diff = $request->getVal( 'diff' ); diff --git a/includes/page/ImagePage.php b/includes/page/ImagePage.php index be5535a1f5..af778682c7 100644 --- a/includes/page/ImagePage.php +++ b/includes/page/ImagePage.php @@ -52,18 +52,6 @@ class ImagePage extends Article { return new WikiFilePage( $title ); } - /** - * Constructor from a page id - * @param int $id Article ID to load - * @return ImagePage|null - */ - public static function newFromID( $id ) { - $t = Title::newFromID( $id ); - # @todo FIXME: Doesn't inherit right - return $t == null ? null : new self( $t ); - # return $t == null ? null : new static( $t ); // PHP 5.3 - } - /** * @param File $file * @return void -- 2.20.1