Completed
Pull Request — 3.4 (#135)
by
unknown
09:27
created
src/Mouf/Database/TDBM/Filters/OrderBySQLString.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -133,14 +133,14 @@
 block discarded – undo
133 133
 		$work_table = explode("'", $work_str);
134 134
 
135 135
 		if (count($work_table) == 0)
136
-		    return '';
136
+			return '';
137 137
 
138 138
 		// if we start with a ', let's remove the first text
139 139
 		if (strstr($work_str,"'") === 0)
140
-		    array_shift($work_table);
140
+			array_shift($work_table);
141 141
 			
142 142
 		if (count($work_table) == 0)
143
-		    return '';
143
+			return '';
144 144
 
145 145
 		// Now, let's take only the stuff outside the quotes.
146 146
 		$work_str2 = '';
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/AmbiguityException.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@
 block discarded – undo
45 45
 	}
46 46
 
47 47
 	private function getAllPossiblePaths() {
48
-        return AmbiguityException::getAllPossiblePathsRec($this->paths);
48
+		return AmbiguityException::getAllPossiblePathsRec($this->paths);
49 49
 	}
50 50
 
51 51
 	private static function getAllPossiblePathsRec($sub_table_paths)
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/TDBMObjectArray.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -65,9 +65,9 @@
 block discarded – undo
65 65
 	 * @param string $func_name
66 66
 	 * @param $values
67 67
 	 * @return array|void
68
-     * @throws TDBMException
68
+	 * @throws TDBMException
69 69
 	 */
70
-    public function __call($func_name, $values) {
70
+	public function __call($func_name, $values) {
71 71
 
72 72
 		if (strpos($func_name,"getarray_") === 0) {
73 73
 			$column = substr($func_name, 9);
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/Controllers/TdbmInstallController.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -170,6 +170,9 @@
 block discarded – undo
170 170
 	
171 171
 	protected $errorMsg;
172 172
 	
173
+	/**
174
+	 * @param string $msg
175
+	 */
173 176
 	private function displayErrorMsg($msg) {
174 177
 		$this->errorMsg = $msg;
175 178
 		$this->content->addFile(dirname(__FILE__)."/../../../../views/installError.php", $this);
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -111,12 +111,12 @@  discard block
 block discarded – undo
111 111
 		$this->beanNamespace = $this->moufManager->getVariable("tdbmDefaultBeanNamespace_tdbmService");
112 112
 		
113 113
 		if ($this->daoNamespace == null && $this->beanNamespace == null) {
114
-            $classNameMapper = ClassNameMapper::createFromComposerFile(__DIR__.'/../../../../../../../../composer.json');
114
+			$classNameMapper = ClassNameMapper::createFromComposerFile(__DIR__.'/../../../../../../../../composer.json');
115 115
 
116
-            $autoloadNamespaces = $classNameMapper->getManagedNamespaces();
116
+			$autoloadNamespaces = $classNameMapper->getManagedNamespaces();
117 117
 			if ($autoloadNamespaces) {
118 118
 				$this->autoloadDetected = true;
119
-                $rootNamespace = $autoloadNamespaces[0];
119
+				$rootNamespace = $autoloadNamespaces[0];
120 120
 				$this->daoNamespace = $rootNamespace."Dao";
121 121
 				$this->beanNamespace = $rootNamespace."Dao\\Bean";
122 122
 			} else {
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 	 * @param string $selfedit
147 147
 	 * @throws \Mouf\MoufException
148 148
 	 */
149
-    public function generate($daonamespace, $beannamespace, $keepSupport = 0, $storeInUtc = 0, $castDatesToDateTime = 1, $selfedit="false") {
149
+	public function generate($daonamespace, $beannamespace, $keepSupport = 0, $storeInUtc = 0, $castDatesToDateTime = 1, $selfedit="false") {
150 150
 		$this->selfedit = $selfedit;
151 151
 		
152 152
 		if ($selfedit == "true") {
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/TDBMObject.php 2 patches
Doc Comments   +8 added lines, -1 removed lines patch added patch discarded remove patch
@@ -238,6 +238,9 @@  discard block
 block discarded – undo
238 238
 		}
239 239
 	}
240 240
 
241
+	/**
242
+	 * @param string $var
243
+	 */
241 244
 	public function __get($var) {
242 245
 		$this->_dbLoadIfNotLoaded();
243 246
 
@@ -290,6 +293,10 @@  discard block
 block discarded – undo
290 293
 		return isset($this->db_row[$var]);
291 294
 	}
292 295
 	
296
+	/**
297
+	 * @param string $var
298
+	 * @param string|null $value
299
+	 */
293 300
 	public function __set($var, $value) {
294 301
 		$this->_dbLoadIfNotLoaded();
295 302
 
@@ -642,7 +649,7 @@  discard block
 block discarded – undo
642 649
 	/**
643 650
 	 * Returns the tables used in the filter in an array.
644 651
 	 *
645
-	 * @return array<string>
652
+	 * @return string[]
646 653
 	 */
647 654
 	public function getUsedTables() {
648 655
 		return array($this->db_table_name);
Please login to merge, or discard this patch.
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -170,26 +170,26 @@  discard block
 block discarded – undo
170 170
 		$this->TDBMObject_state = $state;	
171 171
 	}
172 172
 
173
-    /**
174
-     * Internal TDBM method, you should not use this.
175
-     * Loads the db_row property of the object from the $row array.
176
-     * Any row having a key starting with 'tdbm_reserved_col_' is ignored.
177
-     *
178
-     * @param array $row
179
-     * @param array|null $colsArray A big optimization to avoid calling strpos to many times. This array should
180
-     *                              contain as keys the list of interesting columns. If null, this list will be initialized.
181
-     */
173
+	/**
174
+	 * Internal TDBM method, you should not use this.
175
+	 * Loads the db_row property of the object from the $row array.
176
+	 * Any row having a key starting with 'tdbm_reserved_col_' is ignored.
177
+	 *
178
+	 * @param array $row
179
+	 * @param array|null $colsArray A big optimization to avoid calling strpos to many times. This array should
180
+	 *                              contain as keys the list of interesting columns. If null, this list will be initialized.
181
+	 */
182 182
 	public function loadFromRow($row, &$colsArray) {
183
-        if ($colsArray === null) {
184
-            foreach ($row as $key=>$value) {
185
-                if (strpos($key, 'tdbm_reserved_col_')!==0) {
186
-                    $colsArray[$key] = true;
187
-                }
188
-            }
189
-        }
190
-
191
-        $this->db_row = array_intersect_key($row, $colsArray);
192
-        $this->TDBMObject_state = "loaded";
183
+		if ($colsArray === null) {
184
+			foreach ($row as $key=>$value) {
185
+				if (strpos($key, 'tdbm_reserved_col_')!==0) {
186
+					$colsArray[$key] = true;
187
+				}
188
+			}
189
+		}
190
+
191
+		$this->db_row = array_intersect_key($row, $colsArray);
192
+		$this->TDBMObject_state = "loaded";
193 193
 	}
194 194
 
195 195
 	/**
@@ -325,9 +325,9 @@  discard block
 block discarded – undo
325 325
 
326 326
 	/**
327 327
 	 * Saves the current object by INSERTing or UPDAT(E)ing it in the database.
328
-     *
329
-     * This method must be called only from the DAOs.
330
-     * @internal
328
+	 *
329
+	 * This method must be called only from the DAOs.
330
+	 * @internal
331 331
 	 */
332 332
 	public function save() {
333 333
 		if (!is_array($this->db_row)) {
@@ -510,10 +510,10 @@  discard block
 block discarded – undo
510 510
 	 *
511 511
 	 * @param string $func_name
512 512
 	 * @param $values
513
-     * @return TDBMObjectArray A TDBMObjectArray containing the resulting objects of the query.
514
-     * @throws TDBMException
513
+	 * @return TDBMObjectArray A TDBMObjectArray containing the resulting objects of the query.
514
+	 * @throws TDBMException
515 515
 	 */
516
-    public function __call($func_name, $values) {
516
+	public function __call($func_name, $values) {
517 517
 
518 518
 		if (strpos($func_name,"get_") === 0) {
519 519
 			$table = substr($func_name,4);
@@ -548,48 +548,48 @@  discard block
 block discarded – undo
548 548
 	}
549 549
 	
550 550
 		/**
551
-	 * Implements array behaviour for our object.
552
-	 * 
553
-	 * @param string $offset
554
-	 * @param string $value
555
-	 */
551
+		 * Implements array behaviour for our object.
552
+		 * 
553
+		 * @param string $offset
554
+		 * @param string $value
555
+		 */
556 556
 	public function offsetSet($offset, $value) {
557 557
 		$this->__set($offset, $value);
558
-    }
558
+	}
559 559
 	/**
560 560
 	 * Implements array behaviour for our object.
561 561
 	 * 
562 562
 	 * @param string $offset
563
-     * @return bool
563
+	 * @return bool
564 564
 	 */
565
-    public function offsetExists($offset) {
566
-    	$this->_dbLoadIfNotLoaded();
567
-        return isset($this->db_row[$offset]);
568
-    }
565
+	public function offsetExists($offset) {
566
+		$this->_dbLoadIfNotLoaded();
567
+		return isset($this->db_row[$offset]);
568
+	}
569 569
 	/**
570 570
 	 * Implements array behaviour for our object.
571 571
 	 * 
572 572
 	 * @param string $offset
573 573
 	 */
574
-    public function offsetUnset($offset) {
574
+	public function offsetUnset($offset) {
575 575
 		$this->__set($offset, null);
576
-    }
576
+	}
577 577
 	/**
578 578
 	 * Implements array behaviour for our object.
579 579
 	 * 
580 580
 	 * @param string $offset
581
-     * @return mixed|null
581
+	 * @return mixed|null
582 582
 	 */
583
-    public function offsetGet($offset) {
584
-        return $this->__get($offset);
585
-    }
583
+	public function offsetGet($offset) {
584
+		return $this->__get($offset);
585
+	}
586 586
 	
587 587
 	private $_validIterator = false;
588 588
 	/**
589 589
 	 * Implements iterator behaviour for our object (so we can each column).
590 590
 	 */
591 591
 	public function rewind() {
592
-    	$this->_dbLoadIfNotLoaded();
592
+		$this->_dbLoadIfNotLoaded();
593 593
 		if (count($this->db_row)>0) {
594 594
 			$this->_validIterator = true;
595 595
 		} else {
@@ -677,21 +677,21 @@  discard block
 block discarded – undo
677 677
 		return $sql_where;
678 678
 	}
679 679
 
680
-    /**
681
-     * Override the native php clone function for TDBMObjects
682
-     */
683
-    public function __clone(){
684
-        $this->_dbLoadIfNotLoaded();
685
-        //First lets set the status to new (to enter the save function)
686
-        $this->TDBMObject_state = "new";
687
-
688
-        // Add the current TDBMObject to the save object list
689
-        $this->tdbmService->_addToToSaveObjectList($this);
690
-
691
-        //Now unset the PK from the row
692
-        $pk_array = $this->getPrimaryKey();
693
-        foreach ($pk_array as $pk) {
694
-            $this->db_row[$pk] = null;
695
-        }
696
-    }
680
+	/**
681
+	 * Override the native php clone function for TDBMObjects
682
+	 */
683
+	public function __clone(){
684
+		$this->_dbLoadIfNotLoaded();
685
+		//First lets set the status to new (to enter the save function)
686
+		$this->TDBMObject_state = "new";
687
+
688
+		// Add the current TDBMObject to the save object list
689
+		$this->tdbmService->_addToToSaveObjectList($this);
690
+
691
+		//Now unset the PK from the row
692
+		$pk_array = $this->getPrimaryKey();
693
+		foreach ($pk_array as $pk) {
694
+			$this->db_row[$pk] = null;
695
+		}
696
+	}
697 697
 }
698 698
\ No newline at end of file
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/TDBMObjectArrayCursorIterator.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -166,7 +166,7 @@
 block discarded – undo
166 166
 	}
167 167
 	/**
168 168
 	 * Returns the current result's _id
169
-	 * @return string The current result's _id as a string.
169
+	 * @return integer The current result's _id as a string.
170 170
 	 */
171 171
 	public function key()
172 172
 	{
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 */
56 56
 	protected $current = false;
57 57
 
58
-    private $colsArray = null;
58
+	private $colsArray = null;
59 59
 	
60 60
 	public function __construct(\PDOStatement $pdoStatement, ConnectionInterface $dbConnection, $primary_keys, $table_name, $objectStorage, $className, TDBMService $tdbmService, $sql)
61 61
 	{
@@ -73,9 +73,9 @@  discard block
 block discarded – undo
73 73
 	 * Casts a document to a new instance specified in the $recordClass
74 74
 	 * @param array $fullCaseRow
75 75
 	 * @return Record_Abstract|false
76
-     * @throws TDBMException
76
+	 * @throws TDBMException
77 77
 	 */
78
-    protected function cast($fullCaseRow)
78
+	protected function cast($fullCaseRow)
79 79
 	{
80 80
 		if (!is_array($fullCaseRow)) {
81 81
 			return false;
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/TDBMService.php 2 patches
Doc Comments   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -711,10 +711,10 @@  discard block
 block discarded – undo
711 711
 	
712 712
 	/**
713 713
 	 * Returns a generator for the database.
714
-	 * @param unknown $result
714
+	 * @param \PDOStatement $result
715 715
 	 * @param unknown $table_name
716
-	 * @param unknown $className
717
-	 * @param unknown $sql
716
+	 * @param string $className
717
+	 * @param string $sql
718 718
 	 */
719 719
 	private function getObjectsFromSQLGenerator($result, $table_name, $className, $sql) {
720 720
 		$keysStandardCased = array();
@@ -1100,7 +1100,7 @@  discard block
 block discarded – undo
1100 1100
 	 * @param unknown_type $target_tables
1101 1101
 	 * @param unknown_type $path
1102 1102
 	 * @param unknown_type $queue
1103
-	 * @return unknown
1103
+	 * @return boolean
1104 1104
 	 */
1105 1105
 	private function find_paths_iter(&$target_tables, &$path, &$queue) {
1106 1106
 		// Get table to look at:
@@ -1569,7 +1569,7 @@  discard block
 block discarded – undo
1569 1569
 	 * Takes in input a filter_bag (which can be about anything from a string to an array of TDBMObjects... see above from documentation),
1570 1570
 	 * and gives back a proper Filter object.
1571 1571
 	 *
1572
-	 * @param unknown_type $filter_bag
1572
+	 * @param unknown_type|null $filter_bag
1573 1573
 	 * @return FilterInterface
1574 1574
 	 */
1575 1575
 	public function buildFilterFromFilterBag($filter_bag) {
@@ -1634,7 +1634,7 @@  discard block
 block discarded – undo
1634 1634
 	 * Takes in input an order_bag (which can be about anything from a string to an array of OrderByColumn objects... see above from documentation),
1635 1635
 	 * and gives back an array of OrderByColumn / OrderBySQLString objects.
1636 1636
 	 *
1637
-	 * @param unknown_type $orderby_bag
1637
+	 * @param unknown_type|null $orderby_bag
1638 1638
 	 * @return array
1639 1639
 	 */
1640 1640
 	public function buildOrderArrayFromOrderBag($orderby_bag) {
@@ -1851,7 +1851,7 @@  discard block
 block discarded – undo
1851 1851
 	 * @param bool $support If the generated daos should keep support for old functions (eg : getUserList and getList)
1852 1852
 	 * @param bool $storeInUtc If the generated daos should store the date in UTC timezone instead of user's timezone.
1853 1853
 	 * @param bool $castDatesToDateTime
1854
-	 * @return \string[] the list of tables
1854
+	 * @return string[] the list of tables
1855 1855
 	 */
1856 1856
 	public function generateAllDaosAndBeans($daoFactoryClassName, $daonamespace, $beannamespace, $support, $storeInUtc, $castDatesToDateTime) {
1857 1857
 		$tdbmDaoGenerator = new TDBMDaoGenerator($this->dbConnection);
Please login to merge, or discard this patch.
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -545,45 +545,45 @@  discard block
 block discarded – undo
545 545
 		}
546 546
 	}
547 547
 
548
-    /**
549
-     * This function removes the given object from the database. It will also remove all objects relied to the one given
550
-     * by parameter before all.
551
-     *
552
-     * Notice: if the object has a multiple primary key, the function will not work.
553
-     *
554
-     * @param TDBMObject $objToDelete
555
-     */
556
-    public function deleteCascade(TDBMObject $objToDelete) {
557
-        $this->deleteAllConstraintWithThisObject($objToDelete);
558
-        $this->deleteObject($objToDelete);
559
-    }
560
-
561
-    /**
562
-     * This function is used only in TDBMService (private function)
563
-     * It will call deleteCascade function foreach object relied with a foreign key to the object given by parameter
564
-     *
565
-     * @param TDBMObject $obj
566
-     * @return TDBMObjectArray
567
-     */
568
-    private function deleteAllConstraintWithThisObject(TDBMObject $obj) {
569
-        $tableFrom = $this->dbConnection->escapeDBItem($obj->_getDbTableName());
570
-        $constraints = $this->dbConnection->getConstraintsFromTable($tableFrom);
571
-        foreach ($constraints as $constraint) {
572
-            $tableTo = $this->dbConnection->escapeDBItem($constraint["table1"]);
573
-            $colFrom = $this->dbConnection->escapeDBItem($constraint["col2"]);
574
-            $colTo = $this->dbConnection->escapeDBItem($constraint["col1"]);
575
-            $idVarName = $this->dbConnection->escapeDBItem($obj->getPrimaryKey()[0]);
576
-            $idValue = $this->dbConnection->quoteSmart($obj->TDBMObject_id);
577
-            $sql = "SELECT DISTINCT ".$tableTo.".*"
578
-                    ." FROM ".$tableFrom
579
-                    ." LEFT JOIN ".$tableTo." ON ".$tableFrom.".".$colFrom." = ".$tableTo.".".$colTo
580
-                    ." WHERE ".$tableFrom.".".$idVarName."=".$idValue;
581
-            $result = $this->getObjectsFromSQL($constraint["table1"], $sql);
582
-            foreach ($result as $tdbmObj) {
583
-                $this->deleteCascade($tdbmObj);
584
-            }
585
-        }
586
-    }
548
+	/**
549
+	 * This function removes the given object from the database. It will also remove all objects relied to the one given
550
+	 * by parameter before all.
551
+	 *
552
+	 * Notice: if the object has a multiple primary key, the function will not work.
553
+	 *
554
+	 * @param TDBMObject $objToDelete
555
+	 */
556
+	public function deleteCascade(TDBMObject $objToDelete) {
557
+		$this->deleteAllConstraintWithThisObject($objToDelete);
558
+		$this->deleteObject($objToDelete);
559
+	}
560
+
561
+	/**
562
+	 * This function is used only in TDBMService (private function)
563
+	 * It will call deleteCascade function foreach object relied with a foreign key to the object given by parameter
564
+	 *
565
+	 * @param TDBMObject $obj
566
+	 * @return TDBMObjectArray
567
+	 */
568
+	private function deleteAllConstraintWithThisObject(TDBMObject $obj) {
569
+		$tableFrom = $this->dbConnection->escapeDBItem($obj->_getDbTableName());
570
+		$constraints = $this->dbConnection->getConstraintsFromTable($tableFrom);
571
+		foreach ($constraints as $constraint) {
572
+			$tableTo = $this->dbConnection->escapeDBItem($constraint["table1"]);
573
+			$colFrom = $this->dbConnection->escapeDBItem($constraint["col2"]);
574
+			$colTo = $this->dbConnection->escapeDBItem($constraint["col1"]);
575
+			$idVarName = $this->dbConnection->escapeDBItem($obj->getPrimaryKey()[0]);
576
+			$idValue = $this->dbConnection->quoteSmart($obj->TDBMObject_id);
577
+			$sql = "SELECT DISTINCT ".$tableTo.".*"
578
+					." FROM ".$tableFrom
579
+					." LEFT JOIN ".$tableTo." ON ".$tableFrom.".".$colFrom." = ".$tableTo.".".$colTo
580
+					." WHERE ".$tableFrom.".".$idVarName."=".$idValue;
581
+			$result = $this->getObjectsFromSQL($constraint["table1"], $sql);
582
+			foreach ($result as $tdbmObj) {
583
+				$this->deleteCascade($tdbmObj);
584
+			}
585
+		}
586
+	}
587 587
 
588 588
 	/**
589 589
 	 * The getObjectsFromSQL is used to retrieve objects from the database using a full SQL query.
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
 			}
645 645
 			$keysStandardCased = array();
646 646
 			$firstLine = true;
647
-            $colsArray = null;
647
+			$colsArray = null;
648 648
 			while ($fullCaseRow = $result->fetch(\PDO::FETCH_ASSOC))
649 649
 			{
650 650
 				$row = array();
@@ -676,17 +676,17 @@  discard block
 block discarded – undo
676 676
 					$id = serialize($ids);
677 677
 				}
678 678
 
679
-                $obj = $this->objectStorage->get($table_name,$id);
679
+				$obj = $this->objectStorage->get($table_name,$id);
680 680
 				if ($obj === null)
681 681
 				{
682 682
 					if (!is_a($className, "Mouf\\Database\\TDBM\\TDBMObject", true)) {
683 683
 						throw new TDBMException("Error while calling TDBM: The class ".$className." should extend TDBMObject.");
684 684
 					}
685 685
 					$obj = new $className($this, $table_name, $id);
686
-                    $obj->loadFromRow($row, $colsArray);
687
-                    $this->objectStorage->set($table_name, $id, $obj);
686
+					$obj->loadFromRow($row, $colsArray);
687
+					$this->objectStorage->set($table_name, $id, $obj);
688 688
 				} elseif ($obj->_getStatus() == "not loaded") {
689
-                    $obj->loadFromRow($row, $colsArray);
689
+					$obj->loadFromRow($row, $colsArray);
690 690
 					// Check that the object fetched from cache is from the requested class.
691 691
 					if (!is_a($obj, $className)) {
692 692
 						throw new TDBMException("Error while calling TDBM: An object fetched from database is already present in TDBM cache and they do not share the same class. You requested the object to be of the class ".$className." but the object available locally is of the class ".get_class($obj).".");
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
 	private function getObjectsFromSQLGenerator($result, $table_name, $className, $sql) {
720 720
 		$keysStandardCased = array();
721 721
 		$firstLine = true;
722
-        $colsArray = null;
722
+		$colsArray = null;
723 723
 		while ($fullCaseRow = $result->fetch(\PDO::FETCH_ASSOC))
724 724
 		{
725 725
 			$row = array();
@@ -750,7 +750,7 @@  discard block
 block discarded – undo
750 750
 				}
751 751
 				$id = serialize($ids);
752 752
 			}
753
-            $obj = $this->objectStorage->get($table_name, $id);
753
+			$obj = $this->objectStorage->get($table_name, $id);
754 754
 			if ($obj === null)
755 755
 			{
756 756
 				if ($className == null) {
@@ -763,10 +763,10 @@  discard block
 block discarded – undo
763 763
 				} else {
764 764
 					throw new TDBMException("Error while casting TDBMObject to class, the parameter passed is not a string. Value passed: ".$className);
765 765
 				}
766
-                $obj->loadFromRow($row, $colsArray);
767
-                $this->objectStorage->set($table_name, $id, $obj);
766
+				$obj->loadFromRow($row, $colsArray);
767
+				$this->objectStorage->set($table_name, $id, $obj);
768 768
 			} elseif ($obj->_getStatus() == "not loaded") {
769
-                $obj->loadFromRow($row, $colsArray);
769
+				$obj->loadFromRow($row, $colsArray);
770 770
 				// Check that the object fetched from cache is from the requested class.
771 771
 				if ($className != null) {
772 772
 					if (!is_subclass_of(get_class($obj), $className) && get_class($obj) != $className) {
@@ -1665,9 +1665,9 @@  discard block
 block discarded – undo
1665 1665
 	 * Throws a TDBMException if one of those table does not exist.
1666 1666
 	 *
1667 1667
 	 * @param array $tables
1668
-     * @throws TDBMException
1668
+	 * @throws TDBMException
1669 1669
 	 */
1670
-    private function checkTablesExist($tables) {
1670
+	private function checkTablesExist($tables) {
1671 1671
 		foreach ($tables as $table) {
1672 1672
 			$possible_tables = $this->dbConnection->checkTableExist($table);
1673 1673
 			if ($possible_tables !== true)
@@ -1740,12 +1740,12 @@  discard block
 block discarded – undo
1740 1740
 	 * This function returns the HTML to draw a tree of DisplayNode.
1741 1741
 	 *
1742 1742
 	 * @param DisplayNode $tree
1743
-     * @param int $x
1744
-     * @param int $y
1745
-     * @param int $ret_width
1746
-     * @param int $ret_height
1747
-     *
1748
-     * @return string
1743
+	 * @param int $x
1744
+	 * @param int $y
1745
+	 * @param int $ret_width
1746
+	 * @param int $ret_height
1747
+	 *
1748
+	 * @return string
1749 1749
 	 */
1750 1750
 	public function drawTree($tree, $x, $y, &$ret_width=0, &$ret_height=0) {
1751 1751
 
@@ -1859,8 +1859,8 @@  discard block
 block discarded – undo
1859 1859
 	}
1860 1860
 
1861 1861
 	/**
1862
- 	* @param array<string, string> $tableToBeanMap
1863
- 	*/
1862
+	 * @param array<string, string> $tableToBeanMap
1863
+	 */
1864 1864
 	public function setTableToBeanMap(array $tableToBeanMap) {
1865 1865
 		$this->tableToBeanMap = $tableToBeanMap;
1866 1866
 	}
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/Utils/TDBMDaoGenerator.php 2 patches
Doc Comments   +14 added lines, -7 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 * @param bool $support If the generated daos should keep support for old functions (eg : getUserList and getList)
57 57
 	 * @param bool $storeInUtc If the generated daos should store the date in UTC timezone instead of user's timezone.
58 58
 	 * @param bool $castDatesToDateTime Whether dates are converted to DateTimeImmutable or to timestamp
59
-	 * @return \string[] the list of tables
59
+	 * @return string[] the list of tables
60 60
 	 * @throws TDBMException
61 61
 	 */
62 62
 	public function generateAllDaosAndBeans($daoFactoryClassName, $daonamespace, $beannamespace, $support, $storeInUtc, $castDatesToDateTime) {
@@ -84,7 +84,12 @@  discard block
 block discarded – undo
84 84
 	/**
85 85
 	 * Generates in one method call the daos and the beans for one table.
86 86
 	 * 
87
-	 * @param $tableName
87
+	 * @param string $tableName
88
+	 * @param string $daonamespace
89
+	 * @param string $beannamespace
90
+	 * @param boolean $support
91
+	 * @param boolean $storeInUtc
92
+	 * @param boolean $castDatesToDateTime
88 93
 	 */
89 94
 	public function generateDaoAndBean($tableName, $daonamespace, $beannamespace, ClassNameMapper $classNameMapper, $support, $storeInUtc, $castDatesToDateTime) {
90 95
 		$daoName = $this->getDaoNameFromTableName($tableName);
@@ -412,9 +417,10 @@  discard block
 block discarded – undo
412 417
 	/**
413 418
 	 * Writes the PHP bean DAO with simple functions to create/get/save objects.
414 419
 	 *
415
-	 * @param string $fileName The file that will be written (without the directory)
416 420
 	 * @param string $className The name of the class
417 421
 	 * @param string $tableName The name of the table
422
+	 * @param string $baseClassName
423
+	 * @param string $beanClassName
418 424
 	 */
419 425
 	public function generateDao($className, $baseClassName, $beanClassName, $tableName, ClassNameMapper $classNameMapper, $support) {
420 426
 		$info = $this->dbConnection->getTableInfo($tableName);
@@ -702,7 +708,9 @@  discard block
 block discarded – undo
702 708
 	/**
703 709
 	 * Generates the factory bean.
704 710
 	 * 
705
-	 * @param $tableList
711
+	 * @param string[] $tableList
712
+	 * @param string $daoFactoryClassName
713
+	 * @param string $daoNamespace
706 714
 	 */
707 715
 	private function generateFactory($tableList, $daoFactoryClassName, $daoNamespace, ClassNameMapper $classNameMapper) {
708 716
 		// For each table, let's write a property.
@@ -774,7 +782,6 @@  discard block
 block discarded – undo
774 782
 	 * Transforms the property name in a setter name.
775 783
 	 * For instance, phone => getPhone or name => getName
776 784
 	 *
777
-	 * @param string $methodName
778 785
 	 * @return string
779 786
 	 */
780 787
 	public static function getSetterNameForPropertyName($propertyName) {
@@ -854,7 +861,7 @@  discard block
 block discarded – undo
854 861
 	 * Tries to put string to the singular form (if it is plural).
855 862
 	 * Obviously, this can't be perfect, be we do the best we can.
856 863
 	 * 
857
-	 * @param $str string
864
+	 * @param string $str string
858 865
 	 * @return string
859 866
 	 */
860 867
 	public static function toSingular($str) {
@@ -875,7 +882,7 @@  discard block
 block discarded – undo
875 882
 	 * Put the first letter of the string in lower case.
876 883
 	 * Very useful to transform a class name into a variable name.
877 884
 	 * 
878
-	 * @param $str string
885
+	 * @param string $str string
879 886
 	 * @return string
880 887
 	 */
881 888
 	public static function toVariableName($str) {
Please login to merge, or discard this patch.
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	 */
62 62
 	public function generateAllDaosAndBeans($daoFactoryClassName, $daonamespace, $beannamespace, $support, $storeInUtc, $castDatesToDateTime) {
63 63
 		// TODO: migrate $this->daoNamespace to $daonamespace that is passed in parameter!
64
-        $classNameMapper = ClassNameMapper::createFromComposerFile($this->rootPath.'composer.json');
64
+		$classNameMapper = ClassNameMapper::createFromComposerFile($this->rootPath.'composer.json');
65 65
 
66 66
 		$this->daoNamespace = $daonamespace;
67 67
 		$this->beanNamespace = $beannamespace;
@@ -91,10 +91,10 @@  discard block
 block discarded – undo
91 91
 		$beanName = $this->getBeanNameFromTableName($tableName);
92 92
 		$baseBeanName = $this->getBaseBeanNameFromTableName($tableName);
93 93
 
94
-        $connection = $this->dbConnection;
95
-        if ($connection instanceof CachedConnection){
96
-            $connection->cacheService->purgeAll();
97
-        }
94
+		$connection = $this->dbConnection;
95
+		if ($connection instanceof CachedConnection){
96
+			$connection->cacheService->purgeAll();
97
+		}
98 98
 		
99 99
 		$this->generateBean($beanName, $baseBeanName, $tableName, $beannamespace, $classNameMapper, $storeInUtc, $castDatesToDateTime);
100 100
 		$this->generateDao($daoName, $daoName."Base", $beanName, $tableName, $classNameMapper, $support);
@@ -130,16 +130,16 @@  discard block
 block discarded – undo
130 130
 		return TDBMDaoGenerator::toSingular(TDBMDaoGenerator::toCamelCase($tableName))."BaseBean";
131 131
 	}
132 132
 
133
-    /**
134
-     * Writes the PHP bean file with all getters and setters from the table passed in parameter.
135
-     *
136
-     * @param string $className The name of the class
137
-     * @param string $baseClassName The name of the base class which will be extended (name only, no directory)
138
-     * @param string $tableName The name of the table
139
-     * @param string $beannamespace The namespace of the bean
140
-     * @param ClassNameMapper $classNameMapper
141
-     * @throws TDBMException
142
-     */
133
+	/**
134
+	 * Writes the PHP bean file with all getters and setters from the table passed in parameter.
135
+	 *
136
+	 * @param string $className The name of the class
137
+	 * @param string $baseClassName The name of the base class which will be extended (name only, no directory)
138
+	 * @param string $tableName The name of the table
139
+	 * @param string $beannamespace The namespace of the bean
140
+	 * @param ClassNameMapper $classNameMapper
141
+	 * @throws TDBMException
142
+	 */
143 143
 	public function generateBean($className, $baseClassName, $tableName, $beannamespace, ClassNameMapper $classNameMapper, $storeInUtc, $castDatesToDateTime) {
144 144
 		$table = $this->dbConnection->getTableFromDbModel($tableName);
145 145
 
@@ -367,25 +367,25 @@  discard block
 block discarded – undo
367 367
 		$str .= "}
368 368
 ?>";
369 369
 
370
-        $possibleBaseFileNames = $classNameMapper->getPossibleFileNames($beannamespace."\\".$baseClassName);
371
-        if (!$possibleBaseFileNames) {
372
-            throw new TDBMException('Sorry, autoload namespace issue. The class "'.$beannamespace."\\".$baseClassName.'" is not autoloadable.');
373
-        }
374
-        $possibleBaseFileName = $this->rootPath.$possibleBaseFileNames[0];
370
+		$possibleBaseFileNames = $classNameMapper->getPossibleFileNames($beannamespace."\\".$baseClassName);
371
+		if (!$possibleBaseFileNames) {
372
+			throw new TDBMException('Sorry, autoload namespace issue. The class "'.$beannamespace."\\".$baseClassName.'" is not autoloadable.');
373
+		}
374
+		$possibleBaseFileName = $this->rootPath.$possibleBaseFileNames[0];
375 375
 
376
-        $this->ensureDirectoryExist($possibleBaseFileName);
376
+		$this->ensureDirectoryExist($possibleBaseFileName);
377 377
 		file_put_contents($possibleBaseFileName, $str);
378 378
 		@chmod($possibleBaseFileName, 0664);
379 379
 
380 380
 
381 381
 
382
-        $possibleFileNames = $classNameMapper->getPossibleFileNames($beannamespace."\\".$className);
383
-        if (!$possibleFileNames) {
384
-            throw new TDBMException('Sorry, autoload namespace issue. The class "'.$beannamespace."\\".$className.'" is not autoloadable.');
385
-        }
386
-        $possibleFileName = $this->rootPath.$possibleFileNames[0];
382
+		$possibleFileNames = $classNameMapper->getPossibleFileNames($beannamespace."\\".$className);
383
+		if (!$possibleFileNames) {
384
+			throw new TDBMException('Sorry, autoload namespace issue. The class "'.$beannamespace."\\".$className.'" is not autoloadable.');
385
+		}
386
+		$possibleFileName = $this->rootPath.$possibleFileNames[0];
387 387
 
388
-        if (!file_exists($possibleFileName)) {
388
+		if (!file_exists($possibleFileName)) {
389 389
 			$str = "<?php
390 390
 /*
391 391
  * This file has been automatically generated by TDBM.
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 {
404 404
 
405 405
 }";
406
-            $this->ensureDirectoryExist($possibleFileName);
406
+			$this->ensureDirectoryExist($possibleFileName);
407 407
 			file_put_contents($possibleFileName ,$str);
408 408
 			@chmod($possibleFileName, 0664);
409 409
 		}
@@ -659,21 +659,21 @@  discard block
 block discarded – undo
659 659
 }
660 660
 ?>";
661 661
 
662
-        $possibleBaseFileNames = $classNameMapper->getPossibleFileNames($this->daoNamespace."\\".$baseClassName);
663
-        if (!$possibleBaseFileNames) {
664
-            throw new TDBMException('Sorry, autoload namespace issue. The class "'.$baseClassName.'" is not autoloadable.');
665
-        }
666
-        $possibleBaseFileName = $this->rootPath.$possibleBaseFileNames[0];
662
+		$possibleBaseFileNames = $classNameMapper->getPossibleFileNames($this->daoNamespace."\\".$baseClassName);
663
+		if (!$possibleBaseFileNames) {
664
+			throw new TDBMException('Sorry, autoload namespace issue. The class "'.$baseClassName.'" is not autoloadable.');
665
+		}
666
+		$possibleBaseFileName = $this->rootPath.$possibleBaseFileNames[0];
667 667
 
668
-        $this->ensureDirectoryExist($possibleBaseFileName);
668
+		$this->ensureDirectoryExist($possibleBaseFileName);
669 669
 		file_put_contents($possibleBaseFileName ,$str);
670 670
 		@chmod($possibleBaseFileName, 0664);
671 671
 
672
-        $possibleFileNames = $classNameMapper->getPossibleFileNames($this->daoNamespace."\\".$className);
673
-        if (!$possibleFileNames) {
674
-            throw new TDBMException('Sorry, autoload namespace issue. The class "'.$className.'" is not autoloadable.');
675
-        }
676
-        $possibleFileName = $this->rootPath.$possibleFileNames[0];
672
+		$possibleFileNames = $classNameMapper->getPossibleFileNames($this->daoNamespace."\\".$className);
673
+		if (!$possibleFileNames) {
674
+			throw new TDBMException('Sorry, autoload namespace issue. The class "'.$className.'" is not autoloadable.');
675
+		}
676
+		$possibleFileName = $this->rootPath.$possibleFileNames[0];
677 677
 		
678 678
 		// Now, let's generate the "editable" class
679 679
 		if (!file_exists($possibleFileName)) {
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
 {
694 694
 
695 695
 }";
696
-            $this->ensureDirectoryExist($possibleFileName);
696
+			$this->ensureDirectoryExist($possibleFileName);
697 697
 			file_put_contents($possibleFileName ,$str);
698 698
 			@chmod($possibleFileName, 0664);
699 699
 		}
@@ -760,13 +760,13 @@  discard block
 block discarded – undo
760 760
 }
761 761
 ?>';
762 762
 
763
-        $possibleFileNames = $classNameMapper->getPossibleFileNames($daoNamespace."\\".$daoFactoryClassName);
764
-        if (!$possibleFileNames) {
765
-            throw new TDBMException('Sorry, autoload namespace issue. The class "'.$daoNamespace."\\".$daoFactoryClassName.'" is not autoloadable.');
766
-        }
767
-        $possibleFileName = $this->rootPath.$possibleFileNames[0];
763
+		$possibleFileNames = $classNameMapper->getPossibleFileNames($daoNamespace."\\".$daoFactoryClassName);
764
+		if (!$possibleFileNames) {
765
+			throw new TDBMException('Sorry, autoload namespace issue. The class "'.$daoNamespace."\\".$daoFactoryClassName.'" is not autoloadable.');
766
+		}
767
+		$possibleFileName = $this->rootPath.$possibleFileNames[0];
768 768
 
769
-        $this->ensureDirectoryExist($possibleFileName);
769
+		$this->ensureDirectoryExist($possibleFileName);
770 770
 		file_put_contents($possibleFileName ,$str);
771 771
 	}
772 772
 	
@@ -882,22 +882,22 @@  discard block
 block discarded – undo
882 882
 		return strtolower(substr($str, 0, 1)).substr($str, 1);
883 883
 	}
884 884
 
885
-    /**
886
-     * Ensures the file passed in parameter can be written in its directory.
887
-     * @param string $fileName
888
-     */
889
-    private function ensureDirectoryExist($fileName) {
890
-        $dirName = dirname($fileName);
891
-        if (!file_exists($dirName)) {
892
-            $old = umask(0);
893
-            $result = mkdir($dirName, 0775, true);
894
-            umask($old);
895
-            if ($result == false) {
896
-                echo "Unable to create directory: ".$dirName.".";
897
-                exit;
898
-            }
899
-        }
900
-    }
885
+	/**
886
+	 * Ensures the file passed in parameter can be written in its directory.
887
+	 * @param string $fileName
888
+	 */
889
+	private function ensureDirectoryExist($fileName) {
890
+		$dirName = dirname($fileName);
891
+		if (!file_exists($dirName)) {
892
+			$old = umask(0);
893
+			$result = mkdir($dirName, 0775, true);
894
+			umask($old);
895
+			if ($result == false) {
896
+				echo "Unable to create directory: ".$dirName.".";
897
+				exit;
898
+			}
899
+		}
900
+	}
901 901
 
902 902
 	/**
903 903
 	 * @param string $rootPath
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/Controllers/TdbmController.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -65,10 +65,10 @@  discard block
 block discarded – undo
65 65
 		}
66 66
 				
67 67
 		if ($this->daoNamespace == null && $this->beanNamespace == null) {
68
-            $classNameMapper = ClassNameMapper::createFromComposerFile(__DIR__.'/../../../../../../../../composer.json');
68
+			$classNameMapper = ClassNameMapper::createFromComposerFile(__DIR__.'/../../../../../../../../composer.json');
69 69
 
70 70
 			$autoloadNamespaces = $classNameMapper->getManagedNamespaces();
71
-            if ($autoloadNamespaces) {
71
+			if ($autoloadNamespaces) {
72 72
 				$this->autoloadDetected = true;
73 73
 				$rootNamespace = $autoloadNamespaces[0];
74 74
 				$this->daoNamespace = $rootNamespace."Dao";
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 		
151 151
 		$tdbmService = new InstanceProxy($name);
152 152
 		/* @var $tdbmService TDBMService */
153
-        $tables = $tdbmService->generateAllDaosAndBeans($daofactoryclassname, $daonamespace, $beannamespace, $keepSupport, $storeInUtc, $castDatesToDateTime);
153
+		$tables = $tdbmService->generateAllDaosAndBeans($daofactoryclassname, $daonamespace, $beannamespace, $keepSupport, $storeInUtc, $castDatesToDateTime);
154 154
 
155 155
 
156 156
 		$moufManager->declareComponent($daofactoryinstancename, $daonamespace."\\".$daofactoryclassname, false, MoufManager::DECLARE_ON_EXIST_KEEP_INCOMING_LINKS);
Please login to merge, or discard this patch.