Completed
Pull Request — 4.1 (#107)
by David
11:26 queued 03:10
created
src/Mouf/Database/TDBM/Utils/ObjectBeanPropertyDescriptor.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
     {
66 66
         // First, are there many column or only one?
67 67
         // If one column, we name the setter after it. Otherwise, we name the setter after the table name
68
-        if (count($this->foreignKey->getLocalColumns()) > 1) {
68
+        if (count($this->foreignKey->getLocalColumns())>1) {
69 69
             $name = TDBMDaoGenerator::toSingular(TDBMDaoGenerator::toCamelCase($this->foreignKey->getForeignTableName()));
70 70
             if ($this->alternativeName) {
71 71
                 $camelizedColumns = array_map(['Mouf\\Database\\TDBM\\Utils\\TDBMDaoGenerator', 'toCamelCase'], $this->foreignKey->getLocalColumns());
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
             if (strpos(strtolower($column), 'id_') === 0) {
79 79
                 $column = substr($column, 3);
80 80
             }
81
-            if (strrpos(strtolower($column), '_id') === strlen($column) - 3) {
82
-                $column = substr($column, 0, strlen($column) - 3);
81
+            if (strrpos(strtolower($column), '_id') === strlen($column)-3) {
82
+                $column = substr($column, 0, strlen($column)-3);
83 83
             }
84 84
             $name = TDBMDaoGenerator::toCamelCase($column);
85 85
             if ($this->alternativeName) {
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/InnerResultArray.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 
84 84
     private function toIndex($offset)
85 85
     {
86
-        if ($offset < 0 || filter_var($offset, FILTER_VALIDATE_INT) === false) {
86
+        if ($offset<0 || filter_var($offset, FILTER_VALIDATE_INT) === false) {
87 87
             throw new TDBMInvalidOffsetException('Trying to access result set using offset "'.$offset.'". An offset must be a positive integer.');
88 88
         }
89 89
         if ($this->statement === null) {
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
     public function next()
101 101
     {
102 102
         // Let's overload the next() method to store the result.
103
-        if (isset($this->results[$this->key + 1])) {
103
+        if (isset($this->results[$this->key+1])) {
104 104
             ++$this->key;
105 105
             $this->current = $this->results[$this->key];
106 106
         } else {
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/PageIterator.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
      */
113 113
     public function getCurrentPage()
114 114
     {
115
-        return floor($this->offset / $this->limit) + 1;
115
+        return floor($this->offset/$this->limit)+1;
116 116
     }
117 117
 
118 118
     /**
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
      */
252 252
     public function jsonSerialize()
253 253
     {
254
-        return array_map(function (AbstractTDBMObject $item) {
254
+        return array_map(function(AbstractTDBMObject $item) {
255 255
             return $item->jsonSerialize();
256 256
         }, $this->toArray());
257 257
     }
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/AbstractTDBMObject.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
      */
187 187
     private function checkTableName($tableName = null) {
188 188
         if ($tableName === null) {
189
-            if (count($this->dbRows) > 1) {
189
+            if (count($this->dbRows)>1) {
190 190
                 throw new TDBMException('This object is based on several tables. You must specify which table you are retrieving data from.');
191 191
             } elseif (count($this->dbRows) === 1) {
192 192
                 $tableName = array_keys($this->dbRows)[0];
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
     protected function set($var, $value, $tableName = null)
214 214
     {
215 215
         if ($tableName === null) {
216
-            if (count($this->dbRows) > 1) {
216
+            if (count($this->dbRows)>1) {
217 217
                 throw new TDBMException('This object is based on several tables. You must specify which table you are retrieving data from.');
218 218
             } elseif (count($this->dbRows) === 1) {
219 219
                 $tableName = array_keys($this->dbRows)[0];
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
     protected function setRef($foreignKeyName, AbstractTDBMObject $bean, $tableName = null)
240 240
     {
241 241
         if ($tableName === null) {
242
-            if (count($this->dbRows) > 1) {
242
+            if (count($this->dbRows)>1) {
243 243
                 throw new TDBMException('This object is based on several tables. You must specify which table you are retrieving data from.');
244 244
             } elseif (count($this->dbRows) === 1) {
245 245
                 $tableName = array_keys($this->dbRows)[0];
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/ResultIterator.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -245,7 +245,7 @@
 block discarded – undo
245 245
      */
246 246
     public function jsonSerialize($stopRecursion = false)
247 247
     {
248
-        return array_map(function (AbstractTDBMObject $item) use ($stopRecursion) {
248
+        return array_map(function(AbstractTDBMObject $item) use ($stopRecursion) {
249 249
             return $item->jsonSerialize($stopRecursion);
250 250
         }, $this->toArray());
251 251
     }
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/DbRow.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -374,11 +374,11 @@
 block discarded – undo
374 374
                 $refDbRows = $reference->_getDbRows();
375 375
                 $firstRefDbRow = reset($refDbRows);
376 376
                 $pkValues = array_values($firstRefDbRow->_getPrimaryKeys());
377
-                for ($i = 0, $count = count($localColumns); $i < $count; ++$i) {
377
+                for ($i = 0, $count = count($localColumns); $i<$count; ++$i) {
378 378
                     $dbRow[$localColumns[$i]] = $pkValues[$i];
379 379
                 }
380 380
             } else {
381
-                for ($i = 0, $count = count($localColumns); $i < $count; ++$i) {
381
+                for ($i = 0, $count = count($localColumns); $i<$count; ++$i) {
382 382
                     $dbRow[$localColumns[$i]] = null;
383 383
                 }
384 384
             }
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/Utils/TDBMDaoGenerator.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -83,11 +83,11 @@  discard block
 block discarded – undo
83 83
 
84 84
         // Remove all beans and daos from junction tables
85 85
         $junctionTables = $this->schemaAnalyzer->detectJunctionTables(true);
86
-        $junctionTableNames = array_map(function (Table $table) {
86
+        $junctionTableNames = array_map(function(Table $table) {
87 87
             return $table->getName();
88 88
         }, $junctionTables);
89 89
 
90
-        $tableList = array_filter($tableList, function (Table $table) use ($junctionTableNames) {
90
+        $tableList = array_filter($tableList, function(Table $table) use ($junctionTableNames) {
91 91
             return !in_array($table->getName(), $junctionTableNames);
92 92
         });
93 93
 
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
         // Ok, let's return the list of all tables.
101 101
         // These will be used by the calling script to create Mouf instances.
102 102
 
103
-        return array_map(function (Table $table) {
103
+        return array_map(function(Table $table) {
104 104
             return $table->getName();
105 105
         }, $tableList);
106 106
     }
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
         $usedBeans[] = $beanClassName;
295 295
         // Let's suppress duplicates in used beans (if any)
296 296
         $usedBeans = array_flip(array_flip($usedBeans));
297
-        $useStatements = array_map(function ($usedBean) {
297
+        $useStatements = array_map(function($usedBean) {
298 298
             return "use $usedBean;\n";
299 299
         }, $usedBeans);
300 300
 
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
                 $pos = strpos($str, ' ');
645 645
             }
646 646
             $before = substr($str, 0, $pos);
647
-            $after = substr($str, $pos + 1);
647
+            $after = substr($str, $pos+1);
648 648
             $str = $before.strtoupper(substr($after, 0, 1)).substr($after, 1);
649 649
         }
650 650
 
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/Utils/BeanDescriptor.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
      */
93 93
     public function getConstructorProperties()
94 94
     {
95
-        $constructorProperties = array_filter($this->beanPropertyDescriptors, function (AbstractBeanPropertyDescriptor $property) {
95
+        $constructorProperties = array_filter($this->beanPropertyDescriptors, function(AbstractBeanPropertyDescriptor $property) {
96 96
             return $property->isCompulsory();
97 97
         });
98 98
 
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
     public function getPropertiesWithDefault()
108 108
     {
109 109
         $properties = $this->getPropertiesForTable($this->table);
110
-        $defaultProperties = array_filter($properties, function (AbstractBeanPropertyDescriptor $property) {
110
+        $defaultProperties = array_filter($properties, function(AbstractBeanPropertyDescriptor $property) {
111 111
             return $property->hasDefault();
112 112
         });
113 113
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
      */
122 122
     public function getExposedProperties()
123 123
     {
124
-        $exposedProperties = array_filter($this->beanPropertyDescriptors, function (AbstractBeanPropertyDescriptor $property) {
124
+        $exposedProperties = array_filter($this->beanPropertyDescriptors, function(AbstractBeanPropertyDescriptor $property) {
125 125
             return $property->getTable()->getName() == $this->table->getName();
126 126
         });
127 127
 
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
         $fksByMethodName = [];
292 292
 
293 293
         foreach ($fksByTable as $tableName => $fksForTable) {
294
-            if (count($fksForTable) > 1) {
294
+            if (count($fksForTable)>1) {
295 295
                 foreach ($fksForTable as $fk) {
296 296
                     $methodName = 'get'.TDBMDaoGenerator::toCamelCase($fk->getLocalTableName()).'By';
297 297
 
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
 
400 400
         $finalDescs = [];
401 401
         foreach ($descs as $descArray) {
402
-            if (count($descArray) > 1) {
402
+            if (count($descArray)>1) {
403 403
                 foreach ($descArray as $desc) {
404 404
                     $desc['name'] = TDBMDaoGenerator::toCamelCase($desc['remoteFK']->getForeignTableName()).'By'.TDBMDaoGenerator::toCamelCase($desc['table']->getName());
405 405
                     $finalDescs[] = $desc;
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
 
588 588
         $classes = $this->generateExtendsAndUseStatements($parentFk);
589 589
 
590
-        $uses = array_map(function ($className) use ($beannamespace) {
590
+        $uses = array_map(function($className) use ($beannamespace) {
591 591
             return 'use '.$beannamespace.'\\'.$className.";\n";
592 592
         }, $classes);
593 593
         $use = implode('', $uses);
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/TDBMService.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1056,7 +1056,7 @@  discard block
 block discarded – undo
1056 1056
         sort($tables);
1057 1057
 
1058 1058
         return $this->fromCache($this->cachePrefix.'_linkbetweeninheritedtables_'.implode('__split__', $tables),
1059
-            function () use ($tables) {
1059
+            function() use ($tables) {
1060 1060
                 return $this->_getLinkBetweenInheritedTablesWithoutCache($tables);
1061 1061
             });
1062 1062
     }
@@ -1103,7 +1103,7 @@  discard block
 block discarded – undo
1103 1103
      */
1104 1104
     public function _getRelatedTablesByInheritance($table)
1105 1105
     {
1106
-        return $this->fromCache($this->cachePrefix.'_relatedtables_'.$table, function () use ($table) {
1106
+        return $this->fromCache($this->cachePrefix.'_relatedtables_'.$table, function() use ($table) {
1107 1107
             return $this->_getRelatedTablesByInheritanceWithoutCache($table);
1108 1108
         });
1109 1109
     }
@@ -1162,7 +1162,7 @@  discard block
 block discarded – undo
1162 1162
      */
1163 1163
     private function getParentRelationshipForeignKeys($tableName)
1164 1164
     {
1165
-        return $this->fromCache($this->cachePrefix.'_parentrelationshipfks_'.$tableName, function () use ($tableName) {
1165
+        return $this->fromCache($this->cachePrefix.'_parentrelationshipfks_'.$tableName, function() use ($tableName) {
1166 1166
             return $this->getParentRelationshipForeignKeysWithoutCache($tableName);
1167 1167
         });
1168 1168
     }
@@ -1191,7 +1191,7 @@  discard block
 block discarded – undo
1191 1191
      */
1192 1192
     private function getChildrenRelationshipForeignKeys($tableName)
1193 1193
     {
1194
-        return $this->fromCache($this->cachePrefix.'_childrenrelationshipfks_'.$tableName, function () use ($tableName) {
1194
+        return $this->fromCache($this->cachePrefix.'_childrenrelationshipfks_'.$tableName, function() use ($tableName) {
1195 1195
             return $this->getChildrenRelationshipForeignKeysWithoutCache($tableName);
1196 1196
         });
1197 1197
     }
@@ -1206,7 +1206,7 @@  discard block
 block discarded – undo
1206 1206
         $children = $this->schemaAnalyzer->getChildrenRelationships($tableName);
1207 1207
 
1208 1208
         if (!empty($children)) {
1209
-            $fksTables = array_map(function (ForeignKeyConstraint $fk) {
1209
+            $fksTables = array_map(function(ForeignKeyConstraint $fk) {
1210 1210
                 return $this->getChildrenRelationshipForeignKeys($fk->getLocalTableName());
1211 1211
             }, $children);
1212 1212
 
@@ -1321,7 +1321,7 @@  discard block
 block discarded – undo
1321 1321
 
1322 1322
         $schema = $this->tdbmSchemaAnalyzer->getSchema();
1323 1323
         $pkColumnNames = $schema->getTable($mainTable)->getPrimaryKeyColumns();
1324
-        $pkColumnNames = array_map(function ($pkColumn) use ($mainTable) {
1324
+        $pkColumnNames = array_map(function($pkColumn) use ($mainTable) {
1325 1325
             return $this->connection->quoteIdentifier($mainTable).'.'.$this->connection->quoteIdentifier($pkColumn);
1326 1326
         }, $pkColumnNames);
1327 1327
 
@@ -1389,17 +1389,17 @@  discard block
 block discarded – undo
1389 1389
             ];
1390 1390
         }
1391 1391
 
1392
-        $sql = 'SELECT DISTINCT '.implode(', ', array_map(function ($columnDesc) use ($mainTable) {
1392
+        $sql = 'SELECT DISTINCT '.implode(', ', array_map(function($columnDesc) use ($mainTable) {
1393 1393
             return $this->connection->quoteIdentifier($mainTable).'.'.$this->connection->quoteIdentifier($columnDesc['column']);
1394 1394
         }, $columnDescList)).' FROM '.$from;
1395 1395
 
1396
-        if (count($allFetchedTables) > 1) {
1396
+        if (count($allFetchedTables)>1) {
1397 1397
             list($columnDescList, $columnsList) = $this->getColumnsList($mainTable, []);
1398 1398
         }
1399 1399
 
1400 1400
         // Let's compute the COUNT.
1401 1401
         $pkColumnNames = $schema->getTable($mainTable)->getPrimaryKeyColumns();
1402
-        $pkColumnNames = array_map(function ($pkColumn) use ($mainTable) {
1402
+        $pkColumnNames = array_map(function($pkColumn) use ($mainTable) {
1403 1403
             return $this->connection->quoteIdentifier($mainTable).'.'.$this->connection->quoteIdentifier($pkColumn);
1404 1404
         }, $pkColumnNames);
1405 1405
 
@@ -1583,7 +1583,7 @@  discard block
 block discarded – undo
1583 1583
         $objects = $this->findObjects($mainTable, $filter, $parameters, null, $additionalTablesFetch, self::MODE_ARRAY, $className);
1584 1584
         $page = $objects->take(0, 2);
1585 1585
         $count = $page->count();
1586
-        if ($count > 1) {
1586
+        if ($count>1) {
1587 1587
             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.");
1588 1588
         } elseif ($count === 0) {
1589 1589
             return;
@@ -1610,7 +1610,7 @@  discard block
 block discarded – undo
1610 1610
         $objects = $this->findObjectsFromSql($mainTable, $from, $filter, $parameters, null, self::MODE_ARRAY, $className);
1611 1611
         $page = $objects->take(0, 2);
1612 1612
         $count = $page->count();
1613
-        if ($count > 1) {
1613
+        if ($count>1) {
1614 1614
             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.");
1615 1615
         } elseif ($count === 0) {
1616 1616
             return;
@@ -1728,7 +1728,7 @@  discard block
 block discarded – undo
1728 1728
         $remoteTable = $remoteFk->getForeignTableName();
1729 1729
 
1730 1730
         $primaryKeys = $this->getPrimaryKeyValues($bean);
1731
-        $columnNames = array_map(function ($name) use ($pivotTableName) {
1731
+        $columnNames = array_map(function($name) use ($pivotTableName) {
1732 1732
             return $pivotTableName.'.'.$name;
1733 1733
         }, $localFk->getLocalColumns());
1734 1734
 
@@ -1751,7 +1751,7 @@  discard block
 block discarded – undo
1751 1751
         $table1 = $fks[0]->getForeignTableName();
1752 1752
         $table2 = $fks[1]->getForeignTableName();
1753 1753
 
1754
-        $beanTables = array_map(function (DbRow $dbRow) {
1754
+        $beanTables = array_map(function(DbRow $dbRow) {
1755 1755
             return $dbRow->_getDbTableName();
1756 1756
         }, $bean->_getDbRows());
1757 1757
 
@@ -1809,7 +1809,7 @@  discard block
 block discarded – undo
1809 1809
     {
1810 1810
         if (!isset($typesForTable[$tableName])) {
1811 1811
             $columns = $this->tdbmSchemaAnalyzer->getSchema()->getTable($tableName)->getColumns();
1812
-            $typesForTable[$tableName] = array_map(function (Column $column) {
1812
+            $typesForTable[$tableName] = array_map(function(Column $column) {
1813 1813
                 return $column->getType();
1814 1814
             }, $columns);
1815 1815
         }
Please login to merge, or discard this patch.