Added ORMIterator interface which can be used for type hinting (in particular when...
authorjeroendedauw <jeroendedauw@gmail.com>
Tue, 12 Jun 2012 11:11:56 +0000 (13:11 +0200)
committerjeroendedauw <jeroendedauw@gmail.com>
Tue, 12 Jun 2012 11:11:56 +0000 (13:11 +0200)
Change-Id: I0d14da35bf35be468a8e2c5530912992577e8dd8

includes/AutoLoader.php
includes/db/IORMTable.php
includes/db/ORMIterator.php [new file with mode: 0644]
includes/db/ORMResult.php

index 78ed450..6631241 100644 (file)
@@ -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',
index 853e8cd..0c5528c 100644 (file)
@@ -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 (file)
index 0000000..f0a6363
--- /dev/null
@@ -0,0 +1,37 @@
+<?php
+
+/**
+ * Interface for Iterators containing IORMRows.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @since 1.20
+ *
+ * @file
+ * @ingroup ORM
+ *
+ * @licence GNU GPL v2 or later
+ * @author Jeroen De Dauw < jeroendedauw@gmail.com >
+ */
+interface ORMIterator extends Iterator {
+
+       /**
+        * @see Iterator::current()
+        * @return IORMRow
+        */
+       public function current();
+
+}
\ No newline at end of file
index 1e6b83d..1342b02 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 /**
- * Result of a ORMTable::select, which returns IORMRow objects.
+ * ORMIterator that takes a ResultWrapper object returned from
+ * a select operation returning IORMRow objects (ie IORMTable::select).
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -26,7 +27,7 @@
  * @author Jeroen De Dauw < jeroendedauw@gmail.com >
  */
 
-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