@@ -23,9 +23,7 @@ |
||
23 | 23 | use Doctrine\Common\Cache\Cache; |
24 | 24 | use Doctrine\Common\Cache\VoidCache; |
25 | 25 | use Doctrine\DBAL\Connection; |
26 | -use Doctrine\DBAL\Schema\Column; |
|
27 | 26 | use Doctrine\DBAL\Schema\ForeignKeyConstraint; |
28 | -use Doctrine\DBAL\Schema\Schema; |
|
29 | 27 | use Doctrine\DBAL\Schema\Table; |
30 | 28 | use Mouf\Database\MagicQuery; |
31 | 29 | use Mouf\Database\SchemaAnalyzer\SchemaAnalyzer; |
@@ -1201,7 +1201,7 @@ discard block |
||
1201 | 1201 | sort($tables); |
1202 | 1202 | |
1203 | 1203 | return $this->fromCache($this->cachePrefix.'_linkbetweeninheritedtables_'.implode('__split__', $tables), |
1204 | - function () use ($tables) { |
|
1204 | + function() use ($tables) { |
|
1205 | 1205 | return $this->_getLinkBetweenInheritedTablesWithoutCache($tables); |
1206 | 1206 | }); |
1207 | 1207 | } |
@@ -1249,7 +1249,7 @@ discard block |
||
1249 | 1249 | */ |
1250 | 1250 | public function _getRelatedTablesByInheritance($table) |
1251 | 1251 | { |
1252 | - return $this->fromCache($this->cachePrefix.'_relatedtables_'.$table, function () use ($table) { |
|
1252 | + return $this->fromCache($this->cachePrefix.'_relatedtables_'.$table, function() use ($table) { |
|
1253 | 1253 | return $this->_getRelatedTablesByInheritanceWithoutCache($table); |
1254 | 1254 | }); |
1255 | 1255 | } |
@@ -1509,7 +1509,7 @@ discard block |
||
1509 | 1509 | $objects = $this->findObjects($mainTable, $filterString, $parameters, null, $additionalTablesFetch, self::MODE_ARRAY, $className); |
1510 | 1510 | $page = $objects->take(0, 2); |
1511 | 1511 | $count = $page->count(); |
1512 | - if ($count > 1) { |
|
1512 | + if ($count>1) { |
|
1513 | 1513 | 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."); |
1514 | 1514 | } elseif ($count === 0) { |
1515 | 1515 | return; |
@@ -1626,7 +1626,7 @@ discard block |
||
1626 | 1626 | $remoteTable = $remoteFk->getForeignTableName(); |
1627 | 1627 | |
1628 | 1628 | $primaryKeys = $this->getPrimaryKeyValues($bean); |
1629 | - $columnNames = array_map(function ($name) use ($pivotTableName) { return $pivotTableName.'.'.$name; }, $localFk->getLocalColumns()); |
|
1629 | + $columnNames = array_map(function($name) use ($pivotTableName) { return $pivotTableName.'.'.$name; }, $localFk->getLocalColumns()); |
|
1630 | 1630 | |
1631 | 1631 | $filter = array_combine($columnNames, $primaryKeys); |
1632 | 1632 | |
@@ -1647,7 +1647,7 @@ discard block |
||
1647 | 1647 | $table1 = $fks[0]->getForeignTableName(); |
1648 | 1648 | $table2 = $fks[1]->getForeignTableName(); |
1649 | 1649 | |
1650 | - $beanTables = array_map(function (DbRow $dbRow) { return $dbRow->_getDbTableName(); }, $bean->_getDbRows()); |
|
1650 | + $beanTables = array_map(function(DbRow $dbRow) { return $dbRow->_getDbTableName(); }, $bean->_getDbRows()); |
|
1651 | 1651 | |
1652 | 1652 | if (in_array($table1, $beanTables)) { |
1653 | 1653 | return [$fks[0], $fks[1]]; |
@@ -4,7 +4,6 @@ |
||
4 | 4 | |
5 | 5 | use Doctrine\Common\Inflector\Inflector; |
6 | 6 | use Doctrine\DBAL\Driver\Connection; |
7 | -use Doctrine\DBAL\Schema\Column; |
|
8 | 7 | use Doctrine\DBAL\Schema\Schema; |
9 | 8 | use Doctrine\DBAL\Schema\Table; |
10 | 9 | use Doctrine\DBAL\Types\Type; |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | |
78 | 78 | // Remove all beans and daos from junction tables |
79 | 79 | $junctionTables = $this->schemaAnalyzer->detectJunctionTables(); |
80 | - $junctionTableNames = array_map(function (Table $table) { |
|
80 | + $junctionTableNames = array_map(function(Table $table) { |
|
81 | 81 | return $table->getName(); |
82 | 82 | }, $junctionTables); |
83 | 83 | |
84 | - $tableList = array_filter($tableList, function (Table $table) use ($junctionTableNames) { |
|
84 | + $tableList = array_filter($tableList, function(Table $table) use ($junctionTableNames) { |
|
85 | 85 | return !in_array($table->getName(), $junctionTableNames); |
86 | 86 | }); |
87 | 87 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | // Ok, let's return the list of all tables. |
95 | 95 | // These will be used by the calling script to create Mouf instances. |
96 | 96 | |
97 | - return array_map(function (Table $table) { return $table->getName(); }, $tableList); |
|
97 | + return array_map(function(Table $table) { return $table->getName(); }, $tableList); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | $usedBeans[] = $beanClassName; |
288 | 288 | // Let's suppress duplicates in used beans (if any) |
289 | 289 | $usedBeans = array_flip(array_flip($usedBeans)); |
290 | - $useStatements = array_map(function ($usedBean) { |
|
290 | + $useStatements = array_map(function($usedBean) { |
|
291 | 291 | return "use $usedBean;\n"; |
292 | 292 | }, $usedBeans); |
293 | 293 | |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | $pos = strpos($str, ' '); |
588 | 588 | } |
589 | 589 | $before = substr($str, 0, $pos); |
590 | - $after = substr($str, $pos + 1); |
|
590 | + $after = substr($str, $pos+1); |
|
591 | 591 | $str = $before.strtoupper(substr($after, 0, 1)).substr($after, 1); |
592 | 592 | } |
593 | 593 |
@@ -241,7 +241,7 @@ |
||
241 | 241 | */ |
242 | 242 | public function jsonSerialize() |
243 | 243 | { |
244 | - return array_map(function (AbstractTDBMObject $item) { |
|
244 | + return array_map(function(AbstractTDBMObject $item) { |
|
245 | 245 | return $item->jsonSerialize(); |
246 | 246 | }, $this->toArray()); |
247 | 247 | } |
@@ -126,14 +126,14 @@ |
||
126 | 126 | if (strpos($daonamespace, '\\') === 0) { |
127 | 127 | $daonamespace = substr($daonamespace, 1); |
128 | 128 | } |
129 | - if (strpos($daonamespace, '\\') === strlen($daonamespace) - 1) { |
|
130 | - $daonamespace = substr($daonamespace, 0, strlen($daonamespace) - 1); |
|
129 | + if (strpos($daonamespace, '\\') === strlen($daonamespace)-1) { |
|
130 | + $daonamespace = substr($daonamespace, 0, strlen($daonamespace)-1); |
|
131 | 131 | } |
132 | 132 | if (strpos($beannamespace, '\\') === 0) { |
133 | 133 | $beannamespace = substr($beannamespace, 1); |
134 | 134 | } |
135 | - if (strpos($beannamespace, '\\') === strlen($beannamespace) - 1) { |
|
136 | - $beannamespace = substr($beannamespace, 0, strlen($beannamespace) - 1); |
|
135 | + if (strpos($beannamespace, '\\') === strlen($beannamespace)-1) { |
|
136 | + $beannamespace = substr($beannamespace, 0, strlen($beannamespace)-1); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | $tdbmService = new InstanceProxy($name); |
@@ -124,7 +124,7 @@ |
||
124 | 124 | public function getIncomingForeignKeys($tableName) |
125 | 125 | { |
126 | 126 | $junctionTables = $this->schemaAnalyzer->detectJunctionTables(); |
127 | - $junctionTableNames = array_map(function (Table $table) { return $table->getName(); }, $junctionTables); |
|
127 | + $junctionTableNames = array_map(function(Table $table) { return $table->getName(); }, $junctionTables); |
|
128 | 128 | $childrenRelationships = $this->schemaAnalyzer->getChildrenRelationships($tableName); |
129 | 129 | |
130 | 130 | $fks = []; |
@@ -65,7 +65,7 @@ discard block |
||
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 |
||
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) { |
@@ -83,7 +83,7 @@ discard block |
||
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 |
||
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 { |
@@ -353,7 +353,7 @@ |
||
353 | 353 | $pkValues = array_values($firstRefDbRow->_getPrimaryKeys()); |
354 | 354 | $localColumns = $fk->getLocalColumns(); |
355 | 355 | |
356 | - for ($i = 0, $count = count($localColumns); $i < $count; ++$i) { |
|
356 | + for ($i = 0, $count = count($localColumns); $i<$count; ++$i) { |
|
357 | 357 | $dbRow[$localColumns[$i]] = $pkValues[$i]; |
358 | 358 | } |
359 | 359 | } |
@@ -112,7 +112,7 @@ discard block |
||
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 |
||
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 | } |