Completed
Pull Request — 3.4 (#46)
by David
18:51
created
src/Mouf/Database/TDBM/Filters/EqualFilter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@
 block discarded – undo
85 85
 	 * @param string $columnName
86 86
 	 * @param string $value
87 87
 	 */
88
-	public function __construct($tableName=null, $columnName=null, $value=null) {
88
+	public function __construct($tableName = null, $columnName = null, $value = null) {
89 89
 		$this->tableName = $tableName;
90 90
 		$this->columnName = $columnName;
91 91
 		$this->value = $value;
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/Filters/GreaterFilter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@
 block discarded – undo
85 85
 	 * @param string $columnName
86 86
 	 * @param string $value
87 87
 	 */
88
-	public function __construct($tableName=null, $columnName=null, $value=null) {
88
+	public function __construct($tableName = null, $columnName = null, $value = null) {
89 89
 		$this->tableName = $tableName;
90 90
 		$this->columnName = $columnName;
91 91
 		$this->value = $value;
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/Filters/GreaterOrEqualFilter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@
 block discarded – undo
85 85
 	 * @param string $columnName
86 86
 	 * @param string $value
87 87
 	 */
88
-	public function __construct($tableName=null, $columnName=null, $value=null) {
88
+	public function __construct($tableName = null, $columnName = null, $value = null) {
89 89
 		$this->tableName = $tableName;
90 90
 		$this->columnName = $columnName;
91 91
 		$this->value = $value;
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/Filters/LessFilter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@
 block discarded – undo
85 85
 	 * @param string $columnName
86 86
 	 * @param string $value
87 87
 	 */
88
-	public function __construct($tableName=null, $columnName=null, $value=null) {
88
+	public function __construct($tableName = null, $columnName = null, $value = null) {
89 89
 		$this->tableName = $tableName;
90 90
 		$this->columnName = $columnName;
91 91
 		$this->value = $value;
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/Filters/LessOrEqualFilter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@
 block discarded – undo
85 85
 	 * @param string $columnName
86 86
 	 * @param string $value
87 87
 	 */
88
-	public function __construct($tableName=null, $columnName=null, $value=null) {
88
+	public function __construct($tableName = null, $columnName = null, $value = null) {
89 89
 		$this->tableName = $tableName;
90 90
 		$this->columnName = $columnName;
91 91
 		$this->value = $value;
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/Filters/LikeFilter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@
 block discarded – undo
85 85
 	 * @param string $columnName
86 86
 	 * @param string $value
87 87
 	 */
88
-	public function __construct($tableName=null, $columnName=null, $value=null) {
88
+	public function __construct($tableName = null, $columnName = null, $value = null) {
89 89
 		$this->tableName = $tableName;
90 90
 		$this->columnName = $columnName;
91 91
 		$this->value = $value;
Please login to merge, or discard this patch.
src/views/tdbmGenerate.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
 <div class="control-group">
30 30
 	<label class="control-label">Store dates / timestamps in UTC:</label>
31 31
 	<div class="controls">
32
-		<input type="checkbox" name="storeInUtc" value="1" <?php echo $this->storeInUtc?'checked="checked"':"" ?>></input>
32
+		<input type="checkbox" name="storeInUtc" value="1" <?php echo $this->storeInUtc ? 'checked="checked"' : "" ?>></input>
33 33
 		<span class="help-block">Select this option if you want timestamps to be stored in UTC.
34 34
 		If your application supports several time zones, you should select this option to store all dates in
35 35
 		the same time zone.</span>
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/TDBMService.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -699,9 +699,9 @@  discard block
 block discarded – undo
699 699
 		// 4-2, let's take all the objects out of the orderby bag, and let's make objects from them
700 700
 		$orderby_bag2 = array();
701 701
 		foreach ($orderby_bag as $thing) {
702
-			if (is_a($thing,'Mouf\\Database\\TDBM\\Filters\\OrderBySQLString')) {
702
+			if (is_a($thing, 'Mouf\\Database\\TDBM\\Filters\\OrderBySQLString')) {
703 703
 				$orderby_bag2[] = $thing;
704
-			} elseif (is_a($thing,'Mouf\\Database\\TDBM\\Filters\\OrderByColumn')) {
704
+			} elseif (is_a($thing, 'Mouf\\Database\\TDBM\\Filters\\OrderByColumn')) {
705 705
 				$orderby_bag2[] = $thing;
706 706
 			} elseif (is_string($thing)) {
707 707
 				$orderby_bag2[] = new OrderBySQLString($thing);
@@ -1204,7 +1204,7 @@  discard block
 block discarded – undo
1204 1204
 		$schemaAnalyzer = $this->schemaAnalyzer;
1205 1205
 
1206 1206
 		foreach ($tables as $currentTable) {
1207
-			$allParents = [ $currentTable ];
1207
+			$allParents = [$currentTable];
1208 1208
 			$currentFk = null;
1209 1209
 			while ($currentFk = $schemaAnalyzer->getParentRelationship($currentTable)) {
1210 1210
 				$currentTable = $currentFk->getForeignTableName();
@@ -1246,7 +1246,7 @@  discard block
 block discarded – undo
1246 1246
 		// Let's scan the parent tables
1247 1247
 		$currentTable = $table;
1248 1248
 
1249
-		$parentTables = [ ];
1249
+		$parentTables = [];
1250 1250
 
1251 1251
 		// Get parent relationship
1252 1252
 		while ($currentFk = $schemaAnalyzer->getParentRelationship($currentTable)) {
@@ -1336,7 +1336,7 @@  discard block
 block discarded – undo
1336 1336
 	 * @return ResultIterator An object representing an array of results.
1337 1337
 	 * @throws TDBMException
1338 1338
 	 */
1339
-	public function findObjects($mainTable, $filter=null, array $parameters = array(), $orderString=null, array $additionalTablesFetch = array(), $mode = null, $className=null) {
1339
+	public function findObjects($mainTable, $filter = null, array $parameters = array(), $orderString = null, array $additionalTablesFetch = array(), $mode = null, $className = null) {
1340 1340
 		// $mainTable is not secured in MagicJoin, let's add a bit of security to avoid SQL injection.
1341 1341
 		if (!preg_match('/^[a-zA-Z_][a-zA-Z0-9_]*$/', $mainTable)) {
1342 1342
 			throw new TDBMException(sprintf("Invalid table name: '%s'", $mainTable));
@@ -1405,7 +1405,7 @@  discard block
 block discarded – undo
1405 1405
 			throw new TDBMException("Unknown fetch mode: '".$this->mode."'");
1406 1406
 		}
1407 1407
 
1408
-		$mode = $mode?:$this->mode;
1408
+		$mode = $mode ?: $this->mode;
1409 1409
 
1410 1410
 		return new ResultIterator($sql, $countSql, $parameters, $columnDescList, $this->objectStorage, $className, $this, $this->magicQuery, $mode);
1411 1411
 	}
@@ -1419,7 +1419,7 @@  discard block
 block discarded – undo
1419 1419
 	 * @return AbstractTDBMObject
1420 1420
 	 * @throws TDBMException
1421 1421
 	 */
1422
-	public function findObjectByPk($table, array $primaryKeys, array $additionalTablesFetch = array(), $lazy = false, $className=null) {
1422
+	public function findObjectByPk($table, array $primaryKeys, array $additionalTablesFetch = array(), $lazy = false, $className = null) {
1423 1423
 		$primaryKeys = $this->_getPrimaryKeysFromObjectData($table, $primaryKeys);
1424 1424
 		$hash = $this->getObjectHash($primaryKeys);
1425 1425
 
@@ -1439,7 +1439,7 @@  discard block
 block discarded – undo
1439 1439
 			// Only allowed if no inheritance.
1440 1440
 			if (count($tables) === 1) {
1441 1441
 				if ($className === null) {
1442
-					$className = isset($this->tableToBeanMap[$table])?$this->tableToBeanMap[$table]:"Mouf\\Database\\TDBM\\TDBMObject";
1442
+					$className = isset($this->tableToBeanMap[$table]) ? $this->tableToBeanMap[$table] : "Mouf\\Database\\TDBM\\TDBMObject";
1443 1443
 				}
1444 1444
 
1445 1445
 				// Let's construct the bean
@@ -1468,11 +1468,11 @@  discard block
 block discarded – undo
1468 1468
 	 * @return AbstractTDBMObject|null The object we want, or null if no object matches the filters.
1469 1469
 	 * @throws TDBMException
1470 1470
 	 */
1471
-	public function findObject($mainTable, $filterString=null, array $parameters = array(), array $additionalTablesFetch = array(), $className = null) {
1471
+	public function findObject($mainTable, $filterString = null, array $parameters = array(), array $additionalTablesFetch = array(), $className = null) {
1472 1472
 		$objects = $this->findObjects($mainTable, $filterString, $parameters, null, $additionalTablesFetch, self::MODE_ARRAY, $className);
1473 1473
 		$page = $objects->take(0, 2);
1474 1474
 		$count = $page->count();
1475
-		if ($count > 1) {
1475
+		if ($count>1) {
1476 1476
 			throw new DuplicateRowException("Error while querying an object for table '$mainTable': More than 1 row have been returned, but we should have received at most one.");
1477 1477
 		} elseif ($count === 0) {
1478 1478
 			return null;
@@ -1492,7 +1492,7 @@  discard block
 block discarded – undo
1492 1492
 	 * @return AbstractTDBMObject The object we want
1493 1493
 	 * @throws TDBMException
1494 1494
 	 */
1495
-	public function findObjectOrFail($mainTable, $filterString=null, array $parameters = array(), array $additionalTablesFetch = array(), $className = null) {
1495
+	public function findObjectOrFail($mainTable, $filterString = null, array $parameters = array(), array $additionalTablesFetch = array(), $className = null) {
1496 1496
 		$bean = $this->findObject($mainTable, $filterString, $parameters, $additionalTablesFetch, $className);
1497 1497
 		if ($bean === null) {
1498 1498
 			throw new NoBeanFoundException("No result found for query on table '".$mainTable."'");
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/AbstractTDBMObject.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	 * @throws TDBMException
96 96
 	 * @throws TDBMInvalidOperationException
97 97
 	 */
98
-	public function __construct($tableName=null, array $primaryKeys=array(), TDBMService $tdbmService=null) {
98
+	public function __construct($tableName = null, array $primaryKeys = array(), TDBMService $tdbmService = null) {
99 99
 		// FIXME: lazy loading should be forbidden on tables with inheritance and dynamic type assignation...
100 100
 		if (!empty($tableName)) {
101 101
 			$this->dbRows[$tableName] = new DbRow($this, $tableName, $primaryKeys, $tdbmService);
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 	 * $status = TDBMObjectStateEnum::STATE_LOADED when the object is cached in memory.
200 200
 	 * @param string $state
201 201
 	 */
202
-	public function _setStatus($state){
202
+	public function _setStatus($state) {
203 203
 		$this->status = $state;
204 204
 
205 205
 		// TODO: we might ignore the loaded => dirty state here! dirty status comes from the db_row itself.
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 
211 211
 	public function get($var, $tableName = null) {
212 212
 		if ($tableName === null) {
213
-			if (count($this->dbRows) > 1) {
213
+			if (count($this->dbRows)>1) {
214 214
 				throw new TDBMException('This object is based on several tables. You must specify which table you are retrieving data from.');
215 215
 			} elseif (count($this->dbRows) === 1) {
216 216
 				$tableName = array_keys($this->dbRows)[0];
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 	 */
237 237
 	public function has($var, $tableName = null) {
238 238
 		if ($tableName === null) {
239
-			if (count($this->dbRows) > 1) {
239
+			if (count($this->dbRows)>1) {
240 240
 				throw new TDBMException('This object is based on several tables. You must specify which table you are retrieving data from.');
241 241
 			} elseif (count($this->dbRows) === 1) {
242 242
 				$tableName = array_keys($this->dbRows)[0];
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 	
257 257
 	public function set($var, $value, $tableName = null) {
258 258
 		if ($tableName === null) {
259
-			if (count($this->dbRows) > 1) {
259
+			if (count($this->dbRows)>1) {
260 260
 				throw new TDBMException('This object is based on several tables. You must specify which table you are retrieving data from.');
261 261
 			} elseif (count($this->dbRows) === 1) {
262 262
 				$tableName = array_keys($this->dbRows)[0];
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 	 */
282 282
 	public function setRef($foreignKeyName, AbstractTDBMObject $bean, $tableName = null) {
283 283
 		if ($tableName === null) {
284
-			if (count($this->dbRows) > 1) {
284
+			if (count($this->dbRows)>1) {
285 285
 				throw new TDBMException('This object is based on several tables. You must specify which table you are retrieving data from.');
286 286
 			} elseif (count($this->dbRows) === 1) {
287 287
 				$tableName = array_keys($this->dbRows)[0];
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 	 */
307 307
 	public function getRef($foreignKeyName, $tableName = null) {
308 308
 		if ($tableName === null) {
309
-			if (count($this->dbRows) > 1) {
309
+			if (count($this->dbRows)>1) {
310 310
 				throw new TDBMException('This object is based on several tables. You must specify which table you are retrieving data from.');
311 311
 			} elseif (count($this->dbRows) === 1) {
312 312
 				$tableName = array_keys($this->dbRows)[0];
@@ -422,13 +422,13 @@  discard block
 block discarded – undo
422 422
 	 */
423 423
 	private function setRelationship($pivotTableName, AbstractTDBMObject $remoteBean, $status) {
424 424
 		$storage = $this->getRelationshipStorage($pivotTableName);
425
-		$storage->attach($remoteBean, [ 'status' => $status, 'reverse' => false ]);
425
+		$storage->attach($remoteBean, ['status' => $status, 'reverse' => false]);
426 426
 		if ($this->status === TDBMObjectStateEnum::STATE_LOADED) {
427 427
 			$this->_setStatus(TDBMObjectStateEnum::STATE_DIRTY);
428 428
 		}
429 429
 
430 430
 		$remoteStorage = $remoteBean->getRelationshipStorage($pivotTableName);
431
-		$remoteStorage->attach($this, [ 'status' => $status, 'reverse' => true ]);
431
+		$remoteStorage->attach($this, ['status' => $status, 'reverse' => true]);
432 432
 	}
433 433
 
434 434
 	/**
@@ -516,23 +516,23 @@  discard block
 block discarded – undo
516 516
 	 *
517 517
 	 * @return string
518 518
 	 */
519
-	private function getPrimaryKeyWhereStatement () {
519
+	private function getPrimaryKeyWhereStatement() {
520 520
 		// Let's first get the primary keys
521 521
 		$pk_table = $this->tdbmService->getPrimaryKeyColumns($this->dbTableName);
522 522
 		// Now for the object_id
523 523
 		$object_id = $this->TDBMObject_id;
524 524
 		// If there is only one primary key:
525
-		if (count($pk_table)==1) {
525
+		if (count($pk_table) == 1) {
526 526
 			$sql_where = $this->db_connection->escapeDBItem($this->dbTableName).'.'.$this->db_connection->escapeDBItem($pk_table[0])."=".$this->db_connection->quoteSmart($this->TDBMObject_id);
527 527
 		} else {
528 528
 			$ids = unserialize($object_id);
529
-			$i=0;
529
+			$i = 0;
530 530
 			$sql_where_array = array();
531 531
 			foreach ($pk_table as $pk) {
532 532
 				$sql_where_array[] = $this->db_connection->escapeDBItem($this->dbTableName).'.'.$this->db_connection->escapeDBItem($pk)."=".$this->db_connection->quoteSmart($ids[$i]);
533 533
 				$i++;
534 534
 			}
535
-			$sql_where = implode(" AND ",$sql_where_array);
535
+			$sql_where = implode(" AND ", $sql_where_array);
536 536
 		}
537 537
 		return $sql_where;
538 538
 	}
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
     /**
541 541
      * Override the native php clone function for TDBMObjects
542 542
      */
543
-    public function __clone(){
543
+    public function __clone() {
544 544
         $this->_dbLoadIfNotLoaded();
545 545
         //First lets set the status to new (to enter the save function)
546 546
         $this->status = TDBMObjectStateEnum::STATE_NEW;
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
 	private function registerTable($tableName) {
568 568
 		$dbRow = new DbRow($this, $tableName);
569 569
 
570
-		if (in_array($this->status, [ TDBMObjectStateEnum::STATE_NOT_LOADED, TDBMObjectStateEnum::STATE_LOADED, TDBMObjectStateEnum::STATE_DIRTY ])) {
570
+		if (in_array($this->status, [TDBMObjectStateEnum::STATE_NOT_LOADED, TDBMObjectStateEnum::STATE_LOADED, TDBMObjectStateEnum::STATE_DIRTY])) {
571 571
 			// Let's get the primary key for the new table
572 572
 			$anotherDbRow = array_values($this->dbRows)[0];
573 573
 			/* @var $anotherDbRow DbRow */
Please login to merge, or discard this patch.