@@ -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 { |
@@ -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 | } |
@@ -181,6 +181,9 @@ |
||
| 181 | 181 | |
| 182 | 182 | protected $errorMsg; |
| 183 | 183 | |
| 184 | + /** |
|
| 185 | + * @param string $msg |
|
| 186 | + */ |
|
| 184 | 187 | private function displayErrorMsg($msg) |
| 185 | 188 | { |
| 186 | 189 | $this->errorMsg = $msg; |
@@ -245,7 +245,7 @@ |
||
| 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 | } |
@@ -62,6 +62,10 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | private $logger; |
| 64 | 64 | |
| 65 | + /** |
|
| 66 | + * @param null|string $className |
|
| 67 | + * @param integer $mode |
|
| 68 | + */ |
|
| 65 | 69 | public function __construct(QueryFactory $queryFactory, array $parameters, $objectStorage, $className, TDBMService $tdbmService, MagicQuery $magicQuery, $mode, LoggerInterface $logger) |
| 66 | 70 | { |
| 67 | 71 | if ($mode !== null && $mode !== TDBMService::MODE_CURSOR && $mode !== TDBMService::MODE_ARRAY) { |
@@ -300,7 +304,6 @@ discard block |
||
| 300 | 304 | * |
| 301 | 305 | * $resultSet = $resultSet->withParameters('label ASC, status DESC'); |
| 302 | 306 | * |
| 303 | - * @param string|UncheckedOrderBy|null $orderBy |
|
| 304 | 307 | * |
| 305 | 308 | * @return ResultIterator |
| 306 | 309 | */ |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | /** |
| 69 | 69 | * Adds an additional object to the result set (if not already available). |
| 70 | 70 | * |
| 71 | - * @param $object |
|
| 71 | + * @param AbstractTDBMObject $object |
|
| 72 | 72 | */ |
| 73 | 73 | public function add($object) |
| 74 | 74 | { |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | /** |
| 86 | 86 | * Removes an object from the result set. |
| 87 | 87 | * |
| 88 | - * @param $object |
|
| 88 | + * @param AbstractTDBMObject $object |
|
| 89 | 89 | */ |
| 90 | 90 | public function remove($object) |
| 91 | 91 | { |
@@ -205,6 +205,7 @@ discard block |
||
| 205 | 205 | |
| 206 | 206 | /** |
| 207 | 207 | * @param int $offset |
| 208 | + * @param integer $limit |
|
| 208 | 209 | * |
| 209 | 210 | * @return \Porpaginas\Page |
| 210 | 211 | */ |
@@ -227,7 +228,7 @@ discard block |
||
| 227 | 228 | /** |
| 228 | 229 | * Return an iterator over all results of the paginatable. |
| 229 | 230 | * |
| 230 | - * @return Iterator |
|
| 231 | + * @return \Iterator |
|
| 231 | 232 | */ |
| 232 | 233 | public function getIterator() |
| 233 | 234 | { |
@@ -124,7 +124,7 @@ |
||
| 124 | 124 | public function getIncomingForeignKeys($tableName) |
| 125 | 125 | { |
| 126 | 126 | $junctionTables = $this->schemaAnalyzer->detectJunctionTables(true); |
| 127 | - $junctionTableNames = array_map(function (Table $table) { |
|
| 127 | + $junctionTableNames = array_map(function(Table $table) { |
|
| 128 | 128 | return $table->getName(); |
| 129 | 129 | }, $junctionTables); |
| 130 | 130 | $childrenRelationships = $this->schemaAnalyzer->getChildrenRelationships($tableName); |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | $results = []; |
| 80 | 80 | |
| 81 | - for ($i = 0, $count = count($parsed['ORDER']); $i < $count; ++$i) { |
|
| 81 | + for ($i = 0, $count = count($parsed['ORDER']); $i<$count; ++$i) { |
|
| 82 | 82 | $orderItem = $parsed['ORDER'][$i]; |
| 83 | 83 | if ($orderItem['expr_type'] === 'colref') { |
| 84 | 84 | $parts = $orderItem['no_quotes']['parts']; |
@@ -97,9 +97,9 @@ discard block |
||
| 97 | 97 | ]; |
| 98 | 98 | } else { |
| 99 | 99 | $position = $orderItem['position']; |
| 100 | - if ($i + 1 < $count) { |
|
| 101 | - $nextPosition = $parsed['ORDER'][$i + 1]['position']; |
|
| 102 | - $str = substr($sql, $position, $nextPosition - $position); |
|
| 100 | + if ($i+1<$count) { |
|
| 101 | + $nextPosition = $parsed['ORDER'][$i+1]['position']; |
|
| 102 | + $str = substr($sql, $position, $nextPosition-$position); |
|
| 103 | 103 | } else { |
| 104 | 104 | $str = substr($sql, $position); |
| 105 | 105 | } |
@@ -1301,7 +1301,7 @@ discard block |
||
| 1301 | 1301 | * @param string $mainTable The name of the table queried |
| 1302 | 1302 | * @param string|array|null $filter The SQL filters to apply to the query (the WHERE part). Columns from tables different from $mainTable must be prefixed by the table name (in the form: table.column) |
| 1303 | 1303 | * @param array $parameters |
| 1304 | - * @param string|UncheckedOrderBy|null $orderString The ORDER BY part of the query. Columns from tables different from $mainTable must be prefixed by the table name (in the form: table.column) |
|
| 1304 | + * @param string|null $orderString The ORDER BY part of the query. Columns from tables different from $mainTable must be prefixed by the table name (in the form: table.column) |
|
| 1305 | 1305 | * @param array $additionalTablesFetch |
| 1306 | 1306 | * @param int $mode |
| 1307 | 1307 | * @param string $className Optional: The name of the class to instantiate. This class must extend the TDBMObject class. If none is specified, a TDBMObject instance will be returned |
@@ -1769,7 +1769,7 @@ discard block |
||
| 1769 | 1769 | * @param $pivotTableName |
| 1770 | 1770 | * @param AbstractTDBMObject $bean |
| 1771 | 1771 | * |
| 1772 | - * @return AbstractTDBMObject[] |
|
| 1772 | + * @return ResultIterator |
|
| 1773 | 1773 | */ |
| 1774 | 1774 | public function _getRelatedBeans(string $pivotTableName, AbstractTDBMObject $bean) |
| 1775 | 1775 | { |
@@ -1064,7 +1064,7 @@ discard block |
||
| 1064 | 1064 | sort($tables); |
| 1065 | 1065 | |
| 1066 | 1066 | return $this->fromCache($this->cachePrefix.'_linkbetweeninheritedtables_'.implode('__split__', $tables), |
| 1067 | - function () use ($tables) { |
|
| 1067 | + function() use ($tables) { |
|
| 1068 | 1068 | return $this->_getLinkBetweenInheritedTablesWithoutCache($tables); |
| 1069 | 1069 | }); |
| 1070 | 1070 | } |
@@ -1111,7 +1111,7 @@ discard block |
||
| 1111 | 1111 | */ |
| 1112 | 1112 | public function _getRelatedTablesByInheritance($table) |
| 1113 | 1113 | { |
| 1114 | - return $this->fromCache($this->cachePrefix.'_relatedtables_'.$table, function () use ($table) { |
|
| 1114 | + return $this->fromCache($this->cachePrefix.'_relatedtables_'.$table, function() use ($table) { |
|
| 1115 | 1115 | return $this->_getRelatedTablesByInheritanceWithoutCache($table); |
| 1116 | 1116 | }); |
| 1117 | 1117 | } |
@@ -1358,7 +1358,7 @@ discard block |
||
| 1358 | 1358 | $objects = $this->findObjects($mainTable, $filter, $parameters, null, $additionalTablesFetch, self::MODE_ARRAY, $className); |
| 1359 | 1359 | $page = $objects->take(0, 2); |
| 1360 | 1360 | $count = $page->count(); |
| 1361 | - if ($count > 1) { |
|
| 1361 | + if ($count>1) { |
|
| 1362 | 1362 | 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."); |
| 1363 | 1363 | } elseif ($count === 0) { |
| 1364 | 1364 | return; |
@@ -1385,7 +1385,7 @@ discard block |
||
| 1385 | 1385 | $objects = $this->findObjectsFromSql($mainTable, $from, $filter, $parameters, null, self::MODE_ARRAY, $className); |
| 1386 | 1386 | $page = $objects->take(0, 2); |
| 1387 | 1387 | $count = $page->count(); |
| 1388 | - if ($count > 1) { |
|
| 1388 | + if ($count>1) { |
|
| 1389 | 1389 | 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."); |
| 1390 | 1390 | } elseif ($count === 0) { |
| 1391 | 1391 | return; |
@@ -1503,7 +1503,7 @@ discard block |
||
| 1503 | 1503 | $remoteTable = $remoteFk->getForeignTableName(); |
| 1504 | 1504 | |
| 1505 | 1505 | $primaryKeys = $this->getPrimaryKeyValues($bean); |
| 1506 | - $columnNames = array_map(function ($name) use ($pivotTableName) { |
|
| 1506 | + $columnNames = array_map(function($name) use ($pivotTableName) { |
|
| 1507 | 1507 | return $pivotTableName.'.'.$name; |
| 1508 | 1508 | }, $localFk->getLocalColumns()); |
| 1509 | 1509 | |
@@ -1526,7 +1526,7 @@ discard block |
||
| 1526 | 1526 | $table1 = $fks[0]->getForeignTableName(); |
| 1527 | 1527 | $table2 = $fks[1]->getForeignTableName(); |
| 1528 | 1528 | |
| 1529 | - $beanTables = array_map(function (DbRow $dbRow) { |
|
| 1529 | + $beanTables = array_map(function(DbRow $dbRow) { |
|
| 1530 | 1530 | return $dbRow->_getDbTableName(); |
| 1531 | 1531 | }, $bean->_getDbRows()); |
| 1532 | 1532 | |
@@ -1584,7 +1584,7 @@ discard block |
||
| 1584 | 1584 | { |
| 1585 | 1585 | if (!isset($typesForTable[$tableName])) { |
| 1586 | 1586 | $columns = $this->tdbmSchemaAnalyzer->getSchema()->getTable($tableName)->getColumns(); |
| 1587 | - $typesForTable[$tableName] = array_map(function (Column $column) { |
|
| 1587 | + $typesForTable[$tableName] = array_map(function(Column $column) { |
|
| 1588 | 1588 | return $column->getType(); |
| 1589 | 1589 | }, $columns); |
| 1590 | 1590 | } |
@@ -39,7 +39,7 @@ |
||
| 39 | 39 | $sql = 'SELECT DISTINCT '.implode(', ', $columnsList).' FROM MAGICJOIN('.$this->mainTable.')'; |
| 40 | 40 | |
| 41 | 41 | $pkColumnNames = $this->schema->getTable($this->mainTable)->getPrimaryKeyColumns(); |
| 42 | - $pkColumnNames = array_map(function ($pkColumn) { |
|
| 42 | + $pkColumnNames = array_map(function($pkColumn) { |
|
| 43 | 43 | return $this->tdbmService->getConnection()->quoteIdentifier($this->mainTable).'.'.$this->tdbmService->getConnection()->quoteIdentifier($pkColumn); |
| 44 | 44 | }, $pkColumnNames); |
| 45 | 45 | |