Completed
Pull Request — 3.4 (#46)
by David
13:58
created
src/Mouf/Database/TDBM/Filters/LikeFilter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@
 block discarded – undo
86 86
 	 * @param string $columnName
87 87
 	 * @param string $value
88 88
 	 */
89
-	public function __construct($tableName=null, $columnName=null, $value=null) {
89
+	public function __construct($tableName = null, $columnName = null, $value = null) {
90 90
 		$this->tableName = $tableName;
91 91
 		$this->columnName = $columnName;
92 92
 		$this->value = $value;
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/Filters/NotFilter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@
 block discarded – undo
59 59
 	 * 
60 60
 	 * @param FilterInterface $filter
61 61
 	 */
62
-	public function __construct($filter=null) {
62
+	public function __construct($filter = null) {
63 63
 		$this->filter = $filter;
64 64
 	}
65 65
 
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/Filters/SqlStringFilter.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	 * 
63 63
 	 * @param string $sqlString
64 64
 	 */
65
-	public function __construct($sqlString=null) {
65
+	public function __construct($sqlString = null) {
66 66
 		$this->sqlString = $sqlString;
67 67
 	}
68 68
 
@@ -95,32 +95,32 @@  discard block
 block discarded – undo
95 95
 		// First, let's remove all the stuff in quotes:
96 96
 
97 97
 		// Let's remove all the \' found
98
-		$work_str = str_replace("\\'",'',$this->sqlString);
98
+		$work_str = str_replace("\\'", '', $this->sqlString);
99 99
 		// Now, let's split the string using '
100 100
 		$work_table = explode("'", $work_str);
101 101
 
102
-		if (count($work_table)==0)
102
+		if (count($work_table) == 0)
103 103
 		return '';
104 104
 
105 105
 		// if we start with a ', let's remove the first text
106
-		if (strstr($work_str,"'")===0)
106
+		if (strstr($work_str, "'") === 0)
107 107
 		array_shift($work_table);
108 108
 			
109
-		if (count($work_table)==0)
109
+		if (count($work_table) == 0)
110 110
 		return '';
111 111
 
112 112
 		// Now, let's take only the stuff outside the quotes.
113 113
 		$work_str2 = '';
114 114
 
115
-		$i=0;
115
+		$i = 0;
116 116
 		foreach ($work_table as $str_fragment) {
117
-			if (($i % 2) == 0)
117
+			if (($i%2) == 0)
118 118
 			$work_str2 .= $str_fragment.' ';
119 119
 			$i++;
120 120
 		}
121 121
 
122 122
 		// Now, let's run a regexp to find all the strings matching the pattern xxx.yyy
123
-		preg_match_all('/([a-zA-Z_](?:[a-zA-Z0-9_]*))\.(?:[a-zA-Z_](?:[a-zA-Z0-9_]*))/', $work_str2,$capture_result);
123
+		preg_match_all('/([a-zA-Z_](?:[a-zA-Z0-9_]*))\.(?:[a-zA-Z_](?:[a-zA-Z0-9_]*))/', $work_str2, $capture_result);
124 124
 
125 125
 		$tables_used = $capture_result[1];
126 126
 		// remove doubles:
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/Filters/AndFilter.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	 * 
50 50
 	 * @param array<FilterInterface> $filters
51 51
 	 */
52
-	public function __construct(array $filters=array()) {
52
+	public function __construct(array $filters = array()) {
53 53
 		$this->filters = $filters;
54 54
 	}
55 55
 
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 		}
92 92
 
93 93
 		if (count($filters_sql)>0) {
94
-			return '('.implode(' AND ',$filters_sql).')';
94
+			return '('.implode(' AND ', $filters_sql).')';
95 95
 		} else {
96 96
 			return '';
97 97
 		}
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 				throw new TDBMException("Error in AndFilter: One of the parameters is not a filter.");
115 115
 			}
116 116
 			
117
-			$tables = array_merge($tables,$filter->getUsedTables());
117
+			$tables = array_merge($tables, $filter->getUsedTables());
118 118
 		}
119 119
 		// Remove tables in double.
120 120
 		$tables = array_flip(array_flip($tables));
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/Filters/BetweenFilter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@
 block discarded – undo
101 101
      * @param string $value1
102 102
      * @param string $value2
103 103
 	 */
104
-	public function __construct($tableName=null, $columnName=null, $value1=null, $value2=null) {
104
+	public function __construct($tableName = null, $columnName = null, $value1 = null, $value2 = null) {
105 105
 		$this->tableName = $tableName;
106 106
 		$this->columnName = $columnName;
107 107
 		$this->value1 = $value1;
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/Filters/OrFilter.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	 * 
60 60
 	 * @param array<FilterInterface> $filters
61 61
 	 */
62
-	public function __construct(array $filters=array()) {
62
+	public function __construct(array $filters = array()) {
63 63
 		$this->filters = $filters;
64 64
 	}
65 65
 
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 		}
92 92
 
93 93
 		if (count($filters_sql)>0) {
94
-			return '('.implode(' OR ',$filters_sql).')';
94
+			return '('.implode(' OR ', $filters_sql).')';
95 95
 		} else {
96 96
 			return '';
97 97
 		}
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
                 throw new TDBMException("Error in OrFilter: One of the parameters is not a filter.");
115 115
             }
116 116
 
117
-            $tables = array_merge($tables,$filter->getUsedTables());
117
+            $tables = array_merge($tables, $filter->getUsedTables());
118 118
         }
119 119
         // Remove tables in double.
120 120
         $tables = array_flip(array_flip($tables));
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
@@ -84,7 +84,7 @@
 block discarded – undo
84 84
 	 * @param string $columnName
85 85
 	 * @param string $value
86 86
 	 */
87
-	public function __construct($tableName=null, $columnName=null, $value=null) {
87
+	public function __construct($tableName = null, $columnName = null, $value = null) {
88 88
 		$this->tableName = $tableName;
89 89
 		$this->columnName = $columnName;
90 90
 		$this->value = $value;
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/Filters/DifferentFilter.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/AbstractTDBMObject.php 1 patch
Spacing   +16 added lines, -16 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];
@@ -421,13 +421,13 @@  discard block
 block discarded – undo
421 421
 	 */
422 422
 	private function setRelationship($pivotTableName, AbstractTDBMObject $remoteBean, $status) {
423 423
 		$storage = $this->getRelationshipStorage($pivotTableName);
424
-		$storage->attach($remoteBean, [ 'status' => $status, 'reverse' => false ]);
424
+		$storage->attach($remoteBean, ['status' => $status, 'reverse' => false]);
425 425
 		if ($this->status === TDBMObjectStateEnum::STATE_LOADED) {
426 426
 			$this->_setStatus(TDBMObjectStateEnum::STATE_DIRTY);
427 427
 		}
428 428
 
429 429
 		$remoteStorage = $remoteBean->getRelationshipStorage($pivotTableName);
430
-		$remoteStorage->attach($this, [ 'status' => $status, 'reverse' => true ]);
430
+		$remoteStorage->attach($this, ['status' => $status, 'reverse' => true]);
431 431
 	}
432 432
 
433 433
 	/**
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
 	 * Implement the unique JsonSerializable method
497 497
 	 * @return array
498 498
 	 */
499
-	public function jsonSerialize(){
499
+	public function jsonSerialize() {
500 500
 		// FIXME
501 501
 		$this->_dbLoadIfNotLoaded();
502 502
 		return $this->dbRow;
@@ -526,23 +526,23 @@  discard block
 block discarded – undo
526 526
 	 *
527 527
 	 * @return string
528 528
 	 */
529
-	private function getPrimaryKeyWhereStatement () {
529
+	private function getPrimaryKeyWhereStatement() {
530 530
 		// Let's first get the primary keys
531 531
 		$pk_table = $this->tdbmService->getPrimaryKeyColumns($this->dbTableName);
532 532
 		// Now for the object_id
533 533
 		$object_id = $this->TDBMObject_id;
534 534
 		// If there is only one primary key:
535
-		if (count($pk_table)==1) {
535
+		if (count($pk_table) == 1) {
536 536
 			$sql_where = $this->db_connection->escapeDBItem($this->dbTableName).'.'.$this->db_connection->escapeDBItem($pk_table[0])."=".$this->db_connection->quoteSmart($this->TDBMObject_id);
537 537
 		} else {
538 538
 			$ids = unserialize($object_id);
539
-			$i=0;
539
+			$i = 0;
540 540
 			$sql_where_array = array();
541 541
 			foreach ($pk_table as $pk) {
542 542
 				$sql_where_array[] = $this->db_connection->escapeDBItem($this->dbTableName).'.'.$this->db_connection->escapeDBItem($pk)."=".$this->db_connection->quoteSmart($ids[$i]);
543 543
 				$i++;
544 544
 			}
545
-			$sql_where = implode(" AND ",$sql_where_array);
545
+			$sql_where = implode(" AND ", $sql_where_array);
546 546
 		}
547 547
 		return $sql_where;
548 548
 	}
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
     /**
551 551
      * Override the native php clone function for TDBMObjects
552 552
      */
553
-    public function __clone(){
553
+    public function __clone() {
554 554
         $this->_dbLoadIfNotLoaded();
555 555
         //First lets set the status to new (to enter the save function)
556 556
         $this->status = TDBMObjectStateEnum::STATE_NEW;
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
 	private function registerTable($tableName) {
578 578
 		$dbRow = new DbRow($this, $tableName);
579 579
 
580
-		if (in_array($this->status, [ TDBMObjectStateEnum::STATE_NOT_LOADED, TDBMObjectStateEnum::STATE_LOADED, TDBMObjectStateEnum::STATE_DIRTY ])) {
580
+		if (in_array($this->status, [TDBMObjectStateEnum::STATE_NOT_LOADED, TDBMObjectStateEnum::STATE_LOADED, TDBMObjectStateEnum::STATE_DIRTY])) {
581 581
 			// Let's get the primary key for the new table
582 582
 			$anotherDbRow = array_values($this->dbRows)[0];
583 583
 			/* @var $anotherDbRow DbRow */
Please login to merge, or discard this patch.