From 36a8c9b6ecb532e6d01f77299e76b7df577d7a3c Mon Sep 17 00:00:00 2001 From: jeroendedauw Date: Tue, 12 Jun 2012 13:11:56 +0200 Subject: [PATCH] Added ORMIterator interface which can be used for type hinting (in particular when passing ORMResult objects) Change-Id: I0d14da35bf35be468a8e2c5530912992577e8dd8 --- includes/AutoLoader.php | 1 + includes/db/IORMTable.php | 8 ++++---- includes/db/ORMIterator.php | 37 +++++++++++++++++++++++++++++++++++++ includes/db/ORMResult.php | 7 ++++--- 4 files changed, 46 insertions(+), 7 deletions(-) create mode 100644 includes/db/ORMIterator.php diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index 78ed45083f..663124106d 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -470,6 +470,7 @@ $wgAutoloadLocalClasses = array( 'MySQLMasterPos' => 'includes/db/DatabaseMysql.php', 'ORAField' => 'includes/db/DatabaseOracle.php', 'ORAResult' => 'includes/db/DatabaseOracle.php', + 'ORMIterator' => 'includes/db/ORMIterator', 'ORMResult' => 'includes/db/ORMResult.php', 'ORMRow' => 'includes/db/ORMRow.php', 'ORMTable' => 'includes/db/ORMTable.php', diff --git a/includes/db/IORMTable.php b/includes/db/IORMTable.php index 853e8cd253..0c5528ca57 100644 --- a/includes/db/IORMTable.php +++ b/includes/db/IORMTable.php @@ -103,7 +103,7 @@ interface IORMTable { * @return ORMResult */ public function select( $fields = null, array $conditions = array(), - array $options = array(), $functionName = null ); + array $options = array(), $functionName = null ); /** * Selects the the specified fields of the records matching the provided @@ -119,7 +119,7 @@ interface IORMTable { * @return array of self */ public function selectObjects( $fields = null, array $conditions = array(), - array $options = array(), $functionName = null ); + array $options = array(), $functionName = null ); /** * Do the actual select. @@ -134,7 +134,7 @@ interface IORMTable { * @return ResultWrapper */ public function rawSelect( $fields = null, array $conditions = array(), - array $options = array(), $functionName = null ); + array $options = array(), $functionName = null ); /** * Selects the the specified fields of the records matching the provided @@ -159,7 +159,7 @@ interface IORMTable { * @return array of array */ public function selectFields( $fields = null, array $conditions = array(), - array $options = array(), $collapse = true, $functionName = null ); + array $options = array(), $collapse = true, $functionName = null ); /** * Selects the the specified fields of the first matching record. diff --git a/includes/db/ORMIterator.php b/includes/db/ORMIterator.php new file mode 100644 index 0000000000..f0a636342b --- /dev/null +++ b/includes/db/ORMIterator.php @@ -0,0 +1,37 @@ + + */ +interface ORMIterator extends Iterator { + + /** + * @see Iterator::current() + * @return IORMRow + */ + public function current(); + +} \ No newline at end of file diff --git a/includes/db/ORMResult.php b/includes/db/ORMResult.php index 1e6b83dda8..1342b0243c 100644 --- a/includes/db/ORMResult.php +++ b/includes/db/ORMResult.php @@ -1,6 +1,7 @@ */ -class ORMResult implements Iterator { +class ORMResult implements ORMIterator { /** * @var ResultWrapper @@ -36,7 +37,7 @@ class ORMResult implements Iterator { /** * @var integer */ - protected $key; + protected $key; /** * @var IORMRow -- 2.20.1