From e3c0ab20bf10ad34a2a1d822889e33d891c0a68e Mon Sep 17 00:00:00 2001 From: addshore Date: Sun, 26 Jan 2014 18:49:18 +0100 Subject: [PATCH] Split Title and User ArrayFromResult classes to own files Change-Id: I8744627330eb9c8f183a8d418d6eb168e6c5407b --- includes/AutoLoader.php | 4 +- includes/TitleArray.php | 63 +--------------------- includes/TitleArrayFromResult.php | 86 ++++++++++++++++++++++++++++++ includes/UserArray.php | 71 +------------------------ includes/UserArrayFromResult.php | 88 +++++++++++++++++++++++++++++++ 5 files changed, 179 insertions(+), 133 deletions(-) create mode 100644 includes/TitleArrayFromResult.php create mode 100644 includes/UserArrayFromResult.php diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index dabcc5c00e..42e16bfc71 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -215,14 +215,14 @@ $wgAutoloadLocalClasses = array( 'TimestampException' => 'includes/TimestampException.php', 'Title' => 'includes/Title.php', 'TitleArray' => 'includes/TitleArray.php', - 'TitleArrayFromResult' => 'includes/TitleArray.php', + 'TitleArrayFromResult' => 'includes/TitleArrayFromResult.php', 'ThrottledError' => 'includes/Exception.php', 'UnlistedSpecialPage' => 'includes/specialpage/UnlistedSpecialPage.php', 'UploadSourceAdapter' => 'includes/Import.php', 'UppercaseCollation' => 'includes/Collation.php', 'User' => 'includes/User.php', 'UserArray' => 'includes/UserArray.php', - 'UserArrayFromResult' => 'includes/UserArray.php', + 'UserArrayFromResult' => 'includes/UserArrayFromResult.php', 'UserBlockedError' => 'includes/Exception.php', 'UserNotLoggedIn' => 'includes/Exception.php', 'UserCache' => 'includes/cache/UserCache.php', diff --git a/includes/TitleArray.php b/includes/TitleArray.php index cc130d253b..eac9211954 100644 --- a/includes/TitleArray.php +++ b/includes/TitleArray.php @@ -1,6 +1,6 @@ res = $res; - $this->key = 0; - $this->setCurrent( $this->res->current() ); - } - - /** - * @param $row ResultWrapper - * @return void - */ - protected function setCurrent( $row ) { - if ( $row === false ) { - $this->current = false; - } else { - $this->current = Title::newFromRow( $row ); - } - } - - /** - * @return int - */ - public function count() { - return $this->res->numRows(); - } - - function current() { - return $this->current; - } - - function key() { - return $this->key; - } - - function next() { - $row = $this->res->next(); - $this->setCurrent( $row ); - $this->key++; - } - - function rewind() { - $this->res->rewind(); - $this->key = 0; - $this->setCurrent( $this->res->current() ); - } - - /** - * @return bool - */ - function valid() { - return $this->current !== false; - } -} diff --git a/includes/TitleArrayFromResult.php b/includes/TitleArrayFromResult.php new file mode 100644 index 0000000000..f90053885a --- /dev/null +++ b/includes/TitleArrayFromResult.php @@ -0,0 +1,86 @@ +res = $res; + $this->key = 0; + $this->setCurrent( $this->res->current() ); + } + + /** + * @param $row ResultWrapper + * @return void + */ + protected function setCurrent( $row ) { + if ( $row === false ) { + $this->current = false; + } else { + $this->current = Title::newFromRow( $row ); + } + } + + /** + * @return int + */ + public function count() { + return $this->res->numRows(); + } + + function current() { + return $this->current; + } + + function key() { + return $this->key; + } + + function next() { + $row = $this->res->next(); + $this->setCurrent( $row ); + $this->key++; + } + + function rewind() { + $this->res->rewind(); + $this->key = 0; + $this->setCurrent( $this->res->current() ); + } + + /** + * @return bool + */ + function valid() { + return $this->current !== false; + } +} \ No newline at end of file diff --git a/includes/UserArray.php b/includes/UserArray.php index 90d1134a51..38f0d9d518 100644 --- a/includes/UserArray.php +++ b/includes/UserArray.php @@ -1,6 +1,6 @@ res = $res; - $this->key = 0; - $this->setCurrent( $this->res->current() ); - } - - /** - * @param $row - * @return void - */ - protected function setCurrent( $row ) { - if ( $row === false ) { - $this->current = false; - } else { - $this->current = User::newFromRow( $row ); - } - } - - /** - * @return int - */ - public function count() { - return $this->res->numRows(); - } - - /** - * @return User - */ - function current() { - return $this->current; - } - - function key() { - return $this->key; - } - - function next() { - $row = $this->res->next(); - $this->setCurrent( $row ); - $this->key++; - } - - function rewind() { - $this->res->rewind(); - $this->key = 0; - $this->setCurrent( $this->res->current() ); - } - - /** - * @return bool - */ - function valid() { - return $this->current !== false; - } -} +} \ No newline at end of file diff --git a/includes/UserArrayFromResult.php b/includes/UserArrayFromResult.php new file mode 100644 index 0000000000..5d5859d674 --- /dev/null +++ b/includes/UserArrayFromResult.php @@ -0,0 +1,88 @@ +res = $res; + $this->key = 0; + $this->setCurrent( $this->res->current() ); + } + + /** + * @param $row + * @return void + */ + protected function setCurrent( $row ) { + if ( $row === false ) { + $this->current = false; + } else { + $this->current = User::newFromRow( $row ); + } + } + + /** + * @return int + */ + public function count() { + return $this->res->numRows(); + } + + /** + * @return User + */ + function current() { + return $this->current; + } + + function key() { + return $this->key; + } + + function next() { + $row = $this->res->next(); + $this->setCurrent( $row ); + $this->key++; + } + + function rewind() { + $this->res->rewind(); + $this->key = 0; + $this->setCurrent( $this->res->current() ); + } + + /** + * @return bool + */ + function valid() { + return $this->current !== false; + } +} -- 2.20.1