Test Failed
Push — master ( 980d37...083cc5 )
by Melquecedec
03:33
created
RedBean.php 1 patch
Spacing   +2242 added lines, -2242 removed lines patch added patch discarded remove patch
@@ -82,25 +82,25 @@  discard block
 block discarded – undo
82 82
 	 */
83 83
 	public function log()
84 84
 	{
85
-		if ( func_num_args() < 1 ) return;
85
+		if (func_num_args() < 1) return;
86 86
 
87
-		foreach ( func_get_args() as $argument ) {
88
-			if ( is_array( $argument ) ) {
89
-				$log = var_export( $argument, TRUE );
90
-				if ( $this->mode === self::C_LOGGER_ECHO ) {
87
+		foreach (func_get_args() as $argument) {
88
+			if (is_array($argument)) {
89
+				$log = var_export($argument, TRUE);
90
+				if ($this->mode === self::C_LOGGER_ECHO) {
91 91
 					echo $log;
92 92
 				} else {
93 93
 					$this->logs[] = $log;
94 94
 				}
95 95
 			} else {
96
-				if ( $this->mode === self::C_LOGGER_ECHO ) {
96
+				if ($this->mode === self::C_LOGGER_ECHO) {
97 97
 					echo $argument;
98 98
 				} else {
99 99
 					$this->logs[] = $argument;
100 100
 				}
101 101
 			}
102 102
 
103
-			if ( $this->mode === self::C_LOGGER_ECHO ) echo "<br>" . PHP_EOL;
103
+			if ($this->mode === self::C_LOGGER_ECHO) echo "<br>".PHP_EOL;
104 104
 		}
105 105
 	}
106 106
 
@@ -138,10 +138,10 @@  discard block
 block discarded – undo
138 138
 	 *
139 139
 	 * @return self
140 140
 	 */
141
-	public function setMode( $mode )
141
+	public function setMode($mode)
142 142
 	{
143
-		if ($mode !== self::C_LOGGER_ARRAY && $mode !== self::C_LOGGER_ECHO ) {
144
-			throw new RedException( 'Invalid mode selected for logger, use C_LOGGER_ARRAY or C_LOGGER_ECHO.' );
143
+		if ($mode !== self::C_LOGGER_ARRAY && $mode !== self::C_LOGGER_ECHO) {
144
+			throw new RedException('Invalid mode selected for logger, use C_LOGGER_ARRAY or C_LOGGER_ECHO.');
145 145
 		}
146 146
 		$this->mode = $mode;
147 147
 		return $this;
@@ -157,11 +157,11 @@  discard block
 block discarded – undo
157 157
 	 *
158 158
 	 * @return array
159 159
 	 */
160
-	public function grep( $needle )
160
+	public function grep($needle)
161 161
 	{
162 162
 		$found = array();
163
-		foreach( $this->logs as $logEntry ) {
164
-			if ( strpos( $logEntry, $needle ) !== FALSE ) $found[] = $logEntry;
163
+		foreach ($this->logs as $logEntry) {
164
+			if (strpos($logEntry, $needle) !== FALSE) $found[] = $logEntry;
165 165
 		}
166 166
 		return $found;
167 167
 	}
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 	 *
213 213
 	 * @return void
214 214
 	 */
215
-	public static function setOverrideCLIOutput( $yesNo )
215
+	public static function setOverrideCLIOutput($yesNo)
216 216
 	{
217 217
 		self::$noCLI = $yesNo;
218 218
 	}
@@ -226,17 +226,17 @@  discard block
 block discarded – undo
226 226
 	 *
227 227
 	 * @return string
228 228
 	 */
229
-	protected function writeQuery( $newSql, $newBindings )
229
+	protected function writeQuery($newSql, $newBindings)
230 230
 	{
231 231
 		//avoid str_replace collisions: slot1 and slot10 (issue 407).
232
-		uksort( $newBindings, function( $a, $b ) {
233
-			return ( strlen( $b ) - strlen( $a ) );
232
+		uksort($newBindings, function($a, $b) {
233
+			return (strlen($b) - strlen($a));
234 234
 		} );
235 235
 
236 236
 		$newStr = $newSql;
237
-		foreach( $newBindings as $slot => $value ) {
238
-			if ( strpos( $slot, ':' ) === 0 ) {
239
-				$newStr = str_replace( $slot, $this->fillInValue( $value ), $newStr );
237
+		foreach ($newBindings as $slot => $value) {
238
+			if (strpos($slot, ':') === 0) {
239
+				$newStr = str_replace($slot, $this->fillInValue($value), $newStr);
240 240
 			}
241 241
 		}
242 242
 		return $newStr;
@@ -250,16 +250,16 @@  discard block
 block discarded – undo
250 250
 	 *
251 251
 	 * @return string
252 252
 	 */
253
-	protected function fillInValue( $value )
253
+	protected function fillInValue($value)
254 254
 	{
255
-		if ( is_null( $value ) ) $value = 'NULL';
255
+		if (is_null($value)) $value = 'NULL';
256 256
 
257
-		$value = strval( $value );
258
-		if ( strlen( $value ) > ( $this->strLen ) ) {
259
-			$value = substr( $value, 0, ( $this->strLen ) ).'... ';
257
+		$value = strval($value);
258
+		if (strlen($value) > ($this->strLen)) {
259
+			$value = substr($value, 0, ($this->strLen)).'... ';
260 260
 		}
261 261
 
262
-		if ( !\RedBeanPHP\QueryWriter\AQueryWriter::canBeTreatedAsInt( $value ) && $value !== 'NULL') {
262
+		if (!\RedBeanPHP\QueryWriter\AQueryWriter::canBeTreatedAsInt($value) && $value !== 'NULL') {
263 263
 			$value = '\''.$value.'\'';
264 264
 		}
265 265
 
@@ -278,15 +278,15 @@  discard block
 block discarded – undo
278 278
 	 *
279 279
 	 * @return void
280 280
 	 */
281
-	protected function output( $str )
281
+	protected function output($str)
282 282
 	{
283 283
 		$this->logs[] = $str;
284
-		if ( !$this->mode ) {
284
+		if (!$this->mode) {
285 285
 			$highlight = FALSE;
286 286
 			/* just a quick heuritsic to highlight schema changes */
287
-			if ( strpos( $str, 'CREATE' ) === 0
288
-			|| strpos( $str, 'ALTER' ) === 0
289
-			|| strpos( $str, 'DROP' ) === 0) {
287
+			if (strpos($str, 'CREATE') === 0
288
+			|| strpos($str, 'ALTER') === 0
289
+			|| strpos($str, 'DROP') === 0) {
290 290
 				$highlight = TRUE;
291 291
 			}
292 292
 			if (PHP_SAPI === 'cli' && !self::$noCLI) {
@@ -312,21 +312,21 @@  discard block
 block discarded – undo
312 312
 	 *
313 313
 	 * @return string
314 314
 	 */
315
-	protected function normalizeSlots( $sql )
315
+	protected function normalizeSlots($sql)
316 316
 	{
317 317
 		$newSql = $sql;
318 318
 		$i = 0;
319
-		while(strpos($newSql, '?') !== FALSE ){
320
-			$pos   = strpos( $newSql, '?' );
319
+		while (strpos($newSql, '?') !== FALSE) {
320
+			$pos   = strpos($newSql, '?');
321 321
 			$slot  = ':slot'.$i;
322
-			$begin = substr( $newSql, 0, $pos );
323
-			$end   = substr( $newSql, $pos+1 );
322
+			$begin = substr($newSql, 0, $pos);
323
+			$end   = substr($newSql, $pos + 1);
324 324
 			if (PHP_SAPI === 'cli' && !self::$noCLI) {
325 325
 				$newSql = "{$begin}\e[32m{$slot}\e[39m{$end}";
326 326
 			} else {
327 327
 				$newSql = "{$begin}<b style=\"color:green\">$slot</b>{$end}";
328 328
 			}
329
-			$i ++;
329
+			$i++;
330 330
 		}
331 331
 		return $newSql;
332 332
 	}
@@ -339,12 +339,12 @@  discard block
 block discarded – undo
339 339
 	 *
340 340
 	 * @return array
341 341
 	 */
342
-	protected function normalizeBindings( $bindings )
342
+	protected function normalizeBindings($bindings)
343 343
 	{
344 344
 		$i = 0;
345 345
 		$newBindings = array();
346
-		foreach( $bindings as $key => $value ) {
347
-			if ( is_numeric($key) ) {
346
+		foreach ($bindings as $key => $value) {
347
+			if (is_numeric($key)) {
348 348
 				$newKey = ':slot'.$i;
349 349
 				$newBindings[$newKey] = $value;
350 350
 				$i++;
@@ -365,24 +365,24 @@  discard block
 block discarded – undo
365 365
 	 */
366 366
 	public function log()
367 367
 	{
368
-		if ( func_num_args() < 1 ) return;
368
+		if (func_num_args() < 1) return;
369 369
 
370
-		$sql = func_get_arg( 0 );
370
+		$sql = func_get_arg(0);
371 371
 
372
-		if ( func_num_args() < 2) {
372
+		if (func_num_args() < 2) {
373 373
 			$bindings = array();
374 374
 		} else {
375
-			$bindings = func_get_arg( 1 );
375
+			$bindings = func_get_arg(1);
376 376
 		}
377 377
 
378
-		if ( !is_array( $bindings ) ) {
379
-			return $this->output( $sql );
378
+		if (!is_array($bindings)) {
379
+			return $this->output($sql);
380 380
 		}
381 381
 
382
-		$newSql = $this->normalizeSlots( $sql );
383
-		$newBindings = $this->normalizeBindings( $bindings );
384
-		$newStr = $this->writeQuery( $newSql, $newBindings );
385
-		$this->output( $newStr );
382
+		$newSql = $this->normalizeSlots($sql);
383
+		$newBindings = $this->normalizeBindings($bindings);
384
+		$newStr = $this->writeQuery($newSql, $newBindings);
385
+		$this->output($newStr);
386 386
 	}
387 387
 
388 388
 	/**
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
 	 *
395 395
 	 * @return self
396 396
 	 */
397
-	public function setParamStringLength( $len = 20 )
397
+	public function setParamStringLength($len = 20)
398 398
 	{
399 399
 		$this->strLen = max(0, $len);
400 400
 		return $this;
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 	 *
429 429
 	 * @return array
430 430
 	 */
431
-	public function GetAll( $sql, $bindings = array() );
431
+	public function GetAll($sql, $bindings = array());
432 432
 
433 433
 	/**
434 434
 	 * Runs a query and fetches results as a column.
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
 	 *
439 439
 	 * @return array
440 440
 	 */
441
-	public function GetCol( $sql, $bindings = array() );
441
+	public function GetCol($sql, $bindings = array());
442 442
 
443 443
 	/**
444 444
 	 * Runs a query and returns results as a single cell.
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
 	 *
449 449
 	 * @return mixed
450 450
 	 */
451
-	public function GetOne( $sql, $bindings = array() );
451
+	public function GetOne($sql, $bindings = array());
452 452
 
453 453
 	/**
454 454
 	 * Runs a query and returns results as an associative array
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
 	 *
460 460
 	 * @return mixed
461 461
 	 */
462
-	public function GetAssocRow( $sql, $bindings = array() );
462
+	public function GetAssocRow($sql, $bindings = array());
463 463
 
464 464
 	/**
465 465
 	 * Runs a query and returns a flat array containing the values of
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
 	 *
471 471
 	 * @return array
472 472
 	 */
473
-	public function GetRow( $sql, $bindings = array() );
473
+	public function GetRow($sql, $bindings = array());
474 474
 
475 475
 	/**
476 476
 	 * Executes SQL code and allows key-value binding.
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
 	 *
488 488
 	 * @return array Affected Rows
489 489
 	 */
490
-	public function Execute( $sql, $bindings = array() );
490
+	public function Execute($sql, $bindings = array());
491 491
 
492 492
 	/**
493 493
 	 * Returns the latest insert ID if driver does support this
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
 	 *
514 514
 	 * @return mixed
515 515
 	 */
516
-	public function GetCursor( $sql, $bindings = array() );
516
+	public function GetCursor($sql, $bindings = array());
517 517
 
518 518
 	/**
519 519
 	 * Toggles debug mode. In debug mode the driver will print all
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
 	 *
542 542
 	 * @return void
543 543
 	 */
544
-	public function setDebugMode( $tf, $customLogger );
544
+	public function setDebugMode($tf, $customLogger);
545 545
 
546 546
 	/**
547 547
 	 * Starts a transaction.
@@ -693,32 +693,32 @@  discard block
 block discarded – undo
693 693
 	 *
694 694
 	 * @return void
695 695
 	 */
696
-	protected function bindParams( $statement, $bindings )
696
+	protected function bindParams($statement, $bindings)
697 697
 	{
698
-		foreach ( $bindings as $key => &$value ) {
699
-			$k = is_integer( $key ) ? $key + 1 : $key;
698
+		foreach ($bindings as $key => &$value) {
699
+			$k = is_integer($key) ? $key + 1 : $key;
700 700
 
701
-			if ( is_array( $value ) && count( $value ) == 2 ) {
702
-				$paramType = end( $value );
703
-				$value = reset( $value );
701
+			if (is_array($value) && count($value) == 2) {
702
+				$paramType = end($value);
703
+				$value = reset($value);
704 704
 			} else {
705 705
 				$paramType = NULL;
706 706
 			}
707 707
 
708
-			if ( is_null( $value ) ) {
709
-				$statement->bindValue( $k, NULL, \PDO::PARAM_NULL );
708
+			if (is_null($value)) {
709
+				$statement->bindValue($k, NULL, \PDO::PARAM_NULL);
710 710
 				continue;
711 711
 			}
712 712
 
713
-			if ( $paramType != \PDO::PARAM_INT && $paramType != \PDO::PARAM_STR ) {
714
-				if ( !$this->flagUseStringOnlyBinding && AQueryWriter::canBeTreatedAsInt( $value ) && abs( $value ) <= $this->max ) {
713
+			if ($paramType != \PDO::PARAM_INT && $paramType != \PDO::PARAM_STR) {
714
+				if (!$this->flagUseStringOnlyBinding && AQueryWriter::canBeTreatedAsInt($value) && abs($value) <= $this->max) {
715 715
 					$paramType = \PDO::PARAM_INT;
716 716
 				} else {
717 717
 					$paramType = \PDO::PARAM_STR;
718 718
 				}
719 719
 			}
720 720
 
721
-			$statement->bindParam( $k, $value, $paramType );
721
+			$statement->bindParam($k, $value, $paramType);
722 722
 		}
723 723
 	}
724 724
 
@@ -736,44 +736,44 @@  discard block
 block discarded – undo
736 736
 	 * @return mixed
737 737
 	 * @throws SQL
738 738
 	 */
739
-	protected function runQuery( $sql, $bindings, $options = array() )
739
+	protected function runQuery($sql, $bindings, $options = array())
740 740
 	{
741 741
 		$this->connect();
742
-		if ( $this->loggingEnabled && $this->logger ) {
743
-			$this->logger->log( $sql, $bindings );
742
+		if ($this->loggingEnabled && $this->logger) {
743
+			$this->logger->log($sql, $bindings);
744 744
 		}
745 745
 		try {
746
-			if ( strpos( 'pgsql', $this->dsn ) === 0 ) {
746
+			if (strpos('pgsql', $this->dsn) === 0) {
747 747
 				//one line because unable to test this otherwise (coverage trick).
748
-				if ( defined( '\PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT' ) ) { $statement = $this->pdo->prepare( $sql, array( \PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT => TRUE ) ); } else { $statement = $this->pdo->prepare( $sql ); }
748
+				if (defined('\PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT')) { $statement = $this->pdo->prepare($sql, array(\PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT => TRUE)); } else { $statement = $this->pdo->prepare($sql); }
749 749
 			} else {
750
-				$statement = $this->pdo->prepare( $sql );
750
+				$statement = $this->pdo->prepare($sql);
751 751
 			}
752
-			$this->bindParams( $statement, $bindings );
752
+			$this->bindParams($statement, $bindings);
753 753
 			$statement->execute();
754
-			$this->queryCounter ++;
754
+			$this->queryCounter++;
755 755
 			$this->affectedRows = $statement->rowCount();
756
-			if ( $statement->columnCount() ) {
757
-				$fetchStyle = ( isset( $options['fetchStyle'] ) ) ? $options['fetchStyle'] : NULL;
758
-				if ( isset( $options['noFetch'] ) && $options['noFetch'] ) {
756
+			if ($statement->columnCount()) {
757
+				$fetchStyle = (isset($options['fetchStyle'])) ? $options['fetchStyle'] : NULL;
758
+				if (isset($options['noFetch']) && $options['noFetch']) {
759 759
 					$this->resultArray = array();
760 760
 					return $statement;
761 761
 				}
762
-				$this->resultArray = $statement->fetchAll( $fetchStyle );
763
-				if ( $this->loggingEnabled && $this->logger ) {
764
-					$this->logger->log( 'resultset: ' . count( $this->resultArray ) . ' rows' );
762
+				$this->resultArray = $statement->fetchAll($fetchStyle);
763
+				if ($this->loggingEnabled && $this->logger) {
764
+					$this->logger->log('resultset: '.count($this->resultArray).' rows');
765 765
 				}
766 766
 			} else {
767 767
 				$this->resultArray = array();
768 768
 			}
769
-		} catch ( \PDOException $e ) {
769
+		} catch (\PDOException $e) {
770 770
 			//Unfortunately the code field is supposed to be int by default (php)
771 771
 			//So we need a property to convey the SQL State code.
772 772
 			$err = $e->getMessage();
773
-			if ( $this->loggingEnabled && $this->logger ) $this->logger->log( 'An error occurred: ' . $err );
774
-			$exception = new SQL( $err, 0, $e );
775
-			$exception->setSQLState( $e->getCode() );
776
-			$exception->setDriverDetails( $e->errorInfo );
773
+			if ($this->loggingEnabled && $this->logger) $this->logger->log('An error occurred: '.$err);
774
+			$exception = new SQL($err, 0, $e);
775
+			$exception->setSQLState($e->getCode());
776
+			$exception->setDriverDetails($e->errorInfo);
777 777
 			throw $exception;
778 778
 		}
779 779
 	}
@@ -788,15 +788,15 @@  discard block
 block discarded – undo
788 788
 	 */
789 789
 	protected function setEncoding()
790 790
 	{
791
-		$driver = $this->pdo->getAttribute( \PDO::ATTR_DRIVER_NAME );
791
+		$driver = $this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME);
792 792
 		if ($driver === 'mysql') {
793
-			$charset = $this->hasCap( 'utf8mb4' ) ? 'utf8mb4' : 'utf8';
794
-			$collate = $this->hasCap( 'utf8mb4_520' ) ? '_unicode_520_ci' : '_unicode_ci';
795
-			$this->pdo->setAttribute(\PDO::MYSQL_ATTR_INIT_COMMAND, 'SET NAMES '. $charset ); //on every re-connect
793
+			$charset = $this->hasCap('utf8mb4') ? 'utf8mb4' : 'utf8';
794
+			$collate = $this->hasCap('utf8mb4_520') ? '_unicode_520_ci' : '_unicode_ci';
795
+			$this->pdo->setAttribute(\PDO::MYSQL_ATTR_INIT_COMMAND, 'SET NAMES '.$charset); //on every re-connect
796 796
 			/* #624 removed space before SET NAMES because it causes trouble with ProxySQL */
797
-			$this->pdo->exec('SET NAMES '. $charset); //also for current connection
797
+			$this->pdo->exec('SET NAMES '.$charset); //also for current connection
798 798
 			$this->mysqlCharset = $charset;
799
-			$this->mysqlCollate = $charset . $collate;
799
+			$this->mysqlCollate = $charset.$collate;
800 800
 		}
801 801
 	}
802 802
 
@@ -820,28 +820,28 @@  discard block
 block discarded – undo
820 820
 	 *
821 821
 	 * @return int|false Whether the database feature is supported, FALSE otherwise.
822 822
 	 **/
823
-	protected function hasCap( $db_cap )
823
+	protected function hasCap($db_cap)
824 824
 	{
825 825
 		$compare = FALSE;
826
-		$version = $this->pdo->getAttribute( \PDO::ATTR_SERVER_VERSION );
827
-		switch ( strtolower( $db_cap ) ) {
826
+		$version = $this->pdo->getAttribute(\PDO::ATTR_SERVER_VERSION);
827
+		switch (strtolower($db_cap)) {
828 828
 			case 'utf8mb4':
829 829
 				//oneliner, to boost code coverage (coverage does not span versions)
830
-				if ( version_compare( $version, '5.5.3', '<' ) ) { return FALSE; }
831
-				$client_version = $this->pdo->getAttribute(\PDO::ATTR_CLIENT_VERSION );
830
+				if (version_compare($version, '5.5.3', '<')) { return FALSE; }
831
+				$client_version = $this->pdo->getAttribute(\PDO::ATTR_CLIENT_VERSION);
832 832
 				/*
833 833
 				 * libmysql has supported utf8mb4 since 5.5.3, same as the MySQL server.
834 834
 				 * mysqlnd has supported utf8mb4 since 5.0.9.
835 835
 				 */
836
-				if ( strpos( $client_version, 'mysqlnd' ) !== FALSE ) {
837
-					$client_version = preg_replace( '/^\D+([\d.]+).*/', '$1', $client_version );
838
-					$compare = version_compare( $client_version, '5.0.9', '>=' );
836
+				if (strpos($client_version, 'mysqlnd') !== FALSE) {
837
+					$client_version = preg_replace('/^\D+([\d.]+).*/', '$1', $client_version);
838
+					$compare = version_compare($client_version, '5.0.9', '>=');
839 839
 				} else {
840
-					$compare = version_compare( $client_version, '5.5.3', '>=' );
840
+					$compare = version_compare($client_version, '5.5.3', '>=');
841 841
 				}
842 842
 			break;
843 843
 			case 'utf8mb4_520':
844
-				$compare = version_compare( $version, '5.6', '>=' );
844
+				$compare = version_compare($version, '5.6', '>=');
845 845
 			break;
846 846
 		}
847 847
 
@@ -877,25 +877,25 @@  discard block
 block discarded – undo
877 877
 	 *
878 878
 	 * @return void
879 879
 	 */
880
-	public function __construct( $dsn, $user = NULL, $pass = NULL )
880
+	public function __construct($dsn, $user = NULL, $pass = NULL)
881 881
 	{
882
-		if ( is_object( $dsn ) ) {
882
+		if (is_object($dsn)) {
883 883
 			$this->pdo = $dsn;
884 884
 			$this->isConnected = TRUE;
885 885
 			$this->setEncoding();
886
-			$this->pdo->setAttribute( \PDO::ATTR_ERRMODE,\PDO::ERRMODE_EXCEPTION );
887
-			$this->pdo->setAttribute( \PDO::ATTR_DEFAULT_FETCH_MODE,\PDO::FETCH_ASSOC );
886
+			$this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
887
+			$this->pdo->setAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE, \PDO::FETCH_ASSOC);
888 888
 			// make sure that the dsn at least contains the type
889 889
 			$this->dsn = $this->getDatabaseType();
890 890
 		} else {
891 891
 			$this->dsn = $dsn;
892
-			$this->connectInfo = array( 'pass' => $pass, 'user' => $user );
892
+			$this->connectInfo = array('pass' => $pass, 'user' => $user);
893 893
 		}
894 894
 
895 895
 		//PHP 5.3 PDO SQLite has a bug with large numbers:
896
-		if ( ( strpos( $this->dsn, 'sqlite' ) === 0 && PHP_MAJOR_VERSION === 5 && PHP_MINOR_VERSION === 3 ) ||  defined('HHVM_VERSION') || $this->dsn === 'test-sqlite-53' ) {
896
+		if ((strpos($this->dsn, 'sqlite') === 0 && PHP_MAJOR_VERSION === 5 && PHP_MINOR_VERSION === 3) || defined('HHVM_VERSION') || $this->dsn === 'test-sqlite-53') {
897 897
 			$this->max = 2147483647; //otherwise you get -2147483648 ?! demonstrated in build #603 on Travis.
898
-		} elseif ( strpos( $this->dsn, 'cubrid' ) === 0 ) {
898
+		} elseif (strpos($this->dsn, 'cubrid') === 0) {
899 899
 			$this->max = 2147483647; //bindParam in pdo_cubrid also fails...
900 900
 		} else {
901 901
 			$this->max = PHP_INT_MAX; //the normal value of course (makes it possible to use large numbers in LIMIT clause)
@@ -922,7 +922,7 @@  discard block
 block discarded – undo
922 922
 	 *
923 923
 	 * @param boolean $bool
924 924
 	 */
925
-	public function stringifyFetches( $bool ) {
925
+	public function stringifyFetches($bool) {
926 926
 		$this->stringifyFetches = $bool;
927 927
 	}
928 928
 
@@ -943,10 +943,10 @@  discard block
 block discarded – undo
943 943
 	 *
944 944
 	 * @return string|array
945 945
 	 */
946
-	public function getMysqlEncoding( $retCol = FALSE )
946
+	public function getMysqlEncoding($retCol = FALSE)
947 947
 	{
948
-		if( $retCol )
949
-			return array( 'charset' => $this->mysqlCharset, 'collate' => $this->mysqlCollate );
948
+		if ($retCol)
949
+			return array('charset' => $this->mysqlCharset, 'collate' => $this->mysqlCollate);
950 950
 		return $this->mysqlCharset;
951 951
 	}
952 952
 
@@ -959,7 +959,7 @@  discard block
 block discarded – undo
959 959
 	 *
960 960
 	 * @return void
961 961
 	 */
962
-	public function setUseStringOnlyBinding( $yesNo )
962
+	public function setUseStringOnlyBinding($yesNo)
963 963
 	{
964 964
 		$this->flagUseStringOnlyBinding = (boolean) $yesNo;
965 965
 	}
@@ -976,9 +976,9 @@  discard block
 block discarded – undo
976 976
 	 *
977 977
 	 * @return integer
978 978
 	 */
979
-	public function setMaxIntBind( $max )
979
+	public function setMaxIntBind($max)
980 980
 	{
981
-		if ( !is_integer( $max ) ) throw new RedException( 'Parameter has to be integer.' );
981
+		if (!is_integer($max)) throw new RedException('Parameter has to be integer.');
982 982
 		$oldMax = $this->max;
983 983
 		$this->max = $max;
984 984
 		return $oldMax;
@@ -995,26 +995,26 @@  discard block
 block discarded – undo
995 995
 	 */
996 996
 	public function connect()
997 997
 	{
998
-		if ( $this->isConnected ) return;
998
+		if ($this->isConnected) return;
999 999
 		try {
1000 1000
 			$user = $this->connectInfo['user'];
1001 1001
 			$pass = $this->connectInfo['pass'];
1002
-			$this->pdo = new \PDO( $this->dsn, $user, $pass );
1002
+			$this->pdo = new \PDO($this->dsn, $user, $pass);
1003 1003
 			$this->setEncoding();
1004
-			$this->pdo->setAttribute( \PDO::ATTR_STRINGIFY_FETCHES, $this->stringifyFetches );
1004
+			$this->pdo->setAttribute(\PDO::ATTR_STRINGIFY_FETCHES, $this->stringifyFetches);
1005 1005
 			//cant pass these as argument to constructor, CUBRID driver does not understand...
1006
-			$this->pdo->setAttribute( \PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION );
1007
-			$this->pdo->setAttribute( \PDO::ATTR_DEFAULT_FETCH_MODE, \PDO::FETCH_ASSOC );
1006
+			$this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
1007
+			$this->pdo->setAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE, \PDO::FETCH_ASSOC);
1008 1008
 			$this->isConnected = TRUE;
1009 1009
 			/* run initialisation query if any */
1010
-			if ( $this->initSQL !== NULL ) {
1011
-				$this->Execute( $this->initSQL );
1010
+			if ($this->initSQL !== NULL) {
1011
+				$this->Execute($this->initSQL);
1012 1012
 				$this->initSQL = NULL;
1013 1013
 			}
1014
-		} catch ( \PDOException $exception ) {
1014
+		} catch (\PDOException $exception) {
1015 1015
 			$matches = array();
1016
-			$dbname  = ( preg_match( '/dbname=(\w+)/', $this->dsn, $matches ) ) ? $matches[1] : '?';
1017
-			throw new \PDOException( 'Could not connect to database (' . $dbname . ').', $exception->getCode() );
1016
+			$dbname  = (preg_match('/dbname=(\w+)/', $this->dsn, $matches)) ? $matches[1] : '?';
1017
+			throw new \PDOException('Could not connect to database ('.$dbname.').', $exception->getCode());
1018 1018
 		}
1019 1019
 	}
1020 1020
 
@@ -1029,25 +1029,25 @@  discard block
 block discarded – undo
1029 1029
 	 *
1030 1030
 	 * @return void
1031 1031
 	 */
1032
-	public function setPDO( \PDO $pdo ) {
1032
+	public function setPDO(\PDO $pdo) {
1033 1033
 		$this->pdo = $pdo;
1034 1034
 	}
1035 1035
 
1036 1036
 	/**
1037 1037
 	 * @see Driver::GetAll
1038 1038
 	 */
1039
-	public function GetAll( $sql, $bindings = array() )
1039
+	public function GetAll($sql, $bindings = array())
1040 1040
 	{
1041
-		$this->runQuery( $sql, $bindings );
1041
+		$this->runQuery($sql, $bindings);
1042 1042
 		return $this->resultArray;
1043 1043
 	}
1044 1044
 
1045 1045
 	/**
1046 1046
 	 * @see Driver::GetAssocRow
1047 1047
 	 */
1048
-	public function GetAssocRow( $sql, $bindings = array() )
1048
+	public function GetAssocRow($sql, $bindings = array())
1049 1049
 	{
1050
-		$this->runQuery( $sql, $bindings, array(
1050
+		$this->runQuery($sql, $bindings, array(
1051 1051
 				'fetchStyle' => \PDO::FETCH_ASSOC
1052 1052
 			)
1053 1053
 		);
@@ -1057,17 +1057,17 @@  discard block
 block discarded – undo
1057 1057
 	/**
1058 1058
 	 * @see Driver::GetCol
1059 1059
 	 */
1060
-	public function GetCol( $sql, $bindings = array() )
1060
+	public function GetCol($sql, $bindings = array())
1061 1061
 	{
1062
-		$rows = $this->GetAll( $sql, $bindings );
1062
+		$rows = $this->GetAll($sql, $bindings);
1063 1063
 
1064
-		if ( empty( $rows ) || !is_array( $rows ) ) {
1064
+		if (empty($rows) || !is_array($rows)) {
1065 1065
 			return array();
1066 1066
 		}
1067 1067
 
1068 1068
 		$cols = array();
1069
-		foreach ( $rows as $row ) {
1070
-			$cols[] = reset( $row );
1069
+		foreach ($rows as $row) {
1070
+			$cols[] = reset($row);
1071 1071
 		}
1072 1072
 
1073 1073
 		return $cols;
@@ -1076,15 +1076,15 @@  discard block
 block discarded – undo
1076 1076
 	/**
1077 1077
 	 * @see Driver::GetOne
1078 1078
 	 */
1079
-	public function GetOne( $sql, $bindings = array() )
1079
+	public function GetOne($sql, $bindings = array())
1080 1080
 	{
1081
-		$arr = $this->GetAll( $sql, $bindings );
1081
+		$arr = $this->GetAll($sql, $bindings);
1082 1082
 
1083
-		if ( empty( $arr[0] ) || !is_array( $arr[0] ) ) {
1083
+		if (empty($arr[0]) || !is_array($arr[0])) {
1084 1084
 			return NULL;
1085 1085
 		}
1086 1086
 
1087
-		return reset( $arr[0] );
1087
+		return reset($arr[0]);
1088 1088
 	}
1089 1089
 
1090 1090
 	/**
@@ -1096,26 +1096,26 @@  discard block
 block discarded – undo
1096 1096
 	 *
1097 1097
 	 * @return mixed
1098 1098
 	 */
1099
-	public function GetCell( $sql, $bindings = array() )
1099
+	public function GetCell($sql, $bindings = array())
1100 1100
 	{
1101
-		return $this->GetOne( $sql, $bindings );
1101
+		return $this->GetOne($sql, $bindings);
1102 1102
 	}
1103 1103
 
1104 1104
 	/**
1105 1105
 	 * @see Driver::GetRow
1106 1106
 	 */
1107
-	public function GetRow( $sql, $bindings = array() )
1107
+	public function GetRow($sql, $bindings = array())
1108 1108
 	{
1109
-		$arr = $this->GetAll( $sql, $bindings );
1110
-		return reset( $arr );
1109
+		$arr = $this->GetAll($sql, $bindings);
1110
+		return reset($arr);
1111 1111
 	}
1112 1112
 
1113 1113
 	/**
1114 1114
 	 * @see Driver::Excecute
1115 1115
 	 */
1116
-	public function Execute( $sql, $bindings = array() )
1116
+	public function Execute($sql, $bindings = array())
1117 1117
 	{
1118
-		$this->runQuery( $sql, $bindings );
1118
+		$this->runQuery($sql, $bindings);
1119 1119
 		return $this->affectedRows;
1120 1120
 	}
1121 1121
 
@@ -1132,10 +1132,10 @@  discard block
 block discarded – undo
1132 1132
 	/**
1133 1133
 	 * @see Driver::GetCursor
1134 1134
 	 */
1135
-	public function GetCursor( $sql, $bindings = array() )
1135
+	public function GetCursor($sql, $bindings = array())
1136 1136
 	{
1137
-		$statement = $this->runQuery( $sql, $bindings, array( 'noFetch' => TRUE ) );
1138
-		$cursor = new PDOCursor( $statement, \PDO::FETCH_ASSOC );
1137
+		$statement = $this->runQuery($sql, $bindings, array('noFetch' => TRUE));
1138
+		$cursor = new PDOCursor($statement, \PDO::FETCH_ASSOC);
1139 1139
 		return $cursor;
1140 1140
 	}
1141 1141
 
@@ -1151,14 +1151,14 @@  discard block
 block discarded – undo
1151 1151
 	/**
1152 1152
 	 * @see Driver::setDebugMode
1153 1153
 	 */
1154
-	public function setDebugMode( $tf, $logger = NULL )
1154
+	public function setDebugMode($tf, $logger = NULL)
1155 1155
 	{
1156 1156
 		$this->connect();
1157 1157
 		$this->loggingEnabled = (bool) $tf;
1158
-		if ( $this->loggingEnabled and !$logger ) {
1158
+		if ($this->loggingEnabled and !$logger) {
1159 1159
 			$logger = new RDefault();
1160 1160
 		}
1161
-		$this->setLogger( $logger );
1161
+		$this->setLogger($logger);
1162 1162
 	}
1163 1163
 
1164 1164
 	/**
@@ -1185,7 +1185,7 @@  discard block
 block discarded – undo
1185 1185
 	 *
1186 1186
 	 * @return self
1187 1187
 	 */
1188
-	public function setLogger( Logger $logger )
1188
+	public function setLogger(Logger $logger)
1189 1189
 	{
1190 1190
 		$this->logger = $logger;
1191 1191
 		return $this;
@@ -1258,7 +1258,7 @@  discard block
 block discarded – undo
1258 1258
 	public function getDatabaseType()
1259 1259
 	{
1260 1260
 		$this->connect();
1261
-		return $this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME );
1261
+		return $this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME);
1262 1262
 	}
1263 1263
 
1264 1264
 	/**
@@ -1290,7 +1290,7 @@  discard block
 block discarded – undo
1290 1290
 	public function getDatabaseVersion()
1291 1291
 	{
1292 1292
 		$this->connect();
1293
-		return $this->pdo->getAttribute(\PDO::ATTR_CLIENT_VERSION );
1293
+		return $this->pdo->getAttribute(\PDO::ATTR_CLIENT_VERSION);
1294 1294
 	}
1295 1295
 
1296 1296
 	/**
@@ -1354,7 +1354,7 @@  discard block
 block discarded – undo
1354 1354
 	 *
1355 1355
 	 * @return self
1356 1356
 	 */
1357
-	public function setEnableLogging( $enable )
1357
+	public function setEnableLogging($enable)
1358 1358
 	{
1359 1359
 		$this->loggingEnabled = (boolean) $enable;
1360 1360
 		return $this;
@@ -1428,7 +1428,7 @@  discard block
 block discarded – undo
1428 1428
 	 *
1429 1429
 	 * @return self
1430 1430
 	 */
1431
-	public function setInitQuery( $sql ) {
1431
+	public function setInitQuery($sql) {
1432 1432
 		$this->initSQL = $sql;
1433 1433
 		return $this;
1434 1434
 	}
@@ -1465,7 +1465,7 @@  discard block
 block discarded – undo
1465 1465
  * This source file is subject to the BSD/GPLv2 License that is bundled
1466 1466
  * with this source code in the file license.txt.
1467 1467
  */
1468
-class OODBBean implements\IteratorAggregate,\ArrayAccess,\Countable,Jsonable
1468
+class OODBBean implements\IteratorAggregate, \ArrayAccess, \Countable, Jsonable
1469 1469
 {
1470 1470
 	/**
1471 1471
 	 * FUSE error modes.
@@ -1582,7 +1582,7 @@  discard block
 block discarded – undo
1582 1582
 	 *
1583 1583
 	 * @return void
1584 1584
 	 */
1585
-	 public static function setEnforceUTF8encoding( $toggle )
1585
+	 public static function setEnforceUTF8encoding($toggle)
1586 1586
 	 {
1587 1587
 		 self::$enforceUTF8encoding = (boolean) $toggle;
1588 1588
 	 }
@@ -1624,15 +1624,15 @@  discard block
 block discarded – undo
1624 1624
 			&& $mode !== self::C_ERR_EXCEPTION
1625 1625
 			&& $mode !== self::C_ERR_FUNC
1626 1626
 			&& $mode !== self::C_ERR_FATAL
1627
-		) throw new \Exception( 'Invalid error mode selected' );
1627
+		) throw new \Exception('Invalid error mode selected');
1628 1628
 
1629
-		if ( $mode === self::C_ERR_FUNC && !is_callable( $func ) ) {
1630
-			throw new \Exception( 'Invalid error handler' );
1629
+		if ($mode === self::C_ERR_FUNC && !is_callable($func)) {
1630
+			throw new \Exception('Invalid error handler');
1631 1631
 		}
1632 1632
 
1633
-		$old = array( self::$errorHandlingFUSE, self::$errorHandler );
1633
+		$old = array(self::$errorHandlingFUSE, self::$errorHandler);
1634 1634
 		self::$errorHandlingFUSE = $mode;
1635
-		if ( is_callable( $func ) ) {
1635
+		if (is_callable($func)) {
1636 1636
 			self::$errorHandler = $func;
1637 1637
 		} else {
1638 1638
 			self::$errorHandler = NULL;
@@ -1651,7 +1651,7 @@  discard block
 block discarded – undo
1651 1651
 	 *
1652 1652
 	 * @return boolean
1653 1653
 	 */
1654
-	public static function convertArraysToJSON( $flag )
1654
+	public static function convertArraysToJSON($flag)
1655 1655
 	{
1656 1656
 		$old = self::$convertArraysToJSON;
1657 1657
 		self::$convertArraysToJSON = $flag;
@@ -1694,7 +1694,7 @@  discard block
 block discarded – undo
1694 1694
 	 *
1695 1695
 	 * @return void
1696 1696
 	 */
1697
-	public static function aliases( $list )
1697
+	public static function aliases($list)
1698 1698
 	{
1699 1699
 		self::$aliases = $list;
1700 1700
 	}
@@ -1709,7 +1709,7 @@  discard block
 block discarded – undo
1709 1709
 	 *
1710 1710
 	 * @return void
1711 1711
 	 */
1712
-	public static function setAutoResolve( $automatic = TRUE )
1712
+	public static function setAutoResolve($automatic = TRUE)
1713 1713
 	{
1714 1714
 		self::$autoResolve = (boolean) $automatic;
1715 1715
 	}
@@ -1726,12 +1726,12 @@  discard block
 block discarded – undo
1726 1726
 	 *
1727 1727
 	 * @return array
1728 1728
 	 */
1729
-	public static function setMetaAll( $beans, $property, $value )
1729
+	public static function setMetaAll($beans, $property, $value)
1730 1730
 	{
1731
-		foreach( $beans as $bean ) {
1732
-			if ( $bean instanceof OODBBean ) $bean->__info[ $property ] = $value;
1733
-			if ( $property == 'type' && !empty($bean->beanHelper)) {
1734
-				$bean->__info['model'] = $bean->beanHelper->getModelForBean( $bean );
1731
+		foreach ($beans as $bean) {
1732
+			if ($bean instanceof OODBBean) $bean->__info[$property] = $value;
1733
+			if ($property == 'type' && !empty($bean->beanHelper)) {
1734
+				$bean->__info['model'] = $bean->beanHelper->getModelForBean($bean);
1735 1735
 			}
1736 1736
 		}
1737 1737
 		return $beans;
@@ -1757,27 +1757,27 @@  discard block
 block discarded – undo
1757 1757
 	 *
1758 1758
 	 * @return string
1759 1759
 	 */
1760
-	private function parseJoin( $type )
1760
+	private function parseJoin($type)
1761 1761
 	{
1762
-		if ( strpos($this->withSql, '@joined.' ) === FALSE ) {
1762
+		if (strpos($this->withSql, '@joined.') === FALSE) {
1763 1763
 			return '';
1764 1764
 		}
1765 1765
 		
1766 1766
 		$joinSql = ' ';
1767 1767
 		$joins = array();
1768 1768
 		$writer   = $this->beanHelper->getToolBox()->getWriter();
1769
-		$oldParts = $parts = explode( '@joined.', $this->withSql );
1770
-		array_shift( $parts );
1771
-		foreach($parts as $part) {
1772
-			$explosion = explode( '.', $part );
1773
-			$joinInfo  = reset( $explosion );
1769
+		$oldParts = $parts = explode('@joined.', $this->withSql);
1770
+		array_shift($parts);
1771
+		foreach ($parts as $part) {
1772
+			$explosion = explode('.', $part);
1773
+			$joinInfo  = reset($explosion);
1774 1774
 			//Dont join more than once..
1775
-			if ( !isset( $joins[$joinInfo] ) ) {
1776
-				$joins[ $joinInfo ] = TRUE;
1777
-				$joinSql  .= $writer->writeJoin( $type, $joinInfo, 'LEFT' );
1775
+			if (!isset($joins[$joinInfo])) {
1776
+				$joins[$joinInfo] = TRUE;
1777
+				$joinSql .= $writer->writeJoin($type, $joinInfo, 'LEFT');
1778 1778
 			}
1779 1779
 		}
1780
-		$this->withSql = implode( '', $oldParts );
1780
+		$this->withSql = implode('', $oldParts);
1781 1781
 		$joinSql      .= ' WHERE ';
1782 1782
 		
1783 1783
 		return $joinSql;
@@ -1807,22 +1807,22 @@  discard block
 block discarded – undo
1807 1807
 	 *
1808 1808
 	 * @return array
1809 1809
 	 */
1810
-	private function getSharedList( $type, $redbean, $toolbox )
1810
+	private function getSharedList($type, $redbean, $toolbox)
1811 1811
 	{
1812 1812
 		$writer = $toolbox->getWriter();
1813
-		if ( $this->via ) {
1814
-			$oldName = $writer->getAssocTable( array( $this->__info['type'], $type ) );
1815
-			if ( $oldName !== $this->via ) {
1813
+		if ($this->via) {
1814
+			$oldName = $writer->getAssocTable(array($this->__info['type'], $type));
1815
+			if ($oldName !== $this->via) {
1816 1816
 				//set the new renaming rule
1817
-				$writer->renameAssocTable( $oldName, $this->via );
1817
+				$writer->renameAssocTable($oldName, $this->via);
1818 1818
 			}
1819 1819
 			$this->via = NULL;
1820 1820
 		}
1821 1821
 		$beans = array();
1822 1822
 		if ($this->getID()) {
1823
-			$type             = $this->beau( $type );
1823
+			$type             = $this->beau($type);
1824 1824
 			$assocManager     = $redbean->getAssociationManager();
1825
-			$beans            = $assocManager->related( $this, $type, $this->withSql, $this->withParams );
1825
+			$beans            = $assocManager->related($this, $type, $this->withSql, $this->withParams);
1826 1826
 		}
1827 1827
 		return $beans;
1828 1828
 	}
@@ -1850,38 +1850,38 @@  discard block
 block discarded – undo
1850 1850
 	 *
1851 1851
 	 * @return array
1852 1852
 	 */
1853
-	private function getOwnList( $type, $redbean )
1853
+	private function getOwnList($type, $redbean)
1854 1854
 	{
1855
-		$type = $this->beau( $type );
1856
-		if ( $this->aliasName ) {
1855
+		$type = $this->beau($type);
1856
+		if ($this->aliasName) {
1857 1857
 			$parentField = $this->aliasName;
1858
-			$myFieldLink = $parentField . '_id';
1858
+			$myFieldLink = $parentField.'_id';
1859 1859
 
1860
-			$this->__info['sys.alias.' . $type] = $this->aliasName;
1860
+			$this->__info['sys.alias.'.$type] = $this->aliasName;
1861 1861
 
1862 1862
 			$this->aliasName = NULL;
1863 1863
 		} else {
1864 1864
 			$parentField = $this->__info['type'];
1865
-			$myFieldLink = $parentField . '_id';
1865
+			$myFieldLink = $parentField.'_id';
1866 1866
 		}
1867 1867
 		$beans = array();
1868
-		if ( $this->getID() ) {
1869
-			reset( $this->withParams );
1870
-			$joinSql = $this->parseJoin( $type );
1871
-			$firstKey = count( $this->withParams ) > 0
1872
-				? key( $this->withParams )
1868
+		if ($this->getID()) {
1869
+			reset($this->withParams);
1870
+			$joinSql = $this->parseJoin($type);
1871
+			$firstKey = count($this->withParams) > 0
1872
+				? key($this->withParams)
1873 1873
 				: 0;
1874
-			if ( is_int( $firstKey ) ) {
1875
-				$bindings = array_merge( array( $this->getID() ), $this->withParams );
1876
-				$beans = $redbean->find( $type, array(), "{$joinSql} $myFieldLink = ? " . $this->withSql, $bindings );
1874
+			if (is_int($firstKey)) {
1875
+				$bindings = array_merge(array($this->getID()), $this->withParams);
1876
+				$beans = $redbean->find($type, array(), "{$joinSql} $myFieldLink = ? ".$this->withSql, $bindings);
1877 1877
 			} else {
1878 1878
 				$bindings           = $this->withParams;
1879 1879
 				$bindings[':slot0'] = $this->getID();
1880
-				$beans = $redbean->find( $type, array(), "{$joinSql} $myFieldLink = :slot0 " . $this->withSql, $bindings );
1880
+				$beans = $redbean->find($type, array(), "{$joinSql} $myFieldLink = :slot0 ".$this->withSql, $bindings);
1881 1881
 			}
1882 1882
 		}
1883
-		foreach ( $beans as $beanFromList ) {
1884
-			$beanFromList->__info['sys.parentcache.' . $parentField] = $this;
1883
+		foreach ($beans as $beanFromList) {
1884
+			$beanFromList->__info['sys.parentcache.'.$parentField] = $this;
1885 1885
 		}
1886 1886
 		return $beans;
1887 1887
 	}
@@ -1901,19 +1901,19 @@  discard block
 block discarded – undo
1901 1901
 	 *
1902 1902
 	 * @return void
1903 1903
 	 */
1904
-	public function initializeForDispense( $type, $beanhelper = NULL )
1904
+	public function initializeForDispense($type, $beanhelper = NULL)
1905 1905
 	{
1906 1906
 		$this->beanHelper         = $beanhelper;
1907 1907
 		$this->__info['type']     = $type;
1908 1908
 		$this->__info['sys.id']   = 'id';
1909
-		$this->__info['sys.orig'] = array( 'id' => 0 );
1909
+		$this->__info['sys.orig'] = array('id' => 0);
1910 1910
 		$this->__info['tainted']  = TRUE;
1911 1911
 		$this->__info['changed']  = TRUE;
1912 1912
 		$this->__info['changelist'] = array();
1913
-		if ( $beanhelper ) {
1914
-			$this->__info['model'] = $this->beanHelper->getModelForBean( $this );
1913
+		if ($beanhelper) {
1914
+			$this->__info['model'] = $this->beanHelper->getModelForBean($this);
1915 1915
 		}
1916
-		$this->properties['id']   = 0;
1916
+		$this->properties['id'] = 0;
1917 1917
 	}
1918 1918
 
1919 1919
 	/**
@@ -1927,7 +1927,7 @@  discard block
 block discarded – undo
1927 1927
 	 *
1928 1928
 	 * @return void
1929 1929
 	 */
1930
-	public function setBeanHelper( BeanHelper $helper )
1930
+	public function setBeanHelper(BeanHelper $helper)
1931 1931
 	{
1932 1932
 		$this->beanHelper = $helper;
1933 1933
 	}
@@ -1948,7 +1948,7 @@  discard block
 block discarded – undo
1948 1948
 	 */
1949 1949
 	public function getIterator()
1950 1950
 	{
1951
-		return new \ArrayIterator( $this->properties );
1951
+		return new \ArrayIterator($this->properties);
1952 1952
 	}
1953 1953
 
1954 1954
 	/**
@@ -1965,40 +1965,40 @@  discard block
 block discarded – undo
1965 1965
 	 *
1966 1966
 	 * @return OODBBean
1967 1967
 	 */
1968
-	public function import( $array, $selection = FALSE, $notrim = FALSE )
1968
+	public function import($array, $selection = FALSE, $notrim = FALSE)
1969 1969
 	{
1970
-		if ( is_string( $selection ) ) {
1971
-			$selection = explode( ',', $selection );
1970
+		if (is_string($selection)) {
1971
+			$selection = explode(',', $selection);
1972 1972
 		}
1973
-		if ( is_array( $selection ) ) {
1974
-			if ( $notrim ) {
1973
+		if (is_array($selection)) {
1974
+			if ($notrim) {
1975 1975
 				$selected = array_flip($selection);
1976 1976
 			} else {
1977 1977
 				$selected = array();
1978
-				foreach ( $selection as $key => $select ) {
1979
-					$selected[trim( $select )] = TRUE;
1978
+				foreach ($selection as $key => $select) {
1979
+					$selected[trim($select)] = TRUE;
1980 1980
 				}
1981 1981
 			}
1982 1982
 		} else {
1983 1983
 			$selected = FALSE;
1984 1984
 		}
1985
-		foreach ( $array as $key => $value ) {
1986
-			if ( $key != '__info' ) {
1987
-				if ( !$selected || isset( $selected[$key] ) ) {
1988
-					if ( is_array($value ) ) {
1989
-						if ( isset( $value['_type'] ) ) {
1990
-							$bean = $this->beanHelper->getToolbox()->getRedBean()->dispense( $value['_type'] );
1991
-							unset( $value['_type'] );
1985
+		foreach ($array as $key => $value) {
1986
+			if ($key != '__info') {
1987
+				if (!$selected || isset($selected[$key])) {
1988
+					if (is_array($value)) {
1989
+						if (isset($value['_type'])) {
1990
+							$bean = $this->beanHelper->getToolbox()->getRedBean()->dispense($value['_type']);
1991
+							unset($value['_type']);
1992 1992
 							$bean->import($value);
1993 1993
 							$this->$key = $bean;
1994 1994
 						} else {
1995 1995
 							$listBeans = array();
1996
-							foreach( $value as $listKey => $listItem ) {
1997
-								$bean = $this->beanHelper->getToolbox()->getRedBean()->dispense( $listItem['_type'] );
1998
-								unset( $listItem['_type'] );
1996
+							foreach ($value as $listKey => $listItem) {
1997
+								$bean = $this->beanHelper->getToolbox()->getRedBean()->dispense($listItem['_type']);
1998
+								unset($listItem['_type']);
1999 1999
 								$bean->import($listItem);
2000 2000
 								$list = &$this->$key;
2001
-								$list[ $listKey ] = $bean;
2001
+								$list[$listKey] = $bean;
2002 2002
 							}
2003 2003
 						}
2004 2004
 					} else {
@@ -2022,7 +2022,7 @@  discard block
 block discarded – undo
2022 2022
 	*
2023 2023
 	* @return self
2024 2024
 	*/
2025
-	public function importRow( $row )
2025
+	public function importRow($row)
2026 2026
 	{
2027 2027
 		$this->properties = $row;
2028 2028
 		$this->__info['sys.orig'] = $row;
@@ -2048,7 +2048,7 @@  discard block
 block discarded – undo
2048 2048
 	 *
2049 2049
 	 * @return OODBBean
2050 2050
 	 */
2051
-	public function importFrom( OODBBean $sourceBean )
2051
+	public function importFrom(OODBBean $sourceBean)
2052 2052
 	{
2053 2053
 		$this->__info['tainted'] = TRUE;
2054 2054
 		$this->__info['changed'] = TRUE;
@@ -2066,10 +2066,10 @@  discard block
 block discarded – undo
2066 2066
 	 *
2067 2067
 	 * @return OODBBean
2068 2068
 	 */
2069
-	public function inject( OODBBean $otherBean )
2069
+	public function inject(OODBBean $otherBean)
2070 2070
 	{
2071 2071
 		$myID = $this->properties['id'];
2072
-		$this->import( $otherBean->export( FALSE, FALSE, TRUE ) );
2072
+		$this->import($otherBean->export(FALSE, FALSE, TRUE));
2073 2073
 		$this->id = $myID;
2074 2074
 
2075 2075
 		return $this;
@@ -2098,35 +2098,35 @@  discard block
 block discarded – undo
2098 2098
 	 *
2099 2099
 	 * @return array
2100 2100
 	 */
2101
-	public function export( $meta = FALSE, $parents = FALSE, $onlyMe = FALSE, $filters = array() )
2101
+	public function export($meta = FALSE, $parents = FALSE, $onlyMe = FALSE, $filters = array())
2102 2102
 	{
2103 2103
 		$arr = array();
2104
-		if ( $parents ) {
2105
-			foreach ( $this as $key => $value ) {
2106
-				if ( substr( $key, -3 ) != '_id' ) continue;
2104
+		if ($parents) {
2105
+			foreach ($this as $key => $value) {
2106
+				if (substr($key, -3) != '_id') continue;
2107 2107
 
2108
-				$prop = substr( $key, 0, strlen( $key ) - 3 );
2108
+				$prop = substr($key, 0, strlen($key) - 3);
2109 2109
 				$this->$prop;
2110 2110
 			}
2111 2111
 		}
2112
-		$hasFilters = is_array( $filters ) && count( $filters );
2113
-		foreach ( $this as $key => $value ) {
2114
-			if ( !$onlyMe && is_array( $value ) ) {
2112
+		$hasFilters = is_array($filters) && count($filters);
2113
+		foreach ($this as $key => $value) {
2114
+			if (!$onlyMe && is_array($value)) {
2115 2115
 				$vn = array();
2116 2116
 
2117
-				foreach ( $value as $i => $b ) {
2118
-					if ( !( $b instanceof OODBBean ) ) continue;
2119
-					$vn[] = $b->export( $meta, FALSE, FALSE, $filters );
2117
+				foreach ($value as $i => $b) {
2118
+					if (!($b instanceof OODBBean)) continue;
2119
+					$vn[] = $b->export($meta, FALSE, FALSE, $filters);
2120 2120
 					$value = $vn;
2121 2121
 				}
2122
-			} elseif ( $value instanceof OODBBean ) { if ( $hasFilters ) { //has to be on one line, otherwise code coverage miscounts as miss
2123
-					if ( !in_array( strtolower( $value->getMeta( 'type' ) ), $filters ) ) continue;
2122
+			} elseif ($value instanceof OODBBean) { if ($hasFilters) { //has to be on one line, otherwise code coverage miscounts as miss
2123
+					if (!in_array(strtolower($value->getMeta('type')), $filters)) continue;
2124 2124
 				}
2125
-				$value = $value->export( $meta, $parents, FALSE, $filters );
2125
+				$value = $value->export($meta, $parents, FALSE, $filters);
2126 2126
 			}
2127 2127
 			$arr[$key] = $value;
2128 2128
 		}
2129
-		if ( $meta ) {
2129
+		if ($meta) {
2130 2130
 			$arr['__info'] = $this->__info;
2131 2131
 		}
2132 2132
 		return $arr;
@@ -2150,13 +2150,13 @@  discard block
 block discarded – undo
2150 2150
 	 *
2151 2151
 	 * @return boolean
2152 2152
 	 */
2153
-	public function __isset( $property )
2153
+	public function __isset($property)
2154 2154
 	{
2155
-		$property = $this->beau( $property );
2156
-		if ( strpos( $property, 'xown' ) === 0 && ctype_upper( substr( $property, 4, 1 ) ) ) {
2155
+		$property = $this->beau($property);
2156
+		if (strpos($property, 'xown') === 0 && ctype_upper(substr($property, 4, 1))) {
2157 2157
 			$property = substr($property, 1);
2158 2158
 		}
2159
-		return isset( $this->properties[$property] );
2159
+		return isset($this->properties[$property]);
2160 2160
 	}
2161 2161
 
2162 2162
 	/**
@@ -2169,13 +2169,13 @@  discard block
 block discarded – undo
2169 2169
 	 *
2170 2170
 	 * @return boolean
2171 2171
 	 */
2172
-	public function exists( $property )
2172
+	public function exists($property)
2173 2173
 	{
2174
-		$property = $this->beau( $property );
2174
+		$property = $this->beau($property);
2175 2175
 		/* fixes issue #549, see Base/Bean test */
2176 2176
 		$hiddenRelationField = "{$property}_id";
2177
-		if ( array_key_exists( $hiddenRelationField, $this->properties ) ) {
2178
-			if ( !is_null( $this->properties[$hiddenRelationField] ) ) {
2177
+		if (array_key_exists($hiddenRelationField, $this->properties)) {
2178
+			if (!is_null($this->properties[$hiddenRelationField])) {
2179 2179
 				return TRUE;
2180 2180
 			}
2181 2181
 		}
@@ -2194,7 +2194,7 @@  discard block
 block discarded – undo
2194 2194
 	 */
2195 2195
 	public function getID()
2196 2196
 	{
2197
-		return ( isset( $this->properties['id'] ) ) ? (string) $this->properties['id'] : NULL;
2197
+		return (isset($this->properties['id'])) ? (string) $this->properties['id'] : NULL;
2198 2198
 	}
2199 2199
 
2200 2200
 	/**
@@ -2207,16 +2207,16 @@  discard block
 block discarded – undo
2207 2207
 	 *
2208 2208
 	 * @return void
2209 2209
 	 */
2210
-	public function __unset( $property )
2210
+	public function __unset($property)
2211 2211
 	{
2212
-		$property = $this->beau( $property );
2212
+		$property = $this->beau($property);
2213 2213
 
2214
-		if ( strpos( $property, 'xown' ) === 0 && ctype_upper( substr( $property, 4, 1 ) ) ) {
2214
+		if (strpos($property, 'xown') === 0 && ctype_upper(substr($property, 4, 1))) {
2215 2215
 			$property = substr($property, 1);
2216 2216
 		}
2217
-		unset( $this->properties[$property] );
2217
+		unset($this->properties[$property]);
2218 2218
 		$shadowKey = 'sys.shadow.'.$property;
2219
-		if ( isset( $this->__info[ $shadowKey ] ) ) unset( $this->__info[$shadowKey] );
2219
+		if (isset($this->__info[$shadowKey])) unset($this->__info[$shadowKey]);
2220 2220
 		//also clear modifiers
2221 2221
 		$this->clearModifiers();
2222 2222
 		return;
@@ -2240,7 +2240,7 @@  discard block
 block discarded – undo
2240 2240
 	 *
2241 2241
 	 * @return OODBBean
2242 2242
 	 */
2243
-	public function with( $sql, $bindings = array() )
2243
+	public function with($sql, $bindings = array())
2244 2244
 	{
2245 2245
 		$this->withSql    = $sql;
2246 2246
 		$this->withParams = $bindings;
@@ -2262,9 +2262,9 @@  discard block
 block discarded – undo
2262 2262
 	 *
2263 2263
 	 * @return OODBBean
2264 2264
 	 */
2265
-	public function withCondition( $sql, $bindings = array() )
2265
+	public function withCondition($sql, $bindings = array())
2266 2266
 	{
2267
-		$this->withSql    = ' AND ' . $sql;
2267
+		$this->withSql    = ' AND '.$sql;
2268 2268
 		$this->withParams = $bindings;
2269 2269
 		return $this;
2270 2270
 	}
@@ -2346,9 +2346,9 @@  discard block
 block discarded – undo
2346 2346
 	 *
2347 2347
 	 * @return OODBBean
2348 2348
 	 */
2349
-	public function alias( $aliasName )
2349
+	public function alias($aliasName)
2350 2350
 	{
2351
-		$this->aliasName = $this->beau( $aliasName );
2351
+		$this->aliasName = $this->beau($aliasName);
2352 2352
 		return $this;
2353 2353
 	}
2354 2354
 
@@ -2377,7 +2377,7 @@  discard block
 block discarded – undo
2377 2377
 	 */
2378 2378
 	public function getPropertiesAndType()
2379 2379
 	{
2380
-		return array( $this->properties, $this->__info['type'] );
2380
+		return array($this->properties, $this->__info['type']);
2381 2381
 	}
2382 2382
 
2383 2383
 	/**
@@ -2394,22 +2394,22 @@  discard block
 block discarded – undo
2394 2394
 	 *
2395 2395
 	 * @return string
2396 2396
 	 */
2397
-	public function beau( $property )
2397
+	public function beau($property)
2398 2398
 	{
2399 2399
 		static $beautifulColumns = array();
2400 2400
 
2401
-		if ( ctype_lower( $property ) ) return $property;
2401
+		if (ctype_lower($property)) return $property;
2402 2402
 		if (
2403
-			( strpos( $property, 'own' ) === 0 && ctype_upper( substr( $property, 3, 1 ) ) )
2404
-			|| ( strpos( $property, 'xown' ) === 0 && ctype_upper( substr( $property, 4, 1 ) ) )
2405
-			|| ( strpos( $property, 'shared' ) === 0 && ctype_upper( substr( $property, 6, 1 ) ) )
2403
+			(strpos($property, 'own') === 0 && ctype_upper(substr($property, 3, 1)))
2404
+			|| (strpos($property, 'xown') === 0 && ctype_upper(substr($property, 4, 1)))
2405
+			|| (strpos($property, 'shared') === 0 && ctype_upper(substr($property, 6, 1)))
2406 2406
 		) {
2407 2407
 
2408
-			$property = preg_replace( '/List$/', '', $property );
2408
+			$property = preg_replace('/List$/', '', $property);
2409 2409
 			return $property;
2410 2410
 		}
2411
-		if ( !isset( $beautifulColumns[$property] ) ) {
2412
-			$beautifulColumns[$property] = AQueryWriter::camelsSnake( $property );
2411
+		if (!isset($beautifulColumns[$property])) {
2412
+			$beautifulColumns[$property] = AQueryWriter::camelsSnake($property);
2413 2413
 		}
2414 2414
 		return $beautifulColumns[$property];
2415 2415
 	}
@@ -2464,15 +2464,15 @@  discard block
 block discarded – undo
2464 2464
 	 *
2465 2465
 	 * @return boolean
2466 2466
 	 */
2467
-	public function isListInExclusiveMode( $listName )
2467
+	public function isListInExclusiveMode($listName)
2468 2468
 	{
2469
-		$listName = $this->beau( $listName );
2469
+		$listName = $this->beau($listName);
2470 2470
 
2471
-		if ( strpos( $listName, 'xown' ) === 0 && ctype_upper( substr( $listName, 4, 1 ) ) ) {
2471
+		if (strpos($listName, 'xown') === 0 && ctype_upper(substr($listName, 4, 1))) {
2472 2472
 			$listName = substr($listName, 1);
2473 2473
 		}
2474
-		$listName = lcfirst( substr( $listName, 3 ) );
2475
-		return ( isset( $this->__info['sys.exclusive-'.$listName] ) && $this->__info['sys.exclusive-'.$listName] );
2474
+		$listName = lcfirst(substr($listName, 3));
2475
+		return (isset($this->__info['sys.exclusive-'.$listName]) && $this->__info['sys.exclusive-'.$listName]);
2476 2476
 	}
2477 2477
 
2478 2478
 	/**
@@ -2498,31 +2498,31 @@  discard block
 block discarded – undo
2498 2498
 	 *
2499 2499
 	 * @return mixed
2500 2500
 	 */
2501
-	public function &__get( $property )
2501
+	public function &__get($property)
2502 2502
 	{
2503 2503
 		$isEx          = FALSE;
2504 2504
 		$isOwn         = FALSE;
2505 2505
 		$isShared      = FALSE;
2506
-		if ( !ctype_lower( $property ) ) {
2507
-			$property = $this->beau( $property );
2508
-			if ( strpos( $property, 'xown' ) === 0 && ctype_upper( substr( $property, 4, 1 ) ) ) {
2506
+		if (!ctype_lower($property)) {
2507
+			$property = $this->beau($property);
2508
+			if (strpos($property, 'xown') === 0 && ctype_upper(substr($property, 4, 1))) {
2509 2509
 				$property = substr($property, 1);
2510
-				$listName = lcfirst( substr( $property, 3 ) );
2510
+				$listName = lcfirst(substr($property, 3));
2511 2511
 				$isEx     = TRUE;
2512 2512
 				$isOwn    = TRUE;
2513 2513
 				$this->__info['sys.exclusive-'.$listName] = TRUE;
2514
-			} elseif ( strpos( $property, 'own' ) === 0 && ctype_upper( substr( $property, 3, 1 ) ) )  {
2514
+			} elseif (strpos($property, 'own') === 0 && ctype_upper(substr($property, 3, 1))) {
2515 2515
 				$isOwn    = TRUE;
2516
-				$listName = lcfirst( substr( $property, 3 ) );
2517
-			} elseif ( strpos( $property, 'shared' ) === 0 && ctype_upper( substr( $property, 6, 1 ) ) ) {
2516
+				$listName = lcfirst(substr($property, 3));
2517
+			} elseif (strpos($property, 'shared') === 0 && ctype_upper(substr($property, 6, 1))) {
2518 2518
 				$isShared = TRUE;
2519 2519
 			}
2520 2520
 		}
2521
-		$fieldLink      = $property . '_id';
2522
-		$exists         = isset( $this->properties[$property] );
2521
+		$fieldLink      = $property.'_id';
2522
+		$exists         = isset($this->properties[$property]);
2523 2523
 
2524 2524
 		//If not exists and no field link and no list, bail out.
2525
-		if ( !$exists && !isset($this->$fieldLink) && (!$isOwn && !$isShared )) {
2525
+		if (!$exists && !isset($this->$fieldLink) && (!$isOwn && !$isShared)) {
2526 2526
 			$this->clearModifiers();
2527 2527
 			/**
2528 2528
 			 * Github issue:
@@ -2552,35 +2552,35 @@  discard block
 block discarded – undo
2552 2552
 		$hasAll         = (boolean) ($this->all);
2553 2553
 
2554 2554
 		//If exists and no list or exits and list not changed, bail out.
2555
-		if ( $exists && ((!$isOwn && !$isShared ) || (!$hasSQL && !$differentAlias && !$hasAll)) ) {
2555
+		if ($exists && ((!$isOwn && !$isShared) || (!$hasSQL && !$differentAlias && !$hasAll))) {
2556 2556
 			$this->clearModifiers();
2557 2557
 			return $this->properties[$property];
2558 2558
 		}
2559 2559
 
2560
-		list( $redbean, , , $toolbox ) = $this->beanHelper->getExtractedToolbox();
2560
+		list($redbean,,, $toolbox) = $this->beanHelper->getExtractedToolbox();
2561 2561
 
2562 2562
 		//If it's another bean, then we load it and return
2563
-		if ( isset( $this->$fieldLink ) ) {
2563
+		if (isset($this->$fieldLink)) {
2564 2564
 			$this->__info['tainted'] = TRUE;
2565
-			if ( isset( $this->__info["sys.parentcache.$property"] ) ) {
2565
+			if (isset($this->__info["sys.parentcache.$property"])) {
2566 2566
 				$bean = $this->__info["sys.parentcache.$property"];
2567 2567
 			} else {
2568
-				if ( isset( self::$aliases[$property] ) ) {
2568
+				if (isset(self::$aliases[$property])) {
2569 2569
 					$type = self::$aliases[$property];
2570
-				} elseif ( $this->fetchType ) {
2570
+				} elseif ($this->fetchType) {
2571 2571
 					$type = $this->fetchType;
2572 2572
 					$this->fetchType = NULL;
2573 2573
 				} else {
2574 2574
 					$type = $property;
2575 2575
 				}
2576 2576
 				$bean = NULL;
2577
-				if ( !is_null( $this->properties[$fieldLink] ) ) {
2578
-					$bean = $redbean->load( $type, $this->properties[$fieldLink] );
2577
+				if (!is_null($this->properties[$fieldLink])) {
2578
+					$bean = $redbean->load($type, $this->properties[$fieldLink]);
2579 2579
 					//If the IDs dont match, we failed to load, so try autoresolv in that case...
2580
-					if ( $bean->id !== $this->properties[$fieldLink] && self::$autoResolve ) {
2581
-						$type = $this->beanHelper->getToolbox()->getWriter()->inferFetchType( $this->__info['type'], $property );
2582
-						if ( !is_null( $type) ) {
2583
-							$bean = $redbean->load( $type, $this->properties[$fieldLink] );
2580
+					if ($bean->id !== $this->properties[$fieldLink] && self::$autoResolve) {
2581
+						$type = $this->beanHelper->getToolbox()->getWriter()->inferFetchType($this->__info['type'], $property);
2582
+						if (!is_null($type)) {
2583
+							$bean = $redbean->load($type, $this->properties[$fieldLink]);
2584 2584
 							$this->__info["sys.autoresolved.{$property}"] = $type;
2585 2585
 						}
2586 2586
 					}
@@ -2592,12 +2592,12 @@  discard block
 block discarded – undo
2592 2592
 		}
2593 2593
 
2594 2594
 		//Implicit: elseif ( $isOwn || $isShared ) {
2595
-		if ( $this->noLoad ) {
2595
+		if ($this->noLoad) {
2596 2596
 			$beans = array();
2597
-		} elseif ( $isOwn ) {
2598
-			$beans = $this->getOwnList( $listName, $redbean );
2597
+		} elseif ($isOwn) {
2598
+			$beans = $this->getOwnList($listName, $redbean);
2599 2599
 		} else {
2600
-			$beans = $this->getSharedList( lcfirst( substr( $property, 6 ) ), $redbean, $toolbox );
2600
+			$beans = $this->getSharedList(lcfirst(substr($property, 6)), $redbean, $toolbox);
2601 2601
 		}
2602 2602
 		$this->properties[$property]          = $beans;
2603 2603
 		$this->__info["sys.shadow.$property"] = $beans;
@@ -2620,47 +2620,47 @@  discard block
 block discarded – undo
2620 2620
 	 *
2621 2621
 	 * @return void
2622 2622
 	 */
2623
-	public function __set( $property, $value )
2623
+	public function __set($property, $value)
2624 2624
 	{
2625 2625
 		$isEx          = FALSE;
2626 2626
 		$isOwn         = FALSE;
2627 2627
 		$isShared      = FALSE;
2628 2628
 
2629
-		if ( !ctype_lower( $property ) ) {
2630
-			$property = $this->beau( $property );
2631
-			if ( strpos( $property, 'xown' ) === 0 && ctype_upper( substr( $property, 4, 1 ) ) ) {
2629
+		if (!ctype_lower($property)) {
2630
+			$property = $this->beau($property);
2631
+			if (strpos($property, 'xown') === 0 && ctype_upper(substr($property, 4, 1))) {
2632 2632
 				$property = substr($property, 1);
2633
-				$listName = lcfirst( substr( $property, 3 ) );
2633
+				$listName = lcfirst(substr($property, 3));
2634 2634
 				$isEx     = TRUE;
2635 2635
 				$isOwn    = TRUE;
2636 2636
 				$this->__info['sys.exclusive-'.$listName] = TRUE;
2637
-			} elseif ( strpos( $property, 'own' ) === 0 && ctype_upper( substr( $property, 3, 1 ) ) )  {
2637
+			} elseif (strpos($property, 'own') === 0 && ctype_upper(substr($property, 3, 1))) {
2638 2638
 				$isOwn    = TRUE;
2639
-				$listName = lcfirst( substr( $property, 3 ) );
2640
-			} elseif ( strpos( $property, 'shared' ) === 0 && ctype_upper( substr( $property, 6, 1 ) ) ) {
2639
+				$listName = lcfirst(substr($property, 3));
2640
+			} elseif (strpos($property, 'shared') === 0 && ctype_upper(substr($property, 6, 1))) {
2641 2641
 				$isShared = TRUE;
2642 2642
 			}
2643
-		} elseif ( self::$convertArraysToJSON && is_array( $value ) ) {
2644
-			$value = json_encode( $value );
2643
+		} elseif (self::$convertArraysToJSON && is_array($value)) {
2644
+			$value = json_encode($value);
2645 2645
 		}
2646 2646
 
2647 2647
 		$hasAlias       = (!is_null($this->aliasName));
2648 2648
 		$differentAlias = ($hasAlias && $isOwn && isset($this->__info['sys.alias.'.$listName])) ?
2649 2649
 								($this->__info['sys.alias.'.$listName] !== $this->aliasName) : FALSE;
2650 2650
 		$hasSQL         = ($this->withSql !== '' || $this->via !== NULL);
2651
-		$exists         = isset( $this->properties[$property] );
2652
-		$fieldLink      = $property . '_id';
2653
-		$isFieldLink	= (($pos = strrpos($property, '_id')) !== FALSE) && array_key_exists( ($fieldName = substr($property, 0, $pos)), $this->properties );
2651
+		$exists         = isset($this->properties[$property]);
2652
+		$fieldLink      = $property.'_id';
2653
+		$isFieldLink = (($pos = strrpos($property, '_id')) !== FALSE) && array_key_exists(($fieldName = substr($property, 0, $pos)), $this->properties);
2654 2654
 
2655 2655
 
2656
-		if ( ($isOwn || $isShared) &&  (!$exists || $hasSQL || $differentAlias) ) {
2656
+		if (($isOwn || $isShared) && (!$exists || $hasSQL || $differentAlias)) {
2657 2657
 
2658
-			if ( !$this->noLoad ) {
2659
-				list( $redbean, , , $toolbox ) = $this->beanHelper->getExtractedToolbox();
2660
-				if ( $isOwn ) {
2661
-					$beans = $this->getOwnList( $listName, $redbean );
2658
+			if (!$this->noLoad) {
2659
+				list($redbean,,, $toolbox) = $this->beanHelper->getExtractedToolbox();
2660
+				if ($isOwn) {
2661
+					$beans = $this->getOwnList($listName, $redbean);
2662 2662
 				} else {
2663
-					$beans = $this->getSharedList( lcfirst( substr( $property, 6 ) ), $redbean, $toolbox );
2663
+					$beans = $this->getSharedList(lcfirst(substr($property, 6)), $redbean, $toolbox);
2664 2664
 				}
2665 2665
 				$this->__info["sys.shadow.$property"] = $beans;
2666 2666
 			}
@@ -2670,32 +2670,32 @@  discard block
 block discarded – undo
2670 2670
 
2671 2671
 		$this->__info['tainted'] = TRUE;
2672 2672
 		$this->__info['changed'] = TRUE;
2673
-		array_push( $this->__info['changelist'], $property );
2673
+		array_push($this->__info['changelist'], $property);
2674 2674
 
2675
-		if ( array_key_exists( $fieldLink, $this->properties ) && !( $value instanceof OODBBean ) ) {
2676
-			if ( is_null( $value ) || $value === FALSE ) {
2675
+		if (array_key_exists($fieldLink, $this->properties) && !($value instanceof OODBBean)) {
2676
+			if (is_null($value) || $value === FALSE) {
2677 2677
 
2678
-				unset( $this->properties[ $property ]);
2679
-				$this->properties[ $fieldLink ] = NULL;
2678
+				unset($this->properties[$property]);
2679
+				$this->properties[$fieldLink] = NULL;
2680 2680
 
2681 2681
 				return;
2682 2682
 			} else {
2683
-				throw new RedException( 'Cannot cast to bean.' );
2683
+				throw new RedException('Cannot cast to bean.');
2684 2684
 			}
2685 2685
 		}
2686 2686
 		
2687
-		if ( $isFieldLink ){
2688
-			unset( $this->properties[ $fieldName ]);
2689
-			$this->properties[ $property ] = NULL;
2687
+		if ($isFieldLink) {
2688
+			unset($this->properties[$fieldName]);
2689
+			$this->properties[$property] = NULL;
2690 2690
 		}
2691 2691
 
2692 2692
 
2693
-		if ( $value === FALSE ) {
2693
+		if ($value === FALSE) {
2694 2694
 			$value = '0';
2695
-		} elseif ( $value === TRUE ) {
2695
+		} elseif ($value === TRUE) {
2696 2696
 			$value = '1';
2697 2697
 			/* for some reason there is some kind of bug in xdebug so that it doesnt count this line otherwise... */
2698
-		} elseif ( $value instanceof \DateTime ) { $value = $value->format( 'Y-m-d H:i:s' ); }
2698
+		} elseif ($value instanceof \DateTime) { $value = $value->format('Y-m-d H:i:s'); }
2699 2699
 		$this->properties[$property] = $value;
2700 2700
 	}
2701 2701
 
@@ -2717,15 +2717,15 @@  discard block
 block discarded – undo
2717 2717
 	 *
2718 2718
 	 * @return void
2719 2719
 	 */
2720
-	public function setProperty( $property, $value, $updateShadow = FALSE, $taint = FALSE )
2720
+	public function setProperty($property, $value, $updateShadow = FALSE, $taint = FALSE)
2721 2721
 	{
2722 2722
 		$this->properties[$property] = $value;
2723 2723
 
2724
-		if ( $updateShadow ) {
2725
-			$this->__info['sys.shadow.' . $property] = $value;
2724
+		if ($updateShadow) {
2725
+			$this->__info['sys.shadow.'.$property] = $value;
2726 2726
 		}
2727 2727
 
2728
-		if ( $taint ) {
2728
+		if ($taint) {
2729 2729
 			$this->__info['tainted'] = TRUE;
2730 2730
 			$this->__info['changed'] = TRUE;
2731 2731
 		}
@@ -2752,9 +2752,9 @@  discard block
 block discarded – undo
2752 2752
 	 *
2753 2753
 	 * @return mixed
2754 2754
 	 */
2755
-	public function getMeta( $path, $default = NULL )
2755
+	public function getMeta($path, $default = NULL)
2756 2756
 	{
2757
-		return ( isset( $this->__info[$path] ) ) ? $this->__info[$path] : $default;
2757
+		return (isset($this->__info[$path])) ? $this->__info[$path] : $default;
2758 2758
 	}
2759 2759
 
2760 2760
 	/**
@@ -2768,11 +2768,11 @@  discard block
 block discarded – undo
2768 2768
 	 *
2769 2769
 	 * @return mixed
2770 2770
 	 */
2771
-	public function moveMeta( $path, $value = NULL )
2771
+	public function moveMeta($path, $value = NULL)
2772 2772
 	{
2773
-		if ( isset( $this->__info[$path] ) ) {
2774
-			$value = $this->__info[ $path ];
2775
-			unset( $this->__info[ $path ] );
2773
+		if (isset($this->__info[$path])) {
2774
+			$value = $this->__info[$path];
2775
+			unset($this->__info[$path]);
2776 2776
 		}
2777 2777
 		return $value;
2778 2778
 	}
@@ -2790,11 +2790,11 @@  discard block
 block discarded – undo
2790 2790
 	 *
2791 2791
 	 * @return OODBBean
2792 2792
 	 */
2793
-	public function setMeta( $path, $value )
2793
+	public function setMeta($path, $value)
2794 2794
 	{
2795 2795
 		$this->__info[$path] = $value;
2796
-		if ( $path == 'type' && !empty($this->beanHelper)) {
2797
-			$this->__info['model'] = $this->beanHelper->getModelForBean( $this );
2796
+		if ($path == 'type' && !empty($this->beanHelper)) {
2797
+			$this->__info['model'] = $this->beanHelper->getModelForBean($this);
2798 2798
 		}
2799 2799
 
2800 2800
 		return $this;
@@ -2809,7 +2809,7 @@  discard block
 block discarded – undo
2809 2809
 	 *
2810 2810
 	 * @return OODBBean
2811 2811
 	 */
2812
-	public function copyMetaFrom( OODBBean $bean )
2812
+	public function copyMetaFrom(OODBBean $bean)
2813 2813
 	{
2814 2814
 		$this->__info = $bean->__info;
2815 2815
 
@@ -2838,41 +2838,41 @@  discard block
 block discarded – undo
2838 2838
 	 *
2839 2839
 	 * @return mixed
2840 2840
 	 */
2841
-	public function __call( $method, $args )
2841
+	public function __call($method, $args)
2842 2842
 	{
2843
-		if ( empty( $this->__info['model'] ) ) {
2843
+		if (empty($this->__info['model'])) {
2844 2844
 			return NULL;
2845 2845
 		}
2846 2846
 		
2847 2847
 		$overrideDontFail = FALSE;
2848
-		if ( strpos( $method, '@' ) === 0 ) {
2849
-			$method = substr( $method, 1 );
2848
+		if (strpos($method, '@') === 0) {
2849
+			$method = substr($method, 1);
2850 2850
 			$overrideDontFail = TRUE;
2851 2851
 		}
2852 2852
 		
2853
-		if ( !method_exists( $this->__info['model'], $method ) ) {
2853
+		if (!method_exists($this->__info['model'], $method)) {
2854 2854
 
2855
-			if ( self::$errorHandlingFUSE === FALSE || $overrideDontFail ) {
2855
+			if (self::$errorHandlingFUSE === FALSE || $overrideDontFail) {
2856 2856
 				return NULL;
2857 2857
 			}
2858 2858
 
2859
-			if ( in_array( $method, array( 'update', 'open', 'delete', 'after_delete', 'after_update', 'dispense' ), TRUE ) ) {
2859
+			if (in_array($method, array('update', 'open', 'delete', 'after_delete', 'after_update', 'dispense'), TRUE)) {
2860 2860
 				return NULL;
2861 2861
 			}
2862 2862
 
2863 2863
 			$message = "FUSE: method does not exist in model: $method";
2864
-			if ( self::$errorHandlingFUSE === self::C_ERR_LOG ) {
2865
-				error_log( $message );
2864
+			if (self::$errorHandlingFUSE === self::C_ERR_LOG) {
2865
+				error_log($message);
2866 2866
 				return NULL;
2867
-			} elseif ( self::$errorHandlingFUSE === self::C_ERR_NOTICE ) {
2868
-				trigger_error( $message, E_USER_NOTICE );
2867
+			} elseif (self::$errorHandlingFUSE === self::C_ERR_NOTICE) {
2868
+				trigger_error($message, E_USER_NOTICE);
2869 2869
 				return NULL;
2870
-			} elseif ( self::$errorHandlingFUSE === self::C_ERR_WARN ) {
2871
-				trigger_error( $message, E_USER_WARNING );
2870
+			} elseif (self::$errorHandlingFUSE === self::C_ERR_WARN) {
2871
+				trigger_error($message, E_USER_WARNING);
2872 2872
 				return NULL;
2873
-			} elseif ( self::$errorHandlingFUSE === self::C_ERR_EXCEPTION ) {
2874
-				throw new \Exception( $message );
2875
-			} elseif ( self::$errorHandlingFUSE === self::C_ERR_FUNC ) {
2873
+			} elseif (self::$errorHandlingFUSE === self::C_ERR_EXCEPTION) {
2874
+				throw new \Exception($message);
2875
+			} elseif (self::$errorHandlingFUSE === self::C_ERR_FUNC) {
2876 2876
 				$func = self::$errorHandler;
2877 2877
 				return $func(array(
2878 2878
 					'message' => $message,
@@ -2881,11 +2881,11 @@  discard block
 block discarded – undo
2881 2881
 					'bean' => $this
2882 2882
 				));
2883 2883
 			}
2884
-			trigger_error( $message, E_USER_ERROR );
2884
+			trigger_error($message, E_USER_ERROR);
2885 2885
 			return NULL;
2886 2886
 		}
2887 2887
 
2888
-		return call_user_func_array( array( $this->__info['model'], $method ), $args );
2888
+		return call_user_func_array(array($this->__info['model'], $method), $args);
2889 2889
 	}
2890 2890
 
2891 2891
 	/**
@@ -2900,20 +2900,20 @@  discard block
 block discarded – undo
2900 2900
 	 */
2901 2901
 	public function __toString()
2902 2902
 	{
2903
-		$string = $this->__call( '@__toString', array() );
2903
+		$string = $this->__call('@__toString', array());
2904 2904
 
2905
-		if ( $string === NULL ) {
2905
+		if ($string === NULL) {
2906 2906
 			$list = array();
2907
-			foreach($this->properties as $property => $value) {
2907
+			foreach ($this->properties as $property => $value) {
2908 2908
 				if (is_scalar($value)) {
2909
-					if ( self::$enforceUTF8encoding ) {
2909
+					if (self::$enforceUTF8encoding) {
2910 2910
 						$list[$property] = mb_convert_encoding($value, 'UTF-8', 'UTF-8');
2911 2911
 					} else {
2912 2912
 						$list[$property] = $value;
2913 2913
 					}
2914 2914
 				}
2915 2915
 			}
2916
-			$data = json_encode( $list );
2916
+			$data = json_encode($list);
2917 2917
 			return $data;
2918 2918
 		} else {
2919 2919
 			return $string;
@@ -2930,9 +2930,9 @@  discard block
 block discarded – undo
2930 2930
 	 *
2931 2931
 	 * @return void
2932 2932
 	 */
2933
-	public function offsetSet( $offset, $value )
2933
+	public function offsetSet($offset, $value)
2934 2934
 	{
2935
-		$this->__set( $offset, $value );
2935
+		$this->__set($offset, $value);
2936 2936
 	}
2937 2937
 
2938 2938
 	/**
@@ -2947,9 +2947,9 @@  discard block
 block discarded – undo
2947 2947
 	 *
2948 2948
 	 * @return boolean
2949 2949
 	 */
2950
-	public function offsetExists( $offset )
2950
+	public function offsetExists($offset)
2951 2951
 	{
2952
-		return $this->__isset( $offset );
2952
+		return $this->__isset($offset);
2953 2953
 	}
2954 2954
 
2955 2955
 	/**
@@ -2965,9 +2965,9 @@  discard block
 block discarded – undo
2965 2965
 	 *
2966 2966
 	 * @return void
2967 2967
 	 */
2968
-	public function offsetUnset( $offset )
2968
+	public function offsetUnset($offset)
2969 2969
 	{
2970
-		$this->__unset( $offset );
2970
+		$this->__unset($offset);
2971 2971
 	}
2972 2972
 
2973 2973
 	/**
@@ -2983,9 +2983,9 @@  discard block
 block discarded – undo
2983 2983
 	 *
2984 2984
 	 * @return mixed
2985 2985
 	 */
2986
-	public function &offsetGet( $offset )
2986
+	public function &offsetGet($offset)
2987 2987
 	{
2988
-		return $this->__get( $offset );
2988
+		return $this->__get($offset);
2989 2989
 	}
2990 2990
 
2991 2991
 	/**
@@ -2997,7 +2997,7 @@  discard block
 block discarded – undo
2997 2997
 	 *
2998 2998
 	 * @return OODBBean
2999 2999
 	 */
3000
-	public function fetchAs( $type )
3000
+	public function fetchAs($type)
3001 3001
 	{
3002 3002
 		$this->fetchType = $type;
3003 3003
 
@@ -3034,9 +3034,9 @@  discard block
 block discarded – undo
3034 3034
 	 *
3035 3035
 	 * @return OODBBean
3036 3036
 	 */
3037
-	public function poly( $field )
3037
+	public function poly($field)
3038 3038
 	{
3039
-		return $this->fetchAs( $this->$field );
3039
+		return $this->fetchAs($this->$field);
3040 3040
 	}
3041 3041
 
3042 3042
 	/**
@@ -3065,15 +3065,15 @@  discard block
 block discarded – undo
3065 3065
 	 * @return OODBBean
3066 3066
 	 * @throws RedException
3067 3067
 	 */
3068
-	public function traverse( $property, $function, $maxDepth = NULL )
3068
+	public function traverse($property, $function, $maxDepth = NULL)
3069 3069
 	{
3070 3070
 		$this->via = NULL;
3071
-		if ( strpos( $property, 'shared' ) !== FALSE ) {
3072
-			throw new RedException( 'Traverse only works with (x)own-lists.' );
3071
+		if (strpos($property, 'shared') !== FALSE) {
3072
+			throw new RedException('Traverse only works with (x)own-lists.');
3073 3073
 		}
3074 3074
 
3075
-		if ( !is_null( $maxDepth ) ) {
3076
-			if ( !$maxDepth-- ) return $this;
3075
+		if (!is_null($maxDepth)) {
3076
+			if (!$maxDepth--) return $this;
3077 3077
 		}
3078 3078
 
3079 3079
 		$oldFetchType = $this->fetchType;
@@ -3083,18 +3083,18 @@  discard block
 block discarded – undo
3083 3083
 
3084 3084
 		$beans = $this->$property;
3085 3085
 
3086
-		if ( $beans === NULL ) return $this;
3086
+		if ($beans === NULL) return $this;
3087 3087
 
3088
-		if ( !is_array( $beans ) ) $beans = array( $beans );
3088
+		if (!is_array($beans)) $beans = array($beans);
3089 3089
 
3090
-		foreach( $beans as $bean ) {
3091
-			$function( $bean );
3090
+		foreach ($beans as $bean) {
3091
+			$function($bean);
3092 3092
 			$bean->fetchType  = $oldFetchType;
3093 3093
 			$bean->aliasName  = $oldAliasName;
3094 3094
 			$bean->withSql    = $oldWith;
3095 3095
 			$bean->withParams = $oldBindings;
3096 3096
 
3097
-			$bean->traverse( $property, $function, $maxDepth );
3097
+			$bean->traverse($property, $function, $maxDepth);
3098 3098
 		}
3099 3099
 
3100 3100
 		return $this;
@@ -3125,7 +3125,7 @@  discard block
 block discarded – undo
3125 3125
 	 */
3126 3126
 	public function count()
3127 3127
 	{
3128
-		return count( $this->properties );
3128
+		return count($this->properties);
3129 3129
 	}
3130 3130
 
3131 3131
 	/**
@@ -3149,11 +3149,11 @@  discard block
 block discarded – undo
3149 3149
 	public function isEmpty()
3150 3150
 	{
3151 3151
 		$empty = TRUE;
3152
-		foreach ( $this->properties as $key => $value ) {
3153
-			if ( $key == 'id' ) {
3152
+		foreach ($this->properties as $key => $value) {
3153
+			if ($key == 'id') {
3154 3154
 				continue;
3155 3155
 			}
3156
-			if ( !empty( $value ) ) {
3156
+			if (!empty($value)) {
3157 3157
 				$empty = FALSE;
3158 3158
 			}
3159 3159
 		}
@@ -3182,7 +3182,7 @@  discard block
 block discarded – undo
3182 3182
 	 *
3183 3183
 	 * @return OODBBean
3184 3184
 	 */
3185
-	public function setAttr( $property, $value )
3185
+	public function setAttr($property, $value)
3186 3186
 	{
3187 3187
 		$this->$property = $value;
3188 3188
 
@@ -3208,11 +3208,11 @@  discard block
 block discarded – undo
3208 3208
 	 *
3209 3209
 	 * @return OODBBean
3210 3210
 	 */
3211
-	public function unsetAll( $properties )
3211
+	public function unsetAll($properties)
3212 3212
 	{
3213
-		foreach ( $properties as $prop ) {
3214
-			if ( isset( $this->properties[$prop] ) ) {
3215
-				unset( $this->properties[$prop] );
3213
+		foreach ($properties as $prop) {
3214
+			if (isset($this->properties[$prop])) {
3215
+				unset($this->properties[$prop]);
3216 3216
 			}
3217 3217
 		}
3218 3218
 		return $this;
@@ -3239,11 +3239,11 @@  discard block
 block discarded – undo
3239 3239
 	 *
3240 3240
 	 * @return mixed
3241 3241
 	 */
3242
-	public function old( $property )
3242
+	public function old($property)
3243 3243
 	{
3244
-		$old = $this->getMeta( 'sys.orig', array() );
3244
+		$old = $this->getMeta('sys.orig', array());
3245 3245
 
3246
-		if ( array_key_exists( $property, $old ) ) {
3246
+		if (array_key_exists($property, $old)) {
3247 3247
 			return $old[$property];
3248 3248
 		}
3249 3249
 
@@ -3264,7 +3264,7 @@  discard block
 block discarded – undo
3264 3264
 	 */
3265 3265
 	public function isTainted()
3266 3266
 	{
3267
-		return $this->getMeta( 'tainted' );
3267
+		return $this->getMeta('tainted');
3268 3268
 	}
3269 3269
 
3270 3270
 	/**
@@ -3280,10 +3280,10 @@  discard block
 block discarded – undo
3280 3280
 	 *
3281 3281
 	 * @return boolean
3282 3282
 	 */
3283
-	public function hasChanged( $property )
3283
+	public function hasChanged($property)
3284 3284
 	{
3285
-		return ( array_key_exists( $property, $this->properties ) ) ?
3286
-			$this->old( $property ) != $this->properties[$property] : FALSE;
3285
+		return (array_key_exists($property, $this->properties)) ?
3286
+			$this->old($property) != $this->properties[$property] : FALSE;
3287 3287
 	}
3288 3288
 
3289 3289
 	/**
@@ -3309,13 +3309,13 @@  discard block
 block discarded – undo
3309 3309
 	 *
3310 3310
 	 * @return boolean
3311 3311
 	 */
3312
-	public function hasListChanged( $property )
3312
+	public function hasListChanged($property)
3313 3313
 	{
3314
-		if ( !array_key_exists( $property, $this->properties ) ) return FALSE;
3315
-		$diffAdded = array_diff_assoc( $this->properties[$property], $this->__info['sys.shadow.'.$property] );
3316
-		if ( count( $diffAdded ) ) return TRUE;
3317
-		$diffMissing = array_diff_assoc( $this->__info['sys.shadow.'.$property], $this->properties[$property] );
3318
-		if ( count( $diffMissing ) ) return TRUE;
3314
+		if (!array_key_exists($property, $this->properties)) return FALSE;
3315
+		$diffAdded = array_diff_assoc($this->properties[$property], $this->__info['sys.shadow.'.$property]);
3316
+		if (count($diffAdded)) return TRUE;
3317
+		$diffMissing = array_diff_assoc($this->__info['sys.shadow.'.$property], $this->properties[$property]);
3318
+		if (count($diffMissing)) return TRUE;
3319 3319
 		return FALSE;
3320 3320
 	}
3321 3321
 
@@ -3344,14 +3344,14 @@  discard block
 block discarded – undo
3344 3344
 	public function clearHistory()
3345 3345
 	{
3346 3346
 		$this->__info['sys.orig'] = array();
3347
-		foreach( $this->properties as $key => $value ) {
3348
-			if ( is_scalar($value) ) {
3347
+		foreach ($this->properties as $key => $value) {
3348
+			if (is_scalar($value)) {
3349 3349
 				$this->__info['sys.orig'][$key] = $value;
3350 3350
 			} else {
3351 3351
 				$this->__info['sys.shadow.'.$key] = $value;
3352 3352
 			}
3353 3353
 		}
3354
-		$this->__info[ 'changelist' ] = array();
3354
+		$this->__info['changelist'] = array();
3355 3355
 		return $this;
3356 3356
 	}
3357 3357
 
@@ -3384,24 +3384,24 @@  discard block
 block discarded – undo
3384 3384
 	 *
3385 3385
 	 * @return OODBBean
3386 3386
 	 */
3387
-	public function link( $typeOrBean, $qualification = array() )
3387
+	public function link($typeOrBean, $qualification = array())
3388 3388
 	{
3389
-		if ( is_string( $typeOrBean ) ) {
3390
-			$typeOrBean = AQueryWriter::camelsSnake( $typeOrBean );
3391
-			$bean = $this->beanHelper->getToolBox()->getRedBean()->dispense( $typeOrBean );
3392
-			if ( is_string( $qualification ) ) {
3393
-				$data = json_decode( $qualification, TRUE );
3389
+		if (is_string($typeOrBean)) {
3390
+			$typeOrBean = AQueryWriter::camelsSnake($typeOrBean);
3391
+			$bean = $this->beanHelper->getToolBox()->getRedBean()->dispense($typeOrBean);
3392
+			if (is_string($qualification)) {
3393
+				$data = json_decode($qualification, TRUE);
3394 3394
 			} else {
3395 3395
 				$data = $qualification;
3396 3396
 			}
3397
-			foreach ( $data as $key => $value ) {
3397
+			foreach ($data as $key => $value) {
3398 3398
 				$bean->$key = $value;
3399 3399
 			}
3400 3400
 		} else {
3401 3401
 			$bean = $typeOrBean;
3402 3402
 		}
3403
-		$list = 'own' . ucfirst( $bean->getMeta( 'type' ) );
3404
-		array_push( $this->$list, $bean );
3403
+		$list = 'own'.ucfirst($bean->getMeta('type'));
3404
+		array_push($this->$list, $bean);
3405 3405
 		return $bean;
3406 3406
 	}
3407 3407
 
@@ -3427,11 +3427,11 @@  discard block
 block discarded – undo
3427 3427
 	 *
3428 3428
 	 * @return OODBBean
3429 3429
 	 */
3430
-	public function one( $type ) {
3430
+	public function one($type) {
3431 3431
 		return $this->beanHelper
3432 3432
 			->getToolBox()
3433 3433
 			->getRedBean()
3434
-			->load( $type, $this->id );
3434
+			->load($type, $this->id);
3435 3435
 	}
3436 3436
 
3437 3437
 	/**
@@ -3466,7 +3466,7 @@  discard block
 block discarded – undo
3466 3466
 		return $this->beanHelper
3467 3467
 			->getToolbox()
3468 3468
 			->getRedBean()
3469
-			->load( $this->getMeta( 'type' ), $this->properties['id'] );
3469
+			->load($this->getMeta('type'), $this->properties['id']);
3470 3470
 	}
3471 3471
 
3472 3472
 	/**
@@ -3511,9 +3511,9 @@  discard block
 block discarded – undo
3511 3511
 	 *
3512 3512
 	 * @return OODBBean
3513 3513
 	 */
3514
-	public function via( $via )
3514
+	public function via($via)
3515 3515
 	{
3516
-		$this->via = AQueryWriter::camelsSnake( $via );
3516
+		$this->via = AQueryWriter::camelsSnake($via);
3517 3517
 
3518 3518
 		return $this;
3519 3519
 	}
@@ -3540,29 +3540,29 @@  discard block
 block discarded – undo
3540 3540
 	 *
3541 3541
 	 * @return integer
3542 3542
 	 */
3543
-	public function countOwn( $type )
3543
+	public function countOwn($type)
3544 3544
 	{
3545
-		$type = $this->beau( $type );
3546
-		if ( $this->aliasName ) {
3547
-			$myFieldLink     = $this->aliasName . '_id';
3545
+		$type = $this->beau($type);
3546
+		if ($this->aliasName) {
3547
+			$myFieldLink     = $this->aliasName.'_id';
3548 3548
 			$this->aliasName = NULL;
3549 3549
 		} else {
3550
-			$myFieldLink = $this->__info['type'] . '_id';
3550
+			$myFieldLink = $this->__info['type'].'_id';
3551 3551
 		}
3552 3552
 		$count = 0;
3553
-		if ( $this->getID() ) {
3554
-			reset( $this->withParams );
3555
-			$joinSql = $this->parseJoin( $type );
3556
-			$firstKey = count( $this->withParams ) > 0
3557
-				? key( $this->withParams )
3553
+		if ($this->getID()) {
3554
+			reset($this->withParams);
3555
+			$joinSql = $this->parseJoin($type);
3556
+			$firstKey = count($this->withParams) > 0
3557
+				? key($this->withParams)
3558 3558
 				: 0;
3559
-			if ( is_int( $firstKey ) ) {
3560
-				$bindings = array_merge( array( $this->getID() ), $this->withParams );
3561
-				$count    = $this->beanHelper->getToolbox()->getWriter()->queryRecordCount( $type, array(), "{$joinSql} $myFieldLink = ? " . $this->withSql, $bindings );
3559
+			if (is_int($firstKey)) {
3560
+				$bindings = array_merge(array($this->getID()), $this->withParams);
3561
+				$count    = $this->beanHelper->getToolbox()->getWriter()->queryRecordCount($type, array(), "{$joinSql} $myFieldLink = ? ".$this->withSql, $bindings);
3562 3562
 			} else {
3563 3563
 				$bindings           = $this->withParams;
3564 3564
 				$bindings[':slot0'] = $this->getID();
3565
-				$count              = $this->beanHelper->getToolbox()->getWriter()->queryRecordCount( $type, array(), "{$joinSql} $myFieldLink = :slot0 " . $this->withSql, $bindings );
3565
+				$count              = $this->beanHelper->getToolbox()->getWriter()->queryRecordCount($type, array(), "{$joinSql} $myFieldLink = :slot0 ".$this->withSql, $bindings);
3566 3566
 			}
3567 3567
 		}
3568 3568
 		$this->clearModifiers();
@@ -3592,23 +3592,23 @@  discard block
 block discarded – undo
3592 3592
 	 *
3593 3593
 	 * @return integer
3594 3594
 	 */
3595
-	public function countShared( $type )
3595
+	public function countShared($type)
3596 3596
 	{
3597 3597
 		$toolbox = $this->beanHelper->getToolbox();
3598 3598
 		$redbean = $toolbox->getRedBean();
3599 3599
 		$writer  = $toolbox->getWriter();
3600
-		if ( $this->via ) {
3601
-			$oldName = $writer->getAssocTable( array( $this->__info['type'], $type ) );
3602
-			if ( $oldName !== $this->via ) {
3600
+		if ($this->via) {
3601
+			$oldName = $writer->getAssocTable(array($this->__info['type'], $type));
3602
+			if ($oldName !== $this->via) {
3603 3603
 				//set the new renaming rule
3604
-				$writer->renameAssocTable( $oldName, $this->via );
3604
+				$writer->renameAssocTable($oldName, $this->via);
3605 3605
 				$this->via = NULL;
3606 3606
 			}
3607 3607
 		}
3608
-		$type  = $this->beau( $type );
3608
+		$type  = $this->beau($type);
3609 3609
 		$count = 0;
3610
-		if ( $this->getID() ) {
3611
-			$count = $redbean->getAssociationManager()->relatedCount( $this, $type, $this->withSql, $this->withParams );
3610
+		if ($this->getID()) {
3611
+			$count = $redbean->getAssociationManager()->relatedCount($this, $type, $this->withSql, $this->withParams);
3612 3612
 		}
3613 3613
 		$this->clearModifiers();
3614 3614
 		return (integer) $count;
@@ -3640,33 +3640,33 @@  discard block
 block discarded – undo
3640 3640
 	 *
3641 3641
 	 * @return array
3642 3642
 	 */
3643
-	public function &aggr( $list, $property, $type = NULL )
3643
+	public function &aggr($list, $property, $type = NULL)
3644 3644
 	{
3645 3645
 		$this->via = NULL;
3646 3646
 		$ids = $beanIndex = $references = array();
3647 3647
 
3648
-		if ( strlen( $list ) < 4 ) throw new RedException('Invalid own-list.');
3649
-		if ( strpos( $list, 'own') !== 0 ) throw new RedException('Only own-lists can be aggregated.');
3650
-		if ( !ctype_upper( substr( $list, 3, 1 ) ) ) throw new RedException('Invalid own-list.');
3648
+		if (strlen($list) < 4) throw new RedException('Invalid own-list.');
3649
+		if (strpos($list, 'own') !== 0) throw new RedException('Only own-lists can be aggregated.');
3650
+		if (!ctype_upper(substr($list, 3, 1))) throw new RedException('Invalid own-list.');
3651 3651
 
3652
-		if ( is_null( $type ) ) $type = $property;
3652
+		if (is_null($type)) $type = $property;
3653 3653
 
3654
-		foreach( $this->$list as $bean ) {
3655
-			$field = $property . '_id';
3656
-			if ( isset( $bean->$field)  ) {
3654
+		foreach ($this->$list as $bean) {
3655
+			$field = $property.'_id';
3656
+			if (isset($bean->$field)) {
3657 3657
 				$ids[] = $bean->$field;
3658 3658
 				$beanIndex[$bean->$field] = $bean;
3659 3659
 			}
3660 3660
 		}
3661 3661
 
3662
-		$beans = $this->beanHelper->getToolBox()->getRedBean()->batch( $type, $ids );
3662
+		$beans = $this->beanHelper->getToolBox()->getRedBean()->batch($type, $ids);
3663 3663
 
3664 3664
 		//now preload the beans as well
3665
-		foreach( $beans as $bean ) {
3666
-			$beanIndex[$bean->id]->setProperty( $property, $bean );
3665
+		foreach ($beans as $bean) {
3666
+			$beanIndex[$bean->id]->setProperty($property, $bean);
3667 3667
 		}
3668 3668
 
3669
-		foreach( $beanIndex as $indexedBean ) {
3669
+		foreach ($beanIndex as $indexedBean) {
3670 3670
 			$references[] = $indexedBean->$property;
3671 3671
 		}
3672 3672
 
@@ -3702,8 +3702,8 @@  discard block
 block discarded – undo
3702 3702
 	public function equals(OODBBean $bean)
3703 3703
 	{
3704 3704
 		return (bool) (
3705
-			   ( (string) $this->properties['id'] === (string) $bean->properties['id'] )
3706
-			&& ( (string) $this->__info['type']   === (string) $bean->__info['type']   )
3705
+			   ((string) $this->properties['id'] === (string) $bean->properties['id'])
3706
+			&& ((string) $this->__info['type'] === (string) $bean->__info['type'])
3707 3707
 		);
3708 3708
 	}
3709 3709
 
@@ -3726,9 +3726,9 @@  discard block
 block discarded – undo
3726 3726
 	 */
3727 3727
 	public function jsonSerialize()
3728 3728
 	{
3729
-		$json = $this->__call( '@__jsonSerialize', array( ) );
3729
+		$json = $this->__call('@__jsonSerialize', array( ));
3730 3730
 
3731
-		if ( $json !== NULL ) {
3731
+		if ($json !== NULL) {
3732 3732
 			return $json;
3733 3733
 		}
3734 3734
 
@@ -3773,13 +3773,13 @@  discard block
 block discarded – undo
3773 3773
 	 *
3774 3774
 	 * @return void
3775 3775
 	 */
3776
-	public function addEventListener( $eventname, Observer $observer )
3776
+	public function addEventListener($eventname, Observer $observer)
3777 3777
 	{
3778
-		if ( !isset( $this->observers[$eventname] ) ) {
3778
+		if (!isset($this->observers[$eventname])) {
3779 3779
 			$this->observers[$eventname] = array();
3780 3780
 		}
3781 3781
 
3782
-		if ( in_array( $observer, $this->observers[$eventname] ) ) {
3782
+		if (in_array($observer, $this->observers[$eventname])) {
3783 3783
 			return;
3784 3784
 		}
3785 3785
 
@@ -3797,14 +3797,14 @@  discard block
 block discarded – undo
3797 3797
 	 *
3798 3798
 	 * @return void
3799 3799
 	 */
3800
-	public function signal( $eventname, $info )
3800
+	public function signal($eventname, $info)
3801 3801
 	{
3802
-		if ( !isset( $this->observers[$eventname] ) ) {
3802
+		if (!isset($this->observers[$eventname])) {
3803 3803
 			$this->observers[$eventname] = array();
3804 3804
 		}
3805 3805
 
3806
-		foreach ( $this->observers[$eventname] as $observer ) {
3807
-			$observer->onEvent( $eventname, $info );
3806
+		foreach ($this->observers[$eventname] as $observer) {
3807
+			$observer->onEvent($eventname, $info);
3808 3808
 		}
3809 3809
 	}
3810 3810
 }
@@ -3841,7 +3841,7 @@  discard block
 block discarded – undo
3841 3841
 	 *
3842 3842
 	 * @return void
3843 3843
 	 */
3844
-	public function onEvent( $eventname, $bean );
3844
+	public function onEvent($eventname, $bean);
3845 3845
 }
3846 3846
 }
3847 3847
 
@@ -3884,7 +3884,7 @@  discard block
 block discarded – undo
3884 3884
 	 *
3885 3885
 	 * @return void
3886 3886
 	 */
3887
-	public function exec( $sql, $bindings = array(), $noevent = FALSE );
3887
+	public function exec($sql, $bindings = array(), $noevent = FALSE);
3888 3888
 
3889 3889
 	/**
3890 3890
 	 * Executes an SQL Query and returns a resultset.
@@ -3897,7 +3897,7 @@  discard block
 block discarded – undo
3897 3897
 	 *
3898 3898
 	 * @return array
3899 3899
 	 */
3900
-	public function get( $sql, $bindings = array() );
3900
+	public function get($sql, $bindings = array());
3901 3901
 
3902 3902
 	/**
3903 3903
 	 * Executes an SQL Query and returns a resultset.
@@ -3910,7 +3910,7 @@  discard block
 block discarded – undo
3910 3910
 	 *
3911 3911
 	 * @return array
3912 3912
 	 */
3913
-	public function getRow( $sql, $bindings = array() );
3913
+	public function getRow($sql, $bindings = array());
3914 3914
 
3915 3915
 	/**
3916 3916
 	 * Executes an SQL Query and returns a resultset.
@@ -3923,7 +3923,7 @@  discard block
 block discarded – undo
3923 3923
 	 *
3924 3924
 	 * @return array
3925 3925
 	 */
3926
-	public function getCol( $sql, $bindings = array() );
3926
+	public function getCol($sql, $bindings = array());
3927 3927
 
3928 3928
 	/**
3929 3929
 	 * Executes an SQL Query and returns a resultset.
@@ -3936,7 +3936,7 @@  discard block
 block discarded – undo
3936 3936
 	 *
3937 3937
 	 * @return string
3938 3938
 	 */
3939
-	public function getCell( $sql, $bindings = array() );
3939
+	public function getCell($sql, $bindings = array());
3940 3940
 
3941 3941
 	/**
3942 3942
 	 * Executes the SQL query specified in $sql and takes
@@ -3951,7 +3951,7 @@  discard block
 block discarded – undo
3951 3951
 	 *
3952 3952
 	 * @return array
3953 3953
 	 */
3954
-	public function getAssoc( $sql, $bindings = array() );
3954
+	public function getAssoc($sql, $bindings = array());
3955 3955
 
3956 3956
 	/**
3957 3957
 	 * Executes the SQL query specified in $sql and indexes
@@ -3962,7 +3962,7 @@  discard block
 block discarded – undo
3962 3962
 	 *
3963 3963
 	 * @return array
3964 3964
 	 */
3965
-	public function getAssocRow( $sql, $bindings = array() );
3965
+	public function getAssocRow($sql, $bindings = array());
3966 3966
 
3967 3967
 	/**
3968 3968
 	 * Returns the latest insert ID.
@@ -3987,7 +3987,7 @@  discard block
 block discarded – undo
3987 3987
 	 *
3988 3988
 	 * @return Cursor
3989 3989
 	 */
3990
-	public function getCursor( $sql, $bindings = array() );
3990
+	public function getCursor($sql, $bindings = array());
3991 3991
 
3992 3992
 	/**
3993 3993
 	 * Returns the original database resource. This is useful if you want to
@@ -4045,7 +4045,7 @@  discard block
 block discarded – undo
4045 4045
 	 *
4046 4046
 	 * @return boolean
4047 4047
 	 */
4048
-	public function setOption( $optionKey, $optionValue );
4048
+	public function setOption($optionKey, $optionValue);
4049 4049
 }
4050 4050
 }
4051 4051
 
@@ -4120,7 +4120,7 @@  discard block
 block discarded – undo
4120 4120
 	 *
4121 4121
 	 * @param Driver $database ADO Compatible DB Instance
4122 4122
 	 */
4123
-	public function __construct( $database )
4123
+	public function __construct($database)
4124 4124
 	{
4125 4125
 		$this->db = $database;
4126 4126
 	}
@@ -4146,76 +4146,76 @@  discard block
 block discarded – undo
4146 4146
 	/**
4147 4147
 	 * @see Adapter::exec
4148 4148
 	 */
4149
-	public function exec( $sql, $bindings = array(), $noevent = FALSE )
4149
+	public function exec($sql, $bindings = array(), $noevent = FALSE)
4150 4150
 	{
4151
-		if ( !$noevent ) {
4151
+		if (!$noevent) {
4152 4152
 			$this->sql = $sql;
4153
-			$this->signal( 'sql_exec', $this );
4153
+			$this->signal('sql_exec', $this);
4154 4154
 		}
4155 4155
 
4156
-		return $this->db->Execute( $sql, $bindings );
4156
+		return $this->db->Execute($sql, $bindings);
4157 4157
 	}
4158 4158
 
4159 4159
 	/**
4160 4160
 	 * @see Adapter::get
4161 4161
 	 */
4162
-	public function get( $sql, $bindings = array() )
4162
+	public function get($sql, $bindings = array())
4163 4163
 	{
4164 4164
 		$this->sql = $sql;
4165
-		$this->signal( 'sql_exec', $this );
4165
+		$this->signal('sql_exec', $this);
4166 4166
 
4167
-		return $this->db->GetAll( $sql, $bindings );
4167
+		return $this->db->GetAll($sql, $bindings);
4168 4168
 	}
4169 4169
 
4170 4170
 	/**
4171 4171
 	 * @see Adapter::getRow
4172 4172
 	 */
4173
-	public function getRow( $sql, $bindings = array() )
4173
+	public function getRow($sql, $bindings = array())
4174 4174
 	{
4175 4175
 		$this->sql = $sql;
4176
-		$this->signal( 'sql_exec', $this );
4176
+		$this->signal('sql_exec', $this);
4177 4177
 
4178
-		return $this->db->GetRow( $sql, $bindings );
4178
+		return $this->db->GetRow($sql, $bindings);
4179 4179
 	}
4180 4180
 
4181 4181
 	/**
4182 4182
 	 * @see Adapter::getCol
4183 4183
 	 */
4184
-	public function getCol( $sql, $bindings = array() )
4184
+	public function getCol($sql, $bindings = array())
4185 4185
 	{
4186 4186
 		$this->sql = $sql;
4187
-		$this->signal( 'sql_exec', $this );
4187
+		$this->signal('sql_exec', $this);
4188 4188
 
4189
-		return $this->db->GetCol( $sql, $bindings );
4189
+		return $this->db->GetCol($sql, $bindings);
4190 4190
 	}
4191 4191
 
4192 4192
 	/**
4193 4193
 	 * @see Adapter::getAssoc
4194 4194
 	 */
4195
-	public function getAssoc( $sql, $bindings = array() )
4195
+	public function getAssoc($sql, $bindings = array())
4196 4196
 	{
4197 4197
 		$this->sql = $sql;
4198 4198
 
4199
-		$this->signal( 'sql_exec', $this );
4199
+		$this->signal('sql_exec', $this);
4200 4200
 
4201
-		$rows  = $this->db->GetAll( $sql, $bindings );
4201
+		$rows = $this->db->GetAll($sql, $bindings);
4202 4202
 
4203
-		if ( !$rows ) {
4203
+		if (!$rows) {
4204 4204
 			return array();
4205 4205
 		}
4206 4206
 
4207 4207
 		$assoc = array();
4208 4208
 		
4209
-		foreach ( $rows as $row ) {
4210
-			if ( empty( $row ) ) continue;
4209
+		foreach ($rows as $row) {
4210
+			if (empty($row)) continue;
4211 4211
 
4212
-			$key   = array_shift( $row );
4213
-			switch ( count( $row ) ) {
4212
+			$key = array_shift($row);
4213
+			switch (count($row)) {
4214 4214
 				case 0:
4215 4215
 					$value = $key;
4216 4216
 					break;
4217 4217
 				case 1:
4218
-					$value = reset( $row );
4218
+					$value = reset($row);
4219 4219
 					break;
4220 4220
 				default:
4221 4221
 					$value = $row;
@@ -4233,29 +4233,29 @@  discard block
 block discarded – undo
4233 4233
 	public function getAssocRow($sql, $bindings = array())
4234 4234
 	{
4235 4235
 		$this->sql = $sql;
4236
-		$this->signal( 'sql_exec', $this );
4236
+		$this->signal('sql_exec', $this);
4237 4237
 
4238
-		return $this->db->GetAssocRow( $sql, $bindings );
4238
+		return $this->db->GetAssocRow($sql, $bindings);
4239 4239
 	}
4240 4240
 
4241 4241
 	/**
4242 4242
 	 * @see Adapter::getCell
4243 4243
 	 */
4244
-	public function getCell( $sql, $bindings = array(), $noSignal = NULL )
4244
+	public function getCell($sql, $bindings = array(), $noSignal = NULL)
4245 4245
 	{
4246 4246
 		$this->sql = $sql;
4247 4247
 
4248
-		if ( !$noSignal ) $this->signal( 'sql_exec', $this );
4248
+		if (!$noSignal) $this->signal('sql_exec', $this);
4249 4249
 
4250
-		return $this->db->GetOne( $sql, $bindings );
4250
+		return $this->db->GetOne($sql, $bindings);
4251 4251
 	}
4252 4252
 
4253 4253
 	/**
4254 4254
 	 * @see Adapter::getCursor
4255 4255
 	 */
4256
-	public function getCursor( $sql, $bindings = array() )
4256
+	public function getCursor($sql, $bindings = array())
4257 4257
 	{
4258
-		return $this->db->GetCursor( $sql, $bindings );
4258
+		return $this->db->GetCursor($sql, $bindings);
4259 4259
 	}
4260 4260
 
4261 4261
 	/**
@@ -4317,9 +4317,9 @@  discard block
 block discarded – undo
4317 4317
 	/**
4318 4318
 	 * @see Adapter::setOption
4319 4319
 	 */
4320
-	public function setOption( $optionKey, $optionValue ) {
4321
-		if ( method_exists( $this->db, $optionKey ) ) {
4322
-			call_user_func( array( $this->db, $optionKey ), $optionValue );
4320
+	public function setOption($optionKey, $optionValue) {
4321
+		if (method_exists($this->db, $optionKey)) {
4322
+			call_user_func(array($this->db, $optionKey), $optionValue);
4323 4323
 			return TRUE;
4324 4324
 		}
4325 4325
 		return FALSE;
@@ -4417,7 +4417,7 @@  discard block
 block discarded – undo
4417 4417
 	 *
4418 4418
 	 * @return void
4419 4419
 	 */
4420
-	public function __construct( \PDOStatement $res, $fetchStyle )
4420
+	public function __construct(\PDOStatement $res, $fetchStyle)
4421 4421
 	{
4422 4422
 		$this->res = $res;
4423 4423
 		$this->fetchStyle = $fetchStyle;
@@ -4552,7 +4552,7 @@  discard block
 block discarded – undo
4552 4552
 	 *
4553 4553
 	 * @return void
4554 4554
 	 */
4555
-	public function __construct( $type, Repository $repository, Cursor $cursor )
4555
+	public function __construct($type, Repository $repository, Cursor $cursor)
4556 4556
 	{
4557 4557
 		$this->type = $type;
4558 4558
 		$this->cursor = $cursor;
@@ -4570,9 +4570,9 @@  discard block
 block discarded – undo
4570 4570
 	public function next()
4571 4571
 	{
4572 4572
 		$row = $this->cursor->getNextItem();
4573
-		if ( $row ) {
4574
-			$beans = $this->repository->convertToBeans( $this->type, array( $row ) );
4575
-			return reset( $beans );
4573
+		if ($row) {
4574
+			$beans = $this->repository->convertToBeans($this->type, array($row));
4575
+			return reset($beans);
4576 4576
 		}
4577 4577
 		return NULL;
4578 4578
 	}
@@ -4676,7 +4676,7 @@  discard block
 block discarded – undo
4676 4676
 	 *
4677 4677
 	 * @return string $joinSQLSnippet
4678 4678
 	 */
4679
-	public function writeJoin( $type, $targetType, $joinType );
4679
+	public function writeJoin($type, $targetType, $joinType);
4680 4680
 
4681 4681
 	/**
4682 4682
 	 * Glues an SQL snippet to the beginning of a WHERE clause.
@@ -4709,7 +4709,7 @@  discard block
 block discarded – undo
4709 4709
 	 *
4710 4710
 	 * @return string
4711 4711
 	 */
4712
-	public function glueSQLCondition( $sql, $glue = NULL );
4712
+	public function glueSQLCondition($sql, $glue = NULL);
4713 4713
 
4714 4714
 	/**
4715 4715
 	 * Determines if there is a LIMIT 1 clause in the SQL.
@@ -4722,7 +4722,7 @@  discard block
 block discarded – undo
4722 4722
 	 *
4723 4723
 	 * @return string
4724 4724
 	 */
4725
-	public function glueLimitOne( $sql );
4725
+	public function glueLimitOne($sql);
4726 4726
 
4727 4727
 	/**
4728 4728
 	 * Returns the tables that are in the database.
@@ -4739,7 +4739,7 @@  discard block
 block discarded – undo
4739 4739
 	 *
4740 4740
 	 * @return void
4741 4741
 	 */
4742
-	public function createTable( $type );
4742
+	public function createTable($type);
4743 4743
 
4744 4744
 	/**
4745 4745
 	 * Returns an array containing all the columns of the specified type.
@@ -4753,7 +4753,7 @@  discard block
 block discarded – undo
4753 4753
 	 *
4754 4754
 	 * @return array
4755 4755
 	 */
4756
-	public function getColumns( $type );
4756
+	public function getColumns($type);
4757 4757
 
4758 4758
 	/**
4759 4759
 	 * Returns the Column Type Code (integer) that corresponds
@@ -4775,7 +4775,7 @@  discard block
 block discarded – undo
4775 4775
 	 *
4776 4776
 	 * @return integer
4777 4777
 	 */
4778
-	public function scanType( $value, $alsoScanSpecialForTypes = FALSE );
4778
+	public function scanType($value, $alsoScanSpecialForTypes = FALSE);
4779 4779
 
4780 4780
 	/**
4781 4781
 	 * This method will add a column to a table.
@@ -4787,7 +4787,7 @@  discard block
 block discarded – undo
4787 4787
 	 *
4788 4788
 	 * @return void
4789 4789
 	 */
4790
-	public function addColumn( $type, $column, $field );
4790
+	public function addColumn($type, $column, $field);
4791 4791
 
4792 4792
 	/**
4793 4793
 	 * Returns the Type Code for a Column Description.
@@ -4801,7 +4801,7 @@  discard block
 block discarded – undo
4801 4801
 	 *
4802 4802
 	 * @return integer
4803 4803
 	 */
4804
-	public function code( $typedescription, $includeSpecials = FALSE );
4804
+	public function code($typedescription, $includeSpecials = FALSE);
4805 4805
 
4806 4806
 	/**
4807 4807
 	 * This method will widen the column to the specified data type.
@@ -4813,7 +4813,7 @@  discard block
 block discarded – undo
4813 4813
 	 *
4814 4814
 	 * @return void
4815 4815
 	 */
4816
-	public function widenColumn( $type, $column, $datatype );
4816
+	public function widenColumn($type, $column, $datatype);
4817 4817
 
4818 4818
 	/**
4819 4819
 	 * Selects records from the database.
@@ -4827,7 +4827,7 @@  discard block
 block discarded – undo
4827 4827
 	 *
4828 4828
 	 * @return array
4829 4829
 	 */
4830
-	public function queryRecord( $type, $conditions = array(), $addSql = NULL, $bindings = array() );
4830
+	public function queryRecord($type, $conditions = array(), $addSql = NULL, $bindings = array());
4831 4831
 
4832 4832
 	/**
4833 4833
 	 * Selects records from the database and returns a cursor.
@@ -4841,7 +4841,7 @@  discard block
 block discarded – undo
4841 4841
 	 *
4842 4842
 	 * @return Cursor
4843 4843
 	 */
4844
-	public function queryRecordWithCursor( $type, $addSql = NULL, $bindings = array() );
4844
+	public function queryRecordWithCursor($type, $addSql = NULL, $bindings = array());
4845 4845
 
4846 4846
 	/**
4847 4847
 	 * Returns records through an intermediate type. This method is used to obtain records using a link table and
@@ -4855,7 +4855,7 @@  discard block
 block discarded – undo
4855 4855
 	 *
4856 4856
 	 * @return array
4857 4857
 	 */
4858
-	public function queryRecordRelated( $sourceType, $destType, $linkID, $addSql = '', $bindings = array() );
4858
+	public function queryRecordRelated($sourceType, $destType, $linkID, $addSql = '', $bindings = array());
4859 4859
 
4860 4860
 	/**
4861 4861
 	 * Returns the row that links $sourceType $sourcID to $destType $destID in an N-M relation.
@@ -4867,7 +4867,7 @@  discard block
 block discarded – undo
4867 4867
 	 *
4868 4868
 	 * @return array|null
4869 4869
 	 */
4870
-	public function queryRecordLink( $sourceType, $destType, $sourceID, $destID );
4870
+	public function queryRecordLink($sourceType, $destType, $sourceID, $destID);
4871 4871
 
4872 4872
 	/**
4873 4873
 	 * Counts the number of records in the database that match the
@@ -4880,7 +4880,7 @@  discard block
 block discarded – undo
4880 4880
 	 *
4881 4881
 	 * @return integer
4882 4882
 	 */
4883
-	public function queryRecordCount( $type, $conditions = array(), $addSql = NULL, $bindings = array() );
4883
+	public function queryRecordCount($type, $conditions = array(), $addSql = NULL, $bindings = array());
4884 4884
 
4885 4885
 	/**
4886 4886
 	 * Returns the number of records linked through $linkType and satisfying the SQL in $addSQL/$bindings.
@@ -4893,7 +4893,7 @@  discard block
 block discarded – undo
4893 4893
 	 *
4894 4894
 	 * @return integer
4895 4895
 	 */
4896
-	public function queryRecordCountRelated( $sourceType, $targetType, $linkID, $addSQL = '', $bindings = array() );
4896
+	public function queryRecordCountRelated($sourceType, $targetType, $linkID, $addSQL = '', $bindings = array());
4897 4897
 
4898 4898
 	/**
4899 4899
 	 * Returns all rows of specified type that have been tagged with one of the
@@ -4910,7 +4910,7 @@  discard block
 block discarded – undo
4910 4910
 	 *
4911 4911
 	 * @return array
4912 4912
 	 */
4913
-	public function queryTagged( $type, $tagList, $all = FALSE, $addSql = '', $bindings = array() );
4913
+	public function queryTagged($type, $tagList, $all = FALSE, $addSql = '', $bindings = array());
4914 4914
 
4915 4915
 	/**
4916 4916
 	 * Like queryTagged but only counts.
@@ -4923,7 +4923,7 @@  discard block
 block discarded – undo
4923 4923
 	 *
4924 4924
 	 * @return integer
4925 4925
 	 */
4926
-	public function queryCountTagged( $type, $tagList, $all = FALSE, $addSql = '', $bindings = array() );
4926
+	public function queryCountTagged($type, $tagList, $all = FALSE, $addSql = '', $bindings = array());
4927 4927
 
4928 4928
 	/**
4929 4929
 	 * Returns all parent rows or child rows of a specified row.
@@ -4939,7 +4939,7 @@  discard block
 block discarded – undo
4939 4939
 	 *
4940 4940
 	 * @return array
4941 4941
 	 */
4942
-	public function queryRecursiveCommonTableExpression( $type, $id, $up = TRUE, $addSql = NULL, $bindings = array() );
4942
+	public function queryRecursiveCommonTableExpression($type, $id, $up = TRUE, $addSql = NULL, $bindings = array());
4943 4943
 
4944 4944
 	/**
4945 4945
 	 * This method should update (or insert a record), it takes
@@ -4955,7 +4955,7 @@  discard block
 block discarded – undo
4955 4955
 	 *
4956 4956
 	 * @return integer
4957 4957
 	 */
4958
-	public function updateRecord( $type, $updatevalues, $id = NULL );
4958
+	public function updateRecord($type, $updatevalues, $id = NULL);
4959 4959
 
4960 4960
 	/**
4961 4961
 	 * Deletes records from the database.
@@ -4968,7 +4968,7 @@  discard block
 block discarded – undo
4968 4968
 	 *
4969 4969
 	 * @return void
4970 4970
 	 */
4971
-	public function deleteRecord( $type, $conditions = array(), $addSql = '', $bindings = array() );
4971
+	public function deleteRecord($type, $conditions = array(), $addSql = '', $bindings = array());
4972 4972
 
4973 4973
 	/**
4974 4974
 	 * Deletes all links between $sourceType and $destType in an N-M relation.
@@ -4979,12 +4979,12 @@  discard block
 block discarded – undo
4979 4979
 	 *
4980 4980
 	 * @return void
4981 4981
 	 */
4982
-	public function deleteRelations( $sourceType, $destType, $sourceID );
4982
+	public function deleteRelations($sourceType, $destType, $sourceID);
4983 4983
 
4984 4984
 	/**
4985 4985
 	 * @see QueryWriter::addUniqueConstaint
4986 4986
 	 */
4987
-	public function addUniqueIndex( $type, $columns );
4987
+	public function addUniqueIndex($type, $columns);
4988 4988
 
4989 4989
 	/**
4990 4990
 	 * This method will add a UNIQUE constraint index to a table on columns $columns.
@@ -4995,7 +4995,7 @@  discard block
 block discarded – undo
4995 4995
 	 *
4996 4996
 	 * @return void
4997 4997
 	 */
4998
-	public function addUniqueConstraint( $type, $columns );
4998
+	public function addUniqueConstraint($type, $columns);
4999 4999
 
5000 5000
 	/**
5001 5001
 	 * This method will check whether the SQL state is in the list of specified states
@@ -5012,7 +5012,7 @@  discard block
 block discarded – undo
5012 5012
 	 *
5013 5013
 	 * @return boolean
5014 5014
 	 */
5015
-	public function sqlStateIn( $state, $list, $extraDriverDetails = array() );
5015
+	public function sqlStateIn($state, $list, $extraDriverDetails = array());
5016 5016
 
5017 5017
 	/**
5018 5018
 	 * This method will remove all beans of a certain type.
@@ -5022,7 +5022,7 @@  discard block
 block discarded – undo
5022 5022
 	 *
5023 5023
 	 * @return void
5024 5024
 	 */
5025
-	public function wipe( $type );
5025
+	public function wipe($type);
5026 5026
 
5027 5027
 	/**
5028 5028
 	 * This method will add a foreign key from type and field to
@@ -5042,7 +5042,7 @@  discard block
 block discarded – undo
5042 5042
 	 *
5043 5043
 	 * @return void
5044 5044
 	 */
5045
-	public function addFK( $type, $targetType, $property, $targetProperty, $isDep = FALSE );
5045
+	public function addFK($type, $targetType, $property, $targetProperty, $isDep = FALSE);
5046 5046
 
5047 5047
 	/**
5048 5048
 	 * This method will add an index to a type and field with name
@@ -5055,7 +5055,7 @@  discard block
 block discarded – undo
5055 5055
 	 *
5056 5056
 	 * @return void
5057 5057
 	 */
5058
-	public function addIndex( $type, $name, $property );
5058
+	public function addIndex($type, $name, $property);
5059 5059
 
5060 5060
 	/**
5061 5061
 	 * Checks and filters a database structure element like a table of column
@@ -5069,7 +5069,7 @@  discard block
 block discarded – undo
5069 5069
 	 *
5070 5070
 	 * @return string
5071 5071
 	 */
5072
-	public function esc( $databaseStructure, $dontQuote = FALSE );
5072
+	public function esc($databaseStructure, $dontQuote = FALSE);
5073 5073
 
5074 5074
 	/**
5075 5075
 	 * Removes all tables and views from the database.
@@ -5103,7 +5103,7 @@  discard block
 block discarded – undo
5103 5103
 	 *
5104 5104
 	 * @return void
5105 5105
 	 */
5106
-	public function renameAssocTable( $fromType, $toType = NULL );
5106
+	public function renameAssocTable($fromType, $toType = NULL);
5107 5107
 
5108 5108
 	/**
5109 5109
 	 * Returns the format for link tables.
@@ -5116,7 +5116,7 @@  discard block
 block discarded – undo
5116 5116
 	 *
5117 5117
 	 * @return string
5118 5118
 	 */
5119
-	public function getAssocTable( $types );
5119
+	public function getAssocTable($types);
5120 5120
 
5121 5121
 	/**
5122 5122
 	 * Given a bean type and a property, this method
@@ -5133,7 +5133,7 @@  discard block
 block discarded – undo
5133 5133
 	 *
5134 5134
 	 * @return string|NULL
5135 5135
 	 */
5136
-	public function inferFetchType( $type, $property );
5136
+	public function inferFetchType($type, $property);
5137 5137
 }
5138 5138
 }
5139 5139
 
@@ -5252,7 +5252,7 @@  discard block
 block discarded – undo
5252 5252
 	 *
5253 5253
 	 * @return boolean
5254 5254
 	 */
5255
-	public static function useJSONColumns( $flag )
5255
+	public static function useJSONColumns($flag)
5256 5256
 	{
5257 5257
 		$old = self::$flagUseJSONColumns;
5258 5258
 		self::$flagUseJSONColumns = $flag;
@@ -5268,7 +5268,7 @@  discard block
 block discarded – undo
5268 5268
 	 *
5269 5269
 	 * @return boolean
5270 5270
 	 */
5271
-	public static function forbidNuke( $flag ) {
5271
+	public static function forbidNuke($flag) {
5272 5272
 		$old = self::$noNuke;
5273 5273
 		self::$noNuke = (bool) $flag;
5274 5274
 		return $old;
@@ -5281,30 +5281,30 @@  discard block
 block discarded – undo
5281 5281
 	 *
5282 5282
 	 * @return boolean
5283 5283
 	 */
5284
-	public static function canBeTreatedAsInt( $value )
5284
+	public static function canBeTreatedAsInt($value)
5285 5285
 	{
5286
-		return (bool) ( strval( $value ) === strval( intval( $value ) ) );
5286
+		return (bool) (strval($value) === strval(intval($value)));
5287 5287
 	}
5288 5288
 
5289 5289
 	/**
5290 5290
 	 * @see QueryWriter::getAssocTableFormat
5291 5291
 	 */
5292
-	public static function getAssocTableFormat( $types )
5292
+	public static function getAssocTableFormat($types)
5293 5293
 	{
5294
-		sort( $types );
5294
+		sort($types);
5295 5295
 
5296
-		$assoc = implode( '_', $types );
5296
+		$assoc = implode('_', $types);
5297 5297
 
5298
-		return ( isset( self::$renames[$assoc] ) ) ? self::$renames[$assoc] : $assoc;
5298
+		return (isset(self::$renames[$assoc])) ? self::$renames[$assoc] : $assoc;
5299 5299
 	}
5300 5300
 
5301 5301
 	/**
5302 5302
 	 * @see QueryWriter::renameAssociation
5303 5303
 	 */
5304
-	public static function renameAssociation( $from, $to = NULL )
5304
+	public static function renameAssociation($from, $to = NULL)
5305 5305
 	{
5306
-		if ( is_array( $from ) ) {
5307
-			foreach ( $from as $key => $value ) self::$renames[$key] = $value;
5306
+		if (is_array($from)) {
5307
+			foreach ($from as $key => $value) self::$renames[$key] = $value;
5308 5308
 
5309 5309
 			return;
5310 5310
 		}
@@ -5320,9 +5320,9 @@  discard block
 block discarded – undo
5320 5320
 	 *
5321 5321
 	 * @return string
5322 5322
 	 */
5323
-	public static function camelsSnake( $camel )
5323
+	public static function camelsSnake($camel)
5324 5324
 	{
5325
-		return strtolower( preg_replace( '/(?<=[a-z])([A-Z])|([A-Z])(?=[a-z])/', '_$1$2', $camel ) );
5325
+		return strtolower(preg_replace('/(?<=[a-z])([A-Z])|([A-Z])(?=[a-z])/', '_$1$2', $camel));
5326 5326
 	}
5327 5327
 
5328 5328
 	/**
@@ -5356,7 +5356,7 @@  discard block
 block discarded – undo
5356 5356
 	 *
5357 5357
 	 * @return void
5358 5358
 	 */
5359
-	public static function setNarrowFieldMode( $narrowField )
5359
+	public static function setNarrowFieldMode($narrowField)
5360 5360
 	{
5361 5361
 		self::$flagNarrowFieldMode = (boolean) $narrowField;
5362 5362
 	}
@@ -5396,7 +5396,7 @@  discard block
 block discarded – undo
5396 5396
 	 *
5397 5397
 	 * @return void
5398 5398
 	 */
5399
-	public static function setSQLFilters( $sqlFilters, $safeMode = FALSE )
5399
+	public static function setSQLFilters($sqlFilters, $safeMode = FALSE)
5400 5400
 	{
5401 5401
 		self::$flagSQLFilterSafeMode = (boolean) $safeMode;
5402 5402
 		self::$sqlFilters = $sqlFilters;
@@ -5424,9 +5424,9 @@  discard block
 block discarded – undo
5424 5424
 	 *
5425 5425
 	 * @return string
5426 5426
 	 */
5427
-	private function getCacheKey( $keyValues )
5427
+	private function getCacheKey($keyValues)
5428 5428
 	{
5429
-		return json_encode( $keyValues );
5429
+		return json_encode($keyValues);
5430 5430
 	}
5431 5431
 
5432 5432
 	/**
@@ -5437,11 +5437,11 @@  discard block
 block discarded – undo
5437 5437
 	 *
5438 5438
 	 * @return mixed
5439 5439
 	 */
5440
-	private function getCached( $cacheTag, $key )
5440
+	private function getCached($cacheTag, $key)
5441 5441
 	{
5442 5442
 		$sql = $this->adapter->getSQL();
5443 5443
 		if ($this->updateCache()) {
5444
-			if ( isset( $this->cache[$cacheTag][$key] ) ) {
5444
+			if (isset($this->cache[$cacheTag][$key])) {
5445 5445
 				return $this->cache[$cacheTag][$key];
5446 5446
 			}
5447 5447
 		}
@@ -5461,7 +5461,7 @@  discard block
 block discarded – undo
5461 5461
 	private function updateCache()
5462 5462
 	{
5463 5463
 		$sql = $this->adapter->getSQL();
5464
-		if ( strpos( $sql, '-- keep-cache' ) !== strlen( $sql ) - 13 ) {
5464
+		if (strpos($sql, '-- keep-cache') !== strlen($sql) - 13) {
5465 5465
 			// If SQL has been taken place outside of this method then something else then
5466 5466
 			// a select query might have happened! (or instruct to keep cache)
5467 5467
 			$this->cache = array();
@@ -5488,10 +5488,10 @@  discard block
 block discarded – undo
5488 5488
 	 *
5489 5489
 	 * @return void
5490 5490
 	 */
5491
-	private function putResultInCache( $cacheTag, $key, $values )
5491
+	private function putResultInCache($cacheTag, $key, $values)
5492 5492
 	{
5493
-		if ( isset( $this->cache[$cacheTag] ) ) {
5494
-			if ( count( $this->cache[$cacheTag] ) > $this->maxCacheSizePerType ) array_shift( $this->cache[$cacheTag] );
5493
+		if (isset($this->cache[$cacheTag])) {
5494
+			if (count($this->cache[$cacheTag]) > $this->maxCacheSizePerType) array_shift($this->cache[$cacheTag]);
5495 5495
 		} else {
5496 5496
 			$this->cache[$cacheTag] = array();
5497 5497
 		}
@@ -5515,69 +5515,69 @@  discard block
 block discarded – undo
5515 5515
 	 *
5516 5516
 	 * @return string
5517 5517
 	 */
5518
-	private function makeSQLFromConditions( $conditions, &$bindings, $addSql = '' )
5518
+	private function makeSQLFromConditions($conditions, &$bindings, $addSql = '')
5519 5519
 	{
5520
-		reset( $bindings );
5521
-		$firstKey       = key( $bindings );
5522
-		$paramTypeIsNum = ( is_numeric( $firstKey ) );
5520
+		reset($bindings);
5521
+		$firstKey       = key($bindings);
5522
+		$paramTypeIsNum = (is_numeric($firstKey));
5523 5523
 		$counter        = 0;
5524 5524
 
5525 5525
 		$sqlConditions = array();
5526
-		foreach ( $conditions as $column => $values ) {
5527
-			if ( $values === NULL ) continue;
5526
+		foreach ($conditions as $column => $values) {
5527
+			if ($values === NULL) continue;
5528 5528
 
5529
-			if ( is_array( $values ) ) {
5530
-				if ( empty( $values ) ) continue;
5529
+			if (is_array($values)) {
5530
+				if (empty($values)) continue;
5531 5531
 			} else {
5532
-				$values = array( $values );
5532
+				$values = array($values);
5533 5533
 			}
5534 5534
 
5535
-			$checkOODB = reset( $values );
5536
-			if ( $checkOODB instanceof OODBBean && $checkOODB->getMeta( 'type' ) === $column && substr( $column, -3 ) != '_id' )
5537
-				$column = $column . '_id';
5535
+			$checkOODB = reset($values);
5536
+			if ($checkOODB instanceof OODBBean && $checkOODB->getMeta('type') === $column && substr($column, -3) != '_id')
5537
+				$column = $column.'_id';
5538 5538
 
5539 5539
 
5540
-			$sql = $this->esc( $column );
5540
+			$sql = $this->esc($column);
5541 5541
 			$sql .= ' IN ( ';
5542 5542
 
5543
-			if ( $paramTypeIsNum ) {
5544
-				$sql .= implode( ',', array_fill( 0, count( $values ), '?' ) ) . ' ) ';
5543
+			if ($paramTypeIsNum) {
5544
+				$sql .= implode(',', array_fill(0, count($values), '?')).' ) ';
5545 5545
 
5546 5546
 				array_unshift($sqlConditions, $sql);
5547 5547
 
5548
-				foreach ( $values as $k => $v ) {
5549
-					if ( $v instanceof OODBBean ) {
5548
+				foreach ($values as $k => $v) {
5549
+					if ($v instanceof OODBBean) {
5550 5550
 						$v = $v->id;
5551 5551
 					}
5552
-					$values[$k] = strval( $v );
5552
+					$values[$k] = strval($v);
5553 5553
 
5554
-					array_unshift( $bindings, $v );
5554
+					array_unshift($bindings, $v);
5555 5555
 				}
5556 5556
 			} else {
5557 5557
 
5558 5558
 				$slots = array();
5559 5559
 
5560
-				foreach( $values as $k => $v ) {
5561
-					if ( $v instanceof OODBBean ) {
5560
+				foreach ($values as $k => $v) {
5561
+					if ($v instanceof OODBBean) {
5562 5562
 						$v = $v->id;
5563 5563
 					}
5564 5564
 					$slot            = ':slot'.$counter++;
5565 5565
 					$slots[]         = $slot;
5566
-					$bindings[$slot] = strval( $v );
5566
+					$bindings[$slot] = strval($v);
5567 5567
 				}
5568 5568
 
5569
-				$sql .= implode( ',', $slots ).' ) ';
5569
+				$sql .= implode(',', $slots).' ) ';
5570 5570
 				$sqlConditions[] = $sql;
5571 5571
 			}
5572 5572
 		}
5573 5573
 
5574 5574
 		$sql = '';
5575
-		if ( !empty( $sqlConditions ) ) {
5576
-			$sql .= " WHERE ( " . implode( ' AND ', $sqlConditions ) . ") ";
5575
+		if (!empty($sqlConditions)) {
5576
+			$sql .= " WHERE ( ".implode(' AND ', $sqlConditions).") ";
5577 5577
 		}
5578 5578
 
5579
-		$addSql = $this->glueSQLCondition( $addSql, !empty( $sqlConditions ) ? QueryWriter::C_GLUE_AND : NULL );
5580
-		if ( $addSql ) $sql .= $addSql;
5579
+		$addSql = $this->glueSQLCondition($addSql, !empty($sqlConditions) ? QueryWriter::C_GLUE_AND : NULL);
5580
+		if ($addSql) $sql .= $addSql;
5581 5581
 
5582 5582
 		return $sql;
5583 5583
 	}
@@ -5591,21 +5591,21 @@  discard block
 block discarded – undo
5591 5591
 	 *
5592 5592
 	 * @return array
5593 5593
 	 */
5594
-	private function getRelationalTablesAndColumns( $sourceType, $destType, $noQuote = FALSE )
5594
+	private function getRelationalTablesAndColumns($sourceType, $destType, $noQuote = FALSE)
5595 5595
 	{
5596
-		$linkTable   = $this->esc( $this->getAssocTable( array( $sourceType, $destType ) ), $noQuote );
5597
-		$sourceCol   = $this->esc( $sourceType . '_id', $noQuote );
5596
+		$linkTable   = $this->esc($this->getAssocTable(array($sourceType, $destType)), $noQuote);
5597
+		$sourceCol   = $this->esc($sourceType.'_id', $noQuote);
5598 5598
 
5599
-		if ( $sourceType === $destType ) {
5600
-			$destCol = $this->esc( $destType . '2_id', $noQuote );
5599
+		if ($sourceType === $destType) {
5600
+			$destCol = $this->esc($destType.'2_id', $noQuote);
5601 5601
 		} else {
5602
-			$destCol = $this->esc( $destType . '_id', $noQuote );
5602
+			$destCol = $this->esc($destType.'_id', $noQuote);
5603 5603
 		}
5604 5604
 
5605
-		$sourceTable = $this->esc( $sourceType, $noQuote );
5606
-		$destTable   = $this->esc( $destType, $noQuote );
5605
+		$sourceTable = $this->esc($sourceType, $noQuote);
5606
+		$destTable   = $this->esc($destType, $noQuote);
5607 5607
 
5608
-		return array( $sourceTable, $destTable, $linkTable, $sourceCol, $destCol );
5608
+		return array($sourceTable, $destTable, $linkTable, $sourceCol, $destCol);
5609 5609
 	}
5610 5610
 
5611 5611
 	/**
@@ -5618,7 +5618,7 @@  discard block
 block discarded – undo
5618 5618
 	 *
5619 5619
 	 * @return boolean
5620 5620
 	 */
5621
-	protected function isJSON( $value )
5621
+	protected function isJSON($value)
5622 5622
 	{
5623 5623
 		return (
5624 5624
 			is_string($value) &&
@@ -5636,18 +5636,18 @@  discard block
 block discarded – undo
5636 5636
 	 *
5637 5637
 	 * @return array|NULL
5638 5638
 	 */
5639
-	protected function getForeignKeyForTypeProperty( $type, $property )
5639
+	protected function getForeignKeyForTypeProperty($type, $property)
5640 5640
 	{
5641
-		$property = $this->esc( $property, TRUE );
5641
+		$property = $this->esc($property, TRUE);
5642 5642
 
5643 5643
 		try {
5644
-			$map = $this->getKeyMapForType( $type );
5645
-		} catch ( SQLException $e ) {
5644
+			$map = $this->getKeyMapForType($type);
5645
+		} catch (SQLException $e) {
5646 5646
 			return NULL;
5647 5647
 		}
5648 5648
 
5649
-		foreach( $map as $key ) {
5650
-			if ( $key['from'] === $property ) return $key;
5649
+		foreach ($map as $key) {
5650
+			if ($key['from'] === $property) return $key;
5651 5651
 		}
5652 5652
 		return NULL;
5653 5653
 	}
@@ -5675,7 +5675,7 @@  discard block
 block discarded – undo
5675 5675
 	 *
5676 5676
 	 * @return array
5677 5677
 	 */
5678
-	protected function getKeyMapForType( $type )
5678
+	protected function getKeyMapForType($type)
5679 5679
 	{
5680 5680
 		return array();
5681 5681
 	}
@@ -5706,22 +5706,22 @@  discard block
 block discarded – undo
5706 5706
 	 *
5707 5707
 	 * @return string
5708 5708
 	 */
5709
-	protected function getSQLFilterSnippet( $type )
5709
+	protected function getSQLFilterSnippet($type)
5710 5710
 	{
5711 5711
 		$existingCols = array();
5712 5712
 		if (self::$flagSQLFilterSafeMode) {
5713
-			$existingCols = $this->getColumns( $type );
5713
+			$existingCols = $this->getColumns($type);
5714 5714
 		}
5715 5715
 
5716 5716
 		$sqlFilters = array();
5717
-		if ( isset( self::$sqlFilters[QueryWriter::C_SQLFILTER_READ][$type] ) ) {
5718
-			foreach( self::$sqlFilters[QueryWriter::C_SQLFILTER_READ][$type] as $property => $sqlFilter ) {
5719
-				if ( !self::$flagSQLFilterSafeMode || isset( $existingCols[$property] ) ) {
5717
+		if (isset(self::$sqlFilters[QueryWriter::C_SQLFILTER_READ][$type])) {
5718
+			foreach (self::$sqlFilters[QueryWriter::C_SQLFILTER_READ][$type] as $property => $sqlFilter) {
5719
+				if (!self::$flagSQLFilterSafeMode || isset($existingCols[$property])) {
5720 5720
 					$sqlFilters[] = $sqlFilter.' AS '.$property.' ';
5721 5721
 				}
5722 5722
 			}
5723 5723
 		}
5724
-		$sqlFilterStr = ( count($sqlFilters) ) ? ( ','.implode( ',', $sqlFilters ) ) : '';
5724
+		$sqlFilterStr = (count($sqlFilters)) ? (','.implode(',', $sqlFilters)) : '';
5725 5725
 		return $sqlFilterStr;
5726 5726
 	}
5727 5727
 
@@ -5741,20 +5741,20 @@  discard block
 block discarded – undo
5741 5741
 	 *
5742 5742
 	 * @return string
5743 5743
 	 */
5744
-	protected function getParametersForInClause( &$valueList, $otherBindings, $offset = 0 )
5744
+	protected function getParametersForInClause(&$valueList, $otherBindings, $offset = 0)
5745 5745
 	{
5746
-		if ( is_array( $otherBindings ) && count( $otherBindings ) > 0 ) {
5747
-			reset( $otherBindings );
5746
+		if (is_array($otherBindings) && count($otherBindings) > 0) {
5747
+			reset($otherBindings);
5748 5748
 
5749
-			$key = key( $otherBindings );
5749
+			$key = key($otherBindings);
5750 5750
 
5751
-			if ( !is_numeric($key) ) {
5751
+			if (!is_numeric($key)) {
5752 5752
 				$filler  = array();
5753 5753
 				$newList = (!$offset) ? array() : $valueList;
5754 5754
 				$counter = $offset;
5755 5755
 
5756
-				foreach( $valueList as $value ) {
5757
-					$slot           = ':slot' . ( $counter++ );
5756
+				foreach ($valueList as $value) {
5757
+					$slot           = ':slot'.($counter++);
5758 5758
 					$filler[]       = $slot;
5759 5759
 					$newList[$slot] = $value;
5760 5760
 				}
@@ -5762,11 +5762,11 @@  discard block
 block discarded – undo
5762 5762
 				// Change the keys!
5763 5763
 				$valueList = $newList;
5764 5764
 
5765
-				return implode( ',', $filler );
5765
+				return implode(',', $filler);
5766 5766
 			}
5767 5767
 		}
5768 5768
 
5769
-		return implode( ',', array_fill( 0, count( $valueList ), '?' ) );
5769
+		return implode(',', array_fill(0, count($valueList), '?'));
5770 5770
 	}
5771 5771
 
5772 5772
 	/**
@@ -5779,10 +5779,10 @@  discard block
 block discarded – undo
5779 5779
 	 *
5780 5780
 	 * @return self
5781 5781
 	 */
5782
-	protected function addDataType( $dataTypeID, $SQLDefinition )
5782
+	protected function addDataType($dataTypeID, $SQLDefinition)
5783 5783
 	{
5784
-		$this->typeno_sqltype[ $dataTypeID ] = $SQLDefinition;
5785
-		$this->sqltype_typeno[ $SQLDefinition ] = $dataTypeID;
5784
+		$this->typeno_sqltype[$dataTypeID] = $SQLDefinition;
5785
+		$this->sqltype_typeno[$SQLDefinition] = $dataTypeID;
5786 5786
 		return $this;
5787 5787
 	}
5788 5788
 
@@ -5793,7 +5793,7 @@  discard block
 block discarded – undo
5793 5793
 	 *
5794 5794
 	 * @return string
5795 5795
 	 */
5796
-	protected function getInsertSuffix( $table )
5796
+	protected function getInsertSuffix($table)
5797 5797
 	{
5798 5798
 		return '';
5799 5799
 	}
@@ -5807,11 +5807,11 @@  discard block
 block discarded – undo
5807 5807
 	 *
5808 5808
 	 * @return boolean
5809 5809
 	 */
5810
-	protected function startsWithZeros( $value )
5810
+	protected function startsWithZeros($value)
5811 5811
 	{
5812
-		$value = strval( $value );
5812
+		$value = strval($value);
5813 5813
 
5814
-		if ( strlen( $value ) > 1 && strpos( $value, '0' ) === 0 && strpos( $value, '0.' ) !== 0 ) {
5814
+		if (strlen($value) > 1 && strpos($value, '0') === 0 && strpos($value, '0.') !== 0) {
5815 5815
 			return TRUE;
5816 5816
 		} else {
5817 5817
 			return FALSE;
@@ -5828,17 +5828,17 @@  discard block
 block discarded – undo
5828 5828
 	 *
5829 5829
 	 * @return integer
5830 5830
 	 */
5831
-	protected function insertRecord( $type, $insertcolumns, $insertvalues )
5831
+	protected function insertRecord($type, $insertcolumns, $insertvalues)
5832 5832
 	{
5833 5833
 		$default = $this->defaultValue;
5834
-		$suffix  = $this->getInsertSuffix( $type );
5835
-		$table   = $this->esc( $type );
5834
+		$suffix  = $this->getInsertSuffix($type);
5835
+		$table   = $this->esc($type);
5836 5836
 
5837
-		if ( count( $insertvalues ) > 0 && is_array( $insertvalues[0] ) && count( $insertvalues[0] ) > 0 ) {
5837
+		if (count($insertvalues) > 0 && is_array($insertvalues[0]) && count($insertvalues[0]) > 0) {
5838 5838
 
5839 5839
 			$insertSlots = array();
5840
-			foreach ( $insertcolumns as $k => $v ) {
5841
-				$insertcolumns[$k] = $this->esc( $v );
5840
+			foreach ($insertcolumns as $k => $v) {
5841
+				$insertcolumns[$k] = $this->esc($v);
5842 5842
 
5843 5843
 				if (isset(self::$sqlFilters['w'][$type][$v])) {
5844 5844
 					$insertSlots[] = self::$sqlFilters['w'][$type][$v];
@@ -5847,20 +5847,20 @@  discard block
 block discarded – undo
5847 5847
 				}
5848 5848
 			}
5849 5849
 
5850
-			$insertSQL = "INSERT INTO $table ( id, " . implode( ',', $insertcolumns ) . " ) VALUES
5851
-			( $default, " . implode( ',', $insertSlots ) . " ) $suffix";
5850
+			$insertSQL = "INSERT INTO $table ( id, ".implode(',', $insertcolumns)." ) VALUES
5851
+			( $default, ".implode(',', $insertSlots)." ) $suffix";
5852 5852
 
5853 5853
 			$ids = array();
5854
-			foreach ( $insertvalues as $i => $insertvalue ) {
5855
-				$ids[] = $this->adapter->getCell( $insertSQL, $insertvalue, $i );
5854
+			foreach ($insertvalues as $i => $insertvalue) {
5855
+				$ids[] = $this->adapter->getCell($insertSQL, $insertvalue, $i);
5856 5856
 			}
5857 5857
 
5858
-			$result = count( $ids ) === 1 ? array_pop( $ids ) : $ids;
5858
+			$result = count($ids) === 1 ? array_pop($ids) : $ids;
5859 5859
 		} else {
5860
-			$result = $this->adapter->getCell( "INSERT INTO $table (id) VALUES($default) $suffix" );
5860
+			$result = $this->adapter->getCell("INSERT INTO $table (id) VALUES($default) $suffix");
5861 5861
 		}
5862 5862
 
5863
-		if ( $suffix ) return $result;
5863
+		if ($suffix) return $result;
5864 5864
 
5865 5865
 		$last_id = $this->adapter->getInsertID();
5866 5866
 
@@ -5874,10 +5874,10 @@  discard block
 block discarded – undo
5874 5874
 	 *
5875 5875
 	 * @return string
5876 5876
 	 */
5877
-	protected function check( $struct )
5877
+	protected function check($struct)
5878 5878
 	{
5879
-		if ( !is_string( $struct ) || !preg_match( '/^[a-zA-Z0-9_]+$/', $struct ) ) {
5880
-			throw new RedException( 'Identifier does not conform to RedBeanPHP security policies.' );
5879
+		if (!is_string($struct) || !preg_match('/^[a-zA-Z0-9_]+$/', $struct)) {
5880
+			throw new RedException('Identifier does not conform to RedBeanPHP security policies.');
5881 5881
 		}
5882 5882
 
5883 5883
 		return $struct;
@@ -5891,40 +5891,40 @@  discard block
 block discarded – undo
5891 5891
 	 *
5892 5892
 	 * @return boolean
5893 5893
 	 */
5894
-	public function tableExists( $table )
5894
+	public function tableExists($table)
5895 5895
 	{
5896 5896
 		$tables = $this->getTables();
5897 5897
 
5898
-		return in_array( $table, $tables );
5898
+		return in_array($table, $tables);
5899 5899
 	}
5900 5900
 
5901 5901
 	/**
5902 5902
 	 * @see QueryWriter::glueSQLCondition
5903 5903
 	 */
5904
-	public function glueSQLCondition( $sql, $glue = NULL )
5904
+	public function glueSQLCondition($sql, $glue = NULL)
5905 5905
 	{
5906 5906
 		static $snippetCache = array();
5907 5907
 
5908
-		if ( trim( $sql ) === '' ) {
5908
+		if (trim($sql) === '') {
5909 5909
 			return $sql;
5910 5910
 		}
5911 5911
 
5912
-		$key = $glue . '|' . $sql;
5912
+		$key = $glue.'|'.$sql;
5913 5913
 
5914
-		if ( isset( $snippetCache[$key] ) ) {
5914
+		if (isset($snippetCache[$key])) {
5915 5915
 			return $snippetCache[$key];
5916 5916
 		}
5917 5917
 
5918
-		$lsql = ltrim( $sql );
5918
+		$lsql = ltrim($sql);
5919 5919
 
5920
-		if ( preg_match( '/^(INNER|LEFT|RIGHT|JOIN|AND|OR|WHERE|ORDER|GROUP|HAVING|LIMIT|OFFSET)\s+/i', $lsql ) ) {
5921
-			if ( $glue === QueryWriter::C_GLUE_WHERE && stripos( $lsql, 'AND' ) === 0 ) {
5922
-				$snippetCache[$key] = ' WHERE ' . substr( $lsql, 3 );
5920
+		if (preg_match('/^(INNER|LEFT|RIGHT|JOIN|AND|OR|WHERE|ORDER|GROUP|HAVING|LIMIT|OFFSET)\s+/i', $lsql)) {
5921
+			if ($glue === QueryWriter::C_GLUE_WHERE && stripos($lsql, 'AND') === 0) {
5922
+				$snippetCache[$key] = ' WHERE '.substr($lsql, 3);
5923 5923
 			} else {
5924 5924
 				$snippetCache[$key] = $sql;
5925 5925
 			}
5926 5926
 		} else {
5927
-			$snippetCache[$key] = ( ( $glue === QueryWriter::C_GLUE_AND ) ? ' AND ' : ' WHERE ') . $sql;
5927
+			$snippetCache[$key] = (($glue === QueryWriter::C_GLUE_AND) ? ' AND ' : ' WHERE ').$sql;
5928 5928
 		}
5929 5929
 
5930 5930
 		return $snippetCache[$key];
@@ -5933,80 +5933,80 @@  discard block
 block discarded – undo
5933 5933
 	/**
5934 5934
 	 * @see QueryWriter::glueLimitOne
5935 5935
 	 */
5936
-	public function glueLimitOne( $sql = '')
5936
+	public function glueLimitOne($sql = '')
5937 5937
 	{
5938
-		return ( strpos( strtoupper( $sql ), 'LIMIT' ) === FALSE ) ? ( $sql . ' LIMIT 1 ' ) : $sql;
5938
+		return (strpos(strtoupper($sql), 'LIMIT') === FALSE) ? ($sql.' LIMIT 1 ') : $sql;
5939 5939
 	}
5940 5940
 
5941 5941
 	/**
5942 5942
 	 * @see QueryWriter::esc
5943 5943
 	 */
5944
-	public function esc( $dbStructure, $dontQuote = FALSE )
5944
+	public function esc($dbStructure, $dontQuote = FALSE)
5945 5945
 	{
5946
-		$this->check( $dbStructure );
5946
+		$this->check($dbStructure);
5947 5947
 
5948
-		return ( $dontQuote ) ? $dbStructure : $this->quoteCharacter . $dbStructure . $this->quoteCharacter;
5948
+		return ($dontQuote) ? $dbStructure : $this->quoteCharacter.$dbStructure.$this->quoteCharacter;
5949 5949
 	}
5950 5950
 
5951 5951
 	/**
5952 5952
 	 * @see QueryWriter::addColumn
5953 5953
 	 */
5954
-	public function addColumn( $type, $column, $field )
5954
+	public function addColumn($type, $column, $field)
5955 5955
 	{
5956 5956
 		$table  = $type;
5957 5957
 		$type   = $field;
5958
-		$table  = $this->esc( $table );
5959
-		$column = $this->esc( $column );
5958
+		$table  = $this->esc($table);
5959
+		$column = $this->esc($column);
5960 5960
 
5961
-		$type = ( isset( $this->typeno_sqltype[$type] ) ) ? $this->typeno_sqltype[$type] : '';
5961
+		$type = (isset($this->typeno_sqltype[$type])) ? $this->typeno_sqltype[$type] : '';
5962 5962
 
5963
-		$this->adapter->exec( "ALTER TABLE $table ADD $column $type " );
5963
+		$this->adapter->exec("ALTER TABLE $table ADD $column $type ");
5964 5964
 	}
5965 5965
 
5966 5966
 	/**
5967 5967
 	 * @see QueryWriter::updateRecord
5968 5968
 	 */
5969
-	public function updateRecord( $type, $updatevalues, $id = NULL )
5969
+	public function updateRecord($type, $updatevalues, $id = NULL)
5970 5970
 	{
5971 5971
 		$table = $type;
5972 5972
 
5973
-		if ( !$id ) {
5973
+		if (!$id) {
5974 5974
 			$insertcolumns = $insertvalues = array();
5975 5975
 
5976
-			foreach ( $updatevalues as $pair ) {
5976
+			foreach ($updatevalues as $pair) {
5977 5977
 				$insertcolumns[] = $pair['property'];
5978 5978
 				$insertvalues[]  = $pair['value'];
5979 5979
 			}
5980 5980
 
5981 5981
 			//Otherwise psql returns string while MySQL/SQLite return numeric causing problems with additions (array_diff)
5982
-			return (string) $this->insertRecord( $table, $insertcolumns, array( $insertvalues ) );
5982
+			return (string) $this->insertRecord($table, $insertcolumns, array($insertvalues));
5983 5983
 		}
5984 5984
 
5985
-		if ( $id && !count( $updatevalues ) ) {
5985
+		if ($id && !count($updatevalues)) {
5986 5986
 			return $id;
5987 5987
 		}
5988 5988
 
5989
-		$table = $this->esc( $table );
5989
+		$table = $this->esc($table);
5990 5990
 		$sql   = "UPDATE $table SET ";
5991 5991
 
5992 5992
 		$p = $v = array();
5993 5993
 
5994
-		foreach ( $updatevalues as $uv ) {
5994
+		foreach ($updatevalues as $uv) {
5995 5995
 
5996
-			if ( isset( self::$sqlFilters['w'][$type][$uv['property']] ) ) {
5997
-				$p[] = " {$this->esc( $uv["property"] )} = ". self::$sqlFilters['w'][$type][$uv['property']];
5996
+			if (isset(self::$sqlFilters['w'][$type][$uv['property']])) {
5997
+				$p[] = " {$this->esc($uv["property"])} = ".self::$sqlFilters['w'][$type][$uv['property']];
5998 5998
 			} else {
5999
-				$p[] = " {$this->esc( $uv["property"] )} = ? ";
5999
+				$p[] = " {$this->esc($uv["property"])} = ? ";
6000 6000
 			}
6001 6001
 
6002 6002
 			$v[] = $uv['value'];
6003 6003
 		}
6004 6004
 
6005
-		$sql .= implode( ',', $p ) . ' WHERE id = ? ';
6005
+		$sql .= implode(',', $p).' WHERE id = ? ';
6006 6006
 
6007 6007
 		$v[] = $id;
6008 6008
 
6009
-		$this->adapter->exec( $sql, $v );
6009
+		$this->adapter->exec($sql, $v);
6010 6010
 
6011 6011
 		return $id;
6012 6012
 	}
@@ -6014,14 +6014,14 @@  discard block
 block discarded – undo
6014 6014
 	/**
6015 6015
 	 * @see QueryWriter::writeJoin
6016 6016
 	 */
6017
-	public function writeJoin( $type, $targetType, $leftRight = 'LEFT' )
6017
+	public function writeJoin($type, $targetType, $leftRight = 'LEFT')
6018 6018
 	{
6019
-		if ( $leftRight !== 'LEFT' && $leftRight !== 'RIGHT' && $leftRight !== 'INNER' )
6020
-			throw new RedException( 'Invalid JOIN.' );
6019
+		if ($leftRight !== 'LEFT' && $leftRight !== 'RIGHT' && $leftRight !== 'INNER')
6020
+			throw new RedException('Invalid JOIN.');
6021 6021
 
6022
-		$table = $this->esc( $type );
6023
-		$targetTable = $this->esc( $targetType );
6024
-		$field = $this->esc( $targetType, TRUE );
6022
+		$table = $this->esc($type);
6023
+		$targetTable = $this->esc($targetType);
6024
+		$field = $this->esc($targetType, TRUE);
6025 6025
 		return " {$leftRight} JOIN {$targetTable} ON {$targetTable}.id = {$table}.{$field}_id ";
6026 6026
 	}
6027 6027
 
@@ -6039,7 +6039,7 @@  discard block
 block discarded – undo
6039 6039
 	 *
6040 6040
 	 * return self
6041 6041
 	 */
6042
-	public function setSQLSelectSnippet( $sqlSelectSnippet = '' ) {
6042
+	public function setSQLSelectSnippet($sqlSelectSnippet = '') {
6043 6043
 		$this->sqlSelectSnippet = $sqlSelectSnippet;
6044 6044
 		return $this;
6045 6045
 	}
@@ -6047,35 +6047,35 @@  discard block
 block discarded – undo
6047 6047
 	/**
6048 6048
 	 * @see QueryWriter::queryRecord
6049 6049
 	 */
6050
-	public function queryRecord( $type, $conditions = array(), $addSql = NULL, $bindings = array() )
6050
+	public function queryRecord($type, $conditions = array(), $addSql = NULL, $bindings = array())
6051 6051
 	{
6052
-		if ( $this->flagUseCache ) {
6053
-			$key = $this->getCacheKey( array( $conditions, trim("$addSql {$this->sqlSelectSnippet}"), $bindings, 'select' ) );
6054
-			if ( $cached = $this->getCached( $type, $key ) ) {
6052
+		if ($this->flagUseCache) {
6053
+			$key = $this->getCacheKey(array($conditions, trim("$addSql {$this->sqlSelectSnippet}"), $bindings, 'select'));
6054
+			if ($cached = $this->getCached($type, $key)) {
6055 6055
 				return $cached;
6056 6056
 			}
6057 6057
 		}
6058 6058
 
6059
-		$table = $this->esc( $type );
6059
+		$table = $this->esc($type);
6060 6060
 
6061 6061
 		$sqlFilterStr = '';
6062
-		if ( count( self::$sqlFilters ) ) {
6063
-			$sqlFilterStr = $this->getSQLFilterSnippet( $type );
6062
+		if (count(self::$sqlFilters)) {
6063
+			$sqlFilterStr = $this->getSQLFilterSnippet($type);
6064 6064
 		}
6065 6065
 		
6066
-		if ( is_array ( $conditions ) && !empty ( $conditions ) ) {
6067
-			$sql = $this->makeSQLFromConditions( $conditions, $bindings, $addSql );
6066
+		if (is_array($conditions) && !empty ($conditions)) {
6067
+			$sql = $this->makeSQLFromConditions($conditions, $bindings, $addSql);
6068 6068
 		} else {
6069
-			$sql = $this->glueSQLCondition( $addSql );
6069
+			$sql = $this->glueSQLCondition($addSql);
6070 6070
 		}
6071 6071
 
6072
-		$fieldSelection = ( self::$flagNarrowFieldMode ) ? "{$table}.*" : '*';
6072
+		$fieldSelection = (self::$flagNarrowFieldMode) ? "{$table}.*" : '*';
6073 6073
 		$sql   = "SELECT {$fieldSelection} {$sqlFilterStr} FROM {$table} {$sql} {$this->sqlSelectSnippet} -- keep-cache";
6074 6074
 		$this->sqlSelectSnippet = '';
6075
-		$rows  = $this->adapter->get( $sql, $bindings );
6075
+		$rows  = $this->adapter->get($sql, $bindings);
6076 6076
 
6077
-		if ( $this->flagUseCache ) {
6078
-			$this->putResultInCache( $type, $key, $rows );
6077
+		if ($this->flagUseCache) {
6078
+			$this->putResultInCache($type, $key, $rows);
6079 6079
 		}
6080 6080
 
6081 6081
 		return $rows;
@@ -6084,47 +6084,47 @@  discard block
 block discarded – undo
6084 6084
 	/**
6085 6085
 	 * @see QueryWriter::queryRecordWithCursor
6086 6086
 	 */
6087
-	public function queryRecordWithCursor( $type, $addSql = NULL, $bindings = array() )
6087
+	public function queryRecordWithCursor($type, $addSql = NULL, $bindings = array())
6088 6088
 	{
6089
-		$table = $this->esc( $type );
6089
+		$table = $this->esc($type);
6090 6090
 
6091 6091
 		$sqlFilterStr = '';
6092
-		if ( count( self::$sqlFilters ) ) {
6093
-			$sqlFilterStr = $this->getSQLFilterSnippet( $type );
6092
+		if (count(self::$sqlFilters)) {
6093
+			$sqlFilterStr = $this->getSQLFilterSnippet($type);
6094 6094
 		}
6095 6095
 
6096
-		$fieldSelection = ( self::$flagNarrowFieldMode ) ? "{$table}.*" : '*';
6096
+		$fieldSelection = (self::$flagNarrowFieldMode) ? "{$table}.*" : '*';
6097 6097
 
6098
-		$sql = $this->glueSQLCondition( $addSql, NULL );
6098
+		$sql = $this->glueSQLCondition($addSql, NULL);
6099 6099
 		$sql = "SELECT {$fieldSelection} {$sqlFilterStr} FROM {$table} {$sql} -- keep-cache";
6100 6100
 
6101
-		return $this->adapter->getCursor( $sql, $bindings );
6101
+		return $this->adapter->getCursor($sql, $bindings);
6102 6102
 	}
6103 6103
 
6104 6104
 	/**
6105 6105
 	 * @see QueryWriter::queryRecordRelated
6106 6106
 	 */
6107
-	public function queryRecordRelated( $sourceType, $destType, $linkIDs, $addSql = '', $bindings = array() )
6107
+	public function queryRecordRelated($sourceType, $destType, $linkIDs, $addSql = '', $bindings = array())
6108 6108
 	{
6109
-		list( $sourceTable, $destTable, $linkTable, $sourceCol, $destCol ) = $this->getRelationalTablesAndColumns( $sourceType, $destType );
6109
+		list($sourceTable, $destTable, $linkTable, $sourceCol, $destCol) = $this->getRelationalTablesAndColumns($sourceType, $destType);
6110 6110
 
6111
-		if ( $this->flagUseCache ) {
6112
-			$key = $this->getCacheKey( array( $sourceType, implode( ',', $linkIDs ), trim($addSql), $bindings, 'selectrelated' ) );
6113
-			if ( $cached = $this->getCached( $destType, $key ) ) {
6111
+		if ($this->flagUseCache) {
6112
+			$key = $this->getCacheKey(array($sourceType, implode(',', $linkIDs), trim($addSql), $bindings, 'selectrelated'));
6113
+			if ($cached = $this->getCached($destType, $key)) {
6114 6114
 				return $cached;
6115 6115
 			}
6116 6116
 		}
6117 6117
 
6118
-		$addSql = $this->glueSQLCondition( $addSql, QueryWriter::C_GLUE_WHERE );
6119
-		$inClause = $this->getParametersForInClause( $linkIDs, $bindings );
6118
+		$addSql = $this->glueSQLCondition($addSql, QueryWriter::C_GLUE_WHERE);
6119
+		$inClause = $this->getParametersForInClause($linkIDs, $bindings);
6120 6120
 
6121 6121
 		$sqlFilterStr = '';
6122
-		if ( count( self::$sqlFilters ) ) {
6123
-			$sqlFilterStr = $this->getSQLFilterSnippet( $destType );
6122
+		if (count(self::$sqlFilters)) {
6123
+			$sqlFilterStr = $this->getSQLFilterSnippet($destType);
6124 6124
 		}
6125 6125
 
6126
-		if ( $sourceType === $destType ) {
6127
-			$inClause2 = $this->getParametersForInClause( $linkIDs, $bindings, count( $bindings ) ); //for some databases
6126
+		if ($sourceType === $destType) {
6127
+			$inClause2 = $this->getParametersForInClause($linkIDs, $bindings, count($bindings)); //for some databases
6128 6128
 			$sql = "
6129 6129
 			SELECT
6130 6130
 				{$destTable}.* {$sqlFilterStr} ,
@@ -6138,7 +6138,7 @@  discard block
 block discarded – undo
6138 6138
 			{$addSql}
6139 6139
 			-- keep-cache";
6140 6140
 
6141
-			$linkIDs = array_merge( $linkIDs, $linkIDs );
6141
+			$linkIDs = array_merge($linkIDs, $linkIDs);
6142 6142
 		} else {
6143 6143
 			$sql = "
6144 6144
 			SELECT
@@ -6151,12 +6151,12 @@  discard block
 block discarded – undo
6151 6151
 			-- keep-cache";
6152 6152
 		}
6153 6153
 
6154
-		$bindings = array_merge( $linkIDs, $bindings );
6154
+		$bindings = array_merge($linkIDs, $bindings);
6155 6155
 
6156
-		$rows = $this->adapter->get( $sql, $bindings );
6156
+		$rows = $this->adapter->get($sql, $bindings);
6157 6157
 
6158
-		if ( $this->flagUseCache ) {
6159
-			$this->putResultInCache( $destType, $key, $rows );
6158
+		if ($this->flagUseCache) {
6159
+			$this->putResultInCache($destType, $key, $rows);
6160 6160
 		}
6161 6161
 
6162 6162
 		return $rows;
@@ -6165,35 +6165,35 @@  discard block
 block discarded – undo
6165 6165
 	/**
6166 6166
 	 * @see QueryWriter::queryRecordLink
6167 6167
 	 */
6168
-	public function queryRecordLink( $sourceType, $destType, $sourceID, $destID )
6168
+	public function queryRecordLink($sourceType, $destType, $sourceID, $destID)
6169 6169
 	{
6170
-		list( $sourceTable, $destTable, $linkTable, $sourceCol, $destCol ) = $this->getRelationalTablesAndColumns( $sourceType, $destType );
6170
+		list($sourceTable, $destTable, $linkTable, $sourceCol, $destCol) = $this->getRelationalTablesAndColumns($sourceType, $destType);
6171 6171
 
6172
-		if ( $this->flagUseCache ) {
6173
-			$key = $this->getCacheKey( array( $sourceType, $destType, $sourceID, $destID, 'selectlink' ) );
6174
-			if ( $cached = $this->getCached( $linkTable, $key ) ) {
6172
+		if ($this->flagUseCache) {
6173
+			$key = $this->getCacheKey(array($sourceType, $destType, $sourceID, $destID, 'selectlink'));
6174
+			if ($cached = $this->getCached($linkTable, $key)) {
6175 6175
 				return $cached;
6176 6176
 			}
6177 6177
 		}
6178 6178
 
6179 6179
 		$sqlFilterStr = '';
6180
-		if ( count( self::$sqlFilters ) ) {
6181
-			$sqlFilterStr = $this->getSQLFilterSnippet( $destType );
6180
+		if (count(self::$sqlFilters)) {
6181
+			$sqlFilterStr = $this->getSQLFilterSnippet($destType);
6182 6182
 		}
6183 6183
 
6184
-		if ( $sourceTable === $destTable ) {
6184
+		if ($sourceTable === $destTable) {
6185 6185
 			$sql = "SELECT {$linkTable}.* {$sqlFilterStr} FROM {$linkTable}
6186 6186
 				WHERE ( {$sourceCol} = ? AND {$destCol} = ? ) OR
6187 6187
 				 ( {$destCol} = ? AND {$sourceCol} = ? ) -- keep-cache";
6188
-			$row = $this->adapter->getRow( $sql, array( $sourceID, $destID, $sourceID, $destID ) );
6188
+			$row = $this->adapter->getRow($sql, array($sourceID, $destID, $sourceID, $destID));
6189 6189
 		} else {
6190 6190
 			$sql = "SELECT {$linkTable}.* {$sqlFilterStr} FROM {$linkTable}
6191 6191
 				WHERE {$sourceCol} = ? AND {$destCol} = ? -- keep-cache";
6192
-			$row = $this->adapter->getRow( $sql, array( $sourceID, $destID ) );
6192
+			$row = $this->adapter->getRow($sql, array($sourceID, $destID));
6193 6193
 		}
6194 6194
 
6195
-		if ( $this->flagUseCache ) {
6196
-			$this->putResultInCache( $linkTable, $key, $row );
6195
+		if ($this->flagUseCache) {
6196
+			$this->putResultInCache($linkTable, $key, $row);
6197 6197
 		}
6198 6198
 
6199 6199
 		return $row;
@@ -6215,21 +6215,21 @@  discard block
 block discarded – undo
6215 6215
 	 *
6216 6216
 	 * @return array
6217 6217
 	 */
6218
-	private function queryTaggedGeneric( $type, $tagList, $all = FALSE, $addSql = '', $bindings = array(), $wrap = '%s' )
6218
+	private function queryTaggedGeneric($type, $tagList, $all = FALSE, $addSql = '', $bindings = array(), $wrap = '%s')
6219 6219
 	{
6220
-		if ( $this->flagUseCache ) {
6221
-			$key = $this->getCacheKey( array( implode( ',', $tagList ), $all, trim($addSql), $bindings, 'selectTagged' ) );
6222
-			if ( $cached = $this->getCached( $type, $key ) ) {
6220
+		if ($this->flagUseCache) {
6221
+			$key = $this->getCacheKey(array(implode(',', $tagList), $all, trim($addSql), $bindings, 'selectTagged'));
6222
+			if ($cached = $this->getCached($type, $key)) {
6223 6223
 				return $cached;
6224 6224
 			}
6225 6225
 		}
6226 6226
 
6227
-		$assocType = $this->getAssocTable( array( $type, 'tag' ) );
6228
-		$assocTable = $this->esc( $assocType );
6229
-		$assocField = $type . '_id';
6230
-		$table = $this->esc( $type );
6231
-		$slots = implode( ',', array_fill( 0, count( $tagList ), '?' ) );
6232
-		$score = ( $all ) ? count( $tagList ) : 1;
6227
+		$assocType = $this->getAssocTable(array($type, 'tag'));
6228
+		$assocTable = $this->esc($assocType);
6229
+		$assocField = $type.'_id';
6230
+		$table = $this->esc($type);
6231
+		$slots = implode(',', array_fill(0, count($tagList), '?'));
6232
+		$score = ($all) ? count($tagList) : 1;
6233 6233
 
6234 6234
 		$sql = "
6235 6235
 			SELECT {$table}.* FROM {$table}
@@ -6241,13 +6241,13 @@  discard block
 block discarded – undo
6241 6241
 			{$addSql}
6242 6242
 			-- keep-cache
6243 6243
 		";
6244
-		$sql = sprintf($wrap,$sql);
6244
+		$sql = sprintf($wrap, $sql);
6245 6245
 
6246
-		$bindings = array_merge( $tagList, array( $score ), $bindings );
6247
-		$rows = $this->adapter->get( $sql, $bindings );
6246
+		$bindings = array_merge($tagList, array($score), $bindings);
6247
+		$rows = $this->adapter->get($sql, $bindings);
6248 6248
 
6249
-		if ( $this->flagUseCache ) {
6250
-			$this->putResultInCache( $type, $key, $rows );
6249
+		if ($this->flagUseCache) {
6250
+			$this->putResultInCache($type, $key, $rows);
6251 6251
 		}
6252 6252
 
6253 6253
 		return $rows;
@@ -6256,45 +6256,45 @@  discard block
 block discarded – undo
6256 6256
 	/**
6257 6257
 	 * @see QueryWriter::queryTagged
6258 6258
 	 */
6259
-	public function queryTagged( $type, $tagList, $all = FALSE, $addSql = '', $bindings = array() )
6259
+	public function queryTagged($type, $tagList, $all = FALSE, $addSql = '', $bindings = array())
6260 6260
 	{
6261
-		return $this->queryTaggedGeneric( $type, $tagList, $all, $addSql, $bindings );
6261
+		return $this->queryTaggedGeneric($type, $tagList, $all, $addSql, $bindings);
6262 6262
 	}
6263 6263
 
6264 6264
 	/**
6265 6265
 	 * @see QueryWriter::queryCountTagged
6266 6266
 	 */
6267
-	public function queryCountTagged( $type, $tagList, $all = FALSE, $addSql = '', $bindings = array() )
6267
+	public function queryCountTagged($type, $tagList, $all = FALSE, $addSql = '', $bindings = array())
6268 6268
 	{
6269
-		$rows = $this->queryTaggedGeneric( $type, $tagList, $all, $addSql, $bindings, 'SELECT COUNT(*) AS counted FROM (%s) AS counting' );
6269
+		$rows = $this->queryTaggedGeneric($type, $tagList, $all, $addSql, $bindings, 'SELECT COUNT(*) AS counted FROM (%s) AS counting');
6270 6270
 		return intval($rows[0]['counted']);
6271 6271
 	}
6272 6272
 
6273 6273
 	/**
6274 6274
 	 * @see QueryWriter::queryRecordCount
6275 6275
 	 */
6276
-	public function queryRecordCount( $type, $conditions = array(), $addSql = NULL, $bindings = array() )
6276
+	public function queryRecordCount($type, $conditions = array(), $addSql = NULL, $bindings = array())
6277 6277
 	{
6278
-		if ( $this->flagUseCache ) {
6279
-			$key = $this->getCacheKey( array( $conditions, trim($addSql), $bindings, 'count' ) );
6280
-			if ( $cached = $this->getCached( $type, $key ) ) {
6278
+		if ($this->flagUseCache) {
6279
+			$key = $this->getCacheKey(array($conditions, trim($addSql), $bindings, 'count'));
6280
+			if ($cached = $this->getCached($type, $key)) {
6281 6281
 				return $cached;
6282 6282
 			}
6283 6283
 		}
6284 6284
 
6285
-		$table  = $this->esc( $type );
6285
+		$table = $this->esc($type);
6286 6286
 
6287
-		if ( is_array ( $conditions ) && !empty ( $conditions ) ) {
6288
-			$sql = $this->makeSQLFromConditions( $conditions, $bindings, $addSql );
6287
+		if (is_array($conditions) && !empty ($conditions)) {
6288
+			$sql = $this->makeSQLFromConditions($conditions, $bindings, $addSql);
6289 6289
 		} else {
6290
-			$sql = $this->glueSQLCondition( $addSql );
6290
+			$sql = $this->glueSQLCondition($addSql);
6291 6291
 		}
6292 6292
 
6293 6293
 		$sql    = "SELECT COUNT(*) FROM {$table} {$sql} -- keep-cache";
6294
-		$count  = (int) $this->adapter->getCell( $sql, $bindings );
6294
+		$count  = (int) $this->adapter->getCell($sql, $bindings);
6295 6295
 
6296
-		if ( $this->flagUseCache ) {
6297
-			$this->putResultInCache( $type, $key, $count );
6296
+		if ($this->flagUseCache) {
6297
+			$this->putResultInCache($type, $key, $count);
6298 6298
 		}
6299 6299
 
6300 6300
 		return $count;
@@ -6303,19 +6303,19 @@  discard block
 block discarded – undo
6303 6303
 	/**
6304 6304
 	 * @see QueryWriter::queryRecordCountRelated
6305 6305
 	 */
6306
-	public function queryRecordCountRelated( $sourceType, $destType, $linkID, $addSql = '', $bindings = array() )
6306
+	public function queryRecordCountRelated($sourceType, $destType, $linkID, $addSql = '', $bindings = array())
6307 6307
 	{
6308
-		list( $sourceTable, $destTable, $linkTable, $sourceCol, $destCol ) = $this->getRelationalTablesAndColumns( $sourceType, $destType );
6308
+		list($sourceTable, $destTable, $linkTable, $sourceCol, $destCol) = $this->getRelationalTablesAndColumns($sourceType, $destType);
6309 6309
 
6310
-		if ( $this->flagUseCache ) {
6310
+		if ($this->flagUseCache) {
6311 6311
 			$cacheType = "#{$sourceType}/{$destType}";
6312
-			$key = $this->getCacheKey( array( $sourceType, $destType, $linkID, trim($addSql), $bindings, 'countrelated' ) );
6313
-			if ( $cached = $this->getCached( $cacheType, $key ) ) {
6312
+			$key = $this->getCacheKey(array($sourceType, $destType, $linkID, trim($addSql), $bindings, 'countrelated'));
6313
+			if ($cached = $this->getCached($cacheType, $key)) {
6314 6314
 				return $cached;
6315 6315
 			}
6316 6316
 		}
6317 6317
 
6318
-		if ( $sourceType === $destType ) {
6318
+		if ($sourceType === $destType) {
6319 6319
 			$sql = "
6320 6320
 			SELECT COUNT(*) FROM {$linkTable}
6321 6321
 			INNER JOIN {$destTable} ON
@@ -6324,7 +6324,7 @@  discard block
 block discarded – undo
6324 6324
 			{$addSql}
6325 6325
 			-- keep-cache";
6326 6326
 
6327
-			$bindings = array_merge( array( $linkID, $linkID ), $bindings );
6327
+			$bindings = array_merge(array($linkID, $linkID), $bindings);
6328 6328
 		} else {
6329 6329
 			$sql = "
6330 6330
 			SELECT COUNT(*) FROM {$linkTable}
@@ -6333,13 +6333,13 @@  discard block
 block discarded – undo
6333 6333
 			{$addSql}
6334 6334
 			-- keep-cache";
6335 6335
 
6336
-			$bindings = array_merge( array( $linkID ), $bindings );
6336
+			$bindings = array_merge(array($linkID), $bindings);
6337 6337
 		}
6338 6338
 
6339
-		$count = (int) $this->adapter->getCell( $sql, $bindings );
6339
+		$count = (int) $this->adapter->getCell($sql, $bindings);
6340 6340
 
6341
-		if ( $this->flagUseCache ) {
6342
-			$this->putResultInCache( $cacheType, $key, $count );
6341
+		if ($this->flagUseCache) {
6342
+			$this->putResultInCache($cacheType, $key, $count);
6343 6343
 		}
6344 6344
 
6345 6345
 		return $count;
@@ -6348,14 +6348,14 @@  discard block
 block discarded – undo
6348 6348
 	/**
6349 6349
 	 * @see QueryWriter::queryRecursiveCommonTableExpression
6350 6350
 	 */
6351
-	public function queryRecursiveCommonTableExpression( $type, $id, $up = TRUE, $addSql = NULL, $bindings = array() )
6351
+	public function queryRecursiveCommonTableExpression($type, $id, $up = TRUE, $addSql = NULL, $bindings = array())
6352 6352
 	{
6353 6353
 		$alias     = $up ? 'parent' : 'child';
6354 6354
 		$direction = $up ? " {$alias}.{$type}_id = {$type}.id " : " {$alias}.id = {$type}.{$type}_id ";
6355 6355
 
6356
-		array_unshift( $bindings, $id );
6356
+		array_unshift($bindings, $id);
6357 6357
 
6358
-		$sql = $this->glueSQLCondition( $addSql, QueryWriter::C_GLUE_WHERE );
6358
+		$sql = $this->glueSQLCondition($addSql, QueryWriter::C_GLUE_WHERE);
6359 6359
 
6360 6360
 		$rows = $this->adapter->get("
6361 6361
 			WITH RECURSIVE tree AS
@@ -6376,56 +6376,56 @@  discard block
 block discarded – undo
6376 6376
 	/**
6377 6377
 	 * @see QueryWriter::deleteRecord
6378 6378
 	 */
6379
-	public function deleteRecord( $type, $conditions = array(), $addSql = NULL, $bindings = array() )
6379
+	public function deleteRecord($type, $conditions = array(), $addSql = NULL, $bindings = array())
6380 6380
 	{
6381
-		$table  = $this->esc( $type );
6381
+		$table = $this->esc($type);
6382 6382
 
6383
-		if ( is_array ( $conditions ) && !empty ( $conditions ) ) {
6384
-			$sql = $this->makeSQLFromConditions( $conditions, $bindings, $addSql );
6383
+		if (is_array($conditions) && !empty ($conditions)) {
6384
+			$sql = $this->makeSQLFromConditions($conditions, $bindings, $addSql);
6385 6385
 		} else {
6386
-			$sql = $this->glueSQLCondition( $addSql );
6386
+			$sql = $this->glueSQLCondition($addSql);
6387 6387
 		}
6388 6388
 		
6389
-		$sql    = "DELETE FROM {$table} {$sql}";
6389
+		$sql = "DELETE FROM {$table} {$sql}";
6390 6390
 
6391
-		$this->adapter->exec( $sql, $bindings );
6391
+		$this->adapter->exec($sql, $bindings);
6392 6392
 	}
6393 6393
 
6394 6394
 	/**
6395 6395
 	 * @see QueryWriter::deleteRelations
6396 6396
 	 */
6397
-	public function deleteRelations( $sourceType, $destType, $sourceID )
6397
+	public function deleteRelations($sourceType, $destType, $sourceID)
6398 6398
 	{
6399
-		list( $sourceTable, $destTable, $linkTable, $sourceCol, $destCol ) = $this->getRelationalTablesAndColumns( $sourceType, $destType );
6399
+		list($sourceTable, $destTable, $linkTable, $sourceCol, $destCol) = $this->getRelationalTablesAndColumns($sourceType, $destType);
6400 6400
 
6401
-		if ( $sourceTable === $destTable ) {
6401
+		if ($sourceTable === $destTable) {
6402 6402
 			$sql = "DELETE FROM {$linkTable}
6403 6403
 				WHERE ( {$sourceCol} = ? ) OR
6404 6404
 				( {$destCol} = ?  )
6405 6405
 			";
6406 6406
 
6407
-			$this->adapter->exec( $sql, array( $sourceID, $sourceID ) );
6407
+			$this->adapter->exec($sql, array($sourceID, $sourceID));
6408 6408
 		} else {
6409 6409
 			$sql = "DELETE FROM {$linkTable}
6410 6410
 				WHERE {$sourceCol} = ? ";
6411 6411
 
6412
-			$this->adapter->exec( $sql, array( $sourceID ) );
6412
+			$this->adapter->exec($sql, array($sourceID));
6413 6413
 		}
6414 6414
 	}
6415 6415
 
6416 6416
 	/**
6417 6417
 	 * @see QueryWriter::widenColumn
6418 6418
 	 */
6419
-	public function widenColumn( $type, $property, $dataType )
6419
+	public function widenColumn($type, $property, $dataType)
6420 6420
 	{
6421
-		if ( !isset($this->typeno_sqltype[$dataType]) ) return FALSE;
6421
+		if (!isset($this->typeno_sqltype[$dataType])) return FALSE;
6422 6422
 
6423
-		$table   = $this->esc( $type );
6424
-		$column  = $this->esc( $property );
6423
+		$table   = $this->esc($type);
6424
+		$column  = $this->esc($property);
6425 6425
 
6426 6426
 		$newType = $this->typeno_sqltype[$dataType];
6427 6427
 
6428
-		$this->adapter->exec( "ALTER TABLE $table CHANGE $column $column $newType " );
6428
+		$this->adapter->exec("ALTER TABLE $table CHANGE $column $column $newType ");
6429 6429
 
6430 6430
 		return TRUE;
6431 6431
 	}
@@ -6433,27 +6433,27 @@  discard block
 block discarded – undo
6433 6433
 	/**
6434 6434
 	 * @see QueryWriter::wipe
6435 6435
 	 */
6436
-	public function wipe( $type )
6436
+	public function wipe($type)
6437 6437
 	{
6438
-		$table = $this->esc( $type );
6438
+		$table = $this->esc($type);
6439 6439
 
6440
-		$this->adapter->exec( "TRUNCATE $table " );
6440
+		$this->adapter->exec("TRUNCATE $table ");
6441 6441
 	}
6442 6442
 
6443 6443
 	/**
6444 6444
 	 * @see QueryWriter::renameAssocTable
6445 6445
 	 */
6446
-	public function renameAssocTable( $from, $to = NULL )
6446
+	public function renameAssocTable($from, $to = NULL)
6447 6447
 	{
6448
-		self::renameAssociation( $from, $to );
6448
+		self::renameAssociation($from, $to);
6449 6449
 	}
6450 6450
 
6451 6451
 	/**
6452 6452
 	 * @see QueryWriter::getAssocTable
6453 6453
 	 */
6454
-	public function getAssocTable( $types )
6454
+	public function getAssocTable($types)
6455 6455
 	{
6456
-		return self::getAssocTableFormat( $types );
6456
+		return self::getAssocTableFormat($types);
6457 6457
 	}
6458 6458
 
6459 6459
 	/**
@@ -6465,7 +6465,7 @@  discard block
 block discarded – undo
6465 6465
 	 *
6466 6466
 	 * @return void
6467 6467
 	 */
6468
-	public function setUseCache( $yesNo )
6468
+	public function setUseCache($yesNo)
6469 6469
 	{
6470 6470
 		$this->flushCache();
6471 6471
 
@@ -6479,12 +6479,12 @@  discard block
 block discarded – undo
6479 6479
 	 *
6480 6480
 	 * @return integer
6481 6481
 	 */
6482
-	public function flushCache( $newMaxCacheSizePerType = NULL )
6482
+	public function flushCache($newMaxCacheSizePerType = NULL)
6483 6483
 	{
6484
-		if ( !is_null( $newMaxCacheSizePerType ) && $newMaxCacheSizePerType > 0 ) {
6484
+		if (!is_null($newMaxCacheSizePerType) && $newMaxCacheSizePerType > 0) {
6485 6485
 			$this->maxCacheSizePerType = $newMaxCacheSizePerType;
6486 6486
 		}
6487
-		$count = count( $this->cache, COUNT_RECURSIVE );
6487
+		$count = count($this->cache, COUNT_RECURSIVE);
6488 6488
 		$this->cache = array();
6489 6489
 		return $count;
6490 6490
 	}
@@ -6497,9 +6497,9 @@  discard block
 block discarded – undo
6497 6497
 	 *
6498 6498
 	 * @return string
6499 6499
 	 */
6500
-	public function safeColumn( $column, $noQuotes = FALSE )
6500
+	public function safeColumn($column, $noQuotes = FALSE)
6501 6501
 	{
6502
-		return $this->esc( $column, $noQuotes );
6502
+		return $this->esc($column, $noQuotes);
6503 6503
 	}
6504 6504
 
6505 6505
 	/**
@@ -6510,21 +6510,21 @@  discard block
 block discarded – undo
6510 6510
 	 *
6511 6511
 	 * @return string
6512 6512
 	 */
6513
-	public function safeTable( $table, $noQuotes = FALSE )
6513
+	public function safeTable($table, $noQuotes = FALSE)
6514 6514
 	{
6515
-		return $this->esc( $table, $noQuotes );
6515
+		return $this->esc($table, $noQuotes);
6516 6516
 	}
6517 6517
 
6518 6518
 	/**
6519 6519
 	 * @see QueryWriter::inferFetchType
6520 6520
 	 */
6521
-	public function inferFetchType( $type, $property )
6521
+	public function inferFetchType($type, $property)
6522 6522
 	{
6523
-		$type = $this->esc( $type, TRUE );
6524
-		$field = $this->esc( $property, TRUE ) . '_id';
6525
-		$keys = $this->getKeyMapForType( $type );
6523
+		$type = $this->esc($type, TRUE);
6524
+		$field = $this->esc($property, TRUE).'_id';
6525
+		$keys = $this->getKeyMapForType($type);
6526 6526
 
6527
-		foreach( $keys as $key ) {
6527
+		foreach ($keys as $key) {
6528 6528
 			if (
6529 6529
 				$key['from'] === $field
6530 6530
 			) return $key['table'];
@@ -6535,9 +6535,9 @@  discard block
 block discarded – undo
6535 6535
 	/**
6536 6536
 	 * @see QueryWriter::addUniqueConstraint
6537 6537
 	 */
6538
-	public function addUniqueIndex( $type, $properties )
6538
+	public function addUniqueIndex($type, $properties)
6539 6539
 	{
6540
-		return $this->addUniqueConstraint( $type, $properties );
6540
+		return $this->addUniqueConstraint($type, $properties);
6541 6541
 	}
6542 6542
 }
6543 6543
 }
@@ -6578,14 +6578,14 @@  discard block
 block discarded – undo
6578 6578
 	const C_DATATYPE_TEXT32           = 7;
6579 6579
 	const C_DATATYPE_SPECIAL_DATE     = 80;
6580 6580
 	const C_DATATYPE_SPECIAL_DATETIME = 81;
6581
-	const C_DATATYPE_SPECIAL_TIME     = 83;  //MySQL time column (only manual)
6581
+	const C_DATATYPE_SPECIAL_TIME     = 83; //MySQL time column (only manual)
6582 6582
 	const C_DATATYPE_SPECIAL_POINT    = 90;
6583 6583
 	const C_DATATYPE_SPECIAL_LINESTRING = 91;
6584 6584
 	const C_DATATYPE_SPECIAL_POLYGON    = 92;
6585 6585
 	const C_DATATYPE_SPECIAL_MONEY      = 93;
6586
-	const C_DATATYPE_SPECIAL_JSON       = 94;  //JSON support (only manual)
6586
+	const C_DATATYPE_SPECIAL_JSON       = 94; //JSON support (only manual)
6587 6587
 
6588
-	const C_DATATYPE_SPECIFIED        = 99;
6588
+	const C_DATATYPE_SPECIFIED = 99;
6589 6589
 
6590 6590
 	/**
6591 6591
 	 * @var DBAdapter
@@ -6600,10 +6600,10 @@  discard block
 block discarded – undo
6600 6600
 	/**
6601 6601
 	 * @see AQueryWriter::getKeyMapForType
6602 6602
 	 */
6603
-	protected function getKeyMapForType( $type )
6603
+	protected function getKeyMapForType($type)
6604 6604
 	{
6605 6605
 		$databaseName = $this->adapter->getCell('SELECT DATABASE()');
6606
-		$table = $this->esc( $type, TRUE );
6606
+		$table = $this->esc($type, TRUE);
6607 6607
 		$keys = $this->adapter->get('
6608 6608
 			SELECT
6609 6609
 				information_schema.key_column_usage.constraint_name AS `name`,
@@ -6622,10 +6622,10 @@  discard block
 block discarded – undo
6622 6622
 				AND information_schema.key_column_usage.table_name = :table
6623 6623
 				AND information_schema.key_column_usage.constraint_name != \'PRIMARY\'
6624 6624
 				AND information_schema.key_column_usage.referenced_table_name IS NOT NULL
6625
-		', array( ':database' => $databaseName, ':table' => $table ) );
6625
+		', array(':database' => $databaseName, ':table' => $table));
6626 6626
 		$keyInfoList = array();
6627
-		foreach ( $keys as $k ) {
6628
-			$label = $this->makeFKLabel( $k['from'], $k['table'], $k['to'] );
6627
+		foreach ($keys as $k) {
6628
+			$label = $this->makeFKLabel($k['from'], $k['table'], $k['to']);
6629 6629
 			$keyInfoList[$label] = array(
6630 6630
 				'name'          => $k['name'],
6631 6631
 				'from'          => $k['from'],
@@ -6672,7 +6672,7 @@  discard block
 block discarded – undo
6672 6672
 	 *
6673 6673
 	 * @param Adapter $adapter Database Adapter
6674 6674
 	 */
6675
-	public function __construct( Adapter $adapter )
6675
+	public function __construct(Adapter $adapter)
6676 6676
 	{
6677 6677
 		$this->typeno_sqltype = array(
6678 6678
 			MySQL::C_DATATYPE_BOOL             => ' TINYINT(1) UNSIGNED ',
@@ -6694,8 +6694,8 @@  discard block
 block discarded – undo
6694 6694
 
6695 6695
 		$this->sqltype_typeno = array();
6696 6696
 
6697
-		foreach ( $this->typeno_sqltype as $k => $v ) {
6698
-			$this->sqltype_typeno[trim( strtolower( $v ) )] = $k;
6697
+		foreach ($this->typeno_sqltype as $k => $v) {
6698
+			$this->sqltype_typeno[trim(strtolower($v))] = $k;
6699 6699
 		}
6700 6700
 
6701 6701
 		$this->adapter = $adapter;
@@ -6719,34 +6719,34 @@  discard block
 block discarded – undo
6719 6719
 	 */
6720 6720
 	public function getTables()
6721 6721
 	{
6722
-		return $this->adapter->getCol( 'show tables' );
6722
+		return $this->adapter->getCol('show tables');
6723 6723
 	}
6724 6724
 
6725 6725
 	/**
6726 6726
 	 * @see QueryWriter::createTable
6727 6727
 	 */
6728
-	public function createTable( $table )
6728
+	public function createTable($table)
6729 6729
 	{
6730
-		$table = $this->esc( $table );
6730
+		$table = $this->esc($table);
6731 6731
 
6732
-		$charset_collate = $this->adapter->getDatabase()->getMysqlEncoding( TRUE );
6732
+		$charset_collate = $this->adapter->getDatabase()->getMysqlEncoding(TRUE);
6733 6733
 		$charset = $charset_collate['charset'];
6734 6734
 		$collate = $charset_collate['collate'];
6735 6735
 		
6736
-		$sql   = "CREATE TABLE $table (id INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY ( id )) ENGINE = InnoDB DEFAULT CHARSET={$charset} COLLATE={$collate} ";
6736
+		$sql = "CREATE TABLE $table (id INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY ( id )) ENGINE = InnoDB DEFAULT CHARSET={$charset} COLLATE={$collate} ";
6737 6737
 
6738
-		$this->adapter->exec( $sql );
6738
+		$this->adapter->exec($sql);
6739 6739
 	}
6740 6740
 
6741 6741
 	/**
6742 6742
 	 * @see QueryWriter::getColumns
6743 6743
 	 */
6744
-	public function getColumns( $table )
6744
+	public function getColumns($table)
6745 6745
 	{
6746
-		$columnsRaw = $this->adapter->get( "DESCRIBE " . $this->esc( $table ) );
6746
+		$columnsRaw = $this->adapter->get("DESCRIBE ".$this->esc($table));
6747 6747
 
6748 6748
 		$columns = array();
6749
-		foreach ( $columnsRaw as $r ) {
6749
+		foreach ($columnsRaw as $r) {
6750 6750
 			$columns[$r['Field']] = $r['Type'];
6751 6751
 		}
6752 6752
 
@@ -6756,64 +6756,64 @@  discard block
 block discarded – undo
6756 6756
 	/**
6757 6757
 	 * @see QueryWriter::scanType
6758 6758
 	 */
6759
-	public function scanType( $value, $flagSpecial = FALSE )
6759
+	public function scanType($value, $flagSpecial = FALSE)
6760 6760
 	{
6761 6761
 		$this->svalue = $value;
6762 6762
 
6763
-		if ( is_null( $value ) ) return MySQL::C_DATATYPE_BOOL;
6764
-		if ( $value === INF ) return MySQL::C_DATATYPE_TEXT7;
6763
+		if (is_null($value)) return MySQL::C_DATATYPE_BOOL;
6764
+		if ($value === INF) return MySQL::C_DATATYPE_TEXT7;
6765 6765
 
6766
-		if ( $flagSpecial ) {
6767
-			if ( preg_match( '/^-?\d+\.\d{2}$/', $value ) ) {
6766
+		if ($flagSpecial) {
6767
+			if (preg_match('/^-?\d+\.\d{2}$/', $value)) {
6768 6768
 				return MySQL::C_DATATYPE_SPECIAL_MONEY;
6769 6769
 			}
6770
-			if ( preg_match( '/^\d{4}\-\d\d-\d\d$/', $value ) ) {
6770
+			if (preg_match('/^\d{4}\-\d\d-\d\d$/', $value)) {
6771 6771
 				return MySQL::C_DATATYPE_SPECIAL_DATE;
6772 6772
 			}
6773
-			if ( preg_match( '/^\d{4}\-\d\d-\d\d\s\d\d:\d\d:\d\d$/', $value ) ) {
6773
+			if (preg_match('/^\d{4}\-\d\d-\d\d\s\d\d:\d\d:\d\d$/', $value)) {
6774 6774
 				return MySQL::C_DATATYPE_SPECIAL_DATETIME;
6775 6775
 			}
6776
-			if ( preg_match( '/^POINT\(/', $value ) ) {
6776
+			if (preg_match('/^POINT\(/', $value)) {
6777 6777
 				return MySQL::C_DATATYPE_SPECIAL_POINT;
6778 6778
 			}
6779
-			if ( preg_match( '/^LINESTRING\(/', $value ) ) {
6779
+			if (preg_match('/^LINESTRING\(/', $value)) {
6780 6780
 				return MySQL::C_DATATYPE_SPECIAL_LINESTRING;
6781 6781
 			}
6782
-			if ( preg_match( '/^POLYGON\(/', $value ) ) {
6782
+			if (preg_match('/^POLYGON\(/', $value)) {
6783 6783
 				return MySQL::C_DATATYPE_SPECIAL_POLYGON;
6784 6784
 			}
6785
-			if ( self::$flagUseJSONColumns && $this->isJSON( $value ) ) {
6785
+			if (self::$flagUseJSONColumns && $this->isJSON($value)) {
6786 6786
 				return self::C_DATATYPE_SPECIAL_JSON;
6787 6787
 			}
6788 6788
 		}
6789 6789
 
6790 6790
 		//setter turns TRUE FALSE into 0 and 1 because database has no real bools (TRUE and FALSE only for test?).
6791
-		if ( $value === FALSE || $value === TRUE || $value === '0' || $value === '1' ) {
6791
+		if ($value === FALSE || $value === TRUE || $value === '0' || $value === '1') {
6792 6792
 			return MySQL::C_DATATYPE_BOOL;
6793 6793
 		}
6794 6794
 
6795
-		if ( is_float( $value ) ) return self::C_DATATYPE_DOUBLE;
6795
+		if (is_float($value)) return self::C_DATATYPE_DOUBLE;
6796 6796
 
6797
-		if ( !$this->startsWithZeros( $value ) ) {
6797
+		if (!$this->startsWithZeros($value)) {
6798 6798
 
6799
-			if ( is_numeric( $value ) && ( floor( $value ) == $value ) && $value >= 0 && $value <= 4294967295 ) {
6799
+			if (is_numeric($value) && (floor($value) == $value) && $value >= 0 && $value <= 4294967295) {
6800 6800
 				return MySQL::C_DATATYPE_UINT32;
6801 6801
 			}
6802 6802
 
6803
-			if ( is_numeric( $value ) ) {
6803
+			if (is_numeric($value)) {
6804 6804
 				return MySQL::C_DATATYPE_DOUBLE;
6805 6805
 			}
6806 6806
 		}
6807 6807
 
6808
-		if ( mb_strlen( $value, 'UTF-8' ) <= 191 ) {
6808
+		if (mb_strlen($value, 'UTF-8') <= 191) {
6809 6809
 			return MySQL::C_DATATYPE_TEXT7;
6810 6810
 		}
6811 6811
 
6812
-		if ( mb_strlen( $value, 'UTF-8' ) <= 255 ) {
6812
+		if (mb_strlen($value, 'UTF-8') <= 255) {
6813 6813
 			return MySQL::C_DATATYPE_TEXT8;
6814 6814
 		}
6815 6815
 
6816
-		if ( mb_strlen( $value, 'UTF-8' ) <= 65535 ) {
6816
+		if (mb_strlen($value, 'UTF-8') <= 65535) {
6817 6817
 			return MySQL::C_DATATYPE_TEXT16;
6818 6818
 		}
6819 6819
 
@@ -6823,19 +6823,19 @@  discard block
 block discarded – undo
6823 6823
 	/**
6824 6824
 	 * @see QueryWriter::code
6825 6825
 	 */
6826
-	public function code( $typedescription, $includeSpecials = FALSE )
6826
+	public function code($typedescription, $includeSpecials = FALSE)
6827 6827
 	{
6828
-		if ( isset( $this->sqltype_typeno[$typedescription] ) ) {
6828
+		if (isset($this->sqltype_typeno[$typedescription])) {
6829 6829
 			$r = $this->sqltype_typeno[$typedescription];
6830 6830
 		} else {
6831 6831
 			$r = self::C_DATATYPE_SPECIFIED;
6832 6832
 		}
6833 6833
 
6834
-		if ( $includeSpecials ) {
6834
+		if ($includeSpecials) {
6835 6835
 			return $r;
6836 6836
 		}
6837 6837
 
6838
-		if ( $r >= QueryWriter::C_DATATYPE_RANGE_SPECIAL ) {
6838
+		if ($r >= QueryWriter::C_DATATYPE_RANGE_SPECIAL) {
6839 6839
 			return self::C_DATATYPE_SPECIFIED;
6840 6840
 		}
6841 6841
 
@@ -6845,19 +6845,19 @@  discard block
 block discarded – undo
6845 6845
 	/**
6846 6846
 	 * @see QueryWriter::addUniqueIndex
6847 6847
 	 */
6848
-	public function addUniqueConstraint( $type, $properties )
6848
+	public function addUniqueConstraint($type, $properties)
6849 6849
 	{
6850
-		$tableNoQ = $this->esc( $type, TRUE );
6850
+		$tableNoQ = $this->esc($type, TRUE);
6851 6851
 		$columns = array();
6852
-		foreach( $properties as $key => $column ) $columns[$key] = $this->esc( $column );
6853
-		$table = $this->esc( $type );
6854
-		sort( $columns ); // Else we get multiple indexes due to order-effects
6855
-		$name = 'UQ_' . sha1( implode( ',', $columns ) );
6852
+		foreach ($properties as $key => $column) $columns[$key] = $this->esc($column);
6853
+		$table = $this->esc($type);
6854
+		sort($columns); // Else we get multiple indexes due to order-effects
6855
+		$name = 'UQ_'.sha1(implode(',', $columns));
6856 6856
 		try {
6857 6857
 			$sql = "ALTER TABLE $table
6858
-						 ADD UNIQUE INDEX $name (" . implode( ',', $columns ) . ")";
6859
-			$this->adapter->exec( $sql );
6860
-		} catch ( SQLException $e ) {
6858
+						 ADD UNIQUE INDEX $name (".implode(',', $columns).")";
6859
+			$this->adapter->exec($sql);
6860
+		} catch (SQLException $e) {
6861 6861
 			//do nothing, dont use alter table ignore, this will delete duplicate records in 3-ways!
6862 6862
 			return FALSE;
6863 6863
 		}
@@ -6867,15 +6867,15 @@  discard block
 block discarded – undo
6867 6867
 	/**
6868 6868
 	 * @see QueryWriter::addIndex
6869 6869
 	 */
6870
-	public function addIndex( $type, $name, $property )
6870
+	public function addIndex($type, $name, $property)
6871 6871
 	{
6872 6872
 		try {
6873
-			$table  = $this->esc( $type );
6874
-			$name   = preg_replace( '/\W/', '', $name );
6875
-			$column = $this->esc( $property );
6876
-			$this->adapter->exec( "CREATE INDEX $name ON $table ($column) " );
6873
+			$table  = $this->esc($type);
6874
+			$name   = preg_replace('/\W/', '', $name);
6875
+			$column = $this->esc($property);
6876
+			$this->adapter->exec("CREATE INDEX $name ON $table ($column) ");
6877 6877
 			return TRUE;
6878
-		} catch ( SQLException $e ) {
6878
+		} catch (SQLException $e) {
6879 6879
 			return FALSE;
6880 6880
 		}
6881 6881
 	}
@@ -6884,35 +6884,35 @@  discard block
 block discarded – undo
6884 6884
 	 * @see QueryWriter::addFK
6885 6885
 	 * @return bool
6886 6886
 	 */
6887
-	public function addFK( $type, $targetType, $property, $targetProperty, $isDependent = FALSE )
6887
+	public function addFK($type, $targetType, $property, $targetProperty, $isDependent = FALSE)
6888 6888
 	{
6889
-		$table = $this->esc( $type );
6890
-		$targetTable = $this->esc( $targetType );
6891
-		$targetTableNoQ = $this->esc( $targetType, TRUE );
6892
-		$field = $this->esc( $property );
6893
-		$fieldNoQ = $this->esc( $property, TRUE );
6894
-		$targetField = $this->esc( $targetProperty );
6895
-		$targetFieldNoQ = $this->esc( $targetProperty, TRUE );
6896
-		$tableNoQ = $this->esc( $type, TRUE );
6897
-		$fieldNoQ = $this->esc( $property, TRUE );
6898
-		if ( !is_null( $this->getForeignKeyForTypeProperty( $tableNoQ, $fieldNoQ ) ) ) return FALSE;
6889
+		$table = $this->esc($type);
6890
+		$targetTable = $this->esc($targetType);
6891
+		$targetTableNoQ = $this->esc($targetType, TRUE);
6892
+		$field = $this->esc($property);
6893
+		$fieldNoQ = $this->esc($property, TRUE);
6894
+		$targetField = $this->esc($targetProperty);
6895
+		$targetFieldNoQ = $this->esc($targetProperty, TRUE);
6896
+		$tableNoQ = $this->esc($type, TRUE);
6897
+		$fieldNoQ = $this->esc($property, TRUE);
6898
+		if (!is_null($this->getForeignKeyForTypeProperty($tableNoQ, $fieldNoQ))) return FALSE;
6899 6899
 
6900 6900
 		//Widen the column if it's incapable of representing a foreign key (at least INT).
6901
-		$columns = $this->getColumns( $tableNoQ );
6901
+		$columns = $this->getColumns($tableNoQ);
6902 6902
 		$idType = $this->getTypeForID();
6903
-		if ( $this->code( $columns[$fieldNoQ] ) !==  $idType ) {
6904
-			$this->widenColumn( $type, $property, $idType );
6903
+		if ($this->code($columns[$fieldNoQ]) !== $idType) {
6904
+			$this->widenColumn($type, $property, $idType);
6905 6905
 		}
6906 6906
 
6907 6907
 		$fkName = 'fk_'.($tableNoQ.'_'.$fieldNoQ);
6908 6908
 		$cName = 'c_'.$fkName;
6909 6909
 		try {
6910
-			$this->adapter->exec( "
6910
+			$this->adapter->exec("
6911 6911
 				ALTER TABLE {$table}
6912 6912
 				ADD CONSTRAINT $cName
6913 6913
 				FOREIGN KEY $fkName ( `{$fieldNoQ}` ) REFERENCES `{$targetTableNoQ}`
6914
-				(`{$targetFieldNoQ}`) ON DELETE " . ( $isDependent ? 'CASCADE' : 'SET NULL' ) . ' ON UPDATE '.( $isDependent ? 'CASCADE' : 'SET NULL' ).';');
6915
-		} catch ( SQLException $e ) {
6914
+				(`{$targetFieldNoQ}`) ON DELETE ".($isDependent ? 'CASCADE' : 'SET NULL').' ON UPDATE '.($isDependent ? 'CASCADE' : 'SET NULL').';');
6915
+		} catch (SQLException $e) {
6916 6916
 			// Failure of fk-constraints is not a problem
6917 6917
 		}
6918 6918
 		return TRUE;
@@ -6921,7 +6921,7 @@  discard block
 block discarded – undo
6921 6921
 	/**
6922 6922
 	 * @see QueryWriter::sqlStateIn
6923 6923
 	 */
6924
-	public function sqlStateIn( $state, $list, $extraDriverDetails = array() )
6924
+	public function sqlStateIn($state, $list, $extraDriverDetails = array())
6925 6925
 	{
6926 6926
 		$stateMap = array(
6927 6927
 			'42S02' => QueryWriter::C_SQLSTATE_NO_SUCH_TABLE,
@@ -6929,15 +6929,15 @@  discard block
 block discarded – undo
6929 6929
 			'23000' => QueryWriter::C_SQLSTATE_INTEGRITY_CONSTRAINT_VIOLATION,
6930 6930
 		);
6931 6931
 
6932
-		if ( $state == 'HY000' && !empty( $extraDriverDetails[1] ) ) {
6932
+		if ($state == 'HY000' && !empty($extraDriverDetails[1])) {
6933 6933
 			$driverCode = $extraDriverDetails[1];
6934 6934
 
6935
-			if ( $driverCode == '1205' && in_array( QueryWriter::C_SQLSTATE_LOCK_TIMEOUT, $list ) ) {
6935
+			if ($driverCode == '1205' && in_array(QueryWriter::C_SQLSTATE_LOCK_TIMEOUT, $list)) {
6936 6936
 				return TRUE;
6937 6937
 			}
6938 6938
 		}
6939 6939
 
6940
-		return in_array( ( isset( $stateMap[$state] ) ? $stateMap[$state] : '0' ), $list );
6940
+		return in_array((isset($stateMap[$state]) ? $stateMap[$state] : '0'), $list);
6941 6941
 	}
6942 6942
 
6943 6943
 	/**
@@ -6946,14 +6946,14 @@  discard block
 block discarded – undo
6946 6946
 	public function wipeAll()
6947 6947
 	{
6948 6948
 		if (AQueryWriter::$noNuke) throw new \Exception('The nuke() command has been disabled using noNuke() or R::feature(novice/...).');
6949
-		$this->adapter->exec( 'SET FOREIGN_KEY_CHECKS = 0;' );
6949
+		$this->adapter->exec('SET FOREIGN_KEY_CHECKS = 0;');
6950 6950
 
6951
-		foreach ( $this->getTables() as $t ) {
6952
-			try { $this->adapter->exec( "DROP TABLE IF EXISTS `$t`" ); } catch ( SQLException $e ) { ; }
6953
-			try { $this->adapter->exec( "DROP VIEW IF EXISTS `$t`" ); } catch ( SQLException $e ) { ; }
6951
+		foreach ($this->getTables() as $t) {
6952
+			try { $this->adapter->exec("DROP TABLE IF EXISTS `$t`"); } catch (SQLException $e) {; }
6953
+			try { $this->adapter->exec("DROP VIEW IF EXISTS `$t`"); } catch (SQLException $e) {; }
6954 6954
 		}
6955 6955
 
6956
-		$this->adapter->exec( 'SET FOREIGN_KEY_CHECKS = 1;' );
6956
+		$this->adapter->exec('SET FOREIGN_KEY_CHECKS = 1;');
6957 6957
 	}
6958 6958
 }
6959 6959
 }
@@ -7015,12 +7015,12 @@  discard block
 block discarded – undo
7015 7015
 	 *
7016 7016
 	 * @return array
7017 7017
 	 */
7018
-	protected function getTable( $type )
7018
+	protected function getTable($type)
7019 7019
 	{
7020
-		$tableName = $this->esc( $type, TRUE );
7021
-		$columns   = $this->getColumns( $type );
7022
-		$indexes   = $this->getIndexes( $type );
7023
-		$keys      = $this->getKeyMapForType( $type );
7020
+		$tableName = $this->esc($type, TRUE);
7021
+		$columns   = $this->getColumns($type);
7022
+		$indexes   = $this->getIndexes($type);
7023
+		$keys      = $this->getKeyMapForType($type);
7024 7024
 
7025 7025
 		$table = array(
7026 7026
 			'columns' => $columns,
@@ -7044,30 +7044,30 @@  discard block
 block discarded – undo
7044 7044
 	 *
7045 7045
 	 * @return void
7046 7046
 	 */
7047
-	protected function putTable( $tableMap )
7047
+	protected function putTable($tableMap)
7048 7048
 	{
7049 7049
 		$table = $tableMap['name'];
7050 7050
 		$q     = array();
7051 7051
 		$q[]   = "DROP TABLE IF EXISTS tmp_backup;";
7052 7052
 
7053
-		$oldColumnNames = array_keys( $this->getColumns( $table ) );
7053
+		$oldColumnNames = array_keys($this->getColumns($table));
7054 7054
 
7055
-		foreach ( $oldColumnNames as $k => $v ) $oldColumnNames[$k] = "`$v`";
7055
+		foreach ($oldColumnNames as $k => $v) $oldColumnNames[$k] = "`$v`";
7056 7056
 
7057
-		$q[] = "CREATE TEMPORARY TABLE tmp_backup(" . implode( ",", $oldColumnNames ) . ");";
7057
+		$q[] = "CREATE TEMPORARY TABLE tmp_backup(".implode(",", $oldColumnNames).");";
7058 7058
 		$q[] = "INSERT INTO tmp_backup SELECT * FROM `$table`;";
7059 7059
 		$q[] = "PRAGMA foreign_keys = 0 ";
7060 7060
 		$q[] = "DROP TABLE `$table`;";
7061 7061
 
7062 7062
 		$newTableDefStr = '';
7063
-		foreach ( $tableMap['columns'] as $column => $type ) {
7064
-			if ( $column != 'id' ) {
7063
+		foreach ($tableMap['columns'] as $column => $type) {
7064
+			if ($column != 'id') {
7065 7065
 				$newTableDefStr .= ",`$column` $type";
7066 7066
 			}
7067 7067
 		}
7068 7068
 
7069 7069
 		$fkDef = '';
7070
-		foreach ( $tableMap['keys'] as $key ) {
7070
+		foreach ($tableMap['keys'] as $key) {
7071 7071
 			$fkDef .= ", FOREIGN KEY(`{$key['from']}`)
7072 7072
 						 REFERENCES `{$key['table']}`(`{$key['to']}`)
7073 7073
 						 ON DELETE {$key['on_delete']} ON UPDATE {$key['on_update']}";
@@ -7075,11 +7075,11 @@  discard block
 block discarded – undo
7075 7075
 
7076 7076
 		$q[] = "CREATE TABLE `$table` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT  $newTableDefStr  $fkDef );";
7077 7077
 
7078
-		foreach ( $tableMap['indexes'] as $name => $index ) {
7079
-			if ( strpos( $name, 'UQ_' ) === 0 ) {
7080
-				$cols = explode( '__', substr( $name, strlen( 'UQ_' . $table ) ) );
7081
-				foreach ( $cols as $k => $v ) $cols[$k] = "`$v`";
7082
-				$q[] = "CREATE UNIQUE INDEX $name ON `$table` (" . implode( ',', $cols ) . ")";
7078
+		foreach ($tableMap['indexes'] as $name => $index) {
7079
+			if (strpos($name, 'UQ_') === 0) {
7080
+				$cols = explode('__', substr($name, strlen('UQ_'.$table)));
7081
+				foreach ($cols as $k => $v) $cols[$k] = "`$v`";
7082
+				$q[] = "CREATE UNIQUE INDEX $name ON `$table` (".implode(',', $cols).")";
7083 7083
 			} else $q[] = "CREATE INDEX $name ON `$table` ({$index['name']}) ";
7084 7084
 		}
7085 7085
 
@@ -7087,7 +7087,7 @@  discard block
 block discarded – undo
7087 7087
 		$q[] = "DROP TABLE tmp_backup;";
7088 7088
 		$q[] = "PRAGMA foreign_keys = 1 ";
7089 7089
 
7090
-		foreach ( $q as $sq ) $this->adapter->exec( $sq );
7090
+		foreach ($q as $sq) $this->adapter->exec($sq);
7091 7091
 	}
7092 7092
 
7093 7093
 	/**
@@ -7097,14 +7097,14 @@  discard block
 block discarded – undo
7097 7097
 	 *
7098 7098
 	 * @return array
7099 7099
 	 */
7100
-	protected function getIndexes( $type )
7100
+	protected function getIndexes($type)
7101 7101
 	{
7102
-		$table   = $this->esc( $type, TRUE );
7103
-		$indexes = $this->adapter->get( "PRAGMA index_list('$table')" );
7102
+		$table   = $this->esc($type, TRUE);
7103
+		$indexes = $this->adapter->get("PRAGMA index_list('$table')");
7104 7104
 
7105 7105
 		$indexInfoList = array();
7106
-		foreach ( $indexes as $i ) {
7107
-			$indexInfoList[$i['name']] = $this->adapter->getRow( "PRAGMA index_info('{$i['name']}') " );
7106
+		foreach ($indexes as $i) {
7107
+			$indexInfoList[$i['name']] = $this->adapter->getRow("PRAGMA index_info('{$i['name']}') ");
7108 7108
 
7109 7109
 			$indexInfoList[$i['name']]['unique'] = $i['unique'];
7110 7110
 		}
@@ -7125,20 +7125,20 @@  discard block
 block discarded – undo
7125 7125
 	 *
7126 7126
 	 * @return boolean
7127 7127
 	 */
7128
-	protected function buildFK( $type, $targetType, $property, $targetProperty, $constraint = FALSE )
7128
+	protected function buildFK($type, $targetType, $property, $targetProperty, $constraint = FALSE)
7129 7129
 	{
7130
-		$table           = $this->esc( $type, TRUE );
7131
-		$targetTable     = $this->esc( $targetType, TRUE );
7132
-		$column          = $this->esc( $property, TRUE );
7133
-		$targetColumn    = $this->esc( $targetProperty, TRUE );
7130
+		$table           = $this->esc($type, TRUE);
7131
+		$targetTable     = $this->esc($targetType, TRUE);
7132
+		$column          = $this->esc($property, TRUE);
7133
+		$targetColumn    = $this->esc($targetProperty, TRUE);
7134 7134
 
7135 7135
 		$tables = $this->getTables();
7136
-		if ( !in_array( $targetTable, $tables ) ) return FALSE;
7136
+		if (!in_array($targetTable, $tables)) return FALSE;
7137 7137
 
7138
-		if ( !is_null( $this->getForeignKeyForTypeProperty( $table, $column ) ) ) return FALSE;
7139
-		$t = $this->getTable( $table );
7140
-		$consSQL = ( $constraint ? 'CASCADE' : 'SET NULL' );
7141
-		$label   = 'from_' . $column . '_to_table_' . $targetTable . '_col_' . $targetColumn;
7138
+		if (!is_null($this->getForeignKeyForTypeProperty($table, $column))) return FALSE;
7139
+		$t = $this->getTable($table);
7140
+		$consSQL = ($constraint ? 'CASCADE' : 'SET NULL');
7141
+		$label   = 'from_'.$column.'_to_table_'.$targetTable.'_col_'.$targetColumn;
7142 7142
 		$t['keys'][$label] = array(
7143 7143
 			'table'     => $targetTable,
7144 7144
 			'from'      => $column,
@@ -7146,20 +7146,20 @@  discard block
 block discarded – undo
7146 7146
 			'on_update' => $consSQL,
7147 7147
 			'on_delete' => $consSQL
7148 7148
 		);
7149
-		$this->putTable( $t );
7149
+		$this->putTable($t);
7150 7150
 		return TRUE;
7151 7151
 	}
7152 7152
 
7153 7153
 	/**
7154 7154
 	 * @see AQueryWriter::getKeyMapForType
7155 7155
 	 */
7156
-	protected function getKeyMapForType( $type )
7156
+	protected function getKeyMapForType($type)
7157 7157
 	{
7158
-		$table = $this->esc( $type, TRUE );
7159
-		$keys  = $this->adapter->get( "PRAGMA foreign_key_list('$table')" );
7158
+		$table = $this->esc($type, TRUE);
7159
+		$keys  = $this->adapter->get("PRAGMA foreign_key_list('$table')");
7160 7160
 		$keyInfoList = array();
7161
-		foreach ( $keys as $k ) {
7162
-			$label = $this->makeFKLabel( $k['from'], $k['table'], $k['to'] );
7161
+		foreach ($keys as $k) {
7162
+			$label = $this->makeFKLabel($k['from'], $k['table'], $k['to']);
7163 7163
 			$keyInfoList[$label] = array(
7164 7164
 				'name'          => $label,
7165 7165
 				'from'          => $k['from'],
@@ -7206,7 +7206,7 @@  discard block
 block discarded – undo
7206 7206
 	 *
7207 7207
 	 * @param Adapter $adapter Database Adapter
7208 7208
 	 */
7209
-	public function __construct( Adapter $adapter )
7209
+	public function __construct(Adapter $adapter)
7210 7210
 	{
7211 7211
 		$this->typeno_sqltype = array(
7212 7212
 			SQLiteT::C_DATATYPE_INTEGER => 'INTEGER',
@@ -7216,12 +7216,12 @@  discard block
 block discarded – undo
7216 7216
 
7217 7217
 		$this->sqltype_typeno = array();
7218 7218
 
7219
-		foreach ( $this->typeno_sqltype as $k => $v ) {
7219
+		foreach ($this->typeno_sqltype as $k => $v) {
7220 7220
 			$this->sqltype_typeno[$v] = $k;
7221 7221
 		}
7222 7222
 
7223 7223
 		$this->adapter = $adapter;
7224
-		$this->adapter->setOption( 'setInitQuery', ' PRAGMA foreign_keys = 1 ' );
7224
+		$this->adapter->setOption('setInitQuery', ' PRAGMA foreign_keys = 1 ');
7225 7225
 	}
7226 7226
 
7227 7227
 	/**
@@ -7238,22 +7238,22 @@  discard block
 block discarded – undo
7238 7238
 	/**
7239 7239
 	 * @see QueryWriter::scanType
7240 7240
 	 */
7241
-	public function scanType( $value, $flagSpecial = FALSE )
7241
+	public function scanType($value, $flagSpecial = FALSE)
7242 7242
 	{
7243 7243
 		$this->svalue = $value;
7244 7244
 
7245
-		if ( $value === NULL ) return self::C_DATATYPE_INTEGER;
7246
-		if ( $value === INF ) return self::C_DATATYPE_TEXT;
7245
+		if ($value === NULL) return self::C_DATATYPE_INTEGER;
7246
+		if ($value === INF) return self::C_DATATYPE_TEXT;
7247 7247
 
7248
-		if ( $this->startsWithZeros( $value ) ) return self::C_DATATYPE_TEXT;
7248
+		if ($this->startsWithZeros($value)) return self::C_DATATYPE_TEXT;
7249 7249
 
7250
-		if ( $value === TRUE || $value === FALSE )  return self::C_DATATYPE_INTEGER;
7250
+		if ($value === TRUE || $value === FALSE)  return self::C_DATATYPE_INTEGER;
7251 7251
 
7252
-		if ( is_numeric( $value ) && ( intval( $value ) == $value ) && $value < 2147483648 && $value > -2147483648 ) return self::C_DATATYPE_INTEGER;
7252
+		if (is_numeric($value) && (intval($value) == $value) && $value < 2147483648 && $value > -2147483648) return self::C_DATATYPE_INTEGER;
7253 7253
 
7254
-		if ( ( is_numeric( $value ) && $value < 2147483648 && $value > -2147483648)
7255
-			|| preg_match( '/\d{4}\-\d\d\-\d\d/', $value )
7256
-			|| preg_match( '/\d{4}\-\d\d\-\d\d\s\d\d:\d\d:\d\d/', $value )
7254
+		if ((is_numeric($value) && $value < 2147483648 && $value > -2147483648)
7255
+			|| preg_match('/\d{4}\-\d\d\-\d\d/', $value)
7256
+			|| preg_match('/\d{4}\-\d\d\-\d\d\s\d\d:\d\d:\d\d/', $value)
7257 7257
 		) {
7258 7258
 			return self::C_DATATYPE_NUMERIC;
7259 7259
 		}
@@ -7264,21 +7264,21 @@  discard block
 block discarded – undo
7264 7264
 	/**
7265 7265
 	 * @see QueryWriter::addColumn
7266 7266
 	 */
7267
-	public function addColumn( $table, $column, $type )
7267
+	public function addColumn($table, $column, $type)
7268 7268
 	{
7269
-		$column = $this->check( $column );
7270
-		$table  = $this->check( $table );
7269
+		$column = $this->check($column);
7270
+		$table  = $this->check($table);
7271 7271
 		$type   = $this->typeno_sqltype[$type];
7272 7272
 
7273
-		$this->adapter->exec( "ALTER TABLE `$table` ADD `$column` $type " );
7273
+		$this->adapter->exec("ALTER TABLE `$table` ADD `$column` $type ");
7274 7274
 	}
7275 7275
 
7276 7276
 	/**
7277 7277
 	 * @see QueryWriter::code
7278 7278
 	 */
7279
-	public function code( $typedescription, $includeSpecials = FALSE )
7279
+	public function code($typedescription, $includeSpecials = FALSE)
7280 7280
 	{
7281
-		$r = ( ( isset( $this->sqltype_typeno[$typedescription] ) ) ? $this->sqltype_typeno[$typedescription] : 99 );
7281
+		$r = ((isset($this->sqltype_typeno[$typedescription])) ? $this->sqltype_typeno[$typedescription] : 99);
7282 7282
 
7283 7283
 		return $r;
7284 7284
 	}
@@ -7286,13 +7286,13 @@  discard block
 block discarded – undo
7286 7286
 	/**
7287 7287
 	 * @see QueryWriter::widenColumn
7288 7288
 	 */
7289
-	public function widenColumn( $type, $column, $datatype )
7289
+	public function widenColumn($type, $column, $datatype)
7290 7290
 	{
7291
-		$t = $this->getTable( $type );
7291
+		$t = $this->getTable($type);
7292 7292
 
7293 7293
 		$t['columns'][$column] = $this->typeno_sqltype[$datatype];
7294 7294
 
7295
-		$this->putTable( $t );
7295
+		$this->putTable($t);
7296 7296
 	}
7297 7297
 
7298 7298
 	/**
@@ -7300,33 +7300,33 @@  discard block
 block discarded – undo
7300 7300
 	 */
7301 7301
 	public function getTables()
7302 7302
 	{
7303
-		return $this->adapter->getCol( "SELECT name FROM sqlite_master
7303
+		return $this->adapter->getCol("SELECT name FROM sqlite_master
7304 7304
 			WHERE type='table' AND name!='sqlite_sequence';" );
7305 7305
 	}
7306 7306
 
7307 7307
 	/**
7308 7308
 	 * @see QueryWriter::createTable
7309 7309
 	 */
7310
-	public function createTable( $table )
7310
+	public function createTable($table)
7311 7311
 	{
7312
-		$table = $this->esc( $table );
7312
+		$table = $this->esc($table);
7313 7313
 
7314 7314
 		$sql   = "CREATE TABLE $table ( id INTEGER PRIMARY KEY AUTOINCREMENT ) ";
7315 7315
 
7316
-		$this->adapter->exec( $sql );
7316
+		$this->adapter->exec($sql);
7317 7317
 	}
7318 7318
 
7319 7319
 	/**
7320 7320
 	 * @see QueryWriter::getColumns
7321 7321
 	 */
7322
-	public function getColumns( $table )
7322
+	public function getColumns($table)
7323 7323
 	{
7324
-		$table      = $this->esc( $table, TRUE );
7324
+		$table      = $this->esc($table, TRUE);
7325 7325
 
7326
-		$columnsRaw = $this->adapter->get( "PRAGMA table_info('$table')" );
7326
+		$columnsRaw = $this->adapter->get("PRAGMA table_info('$table')");
7327 7327
 
7328 7328
 		$columns    = array();
7329
-		foreach ( $columnsRaw as $r ) $columns[$r['name']] = $r['type'];
7329
+		foreach ($columnsRaw as $r) $columns[$r['name']] = $r['type'];
7330 7330
 
7331 7331
 		return $columns;
7332 7332
 	}
@@ -7334,15 +7334,15 @@  discard block
 block discarded – undo
7334 7334
 	/**
7335 7335
 	 * @see QueryWriter::addUniqueIndex
7336 7336
 	 */
7337
-	public function addUniqueConstraint( $type, $properties )
7337
+	public function addUniqueConstraint($type, $properties)
7338 7338
 	{
7339
-		$tableNoQ = $this->esc( $type, TRUE );
7340
-		$name  = 'UQ_' . $this->esc( $type, TRUE ) . implode( '__', $properties );
7341
-		$t     = $this->getTable( $type );
7342
-		$t['indexes'][$name] = array( 'name' => $name );
7339
+		$tableNoQ = $this->esc($type, TRUE);
7340
+		$name  = 'UQ_'.$this->esc($type, TRUE).implode('__', $properties);
7341
+		$t     = $this->getTable($type);
7342
+		$t['indexes'][$name] = array('name' => $name);
7343 7343
 		try {
7344
-			$this->putTable( $t );
7345
-		} catch( SQLException $e ) {
7344
+			$this->putTable($t);
7345
+		} catch (SQLException $e) {
7346 7346
 			return FALSE;
7347 7347
 		}
7348 7348
 		return TRUE;
@@ -7351,40 +7351,40 @@  discard block
 block discarded – undo
7351 7351
 	/**
7352 7352
 	 * @see QueryWriter::sqlStateIn
7353 7353
 	 */
7354
-	public function sqlStateIn( $state, $list, $extraDriverDetails = array() )
7354
+	public function sqlStateIn($state, $list, $extraDriverDetails = array())
7355 7355
 	{
7356 7356
 		$stateMap = array(
7357 7357
 			'23000' => QueryWriter::C_SQLSTATE_INTEGRITY_CONSTRAINT_VIOLATION
7358 7358
 		);
7359
-		if ( $state == 'HY000'
7359
+		if ($state == 'HY000'
7360 7360
 		&& isset($extraDriverDetails[1])
7361 7361
 		&& $extraDriverDetails[1] == 1
7362
-		&& ( in_array( QueryWriter::C_SQLSTATE_NO_SUCH_TABLE, $list )
7363
-			|| in_array( QueryWriter::C_SQLSTATE_NO_SUCH_COLUMN, $list )
7362
+		&& (in_array(QueryWriter::C_SQLSTATE_NO_SUCH_TABLE, $list)
7363
+			|| in_array(QueryWriter::C_SQLSTATE_NO_SUCH_COLUMN, $list)
7364 7364
 		)) {
7365 7365
 			return TRUE;
7366 7366
 		}
7367
-		return in_array( ( isset( $stateMap[$state] ) ? $stateMap[$state] : '0' ), $list );
7367
+		return in_array((isset($stateMap[$state]) ? $stateMap[$state] : '0'), $list);
7368 7368
 	}
7369 7369
 
7370 7370
 	/**
7371 7371
 	 * @see QueryWriter::addIndex
7372 7372
 	 */
7373
-	public function addIndex( $type, $name, $column )
7373
+	public function addIndex($type, $name, $column)
7374 7374
 	{
7375
-		$columns = $this->getColumns( $type );
7376
-		if ( !isset( $columns[$column] ) ) return FALSE;
7375
+		$columns = $this->getColumns($type);
7376
+		if (!isset($columns[$column])) return FALSE;
7377 7377
 
7378
-		$table  = $this->esc( $type );
7379
-		$name   = preg_replace( '/\W/', '', $name );
7380
-		$column = $this->esc( $column, TRUE );
7378
+		$table  = $this->esc($type);
7379
+		$name   = preg_replace('/\W/', '', $name);
7380
+		$column = $this->esc($column, TRUE);
7381 7381
 
7382 7382
 		try {
7383
-			$t = $this->getTable( $type );
7384
-			$t['indexes'][$name] = array( 'name' => $column );
7385
-			$this->putTable( $t );
7383
+			$t = $this->getTable($type);
7384
+			$t['indexes'][$name] = array('name' => $column);
7385
+			$this->putTable($t);
7386 7386
 			return TRUE;
7387
-		} catch( SQLException $exception ) {
7387
+		} catch (SQLException $exception) {
7388 7388
 			return FALSE;
7389 7389
 		}
7390 7390
 	}
@@ -7392,19 +7392,19 @@  discard block
 block discarded – undo
7392 7392
 	/**
7393 7393
 	 * @see QueryWriter::wipe
7394 7394
 	 */
7395
-	public function wipe( $type )
7395
+	public function wipe($type)
7396 7396
 	{
7397
-		$table = $this->esc( $type );
7397
+		$table = $this->esc($type);
7398 7398
 
7399
-		$this->adapter->exec( "DELETE FROM $table " );
7399
+		$this->adapter->exec("DELETE FROM $table ");
7400 7400
 	}
7401 7401
 
7402 7402
 	/**
7403 7403
 	 * @see QueryWriter::addFK
7404 7404
 	 */
7405
-	public function addFK( $type, $targetType, $property, $targetProperty, $isDep = FALSE )
7405
+	public function addFK($type, $targetType, $property, $targetProperty, $isDep = FALSE)
7406 7406
 	{
7407
-		return $this->buildFK( $type, $targetType, $property, $targetProperty, $isDep );
7407
+		return $this->buildFK($type, $targetType, $property, $targetProperty, $isDep);
7408 7408
 	}
7409 7409
 
7410 7410
 	/**
@@ -7413,14 +7413,14 @@  discard block
 block discarded – undo
7413 7413
 	public function wipeAll()
7414 7414
 	{
7415 7415
 		if (AQueryWriter::$noNuke) throw new \Exception('The nuke() command has been disabled using noNuke() or R::feature(novice/...).');
7416
-		$this->adapter->exec( 'PRAGMA foreign_keys = 0 ' );
7416
+		$this->adapter->exec('PRAGMA foreign_keys = 0 ');
7417 7417
 
7418
-		foreach ( $this->getTables() as $t ) {
7419
-			try { $this->adapter->exec( "DROP TABLE IF EXISTS `$t`" ); } catch ( SQLException $e ) { ; }
7420
-			try { $this->adapter->exec( "DROP TABLE IF EXISTS `$t`" ); } catch ( SQLException $e ) { ; }
7418
+		foreach ($this->getTables() as $t) {
7419
+			try { $this->adapter->exec("DROP TABLE IF EXISTS `$t`"); } catch (SQLException $e) {; }
7420
+			try { $this->adapter->exec("DROP TABLE IF EXISTS `$t`"); } catch (SQLException $e) {; }
7421 7421
 		}
7422 7422
 
7423
-		$this->adapter->exec( 'PRAGMA foreign_keys = 1 ' );
7423
+		$this->adapter->exec('PRAGMA foreign_keys = 1 ');
7424 7424
 	}
7425 7425
 }
7426 7426
 }
@@ -7490,7 +7490,7 @@  discard block
 block discarded – undo
7490 7490
 	 *
7491 7491
 	 * @return  string $sql SQL Snippet
7492 7492
 	 */
7493
-	protected function getInsertSuffix( $table )
7493
+	protected function getInsertSuffix($table)
7494 7494
 	{
7495 7495
 		return 'RETURNING id ';
7496 7496
 	}
@@ -7498,10 +7498,10 @@  discard block
 block discarded – undo
7498 7498
 	/**
7499 7499
 	 * @see AQueryWriter::getKeyMapForType
7500 7500
 	 */
7501
-	protected function getKeyMapForType( $type )
7501
+	protected function getKeyMapForType($type)
7502 7502
 	{
7503
-		$table = $this->esc( $type, TRUE );
7504
-		$keys = $this->adapter->get( '
7503
+		$table = $this->esc($type, TRUE);
7504
+		$keys = $this->adapter->get('
7505 7505
 			SELECT
7506 7506
 			information_schema.key_column_usage.constraint_name AS "name",
7507 7507
 			information_schema.key_column_usage.column_name AS "from",
@@ -7532,10 +7532,10 @@  discard block
 block discarded – undo
7532 7532
 				information_schema.key_column_usage.table_catalog = current_database()
7533 7533
 				AND information_schema.key_column_usage.table_schema = ANY( current_schemas( FALSE ) )
7534 7534
 				AND information_schema.key_column_usage.table_name = ?
7535
-		', array( $type ) );
7535
+		', array($type));
7536 7536
 		$keyInfoList = array();
7537
-		foreach ( $keys as $k ) {
7538
-			$label = $this->makeFKLabel( $k['from'], $k['table'], $k['to'] );
7537
+		foreach ($keys as $k) {
7538
+			$label = $this->makeFKLabel($k['from'], $k['table'], $k['to']);
7539 7539
 			$keyInfoList[$label] = array(
7540 7540
 				'name'          => $k['name'],
7541 7541
 				'from'          => $k['from'],
@@ -7582,7 +7582,7 @@  discard block
 block discarded – undo
7582 7582
 	 *
7583 7583
 	 * @param Adapter $adapter Database Adapter
7584 7584
 	 */
7585
-	public function __construct( Adapter $adapter )
7585
+	public function __construct(Adapter $adapter)
7586 7586
 	{
7587 7587
 		$this->typeno_sqltype = array(
7588 7588
 			self::C_DATATYPE_INTEGER          => ' integer ',
@@ -7603,8 +7603,8 @@  discard block
 block discarded – undo
7603 7603
 
7604 7604
 		$this->sqltype_typeno = array();
7605 7605
 
7606
-		foreach ( $this->typeno_sqltype as $k => $v ) {
7607
-			$this->sqltype_typeno[trim( strtolower( $v ) )] = $k;
7606
+		foreach ($this->typeno_sqltype as $k => $v) {
7607
+			$this->sqltype_typeno[trim(strtolower($v))] = $k;
7608 7608
 		}
7609 7609
 
7610 7610
 		$this->adapter = $adapter;
@@ -7626,30 +7626,30 @@  discard block
 block discarded – undo
7626 7626
 	 */
7627 7627
 	public function getTables()
7628 7628
 	{
7629
-		return $this->adapter->getCol( 'SELECT table_name FROM information_schema.tables WHERE table_schema = ANY( current_schemas( FALSE ) )' );
7629
+		return $this->adapter->getCol('SELECT table_name FROM information_schema.tables WHERE table_schema = ANY( current_schemas( FALSE ) )');
7630 7630
 	}
7631 7631
 
7632 7632
 	/**
7633 7633
 	 * @see QueryWriter::createTable
7634 7634
 	 */
7635
-	public function createTable( $table )
7635
+	public function createTable($table)
7636 7636
 	{
7637
-		$table = $this->esc( $table );
7637
+		$table = $this->esc($table);
7638 7638
 
7639
-		$this->adapter->exec( " CREATE TABLE $table (id SERIAL PRIMARY KEY); " );
7639
+		$this->adapter->exec(" CREATE TABLE $table (id SERIAL PRIMARY KEY); ");
7640 7640
 	}
7641 7641
 
7642 7642
 	/**
7643 7643
 	 * @see QueryWriter::getColumns
7644 7644
 	 */
7645
-	public function getColumns( $table )
7645
+	public function getColumns($table)
7646 7646
 	{
7647
-		$table      = $this->esc( $table, TRUE );
7647
+		$table      = $this->esc($table, TRUE);
7648 7648
 
7649
-		$columnsRaw = $this->adapter->get( "SELECT column_name, data_type FROM information_schema.columns WHERE table_name='$table' AND table_schema = ANY( current_schemas( FALSE ) )" );
7649
+		$columnsRaw = $this->adapter->get("SELECT column_name, data_type FROM information_schema.columns WHERE table_name='$table' AND table_schema = ANY( current_schemas( FALSE ) )");
7650 7650
 
7651 7651
 		$columns = array();
7652
-		foreach ( $columnsRaw as $r ) {
7652
+		foreach ($columnsRaw as $r) {
7653 7653
 			$columns[$r['column_name']] = $r['data_type'];
7654 7654
 		}
7655 7655
 
@@ -7659,60 +7659,60 @@  discard block
 block discarded – undo
7659 7659
 	/**
7660 7660
 	 * @see QueryWriter::scanType
7661 7661
 	 */
7662
-	public function scanType( $value, $flagSpecial = FALSE )
7662
+	public function scanType($value, $flagSpecial = FALSE)
7663 7663
 	{
7664 7664
 		$this->svalue = $value;
7665 7665
 
7666
-		if ( $value === INF ) return self::C_DATATYPE_TEXT;
7666
+		if ($value === INF) return self::C_DATATYPE_TEXT;
7667 7667
 
7668
-		if ( $flagSpecial && $value ) {
7669
-			if ( preg_match( '/^\d{4}\-\d\d-\d\d$/', $value ) ) {
7668
+		if ($flagSpecial && $value) {
7669
+			if (preg_match('/^\d{4}\-\d\d-\d\d$/', $value)) {
7670 7670
 				return PostgreSQL::C_DATATYPE_SPECIAL_DATE;
7671 7671
 			}
7672 7672
 
7673
-			if ( preg_match( '/^\d{4}\-\d\d-\d\d\s\d\d:\d\d:\d\d(\.\d{1,6})?$/', $value ) ) {
7673
+			if (preg_match('/^\d{4}\-\d\d-\d\d\s\d\d:\d\d:\d\d(\.\d{1,6})?$/', $value)) {
7674 7674
 				return PostgreSQL::C_DATATYPE_SPECIAL_DATETIME;
7675 7675
 			}
7676 7676
 
7677
-			if ( preg_match( '/^\([\d\.]+,[\d\.]+\)$/', $value ) ) {
7677
+			if (preg_match('/^\([\d\.]+,[\d\.]+\)$/', $value)) {
7678 7678
 				return PostgreSQL::C_DATATYPE_SPECIAL_POINT;
7679 7679
 			}
7680 7680
 
7681
-			if ( preg_match( '/^\[\([\d\.]+,[\d\.]+\),\([\d\.]+,[\d\.]+\)\]$/', $value ) ) {
7681
+			if (preg_match('/^\[\([\d\.]+,[\d\.]+\),\([\d\.]+,[\d\.]+\)\]$/', $value)) {
7682 7682
 				return PostgreSQL::C_DATATYPE_SPECIAL_LSEG;
7683 7683
 			}
7684 7684
 
7685
-			if ( preg_match( '/^\<\([\d\.]+,[\d\.]+\),[\d\.]+\>$/', $value ) ) {
7685
+			if (preg_match('/^\<\([\d\.]+,[\d\.]+\),[\d\.]+\>$/', $value)) {
7686 7686
 				return PostgreSQL::C_DATATYPE_SPECIAL_CIRCLE;
7687 7687
 			}
7688 7688
 
7689
-			if ( preg_match( '/^\((\([\d\.]+,[\d\.]+\),?)+\)$/', $value ) ) {
7689
+			if (preg_match('/^\((\([\d\.]+,[\d\.]+\),?)+\)$/', $value)) {
7690 7690
 				return PostgreSQL::C_DATATYPE_SPECIAL_POLYGON;
7691 7691
 			}
7692 7692
 
7693
-			if ( preg_match( '/^\-?(\$|€|¥|£)[\d,\.]+$/', $value ) ) {
7693
+			if (preg_match('/^\-?(\$|€|¥|£)[\d,\.]+$/', $value)) {
7694 7694
 				return PostgreSQL::C_DATATYPE_SPECIAL_MONEY;
7695 7695
 			}
7696 7696
 
7697
-			if ( preg_match( '/^-?\d+\.\d{2}$/', $value ) ) {
7697
+			if (preg_match('/^-?\d+\.\d{2}$/', $value)) {
7698 7698
 				return PostgreSQL::C_DATATYPE_SPECIAL_MONEY2;
7699 7699
 			}
7700
-			if ( self::$flagUseJSONColumns && $this->isJSON( $value ) ) {
7700
+			if (self::$flagUseJSONColumns && $this->isJSON($value)) {
7701 7701
 				return self::C_DATATYPE_SPECIAL_JSON;
7702 7702
 			}
7703 7703
 		}
7704 7704
 
7705
-		if ( is_float( $value ) ) return self::C_DATATYPE_DOUBLE;
7705
+		if (is_float($value)) return self::C_DATATYPE_DOUBLE;
7706 7706
 
7707
-		if ( $this->startsWithZeros( $value ) ) return self::C_DATATYPE_TEXT;
7707
+		if ($this->startsWithZeros($value)) return self::C_DATATYPE_TEXT;
7708 7708
 
7709
-		if ( $value === FALSE || $value === TRUE || $value === NULL || ( is_numeric( $value )
7710
-				&& AQueryWriter::canBeTreatedAsInt( $value )
7709
+		if ($value === FALSE || $value === TRUE || $value === NULL || (is_numeric($value)
7710
+				&& AQueryWriter::canBeTreatedAsInt($value)
7711 7711
 				&& $value < 2147483648
7712
-				&& $value > -2147483648 )
7712
+				&& $value > -2147483648)
7713 7713
 		) {
7714 7714
 			return self::C_DATATYPE_INTEGER;
7715
-		} elseif ( is_numeric( $value ) ) {
7715
+		} elseif (is_numeric($value)) {
7716 7716
 			return self::C_DATATYPE_DOUBLE;
7717 7717
 		} else {
7718 7718
 			return self::C_DATATYPE_TEXT;
@@ -7722,13 +7722,13 @@  discard block
 block discarded – undo
7722 7722
 	/**
7723 7723
 	 * @see QueryWriter::code
7724 7724
 	 */
7725
-	public function code( $typedescription, $includeSpecials = FALSE )
7725
+	public function code($typedescription, $includeSpecials = FALSE)
7726 7726
 	{
7727
-		$r = ( isset( $this->sqltype_typeno[$typedescription] ) ) ? $this->sqltype_typeno[$typedescription] : 99;
7727
+		$r = (isset($this->sqltype_typeno[$typedescription])) ? $this->sqltype_typeno[$typedescription] : 99;
7728 7728
 
7729
-		if ( $includeSpecials ) return $r;
7729
+		if ($includeSpecials) return $r;
7730 7730
 
7731
-		if ( $r >= QueryWriter::C_DATATYPE_RANGE_SPECIAL ) {
7731
+		if ($r >= QueryWriter::C_DATATYPE_RANGE_SPECIAL) {
7732 7732
 			return self::C_DATATYPE_SPECIFIED;
7733 7733
 		}
7734 7734
 
@@ -7738,35 +7738,35 @@  discard block
 block discarded – undo
7738 7738
 	/**
7739 7739
 	 * @see QueryWriter::widenColumn
7740 7740
 	 */
7741
-	public function widenColumn( $type, $column, $datatype )
7741
+	public function widenColumn($type, $column, $datatype)
7742 7742
 	{
7743 7743
 		$table   = $type;
7744 7744
 		$type    = $datatype;
7745 7745
 
7746
-		$table   = $this->esc( $table );
7747
-		$column  = $this->esc( $column );
7746
+		$table   = $this->esc($table);
7747
+		$column  = $this->esc($column);
7748 7748
 
7749 7749
 		$newtype = $this->typeno_sqltype[$type];
7750 7750
 
7751
-		$this->adapter->exec( "ALTER TABLE $table \n\t ALTER COLUMN $column TYPE $newtype " );
7751
+		$this->adapter->exec("ALTER TABLE $table \n\t ALTER COLUMN $column TYPE $newtype ");
7752 7752
 	}
7753 7753
 
7754 7754
 	/**
7755 7755
 	 * @see QueryWriter::addUniqueIndex
7756 7756
 	 */
7757
-	public function addUniqueConstraint( $type, $properties )
7757
+	public function addUniqueConstraint($type, $properties)
7758 7758
 	{
7759
-		$tableNoQ = $this->esc( $type, TRUE );
7759
+		$tableNoQ = $this->esc($type, TRUE);
7760 7760
 		$columns = array();
7761
-		foreach( $properties as $key => $column ) $columns[$key] = $this->esc( $column );
7762
-		$table = $this->esc( $type );
7763
-		sort( $columns ); //else we get multiple indexes due to order-effects
7764
-		$name = "UQ_" . sha1( $table . implode( ',', $columns ) );
7761
+		foreach ($properties as $key => $column) $columns[$key] = $this->esc($column);
7762
+		$table = $this->esc($type);
7763
+		sort($columns); //else we get multiple indexes due to order-effects
7764
+		$name = "UQ_".sha1($table.implode(',', $columns));
7765 7765
 		$sql = "ALTER TABLE {$table}
7766
-                ADD CONSTRAINT $name UNIQUE (" . implode( ',', $columns ) . ")";
7766
+                ADD CONSTRAINT $name UNIQUE (".implode(',', $columns).")";
7767 7767
 		try {
7768
-			$this->adapter->exec( $sql );
7769
-		} catch( SQLException $e ) {
7768
+			$this->adapter->exec($sql);
7769
+		} catch (SQLException $e) {
7770 7770
 			return FALSE;
7771 7771
 		}
7772 7772
 		return TRUE;
@@ -7775,7 +7775,7 @@  discard block
 block discarded – undo
7775 7775
 	/**
7776 7776
 	 * @see QueryWriter::sqlStateIn
7777 7777
 	 */
7778
-	public function sqlStateIn( $state, $list, $extraDriverDetails = array() )
7778
+	public function sqlStateIn($state, $list, $extraDriverDetails = array())
7779 7779
 	{
7780 7780
 		$stateMap = array(
7781 7781
 			'42P01' => QueryWriter::C_SQLSTATE_NO_SUCH_TABLE,
@@ -7783,22 +7783,22 @@  discard block
 block discarded – undo
7783 7783
 			'23505' => QueryWriter::C_SQLSTATE_INTEGRITY_CONSTRAINT_VIOLATION,
7784 7784
 			'55P03' => QueryWriter::C_SQLSTATE_LOCK_TIMEOUT
7785 7785
 		);
7786
-		return in_array( ( isset( $stateMap[$state] ) ? $stateMap[$state] : '0' ), $list );
7786
+		return in_array((isset($stateMap[$state]) ? $stateMap[$state] : '0'), $list);
7787 7787
 	}
7788 7788
 
7789 7789
 	/**
7790 7790
 	 * @see QueryWriter::addIndex
7791 7791
 	 */
7792
-	public function addIndex( $type, $name, $property )
7792
+	public function addIndex($type, $name, $property)
7793 7793
 	{
7794
-		$table  = $this->esc( $type );
7795
-		$name   = preg_replace( '/\W/', '', $name );
7796
-		$column = $this->esc( $property );
7794
+		$table  = $this->esc($type);
7795
+		$name   = preg_replace('/\W/', '', $name);
7796
+		$column = $this->esc($property);
7797 7797
 
7798 7798
 		try {
7799
-			$this->adapter->exec( "CREATE INDEX {$name} ON $table ({$column}) " );
7799
+			$this->adapter->exec("CREATE INDEX {$name} ON $table ({$column}) ");
7800 7800
 			return TRUE;
7801
-		} catch ( SQLException $e ) {
7801
+		} catch (SQLException $e) {
7802 7802
 			return FALSE;
7803 7803
 		}
7804 7804
 	}
@@ -7806,22 +7806,22 @@  discard block
 block discarded – undo
7806 7806
 	/**
7807 7807
 	 * @see QueryWriter::addFK
7808 7808
 	 */
7809
-	public function addFK( $type, $targetType, $property, $targetProperty, $isDep = FALSE )
7810
-	{
7811
-		$table = $this->esc( $type );
7812
-		$targetTable = $this->esc( $targetType );
7813
-		$field = $this->esc( $property );
7814
-		$targetField = $this->esc( $targetProperty );
7815
-		$tableNoQ = $this->esc( $type, TRUE );
7816
-		$fieldNoQ = $this->esc( $property, TRUE );
7817
-		if ( !is_null( $this->getForeignKeyForTypeProperty( $tableNoQ, $fieldNoQ ) ) ) return FALSE;
7818
-		try{
7819
-			$delRule = ( $isDep ? 'CASCADE' : 'SET NULL' );
7820
-			$this->adapter->exec( "ALTER TABLE {$table}
7809
+	public function addFK($type, $targetType, $property, $targetProperty, $isDep = FALSE)
7810
+	{
7811
+		$table = $this->esc($type);
7812
+		$targetTable = $this->esc($targetType);
7813
+		$field = $this->esc($property);
7814
+		$targetField = $this->esc($targetProperty);
7815
+		$tableNoQ = $this->esc($type, TRUE);
7816
+		$fieldNoQ = $this->esc($property, TRUE);
7817
+		if (!is_null($this->getForeignKeyForTypeProperty($tableNoQ, $fieldNoQ))) return FALSE;
7818
+		try {
7819
+			$delRule = ($isDep ? 'CASCADE' : 'SET NULL');
7820
+			$this->adapter->exec("ALTER TABLE {$table}
7821 7821
 				ADD FOREIGN KEY ( {$field} ) REFERENCES  {$targetTable}
7822
-				({$targetField}) ON DELETE {$delRule} ON UPDATE {$delRule} DEFERRABLE ;" );
7822
+				({$targetField}) ON DELETE {$delRule} ON UPDATE {$delRule} DEFERRABLE ;");
7823 7823
 			return TRUE;
7824
-		} catch ( SQLException $e ) {
7824
+		} catch (SQLException $e) {
7825 7825
 			return FALSE;
7826 7826
 		}
7827 7827
 	}
@@ -7832,15 +7832,15 @@  discard block
 block discarded – undo
7832 7832
 	public function wipeAll()
7833 7833
 	{
7834 7834
 		if (AQueryWriter::$noNuke) throw new \Exception('The nuke() command has been disabled using noNuke() or R::feature(novice/...).');
7835
-		$this->adapter->exec( 'SET CONSTRAINTS ALL DEFERRED' );
7835
+		$this->adapter->exec('SET CONSTRAINTS ALL DEFERRED');
7836 7836
 
7837
-		foreach ( $this->getTables() as $t ) {
7838
-			$t = $this->esc( $t );
7837
+		foreach ($this->getTables() as $t) {
7838
+			$t = $this->esc($t);
7839 7839
 			//Some plugins (PostGIS have unremovable tables/views), avoid exceptions.
7840
-			try { $this->adapter->exec( "DROP TABLE IF EXISTS $t CASCADE " ); }catch( \Exception $e ) {}
7840
+			try { $this->adapter->exec("DROP TABLE IF EXISTS $t CASCADE "); } catch (\Exception $e) {}
7841 7841
 		}
7842 7842
 
7843
-		$this->adapter->exec( 'SET CONSTRAINTS ALL IMMEDIATE' );
7843
+		$this->adapter->exec('SET CONSTRAINTS ALL IMMEDIATE');
7844 7844
 	}
7845 7845
 }
7846 7846
 }
@@ -7905,22 +7905,22 @@  discard block
 block discarded – undo
7905 7905
 	 *
7906 7906
 	 * @return bool
7907 7907
 	 */
7908
-	protected function buildFK( $type, $targetType, $property, $targetProperty, $isDep = FALSE )
7908
+	protected function buildFK($type, $targetType, $property, $targetProperty, $isDep = FALSE)
7909 7909
 	{
7910
-		$table           = $this->esc( $type );
7911
-		$tableNoQ        = $this->esc( $type, TRUE );
7912
-		$targetTable     = $this->esc( $targetType );
7913
-		$targetTableNoQ  = $this->esc( $targetType, TRUE );
7914
-		$column          = $this->esc( $property );
7915
-		$columnNoQ       = $this->esc( $property, TRUE );
7916
-		$targetColumn    = $this->esc( $targetProperty );
7917
-		if ( !is_null( $this->getForeignKeyForTypeProperty( $tableNoQ, $columnNoQ ) ) ) return FALSE;
7910
+		$table           = $this->esc($type);
7911
+		$tableNoQ        = $this->esc($type, TRUE);
7912
+		$targetTable     = $this->esc($targetType);
7913
+		$targetTableNoQ  = $this->esc($targetType, TRUE);
7914
+		$column          = $this->esc($property);
7915
+		$columnNoQ       = $this->esc($property, TRUE);
7916
+		$targetColumn    = $this->esc($targetProperty);
7917
+		if (!is_null($this->getForeignKeyForTypeProperty($tableNoQ, $columnNoQ))) return FALSE;
7918 7918
 		$needsToDropFK   = FALSE;
7919
-		$casc = ( $isDep ? 'CASCADE' : 'SET NULL' );
7919
+		$casc = ($isDep ? 'CASCADE' : 'SET NULL');
7920 7920
 		$sql  = "ALTER TABLE $table ADD CONSTRAINT FOREIGN KEY($column) REFERENCES $targetTable($targetColumn) ON DELETE $casc ";
7921 7921
 		try {
7922
-			$this->adapter->exec( $sql );
7923
-		} catch( SQLException $e ) {
7922
+			$this->adapter->exec($sql);
7923
+		} catch (SQLException $e) {
7924 7924
 			return FALSE;
7925 7925
 		}
7926 7926
 		return TRUE;
@@ -7929,18 +7929,18 @@  discard block
 block discarded – undo
7929 7929
 	/**
7930 7930
 	 * @see AQueryWriter::getKeyMapForType
7931 7931
 	 */
7932
-	protected function getKeyMapForType( $type  )
7932
+	protected function getKeyMapForType($type)
7933 7933
 	{
7934 7934
 		$sqlCode = $this->adapter->get("SHOW CREATE TABLE `{$type}`");
7935 7935
 		if (!isset($sqlCode[0])) return array();
7936 7936
 		$matches = array();
7937
-		preg_match_all( '/CONSTRAINT\s+\[([\w_]+)\]\s+FOREIGN\s+KEY\s+\(\[([\w_]+)\]\)\s+REFERENCES\s+\[([\w_]+)\](\s+ON\s+DELETE\s+(CASCADE|SET\sNULL|RESTRICT|NO\sACTION)\s+ON\s+UPDATE\s+(SET\sNULL|RESTRICT|NO\sACTION))?/', $sqlCode[0]['CREATE TABLE'], $matches );
7937
+		preg_match_all('/CONSTRAINT\s+\[([\w_]+)\]\s+FOREIGN\s+KEY\s+\(\[([\w_]+)\]\)\s+REFERENCES\s+\[([\w_]+)\](\s+ON\s+DELETE\s+(CASCADE|SET\sNULL|RESTRICT|NO\sACTION)\s+ON\s+UPDATE\s+(SET\sNULL|RESTRICT|NO\sACTION))?/', $sqlCode[0]['CREATE TABLE'], $matches);
7938 7938
 		$list = array();
7939 7939
 		if (!isset($matches[0])) return $list;
7940 7940
 		$max = count($matches[0]);
7941
-		for($i = 0; $i < $max; $i++) {
7942
-			$label = $this->makeFKLabel( $matches[2][$i], $matches[3][$i], 'id' );
7943
-			$list[ $label ] = array(
7941
+		for ($i = 0; $i < $max; $i++) {
7942
+			$label = $this->makeFKLabel($matches[2][$i], $matches[3][$i], 'id');
7943
+			$list[$label] = array(
7944 7944
 				'name' => $matches[1][$i],
7945 7945
 				'from' => $matches[2][$i],
7946 7946
 				'table' => $matches[3][$i],
@@ -7986,7 +7986,7 @@  discard block
 block discarded – undo
7986 7986
 	 *
7987 7987
 	 * @param Adapter $adapter Database Adapter
7988 7988
 	 */
7989
-	public function __construct( Adapter $adapter )
7989
+	public function __construct(Adapter $adapter)
7990 7990
 	{
7991 7991
 		$this->typeno_sqltype = array(
7992 7992
 			CUBRID::C_DATATYPE_INTEGER          => ' INTEGER ',
@@ -7998,8 +7998,8 @@  discard block
 block discarded – undo
7998 7998
 
7999 7999
 		$this->sqltype_typeno = array();
8000 8000
 
8001
-		foreach ( $this->typeno_sqltype as $k => $v ) {
8002
-			$this->sqltype_typeno[trim( ( $v ) )] = $k;
8001
+		foreach ($this->typeno_sqltype as $k => $v) {
8002
+			$this->sqltype_typeno[trim(($v))] = $k;
8003 8003
 		}
8004 8004
 
8005 8005
 		$this->sqltype_typeno['STRING(1073741823)'] = self::C_DATATYPE_STRING;
@@ -8023,7 +8023,7 @@  discard block
 block discarded – undo
8023 8023
 	 */
8024 8024
 	public function getTables()
8025 8025
 	{
8026
-		$rows = $this->adapter->getCol( "SELECT class_name FROM db_class WHERE is_system_class = 'NO';" );
8026
+		$rows = $this->adapter->getCol("SELECT class_name FROM db_class WHERE is_system_class = 'NO';");
8027 8027
 
8028 8028
 		return $rows;
8029 8029
 	}
@@ -8031,28 +8031,28 @@  discard block
 block discarded – undo
8031 8031
 	/**
8032 8032
 	 * @see QueryWriter::createTable
8033 8033
 	 */
8034
-	public function createTable( $table )
8034
+	public function createTable($table)
8035 8035
 	{
8036
-		$sql  = 'CREATE TABLE '
8037
-			. $this->esc( $table )
8036
+		$sql = 'CREATE TABLE '
8037
+			. $this->esc($table)
8038 8038
 			. ' ("id" integer AUTO_INCREMENT, CONSTRAINT "pk_'
8039
-			. $this->esc( $table, TRUE )
8039
+			. $this->esc($table, TRUE)
8040 8040
 			. '_id" PRIMARY KEY("id"))';
8041 8041
 
8042
-		$this->adapter->exec( $sql );
8042
+		$this->adapter->exec($sql);
8043 8043
 	}
8044 8044
 
8045 8045
 	/**
8046 8046
 	 * @see QueryWriter::getColumns
8047 8047
 	 */
8048
-	public function getColumns( $table )
8048
+	public function getColumns($table)
8049 8049
 	{
8050
-		$table = $this->esc( $table );
8050
+		$table = $this->esc($table);
8051 8051
 
8052
-		$columnsRaw = $this->adapter->get( "SHOW COLUMNS FROM $table" );
8052
+		$columnsRaw = $this->adapter->get("SHOW COLUMNS FROM $table");
8053 8053
 
8054 8054
 		$columns = array();
8055
-		foreach ( $columnsRaw as $r ) {
8055
+		foreach ($columnsRaw as $r) {
8056 8056
 			$columns[$r['Field']] = $r['Type'];
8057 8057
 		}
8058 8058
 
@@ -8062,30 +8062,30 @@  discard block
 block discarded – undo
8062 8062
 	/**
8063 8063
 	 * @see QueryWriter::scanType
8064 8064
 	 */
8065
-	public function scanType( $value, $flagSpecial = FALSE )
8065
+	public function scanType($value, $flagSpecial = FALSE)
8066 8066
 	{
8067 8067
 		$this->svalue = $value;
8068 8068
 
8069
-		if ( is_null( $value ) ) {
8069
+		if (is_null($value)) {
8070 8070
 			return self::C_DATATYPE_INTEGER;
8071 8071
 		}
8072 8072
 
8073
-		if ( $flagSpecial ) {
8074
-			if ( preg_match( '/^\d{4}\-\d\d-\d\d$/', $value ) ) {
8073
+		if ($flagSpecial) {
8074
+			if (preg_match('/^\d{4}\-\d\d-\d\d$/', $value)) {
8075 8075
 				return self::C_DATATYPE_SPECIAL_DATE;
8076 8076
 			}
8077
-			if ( preg_match( '/^\d{4}\-\d\d-\d\d\s\d\d:\d\d:\d\d$/', $value ) ) {
8077
+			if (preg_match('/^\d{4}\-\d\d-\d\d\s\d\d:\d\d:\d\d$/', $value)) {
8078 8078
 				return self::C_DATATYPE_SPECIAL_DATETIME;
8079 8079
 			}
8080 8080
 		}
8081 8081
 
8082
-		$value = strval( $value );
8082
+		$value = strval($value);
8083 8083
 
8084
-		if ( !$this->startsWithZeros( $value ) ) {
8085
-			if ( is_numeric( $value ) && ( floor( $value ) == $value ) && $value >= -2147483647 && $value <= 2147483647 ) {
8084
+		if (!$this->startsWithZeros($value)) {
8085
+			if (is_numeric($value) && (floor($value) == $value) && $value >= -2147483647 && $value <= 2147483647) {
8086 8086
 				return self::C_DATATYPE_INTEGER;
8087 8087
 			}
8088
-			if ( is_numeric( $value ) ) {
8088
+			if (is_numeric($value)) {
8089 8089
 				return self::C_DATATYPE_DOUBLE;
8090 8090
 			}
8091 8091
 		}
@@ -8096,15 +8096,15 @@  discard block
 block discarded – undo
8096 8096
 	/**
8097 8097
 	 * @see QueryWriter::code
8098 8098
 	 */
8099
-	public function code( $typedescription, $includeSpecials = FALSE )
8099
+	public function code($typedescription, $includeSpecials = FALSE)
8100 8100
 	{
8101
-		$r = ( ( isset( $this->sqltype_typeno[$typedescription] ) ) ? $this->sqltype_typeno[$typedescription] : self::C_DATATYPE_SPECIFIED );
8101
+		$r = ((isset($this->sqltype_typeno[$typedescription])) ? $this->sqltype_typeno[$typedescription] : self::C_DATATYPE_SPECIFIED);
8102 8102
 
8103
-		if ( $includeSpecials ) {
8103
+		if ($includeSpecials) {
8104 8104
 			return $r;
8105 8105
 		}
8106 8106
 
8107
-		if ( $r >= QueryWriter::C_DATATYPE_RANGE_SPECIAL ) {
8107
+		if ($r >= QueryWriter::C_DATATYPE_RANGE_SPECIAL) {
8108 8108
 			return self::C_DATATYPE_SPECIFIED;
8109 8109
 		}
8110 8110
 
@@ -8114,34 +8114,34 @@  discard block
 block discarded – undo
8114 8114
 	/**
8115 8115
 	 * @see QueryWriter::addColumn
8116 8116
 	 */
8117
-	public function addColumn( $type, $column, $field )
8117
+	public function addColumn($type, $column, $field)
8118 8118
 	{
8119 8119
 		$table  = $type;
8120 8120
 		$type   = $field;
8121 8121
 
8122
-		$table  = $this->esc( $table );
8123
-		$column = $this->esc( $column );
8122
+		$table  = $this->esc($table);
8123
+		$column = $this->esc($column);
8124 8124
 
8125
-		$type   = array_key_exists( $type, $this->typeno_sqltype ) ? $this->typeno_sqltype[$type] : '';
8125
+		$type   = array_key_exists($type, $this->typeno_sqltype) ? $this->typeno_sqltype[$type] : '';
8126 8126
 
8127
-		$this->adapter->exec( "ALTER TABLE $table ADD COLUMN $column $type " );
8127
+		$this->adapter->exec("ALTER TABLE $table ADD COLUMN $column $type ");
8128 8128
 	}
8129 8129
 
8130 8130
 	/**
8131 8131
 	 * @see QueryWriter::addUniqueIndex
8132 8132
 	 */
8133
-	public function addUniqueConstraint( $type, $properties )
8133
+	public function addUniqueConstraint($type, $properties)
8134 8134
 	{
8135
-		$tableNoQ = $this->esc( $type, TRUE );
8135
+		$tableNoQ = $this->esc($type, TRUE);
8136 8136
 		$columns = array();
8137
-		foreach( $properties as $key => $column ) $columns[$key] = $this->esc( $column );
8138
-		$table = $this->esc( $type );
8139
-		sort( $columns ); // else we get multiple indexes due to order-effects
8140
-		$name = 'UQ_' . sha1( implode( ',', $columns ) );
8141
-		$sql = "ALTER TABLE $table ADD CONSTRAINT UNIQUE $name (" . implode( ',', $columns ) . ")";
8137
+		foreach ($properties as $key => $column) $columns[$key] = $this->esc($column);
8138
+		$table = $this->esc($type);
8139
+		sort($columns); // else we get multiple indexes due to order-effects
8140
+		$name = 'UQ_'.sha1(implode(',', $columns));
8141
+		$sql = "ALTER TABLE $table ADD CONSTRAINT UNIQUE $name (".implode(',', $columns).")";
8142 8142
 		try {
8143
-			$this->adapter->exec( $sql );
8144
-		} catch( SQLException $e ) {
8143
+			$this->adapter->exec($sql);
8144
+		} catch (SQLException $e) {
8145 8145
 			return FALSE;
8146 8146
 		}
8147 8147
 		return TRUE;
@@ -8150,27 +8150,27 @@  discard block
 block discarded – undo
8150 8150
 	/**
8151 8151
 	 * @see QueryWriter::sqlStateIn
8152 8152
 	 */
8153
-	public function sqlStateIn( $state, $list, $extraDriverDetails = array() )
8153
+	public function sqlStateIn($state, $list, $extraDriverDetails = array())
8154 8154
 	{
8155
-		return ( $state == 'HY000' ) ? ( count( array_diff( array(
8155
+		return ($state == 'HY000') ? (count(array_diff(array(
8156 8156
 				QueryWriter::C_SQLSTATE_INTEGRITY_CONSTRAINT_VIOLATION,
8157 8157
 				QueryWriter::C_SQLSTATE_NO_SUCH_COLUMN,
8158 8158
 				QueryWriter::C_SQLSTATE_NO_SUCH_TABLE
8159
-			), $list ) ) !== 3 ) : FALSE;
8159
+			), $list)) !== 3) : FALSE;
8160 8160
 	}
8161 8161
 
8162 8162
 	/**
8163 8163
 	 * @see QueryWriter::addIndex
8164 8164
 	 */
8165
-	public function addIndex( $type, $name, $column )
8165
+	public function addIndex($type, $name, $column)
8166 8166
 	{
8167 8167
 		try {
8168
-			$table  = $this->esc( $type );
8169
-			$name   = preg_replace( '/\W/', '', $name );
8170
-			$column = $this->esc( $column );
8171
-			$this->adapter->exec( "CREATE INDEX $name ON $table ($column) " );
8168
+			$table  = $this->esc($type);
8169
+			$name   = preg_replace('/\W/', '', $name);
8170
+			$column = $this->esc($column);
8171
+			$this->adapter->exec("CREATE INDEX $name ON $table ($column) ");
8172 8172
 			return TRUE;
8173
-		} catch ( SQLException $e ) {
8173
+		} catch (SQLException $e) {
8174 8174
 			return FALSE;
8175 8175
 		}
8176 8176
 	}
@@ -8178,9 +8178,9 @@  discard block
 block discarded – undo
8178 8178
 	/**
8179 8179
 	 * @see QueryWriter::addFK
8180 8180
 	 */
8181
-	public function addFK( $type, $targetType, $property, $targetProperty, $isDependent = FALSE )
8181
+	public function addFK($type, $targetType, $property, $targetProperty, $isDependent = FALSE)
8182 8182
 	{
8183
-		return $this->buildFK( $type, $targetType, $property, $targetProperty, $isDependent );
8183
+		return $this->buildFK($type, $targetType, $property, $targetProperty, $isDependent);
8184 8184
 	}
8185 8185
 
8186 8186
 	/**
@@ -8189,34 +8189,34 @@  discard block
 block discarded – undo
8189 8189
 	public function wipeAll()
8190 8190
 	{
8191 8191
 		if (AQueryWriter::$noNuke) throw new \Exception('The nuke() command has been disabled using noNuke() or R::feature(novice/...).');
8192
-		foreach ( $this->getTables() as $t ) {
8193
-			foreach ( $this->getKeyMapForType( $t ) as $k ) {
8194
-				$this->adapter->exec( "ALTER TABLE \"$t\" DROP FOREIGN KEY \"{$k['name']}\"" );
8192
+		foreach ($this->getTables() as $t) {
8193
+			foreach ($this->getKeyMapForType($t) as $k) {
8194
+				$this->adapter->exec("ALTER TABLE \"$t\" DROP FOREIGN KEY \"{$k['name']}\"");
8195 8195
 			}
8196 8196
 		}
8197
-		foreach ( $this->getTables() as $t ) {
8198
-			$this->adapter->exec( "DROP TABLE \"$t\"" );
8197
+		foreach ($this->getTables() as $t) {
8198
+			$this->adapter->exec("DROP TABLE \"$t\"");
8199 8199
 		}
8200 8200
 	}
8201 8201
 
8202 8202
 	/**
8203 8203
 	 * @see QueryWriter::esc
8204 8204
 	 */
8205
-	public function esc( $dbStructure, $noQuotes = FALSE )
8205
+	public function esc($dbStructure, $noQuotes = FALSE)
8206 8206
 	{
8207
-		return parent::esc( strtolower( $dbStructure ), $noQuotes );
8207
+		return parent::esc(strtolower($dbStructure), $noQuotes);
8208 8208
 	}
8209 8209
 
8210 8210
 	/**
8211 8211
 	 * @see QueryWriter::inferFetchType
8212 8212
 	 */
8213
-	public function inferFetchType( $type, $property )
8213
+	public function inferFetchType($type, $property)
8214 8214
 	{
8215
-		$table = $this->esc( $type, TRUE );
8216
-		$field = $this->esc( $property, TRUE ) . '_id';
8217
-		$keys = $this->getKeyMapForType( $table );
8215
+		$table = $this->esc($type, TRUE);
8216
+		$field = $this->esc($property, TRUE).'_id';
8217
+		$keys = $this->getKeyMapForType($table);
8218 8218
 
8219
-		foreach( $keys as $key ) {
8219
+		foreach ($keys as $key) {
8220 8220
 			if (
8221 8221
 				$key['from'] === $field
8222 8222
 			) return $key['table'];
@@ -8309,7 +8309,7 @@  discard block
 block discarded – undo
8309 8309
 	 *
8310 8310
 	 * @return void
8311 8311
 	 */
8312
-	public function setSQLState( $sqlState )
8312
+	public function setSQLState($sqlState)
8313 8313
 	{
8314 8314
 		$this->sqlState = $sqlState;
8315 8315
 	}
@@ -8321,8 +8321,8 @@  discard block
 block discarded – undo
8321 8321
 	 */
8322 8322
 	public function __toString()
8323 8323
 	{
8324
-		return '[' . $this->getSQLState() . '] - ' . $this->getMessage()."\n".
8325
-				'trace: ' . $this->getTraceAsString();
8324
+		return '['.$this->getSQLState().'] - '.$this->getMessage()."\n".
8325
+				'trace: '.$this->getTraceAsString();
8326 8326
 	}
8327 8327
 }
8328 8328
 }
@@ -8392,7 +8392,7 @@  discard block
 block discarded – undo
8392 8392
 	 *
8393 8393
 	 * @return mixed
8394 8394
 	 */
8395
-	public function usePartialBeans( $yesNoBeans )
8395
+	public function usePartialBeans($yesNoBeans)
8396 8396
 	{
8397 8397
 		$oldValue = $this->partialBeans;
8398 8398
 		$this->partialBeans = $yesNoBeans;
@@ -8418,40 +8418,40 @@  discard block
 block discarded – undo
8418 8418
 	 *
8419 8419
 	 * @return void
8420 8420
 	 */
8421
-	protected function storeBeanWithLists( OODBBean $bean )
8421
+	protected function storeBeanWithLists(OODBBean $bean)
8422 8422
 	{
8423 8423
 		$sharedAdditions = $sharedTrashcan = $sharedresidue = $sharedItems = $ownAdditions = $ownTrashcan = $ownresidue = $embeddedBeans = array(); //Define groups
8424
-		foreach ( $bean as $property => $value ) {
8425
-			$value = ( $value instanceof SimpleModel ) ? $value->unbox() : $value;
8426
-			if ( $value instanceof OODBBean ) {
8427
-				$this->processEmbeddedBean( $embeddedBeans, $bean, $property, $value );
8424
+		foreach ($bean as $property => $value) {
8425
+			$value = ($value instanceof SimpleModel) ? $value->unbox() : $value;
8426
+			if ($value instanceof OODBBean) {
8427
+				$this->processEmbeddedBean($embeddedBeans, $bean, $property, $value);
8428 8428
 				$bean->setMeta("sys.typeof.{$property}", $value->getMeta('type'));
8429
-			} elseif ( is_array( $value ) ) {
8430
-				foreach($value as &$item) {
8431
-					$item = ( $item instanceof SimpleModel ) ? $item->unbox() : $item;
8429
+			} elseif (is_array($value)) {
8430
+				foreach ($value as &$item) {
8431
+					$item = ($item instanceof SimpleModel) ? $item->unbox() : $item;
8432 8432
 				}
8433
-				$originals = $bean->moveMeta( 'sys.shadow.' . $property, array() );
8434
-				if ( strpos( $property, 'own' ) === 0 ) {
8435
-					list( $ownAdditions, $ownTrashcan, $ownresidue ) = $this->processGroups( $originals, $value, $ownAdditions, $ownTrashcan, $ownresidue );
8436
-					$listName = lcfirst( substr( $property, 3 ) );
8437
-					if ($bean->moveMeta( 'sys.exclusive-'.  $listName ) ) {
8438
-						OODBBean::setMetaAll( $ownTrashcan, 'sys.garbage', TRUE );
8439
-						OODBBean::setMetaAll( $ownAdditions, 'sys.buildcommand.fkdependson', $bean->getMeta( 'type' ) );
8433
+				$originals = $bean->moveMeta('sys.shadow.'.$property, array());
8434
+				if (strpos($property, 'own') === 0) {
8435
+					list($ownAdditions, $ownTrashcan, $ownresidue) = $this->processGroups($originals, $value, $ownAdditions, $ownTrashcan, $ownresidue);
8436
+					$listName = lcfirst(substr($property, 3));
8437
+					if ($bean->moveMeta('sys.exclusive-'.$listName)) {
8438
+						OODBBean::setMetaAll($ownTrashcan, 'sys.garbage', TRUE);
8439
+						OODBBean::setMetaAll($ownAdditions, 'sys.buildcommand.fkdependson', $bean->getMeta('type'));
8440 8440
 					}
8441
-					unset( $bean->$property );
8442
-				} elseif ( strpos( $property, 'shared' ) === 0 ) {
8443
-					list( $sharedAdditions, $sharedTrashcan, $sharedresidue ) = $this->processGroups( $originals, $value, $sharedAdditions, $sharedTrashcan, $sharedresidue );
8444
-					unset( $bean->$property );
8441
+					unset($bean->$property);
8442
+				} elseif (strpos($property, 'shared') === 0) {
8443
+					list($sharedAdditions, $sharedTrashcan, $sharedresidue) = $this->processGroups($originals, $value, $sharedAdditions, $sharedTrashcan, $sharedresidue);
8444
+					unset($bean->$property);
8445 8445
 				}
8446 8446
 			}
8447 8447
 		}
8448
-		$this->storeBean( $bean );
8449
-		$this->processTrashcan( $bean, $ownTrashcan );
8450
-		$this->processAdditions( $bean, $ownAdditions );
8451
-		$this->processResidue( $ownresidue );
8452
-		$this->processSharedTrashcan( $bean, $sharedTrashcan );
8453
-		$this->processSharedAdditions( $bean, $sharedAdditions );
8454
-		$this->processSharedResidue( $bean, $sharedresidue );
8448
+		$this->storeBean($bean);
8449
+		$this->processTrashcan($bean, $ownTrashcan);
8450
+		$this->processAdditions($bean, $ownAdditions);
8451
+		$this->processResidue($ownresidue);
8452
+		$this->processSharedTrashcan($bean, $sharedTrashcan);
8453
+		$this->processSharedAdditions($bean, $sharedAdditions);
8454
+		$this->processSharedResidue($bean, $sharedresidue);
8455 8455
 	}
8456 8456
 
8457 8457
 	/**
@@ -8469,12 +8469,12 @@  discard block
 block discarded – undo
8469 8469
 	 *
8470 8470
 	 * @return array
8471 8471
 	 */
8472
-	protected function processGroups( $originals, $current, $additions, $trashcan, $residue )
8472
+	protected function processGroups($originals, $current, $additions, $trashcan, $residue)
8473 8473
 	{
8474 8474
 		return array(
8475
-			array_merge( $additions, array_diff( $current, $originals ) ),
8476
-			array_merge( $trashcan, array_diff( $originals, $current ) ),
8477
-			array_merge( $residue, array_intersect( $current, $originals ) )
8475
+			array_merge($additions, array_diff($current, $originals)),
8476
+			array_merge($trashcan, array_diff($originals, $current)),
8477
+			array_merge($residue, array_intersect($current, $originals))
8478 8478
 		);
8479 8479
 	}
8480 8480
 
@@ -8491,13 +8491,13 @@  discard block
 block discarded – undo
8491 8491
 	 *
8492 8492
 	 * @return void
8493 8493
 	 */
8494
-	protected function processSharedAdditions( $bean, $sharedAdditions )
8494
+	protected function processSharedAdditions($bean, $sharedAdditions)
8495 8495
 	{
8496
-		foreach ( $sharedAdditions as $addition ) {
8497
-			if ( $addition instanceof OODBBean ) {
8498
-				$this->oodb->getAssociationManager()->associate( $addition, $bean );
8496
+		foreach ($sharedAdditions as $addition) {
8497
+			if ($addition instanceof OODBBean) {
8498
+				$this->oodb->getAssociationManager()->associate($addition, $bean);
8499 8499
 			} else {
8500
-				throw new RedException( 'Array may only contain OODBBeans' );
8500
+				throw new RedException('Array may only contain OODBBeans');
8501 8501
 			}
8502 8502
 		}
8503 8503
 	}
@@ -8516,11 +8516,11 @@  discard block
 block discarded – undo
8516 8516
 	 *
8517 8517
 	 * @return void
8518 8518
 	 */
8519
-	protected function processResidue( $ownresidue )
8519
+	protected function processResidue($ownresidue)
8520 8520
 	{
8521
-		foreach ( $ownresidue as $residue ) {
8522
-			if ( $residue->getMeta( 'tainted' ) ) {
8523
-				$this->store( $residue );
8521
+		foreach ($ownresidue as $residue) {
8522
+			if ($residue->getMeta('tainted')) {
8523
+				$this->store($residue);
8524 8524
 			}
8525 8525
 		}
8526 8526
 	}
@@ -8539,19 +8539,19 @@  discard block
 block discarded – undo
8539 8539
 	 *
8540 8540
 	 * @return void
8541 8541
 	 */
8542
-	protected function processTrashcan( $bean, $ownTrashcan )
8542
+	protected function processTrashcan($bean, $ownTrashcan)
8543 8543
 	{
8544
-		foreach ( $ownTrashcan as $trash ) {
8544
+		foreach ($ownTrashcan as $trash) {
8545 8545
 
8546
-			$myFieldLink = $bean->getMeta( 'type' ) . '_id';
8547
-			$alias = $bean->getMeta( 'sys.alias.' . $trash->getMeta( 'type' ) );
8548
-			if ( $alias ) $myFieldLink = $alias . '_id';
8546
+			$myFieldLink = $bean->getMeta('type').'_id';
8547
+			$alias = $bean->getMeta('sys.alias.'.$trash->getMeta('type'));
8548
+			if ($alias) $myFieldLink = $alias.'_id';
8549 8549
 
8550
-			if ( $trash->getMeta( 'sys.garbage' ) === TRUE ) {
8551
-				$this->trash( $trash );
8550
+			if ($trash->getMeta('sys.garbage') === TRUE) {
8551
+				$this->trash($trash);
8552 8552
 			} else {
8553 8553
 				$trash->$myFieldLink = NULL;
8554
-				$this->store( $trash );
8554
+				$this->store($trash);
8555 8555
 			}
8556 8556
 		}
8557 8557
 	}
@@ -8568,10 +8568,10 @@  discard block
 block discarded – undo
8568 8568
 	 *
8569 8569
 	 * @return void
8570 8570
 	 */
8571
-	protected function processSharedTrashcan( $bean, $sharedTrashcan )
8571
+	protected function processSharedTrashcan($bean, $sharedTrashcan)
8572 8572
 	{
8573
-		foreach ( $sharedTrashcan as $trash ) {
8574
-			$this->oodb->getAssociationManager()->unassociate( $trash, $bean );
8573
+		foreach ($sharedTrashcan as $trash) {
8574
+			$this->oodb->getAssociationManager()->unassociate($trash, $bean);
8575 8575
 		}
8576 8576
 	}
8577 8577
 
@@ -8587,10 +8587,10 @@  discard block
 block discarded – undo
8587 8587
 	 *
8588 8588
 	 * @return void
8589 8589
 	 */
8590
-	protected function processSharedResidue( $bean, $sharedresidue )
8590
+	protected function processSharedResidue($bean, $sharedresidue)
8591 8591
 	{
8592
-		foreach ( $sharedresidue as $residue ) {
8593
-			$this->store( $residue );
8592
+		foreach ($sharedresidue as $residue) {
8593
+			$this->store($residue);
8594 8594
 		}
8595 8595
 	}
8596 8596
 
@@ -8603,11 +8603,11 @@  discard block
 block discarded – undo
8603 8603
 	 *
8604 8604
 	 * @return boolean
8605 8605
 	 */
8606
-	protected function hasListsOrObjects( OODBBean $bean )
8606
+	protected function hasListsOrObjects(OODBBean $bean)
8607 8607
 	{
8608 8608
 		$processLists = FALSE;
8609
-		foreach ( $bean as $value ) {
8610
-			if ( is_array( $value ) || is_object( $value ) ) {
8609
+		foreach ($bean as $value) {
8610
+			if (is_array($value) || is_object($value)) {
8611 8611
 				$processLists = TRUE;
8612 8612
 				break;
8613 8613
 			}
@@ -8628,17 +8628,17 @@  discard block
 block discarded – undo
8628 8628
 	 *
8629 8629
 	 * @return void
8630 8630
 	 */
8631
-	protected function processEmbeddedBean( &$embeddedBeans, $bean, $property, OODBBean $value )
8631
+	protected function processEmbeddedBean(&$embeddedBeans, $bean, $property, OODBBean $value)
8632 8632
 	{
8633
-		$linkField = $property . '_id';
8634
-		if ( !$value->id || $value->getMeta( 'tainted' ) ) {
8635
-			$this->store( $value );
8633
+		$linkField = $property.'_id';
8634
+		if (!$value->id || $value->getMeta('tainted')) {
8635
+			$this->store($value);
8636 8636
 		}
8637 8637
 		$id = $value->id;
8638 8638
 		if ($bean->$linkField != $id) $bean->$linkField = $id;
8639
-		$bean->setMeta( 'cast.' . $linkField, 'id' );
8639
+		$bean->setMeta('cast.'.$linkField, 'id');
8640 8640
 		$embeddedBeans[$linkField] = $value;
8641
-		unset( $bean->$property );
8641
+		unset($bean->$property);
8642 8642
 	}
8643 8643
 
8644 8644
 	/**
@@ -8650,7 +8650,7 @@  discard block
 block discarded – undo
8650 8650
 	 *
8651 8651
 	 * @return void
8652 8652
 	 */
8653
-	public function __construct( OODB $oodb, QueryWriter $writer )
8653
+	public function __construct(OODB $oodb, QueryWriter $writer)
8654 8654
 	{
8655 8655
 		$this->writer = $writer;
8656 8656
 		$this->oodb = $oodb;
@@ -8672,33 +8672,33 @@  discard block
 block discarded – undo
8672 8672
 	 *
8673 8673
 	 * @return void
8674 8674
 	 */
8675
-	public function check( OODBBean $bean )
8675
+	public function check(OODBBean $bean)
8676 8676
 	{
8677 8677
 		//Is all meta information present?
8678
-		if ( !isset( $bean->id ) ) {
8679
-			throw new RedException( 'Bean has incomplete Meta Information id ' );
8678
+		if (!isset($bean->id)) {
8679
+			throw new RedException('Bean has incomplete Meta Information id ');
8680 8680
 		}
8681
-		if ( !( $bean->getMeta( 'type' ) ) ) {
8682
-			throw new RedException( 'Bean has incomplete Meta Information II' );
8681
+		if (!($bean->getMeta('type'))) {
8682
+			throw new RedException('Bean has incomplete Meta Information II');
8683 8683
 		}
8684 8684
 		//Pattern of allowed characters
8685 8685
 		$pattern = '/[^a-z0-9_]/i';
8686 8686
 		//Does the type contain invalid characters?
8687
-		if ( preg_match( $pattern, $bean->getMeta( 'type' ) ) ) {
8688
-			throw new RedException( 'Bean Type is invalid' );
8687
+		if (preg_match($pattern, $bean->getMeta('type'))) {
8688
+			throw new RedException('Bean Type is invalid');
8689 8689
 		}
8690 8690
 		//Are the properties and values valid?
8691
-		foreach ( $bean as $prop => $value ) {
8691
+		foreach ($bean as $prop => $value) {
8692 8692
 			if (
8693
-				is_array( $value )
8694
-				|| ( is_object( $value ) )
8693
+				is_array($value)
8694
+				|| (is_object($value))
8695 8695
 			) {
8696
-				throw new RedException( "Invalid Bean value: property $prop" );
8696
+				throw new RedException("Invalid Bean value: property $prop");
8697 8697
 			} else if (
8698
-				strlen( $prop ) < 1
8699
-				|| preg_match( $pattern, $prop )
8698
+				strlen($prop) < 1
8699
+				|| preg_match($pattern, $prop)
8700 8700
 			) {
8701
-				throw new RedException( "Invalid Bean property: property $prop" );
8701
+				throw new RedException("Invalid Bean property: property $prop");
8702 8702
 			}
8703 8703
 		}
8704 8704
 	}
@@ -8729,21 +8729,21 @@  discard block
 block discarded – undo
8729 8729
 	 *
8730 8730
 	 * @return array
8731 8731
 	 */
8732
-	public function find( $type, $conditions = array(), $sql = NULL, $bindings = array() )
8732
+	public function find($type, $conditions = array(), $sql = NULL, $bindings = array())
8733 8733
 	{
8734 8734
 		//for backward compatibility, allow mismatch arguments:
8735
-		if ( is_array( $sql ) ) {
8736
-			if ( isset( $sql[1] ) ) {
8735
+		if (is_array($sql)) {
8736
+			if (isset($sql[1])) {
8737 8737
 				$bindings = $sql[1];
8738 8738
 			}
8739 8739
 			$sql = $sql[0];
8740 8740
 		}
8741 8741
 		try {
8742
-			$beans = $this->convertToBeans( $type, $this->writer->queryRecord( $type, $conditions, $sql, $bindings ) );
8742
+			$beans = $this->convertToBeans($type, $this->writer->queryRecord($type, $conditions, $sql, $bindings));
8743 8743
 
8744 8744
 			return $beans;
8745
-		} catch ( SQLException $exception ) {
8746
-			$this->handleException( $exception );
8745
+		} catch (SQLException $exception) {
8746
+			$this->handleException($exception);
8747 8747
 		}
8748 8748
 
8749 8749
 		return array();
@@ -8767,15 +8767,15 @@  discard block
 block discarded – undo
8767 8767
 	 *
8768 8768
 	 * @return BeanCollection
8769 8769
 	 */
8770
-	public function findCollection( $type, $sql, $bindings = array() )
8770
+	public function findCollection($type, $sql, $bindings = array())
8771 8771
 	{
8772 8772
 		try {
8773
-			$cursor = $this->writer->queryRecordWithCursor( $type, $sql, $bindings );
8774
-			return new BeanCollection( $type, $this, $cursor );
8775
-		} catch ( SQLException $exception ) {
8776
-			$this->handleException( $exception );
8773
+			$cursor = $this->writer->queryRecordWithCursor($type, $sql, $bindings);
8774
+			return new BeanCollection($type, $this, $cursor);
8775
+		} catch (SQLException $exception) {
8776
+			$this->handleException($exception);
8777 8777
 		}
8778
-		return new BeanCollection( $type, $this, new NullCursor );
8778
+		return new BeanCollection($type, $this, new NullCursor);
8779 8779
 	}
8780 8780
 
8781 8781
 	/**
@@ -8798,22 +8798,22 @@  discard block
 block discarded – undo
8798 8798
 	 *
8799 8799
 	 * @return integer|string
8800 8800
 	 */
8801
-	public function store( $bean )
8801
+	public function store($bean)
8802 8802
 	{
8803
-		$processLists = $this->hasListsOrObjects( $bean );
8804
-		if ( !$processLists && !$bean->getMeta( 'tainted' ) ) {
8803
+		$processLists = $this->hasListsOrObjects($bean);
8804
+		if (!$processLists && !$bean->getMeta('tainted')) {
8805 8805
 			return $bean->getID(); //bail out!
8806 8806
 		}
8807
-		$this->oodb->signal( 'update', $bean );
8808
-		$processLists = $this->hasListsOrObjects( $bean ); //check again, might have changed by model!
8809
-		if ( $processLists ) {
8810
-			$this->storeBeanWithLists( $bean );
8807
+		$this->oodb->signal('update', $bean);
8808
+		$processLists = $this->hasListsOrObjects($bean); //check again, might have changed by model!
8809
+		if ($processLists) {
8810
+			$this->storeBeanWithLists($bean);
8811 8811
 		} else {
8812
-			$this->storeBean( $bean );
8812
+			$this->storeBean($bean);
8813 8813
 		}
8814
-		$this->oodb->signal( 'after_update', $bean );
8814
+		$this->oodb->signal('after_update', $bean);
8815 8815
 
8816
-		return ( (string) $bean->id === (string) (int) $bean->id ) ? (int) $bean->id : (string) $bean->id;
8816
+		return ((string) $bean->id === (string) (int) $bean->id) ? (int) $bean->id : (string) $bean->id;
8817 8817
 	}
8818 8818
 
8819 8819
 	/**
@@ -8830,27 +8830,27 @@  discard block
 block discarded – undo
8830 8830
 	 *
8831 8831
 	 * @return array
8832 8832
 	 */
8833
-	public function batch( $type, $ids )
8833
+	public function batch($type, $ids)
8834 8834
 	{
8835
-		if ( !$ids ) {
8835
+		if (!$ids) {
8836 8836
 			return array();
8837 8837
 		}
8838 8838
 		$collection = array();
8839 8839
 		try {
8840
-			$rows = $this->writer->queryRecord( $type, array( 'id' => $ids ) );
8841
-		} catch ( SQLException $e ) {
8842
-			$this->handleException( $e );
8840
+			$rows = $this->writer->queryRecord($type, array('id' => $ids));
8841
+		} catch (SQLException $e) {
8842
+			$this->handleException($e);
8843 8843
 			$rows = FALSE;
8844 8844
 		}
8845 8845
 		$this->stash[$this->nesting] = array();
8846
-		if ( !$rows ) {
8846
+		if (!$rows) {
8847 8847
 			return array();
8848 8848
 		}
8849
-		foreach ( $rows as $row ) {
8849
+		foreach ($rows as $row) {
8850 8850
 			$this->stash[$this->nesting][$row['id']] = $row;
8851 8851
 		}
8852
-		foreach ( $ids as $id ) {
8853
-			$collection[$id] = $this->load( $type, $id );
8852
+		foreach ($ids as $id) {
8853
+			$collection[$id] = $this->load($type, $id);
8854 8854
 		}
8855 8855
 		$this->stash[$this->nesting] = NULL;
8856 8856
 
@@ -8875,19 +8875,19 @@  discard block
 block discarded – undo
8875 8875
 	 *
8876 8876
 	 * @return array
8877 8877
 	 */
8878
-	public function convertToBeans( $type, $rows, $mask = NULL )
8878
+	public function convertToBeans($type, $rows, $mask = NULL)
8879 8879
 	{
8880 8880
 		$masklen = 0;
8881
-		if ( $mask !== NULL ) $masklen = mb_strlen( $mask );
8881
+		if ($mask !== NULL) $masklen = mb_strlen($mask);
8882 8882
 
8883 8883
 		$collection                  = array();
8884 8884
 		$this->stash[$this->nesting] = array();
8885
-		foreach ( $rows as $row ) {
8885
+		foreach ($rows as $row) {
8886 8886
 			$meta = array();
8887
-			if ( !is_null( $mask ) ) {
8888
-				foreach( $row as $key => $value ) {
8889
-					if ( strpos( $key, $mask ) === 0 ) {
8890
-						unset( $row[$key] );
8887
+			if (!is_null($mask)) {
8888
+				foreach ($row as $key => $value) {
8889
+					if (strpos($key, $mask) === 0) {
8890
+						unset($row[$key]);
8891 8891
 						$meta[$key] = $value;
8892 8892
 					}
8893 8893
 				}
@@ -8895,10 +8895,10 @@  discard block
 block discarded – undo
8895 8895
 
8896 8896
 			$id                               = $row['id'];
8897 8897
 			$this->stash[$this->nesting][$id] = $row;
8898
-			$collection[$id]                  = $this->load( $type, $id );
8898
+			$collection[$id]                  = $this->load($type, $id);
8899 8899
 
8900
-			if ( $mask !== NULL ) {
8901
-				$collection[$id]->setMeta( 'data.bundle', $meta );
8900
+			if ($mask !== NULL) {
8901
+				$collection[$id]->setMeta('data.bundle', $meta);
8902 8902
 			}
8903 8903
 		}
8904 8904
 		$this->stash[$this->nesting] = NULL;
@@ -8917,20 +8917,20 @@  discard block
 block discarded – undo
8917 8917
 	 *
8918 8918
 	 * @return integer
8919 8919
 	 */
8920
-	public function count( $type, $addSQL = '', $bindings = array() )
8920
+	public function count($type, $addSQL = '', $bindings = array())
8921 8921
 	{
8922
-		$type = AQueryWriter::camelsSnake( $type );
8923
-		if ( count( explode( '_', $type ) ) > 2 ) {
8924
-			throw new RedException( 'Invalid type for count.' );
8922
+		$type = AQueryWriter::camelsSnake($type);
8923
+		if (count(explode('_', $type)) > 2) {
8924
+			throw new RedException('Invalid type for count.');
8925 8925
 		}
8926 8926
 
8927 8927
 		try {
8928
-			return (int) $this->writer->queryRecordCount( $type, array(), $addSQL, $bindings );
8929
-		} catch ( SQLException $exception ) {
8930
-			if ( !$this->writer->sqlStateIn( $exception->getSQLState(), array(
8928
+			return (int) $this->writer->queryRecordCount($type, array(), $addSQL, $bindings);
8929
+		} catch (SQLException $exception) {
8930
+			if (!$this->writer->sqlStateIn($exception->getSQLState(), array(
8931 8931
 				 QueryWriter::C_SQLSTATE_NO_SUCH_TABLE,
8932 8932
 				 QueryWriter::C_SQLSTATE_NO_SUCH_COLUMN ),
8933
-				 $exception->getDriverDetails() ) ) {
8933
+				 $exception->getDriverDetails())) {
8934 8934
 				throw $exception;
8935 8935
 			}
8936 8936
 		}
@@ -8947,28 +8947,28 @@  discard block
 block discarded – undo
8947 8947
 	 *
8948 8948
 	 * @return void
8949 8949
 	 */
8950
-	public function trash( $bean )
8950
+	public function trash($bean)
8951 8951
 	{
8952
-		$this->oodb->signal( 'delete', $bean );
8953
-		foreach ( $bean as $property => $value ) {
8954
-			if ( $value instanceof OODBBean ) {
8955
-				unset( $bean->$property );
8952
+		$this->oodb->signal('delete', $bean);
8953
+		foreach ($bean as $property => $value) {
8954
+			if ($value instanceof OODBBean) {
8955
+				unset($bean->$property);
8956 8956
 			}
8957
-			if ( is_array( $value ) ) {
8958
-				if ( strpos( $property, 'own' ) === 0 ) {
8959
-					unset( $bean->$property );
8960
-				} elseif ( strpos( $property, 'shared' ) === 0 ) {
8961
-					unset( $bean->$property );
8957
+			if (is_array($value)) {
8958
+				if (strpos($property, 'own') === 0) {
8959
+					unset($bean->$property);
8960
+				} elseif (strpos($property, 'shared') === 0) {
8961
+					unset($bean->$property);
8962 8962
 				}
8963 8963
 			}
8964 8964
 		}
8965 8965
 		try {
8966
-			$this->writer->deleteRecord( $bean->getMeta( 'type' ), array( 'id' => array( $bean->id ) ), NULL );
8967
-		} catch ( SQLException $exception ) {
8968
-			$this->handleException( $exception );
8966
+			$this->writer->deleteRecord($bean->getMeta('type'), array('id' => array($bean->id)), NULL);
8967
+		} catch (SQLException $exception) {
8968
+			$this->handleException($exception);
8969 8969
 		}
8970 8970
 		$bean->id = 0;
8971
-		$this->oodb->signal( 'after_delete', $bean );
8971
+		$this->oodb->signal('after_delete', $bean);
8972 8972
 	}
8973 8973
 
8974 8974
 	/**
@@ -8981,9 +8981,9 @@  discard block
 block discarded – undo
8981 8981
 	 *
8982 8982
 	 * @return boolean
8983 8983
 	 */
8984
-	public function tableExists( $table )
8984
+	public function tableExists($table)
8985 8985
 	{
8986
-		return $this->writer->tableExists( $table );
8986
+		return $this->writer->tableExists($table);
8987 8987
 	}
8988 8988
 
8989 8989
 	/**
@@ -8997,14 +8997,14 @@  discard block
 block discarded – undo
8997 8997
 	 *
8998 8998
 	 * @return boolean
8999 8999
 	 */
9000
-	public function wipe( $type )
9000
+	public function wipe($type)
9001 9001
 	{
9002 9002
 		try {
9003
-			$this->writer->wipe( $type );
9003
+			$this->writer->wipe($type);
9004 9004
 
9005 9005
 			return TRUE;
9006
-		} catch ( SQLException $exception ) {
9007
-			if ( !$this->writer->sqlStateIn( $exception->getSQLState(), array( QueryWriter::C_SQLSTATE_NO_SUCH_TABLE ), $exception->getDriverDetails() ) ) {
9006
+		} catch (SQLException $exception) {
9007
+			if (!$this->writer->sqlStateIn($exception->getSQLState(), array(QueryWriter::C_SQLSTATE_NO_SUCH_TABLE), $exception->getDriverDetails())) {
9008 9008
 				throw $exception;
9009 9009
 			}
9010 9010
 
@@ -9058,16 +9058,16 @@  discard block
 block discarded – undo
9058 9058
 	 *
9059 9059
 	 * @return integer
9060 9060
 	 */
9061
-	private function getTypeFromCast( $cast )
9061
+	private function getTypeFromCast($cast)
9062 9062
 	{
9063
-		if ( $cast == 'string' ) {
9064
-			$typeno = $this->writer->scanType( 'STRING' );
9065
-		} elseif ( $cast == 'id' ) {
9063
+		if ($cast == 'string') {
9064
+			$typeno = $this->writer->scanType('STRING');
9065
+		} elseif ($cast == 'id') {
9066 9066
 			$typeno = $this->writer->getTypeForID();
9067
-		} elseif ( isset( $this->writer->sqltype_typeno[$cast] ) ) {
9067
+		} elseif (isset($this->writer->sqltype_typeno[$cast])) {
9068 9068
 			$typeno = $this->writer->sqltype_typeno[$cast];
9069 9069
 		} else {
9070
-			throw new RedException( 'Invalid Cast' );
9070
+			throw new RedException('Invalid Cast');
9071 9071
 		}
9072 9072
 
9073 9073
 		return $typeno;
@@ -9082,12 +9082,12 @@  discard block
 block discarded – undo
9082 9082
 	 *
9083 9083
 	 * @return void
9084 9084
 	 */
9085
-	private function createTableIfNotExists( OODBBean $bean, $table )
9085
+	private function createTableIfNotExists(OODBBean $bean, $table)
9086 9086
 	{
9087 9087
 		//Does table exist? If not, create
9088
-		if ( !$this->tableExists( $this->writer->esc( $table, TRUE ) ) ) {
9089
-			$this->writer->createTable( $table );
9090
-			$bean->setMeta( 'buildreport.flags.created', TRUE );
9088
+		if (!$this->tableExists($this->writer->esc($table, TRUE))) {
9089
+			$this->writer->createTable($table);
9090
+			$bean->setMeta('buildreport.flags.created', TRUE);
9091 9091
 		}
9092 9092
 	}
9093 9093
 
@@ -9107,50 +9107,50 @@  discard block
 block discarded – undo
9107 9107
 	 *
9108 9108
 	 * @return void
9109 9109
 	 */
9110
-	private function modifySchema( OODBBean $bean, $property, $value, &$columns = NULL )
9110
+	private function modifySchema(OODBBean $bean, $property, $value, &$columns = NULL)
9111 9111
 	{
9112 9112
 		$doFKStuff = FALSE;
9113
-		$table   = $bean->getMeta( 'type' );
9113
+		$table = $bean->getMeta('type');
9114 9114
 		if ($columns === NULL) {
9115
-			$columns = $this->writer->getColumns( $table );
9115
+			$columns = $this->writer->getColumns($table);
9116 9116
 		}
9117
-		$columnNoQ = $this->writer->esc( $property, TRUE );
9118
-		if ( !$this->oodb->isChilled( $bean->getMeta( 'type' ) ) ) {
9119
-			if ( $bean->getMeta( "cast.$property", -1 ) !== -1 ) { //check for explicitly specified types
9120
-				$cast   = $bean->getMeta( "cast.$property" );
9121
-				$typeno = $this->getTypeFromCast( $cast );
9117
+		$columnNoQ = $this->writer->esc($property, TRUE);
9118
+		if (!$this->oodb->isChilled($bean->getMeta('type'))) {
9119
+			if ($bean->getMeta("cast.$property", -1) !== -1) { //check for explicitly specified types
9120
+				$cast   = $bean->getMeta("cast.$property");
9121
+				$typeno = $this->getTypeFromCast($cast);
9122 9122
 			} else {
9123 9123
 				$cast   = FALSE;
9124
-				$typeno = $this->writer->scanType( $value, TRUE );
9124
+				$typeno = $this->writer->scanType($value, TRUE);
9125 9125
 			}
9126
-			if ( isset( $columns[$this->writer->esc( $property, TRUE )] ) ) { //Is this property represented in the table ?
9127
-				if ( !$cast ) { //rescan without taking into account special types >80
9128
-					$typeno = $this->writer->scanType( $value, FALSE );
9126
+			if (isset($columns[$this->writer->esc($property, TRUE)])) { //Is this property represented in the table ?
9127
+				if (!$cast) { //rescan without taking into account special types >80
9128
+					$typeno = $this->writer->scanType($value, FALSE);
9129 9129
 				}
9130
-				$sqlt = $this->writer->code( $columns[$this->writer->esc( $property, TRUE )] );
9131
-				if ( $typeno > $sqlt ) { //no, we have to widen the database column type
9132
-					$this->writer->widenColumn( $table, $property, $typeno );
9133
-					$bean->setMeta( 'buildreport.flags.widen', TRUE );
9130
+				$sqlt = $this->writer->code($columns[$this->writer->esc($property, TRUE)]);
9131
+				if ($typeno > $sqlt) { //no, we have to widen the database column type
9132
+					$this->writer->widenColumn($table, $property, $typeno);
9133
+					$bean->setMeta('buildreport.flags.widen', TRUE);
9134 9134
 					$doFKStuff = TRUE;
9135 9135
 				}
9136 9136
 			} else {
9137
-				$this->writer->addColumn( $table, $property, $typeno );
9138
-				$bean->setMeta( 'buildreport.flags.addcolumn', TRUE );
9137
+				$this->writer->addColumn($table, $property, $typeno);
9138
+				$bean->setMeta('buildreport.flags.addcolumn', TRUE);
9139 9139
 				$doFKStuff = TRUE;
9140 9140
 			}
9141 9141
 			if ($doFKStuff) {
9142
-				if (strrpos($columnNoQ, '_id')===(strlen($columnNoQ)-3)) {
9143
-					$destinationColumnNoQ = substr($columnNoQ, 0, strlen($columnNoQ)-3);
9142
+				if (strrpos($columnNoQ, '_id') === (strlen($columnNoQ) - 3)) {
9143
+					$destinationColumnNoQ = substr($columnNoQ, 0, strlen($columnNoQ) - 3);
9144 9144
 					$indexName = "index_foreignkey_{$table}_{$destinationColumnNoQ}";
9145 9145
 					$this->writer->addIndex($table, $indexName, $columnNoQ);
9146 9146
 					$typeof = $bean->getMeta("sys.typeof.{$destinationColumnNoQ}", $destinationColumnNoQ);
9147
-					$isLink = $bean->getMeta( 'sys.buildcommand.unique', FALSE );
9147
+					$isLink = $bean->getMeta('sys.buildcommand.unique', FALSE);
9148 9148
 					//Make FK CASCADING if part of exclusive list (dependson=typeof) or if link bean
9149
-					$isDep = ( $bean->moveMeta( 'sys.buildcommand.fkdependson' ) === $typeof || is_array( $isLink ) );
9150
-					$result = $this->writer->addFK( $table, $typeof, $columnNoQ, 'id', $isDep );
9149
+					$isDep = ($bean->moveMeta('sys.buildcommand.fkdependson') === $typeof || is_array($isLink));
9150
+					$result = $this->writer->addFK($table, $typeof, $columnNoQ, 'id', $isDep);
9151 9151
 					//If this is a link bean and all unique columns have been added already, then apply unique constraint
9152
-					if ( is_array( $isLink ) && !count( array_diff( $isLink, array_keys( $this->writer->getColumns( $table ) ) ) ) ) {
9153
-						$this->writer->addUniqueConstraint( $table, $bean->moveMeta('sys.buildcommand.unique') );
9152
+					if (is_array($isLink) && !count(array_diff($isLink, array_keys($this->writer->getColumns($table))))) {
9153
+						$this->writer->addUniqueConstraint($table, $bean->moveMeta('sys.buildcommand.unique'));
9154 9154
 						$bean->setMeta("sys.typeof.{$destinationColumnNoQ}", NULL);
9155 9155
 					}
9156 9156
 				}
@@ -9175,29 +9175,29 @@  discard block
 block discarded – undo
9175 9175
 	 *
9176 9176
 	 * @return void
9177 9177
 	 */
9178
-	protected function processAdditions( $bean, $ownAdditions )
9178
+	protected function processAdditions($bean, $ownAdditions)
9179 9179
 	{
9180
-		$beanType = $bean->getMeta( 'type' );
9180
+		$beanType = $bean->getMeta('type');
9181 9181
 
9182
-		foreach ( $ownAdditions as $addition ) {
9183
-			if ( $addition instanceof OODBBean ) {
9182
+		foreach ($ownAdditions as $addition) {
9183
+			if ($addition instanceof OODBBean) {
9184 9184
 
9185
-				$myFieldLink = $beanType . '_id';
9186
-				$alias = $bean->getMeta( 'sys.alias.' . $addition->getMeta( 'type' ) );
9187
-				if ( $alias ) $myFieldLink = $alias . '_id';
9185
+				$myFieldLink = $beanType.'_id';
9186
+				$alias = $bean->getMeta('sys.alias.'.$addition->getMeta('type'));
9187
+				if ($alias) $myFieldLink = $alias.'_id';
9188 9188
 
9189 9189
 				$addition->$myFieldLink = $bean->id;
9190
-				$addition->setMeta( 'cast.' . $myFieldLink, 'id' );
9190
+				$addition->setMeta('cast.'.$myFieldLink, 'id');
9191 9191
 
9192 9192
 				if ($alias) {
9193
-					$addition->setMeta( "sys.typeof.{$alias}", $beanType );
9193
+					$addition->setMeta("sys.typeof.{$alias}", $beanType);
9194 9194
 				} else {
9195
-					$addition->setMeta( "sys.typeof.{$beanType}", $beanType );
9195
+					$addition->setMeta("sys.typeof.{$beanType}", $beanType);
9196 9196
 				}
9197 9197
 
9198
-				$this->store( $addition );
9198
+				$this->store($addition);
9199 9199
 			} else {
9200
-				throw new RedException( 'Array may only contain OODBBeans' );
9200
+				throw new RedException('Array may only contain OODBBeans');
9201 9201
 			}
9202 9202
 		}
9203 9203
 	}
@@ -9212,36 +9212,36 @@  discard block
 block discarded – undo
9212 9212
 	 *
9213 9213
 	 * @return void
9214 9214
 	 */
9215
-	protected function storeBean( OODBBean $bean )
9215
+	protected function storeBean(OODBBean $bean)
9216 9216
 	{
9217
-		if ( $bean->getMeta( 'changed' ) ) {
9218
-			$this->check( $bean );
9219
-			$table = $bean->getMeta( 'type' );
9220
-			$this->createTableIfNotExists( $bean, $table );
9217
+		if ($bean->getMeta('changed')) {
9218
+			$this->check($bean);
9219
+			$table = $bean->getMeta('type');
9220
+			$this->createTableIfNotExists($bean, $table);
9221 9221
 
9222 9222
 			$updateValues = array();
9223 9223
 
9224
-			$partial = ( $this->partialBeans === TRUE || ( is_array( $this->partialBeans ) && in_array( $table, $this->partialBeans ) ) );
9225
-			if ( $partial ) {
9226
-				$mask = $bean->getMeta( 'changelist' );
9227
-				$bean->setMeta( 'changelist', array() );
9224
+			$partial = ($this->partialBeans === TRUE || (is_array($this->partialBeans) && in_array($table, $this->partialBeans)));
9225
+			if ($partial) {
9226
+				$mask = $bean->getMeta('changelist');
9227
+				$bean->setMeta('changelist', array());
9228 9228
 			}
9229 9229
 
9230 9230
 			$columnCache = NULL;
9231
-			foreach ( $bean as $property => $value ) {
9232
-				if ( $partial && !in_array( $property, $mask ) ) continue;
9233
-				if ( $property !== 'id' ) {
9234
-					$this->modifySchema( $bean, $property, $value, $columnCache );
9231
+			foreach ($bean as $property => $value) {
9232
+				if ($partial && !in_array($property, $mask)) continue;
9233
+				if ($property !== 'id') {
9234
+					$this->modifySchema($bean, $property, $value, $columnCache);
9235 9235
 				}
9236
-				if ( $property !== 'id' ) {
9237
-					$updateValues[] = array( 'property' => $property, 'value' => $value );
9236
+				if ($property !== 'id') {
9237
+					$updateValues[] = array('property' => $property, 'value' => $value);
9238 9238
 				}
9239 9239
 			}
9240 9240
 
9241
-			$bean->id = $this->writer->updateRecord( $table, $updateValues, $bean->id );
9242
-			$bean->setMeta( 'changed', FALSE );
9241
+			$bean->id = $this->writer->updateRecord($table, $updateValues, $bean->id);
9242
+			$bean->setMeta('changed', FALSE);
9243 9243
 		}
9244
-		$bean->setMeta( 'tainted', FALSE );
9244
+		$bean->setMeta('tainted', FALSE);
9245 9245
 	}
9246 9246
 
9247 9247
 	/**
@@ -9263,13 +9263,13 @@  discard block
 block discarded – undo
9263 9263
 	 *
9264 9264
 	 * @return void
9265 9265
 	 */
9266
-	protected function handleException( \Exception $exception )
9266
+	protected function handleException(\Exception $exception)
9267 9267
 	{
9268
-		if ( !$this->writer->sqlStateIn( $exception->getSQLState(),
9268
+		if (!$this->writer->sqlStateIn($exception->getSQLState(),
9269 9269
 			array(
9270 9270
 				QueryWriter::C_SQLSTATE_NO_SUCH_TABLE,
9271 9271
 				QueryWriter::C_SQLSTATE_NO_SUCH_COLUMN ),
9272
-				$exception->getDriverDetails() )
9272
+				$exception->getDriverDetails())
9273 9273
 		) {
9274 9274
 			throw $exception;
9275 9275
 		}
@@ -9290,19 +9290,19 @@  discard block
 block discarded – undo
9290 9290
 	 *
9291 9291
 	 * @return OODBBean
9292 9292
 	 */
9293
-	public function dispense( $type, $number = 1, $alwaysReturnArray = FALSE )
9293
+	public function dispense($type, $number = 1, $alwaysReturnArray = FALSE)
9294 9294
 	{
9295
-		$OODBBEAN = defined( 'REDBEAN_OODBBEAN_CLASS' ) ? REDBEAN_OODBBEAN_CLASS : '\RedBeanPHP\OODBBean';
9295
+		$OODBBEAN = defined('REDBEAN_OODBBEAN_CLASS') ? REDBEAN_OODBBEAN_CLASS : '\RedBeanPHP\OODBBean';
9296 9296
 		$beans = array();
9297
-		for ( $i = 0; $i < $number; $i++ ) {
9297
+		for ($i = 0; $i < $number; $i++) {
9298 9298
 			$bean = new $OODBBEAN;
9299
-			$bean->initializeForDispense( $type, $this->oodb->getBeanHelper() );
9300
-			$this->check( $bean );
9301
-			$this->oodb->signal( 'dispense', $bean );
9299
+			$bean->initializeForDispense($type, $this->oodb->getBeanHelper());
9300
+			$this->check($bean);
9301
+			$this->oodb->signal('dispense', $bean);
9302 9302
 			$beans[] = $bean;
9303 9303
 		}
9304 9304
 
9305
-		return ( count( $beans ) === 1 && !$alwaysReturnArray ) ? array_pop( $beans ) : $beans;
9305
+		return (count($beans) === 1 && !$alwaysReturnArray) ? array_pop($beans) : $beans;
9306 9306
 	}
9307 9307
 
9308 9308
 	/**
@@ -9327,16 +9327,16 @@  discard block
 block discarded – undo
9327 9327
 	 *
9328 9328
 	 * @return OODBBean
9329 9329
 	 */
9330
-	public function load( $type, $id )
9330
+	public function load($type, $id)
9331 9331
 	{
9332 9332
 		$rows = array();
9333
-		$bean = $this->dispense( $type );
9334
-		if ( isset( $this->stash[$this->nesting][$id] ) ) {
9333
+		$bean = $this->dispense($type);
9334
+		if (isset($this->stash[$this->nesting][$id])) {
9335 9335
 			$row = $this->stash[$this->nesting][$id];
9336 9336
 		} else {
9337 9337
 			try {
9338
-				$rows = $this->writer->queryRecord( $type, array( 'id' => array( $id ) ) );
9339
-			} catch ( SQLException $exception ) {
9338
+				$rows = $this->writer->queryRecord($type, array('id' => array($id)));
9339
+			} catch (SQLException $exception) {
9340 9340
 				if (
9341 9341
 					$this->writer->sqlStateIn(
9342 9342
 						$exception->getSQLState(),
@@ -9352,17 +9352,17 @@  discard block
 block discarded – undo
9352 9352
 					throw $exception;
9353 9353
 				}
9354 9354
 			}
9355
-			if ( !count( $rows ) ) {
9355
+			if (!count($rows)) {
9356 9356
 				return $bean;
9357 9357
 			}
9358
-			$row = array_pop( $rows );
9358
+			$row = array_pop($rows);
9359 9359
 		}
9360
-		$bean->importRow( $row );
9360
+		$bean->importRow($row);
9361 9361
 		$this->nesting++;
9362
-		$this->oodb->signal( 'open', $bean );
9362
+		$this->oodb->signal('open', $bean);
9363 9363
 		$this->nesting--;
9364 9364
 
9365
-		return $bean->setMeta( 'tainted', FALSE );
9365
+		return $bean->setMeta('tainted', FALSE);
9366 9366
 	}
9367 9367
 }
9368 9368
 }
@@ -9415,7 +9415,7 @@  discard block
 block discarded – undo
9415 9415
 	 *
9416 9416
 	 * @return void
9417 9417
 	 */
9418
-	protected function handleException( \Exception $exception )
9418
+	protected function handleException(\Exception $exception)
9419 9419
 	{
9420 9420
 		throw $exception;
9421 9421
 	}
@@ -9430,31 +9430,31 @@  discard block
 block discarded – undo
9430 9430
 	 *
9431 9431
 	 * @return void
9432 9432
 	 */
9433
-	protected function storeBean( OODBBean $bean )
9433
+	protected function storeBean(OODBBean $bean)
9434 9434
 	{
9435
-		if ( $bean->getMeta( 'changed' ) ) {
9435
+		if ($bean->getMeta('changed')) {
9436 9436
 
9437
-			list( $properties, $table ) = $bean->getPropertiesAndType();
9437
+			list($properties, $table) = $bean->getPropertiesAndType();
9438 9438
 			$id = $properties['id'];
9439 9439
 			unset($properties['id']);
9440 9440
 			$updateValues = array();
9441 9441
 			$k1 = 'property';
9442 9442
 			$k2 = 'value';
9443 9443
 
9444
-			$partial = ( $this->partialBeans === TRUE || ( is_array( $this->partialBeans ) && in_array( $table, $this->partialBeans ) ) );
9445
-			if ( $partial ) {
9446
-				$mask = $bean->getMeta( 'changelist' );
9447
-				$bean->setMeta( 'changelist', array() );
9444
+			$partial = ($this->partialBeans === TRUE || (is_array($this->partialBeans) && in_array($table, $this->partialBeans)));
9445
+			if ($partial) {
9446
+				$mask = $bean->getMeta('changelist');
9447
+				$bean->setMeta('changelist', array());
9448 9448
 			}
9449 9449
 
9450
-			foreach( $properties as $key => $value ) {
9451
-				if ( $partial && !in_array( $key, $mask ) ) continue;
9452
-				$updateValues[] = array( $k1 => $key, $k2 => $value );
9450
+			foreach ($properties as $key => $value) {
9451
+				if ($partial && !in_array($key, $mask)) continue;
9452
+				$updateValues[] = array($k1 => $key, $k2 => $value);
9453 9453
 			}
9454
-			$bean->id = $this->writer->updateRecord( $table, $updateValues, $id );
9455
-			$bean->setMeta( 'changed', FALSE );
9454
+			$bean->id = $this->writer->updateRecord($table, $updateValues, $id);
9455
+			$bean->setMeta('changed', FALSE);
9456 9456
 		}
9457
-		$bean->setMeta( 'tainted', FALSE );
9457
+		$bean->setMeta('tainted', FALSE);
9458 9458
 	}
9459 9459
 
9460 9460
 	/**
@@ -9475,24 +9475,24 @@  discard block
 block discarded – undo
9475 9475
 	 * @return void
9476 9476
 	 * @throws RedException
9477 9477
 	 */
9478
-	protected function processAdditions( $bean, $ownAdditions )
9478
+	protected function processAdditions($bean, $ownAdditions)
9479 9479
 	{
9480
-		$beanType = $bean->getMeta( 'type' );
9480
+		$beanType = $bean->getMeta('type');
9481 9481
 
9482 9482
 		$cachedIndex = array();
9483
-		foreach ( $ownAdditions as $addition ) {
9484
-			if ( $addition instanceof OODBBean ) {
9483
+		foreach ($ownAdditions as $addition) {
9484
+			if ($addition instanceof OODBBean) {
9485 9485
 
9486
-				$myFieldLink = $beanType . '_id';
9487
-				$alias = $bean->getMeta( 'sys.alias.' . $addition->getMeta( 'type' ) );
9488
-				if ( $alias ) $myFieldLink = $alias . '_id';
9486
+				$myFieldLink = $beanType.'_id';
9487
+				$alias = $bean->getMeta('sys.alias.'.$addition->getMeta('type'));
9488
+				if ($alias) $myFieldLink = $alias.'_id';
9489 9489
 
9490 9490
 				$addition->$myFieldLink = $bean->id;
9491
-				$addition->setMeta( 'cast.' . $myFieldLink, 'id' );
9492
-				$this->store( $addition );
9491
+				$addition->setMeta('cast.'.$myFieldLink, 'id');
9492
+				$this->store($addition);
9493 9493
 
9494 9494
 			} else {
9495
-				throw new RedException( 'Array may only contain OODBBeans' );
9495
+				throw new RedException('Array may only contain OODBBeans');
9496 9496
 			}
9497 9497
 		}
9498 9498
 	}
@@ -9512,19 +9512,19 @@  discard block
 block discarded – undo
9512 9512
 	 *
9513 9513
 	 * @return OODBBean
9514 9514
 	 */
9515
-	public function dispense( $type, $number = 1, $alwaysReturnArray = FALSE )
9515
+	public function dispense($type, $number = 1, $alwaysReturnArray = FALSE)
9516 9516
 	{
9517
-		$OODBBEAN = defined( 'REDBEAN_OODBBEAN_CLASS' ) ? REDBEAN_OODBBEAN_CLASS : '\RedBeanPHP\OODBBean';
9517
+		$OODBBEAN = defined('REDBEAN_OODBBEAN_CLASS') ? REDBEAN_OODBBEAN_CLASS : '\RedBeanPHP\OODBBean';
9518 9518
 		$beans = array();
9519
-		for ( $i = 0; $i < $number; $i++ ) {
9519
+		for ($i = 0; $i < $number; $i++) {
9520 9520
 			/** @var \RedBeanPHP\OODBBean $bean */
9521 9521
 			$bean = new $OODBBEAN;
9522
-			$bean->initializeForDispense( $type, $this->oodb->getBeanHelper() );
9523
-			$this->oodb->signal( 'dispense', $bean );
9522
+			$bean->initializeForDispense($type, $this->oodb->getBeanHelper());
9523
+			$this->oodb->signal('dispense', $bean);
9524 9524
 			$beans[] = $bean;
9525 9525
 		}
9526 9526
 
9527
-		return ( count( $beans ) === 1 && !$alwaysReturnArray ) ? array_pop( $beans ) : $beans;
9527
+		return (count($beans) === 1 && !$alwaysReturnArray) ? array_pop($beans) : $beans;
9528 9528
 	}
9529 9529
 
9530 9530
 	/**
@@ -9550,25 +9550,25 @@  discard block
 block discarded – undo
9550 9550
 	 * @return OODBBean
9551 9551
 	 * @throws SQLException
9552 9552
 	 */
9553
-	public function load( $type, $id )
9553
+	public function load($type, $id)
9554 9554
 	{
9555 9555
 		$rows = array();
9556
-		$bean = $this->dispense( $type );
9557
-		if ( isset( $this->stash[$this->nesting][$id] ) ) {
9556
+		$bean = $this->dispense($type);
9557
+		if (isset($this->stash[$this->nesting][$id])) {
9558 9558
 			$row = $this->stash[$this->nesting][$id];
9559 9559
 		} else {
9560
-			$rows = $this->writer->queryRecord( $type, array( 'id' => array( $id ) ) );
9561
-			if ( !count( $rows ) ) {
9560
+			$rows = $this->writer->queryRecord($type, array('id' => array($id)));
9561
+			if (!count($rows)) {
9562 9562
 				return $bean;
9563 9563
 			}
9564
-			$row = array_pop( $rows );
9564
+			$row = array_pop($rows);
9565 9565
 		}
9566
-		$bean->importRow( $row );
9566
+		$bean->importRow($row);
9567 9567
 		$this->nesting++;
9568
-		$this->oodb->signal( 'open', $bean );
9568
+		$this->oodb->signal('open', $bean);
9569 9569
 		$this->nesting--;
9570 9570
 
9571
-		return $bean->setMeta( 'tainted', FALSE );
9571
+		return $bean->setMeta('tainted', FALSE);
9572 9572
 	}
9573 9573
 }
9574 9574
 }
@@ -9670,7 +9670,7 @@  discard block
 block discarded – undo
9670 9670
 	 *
9671 9671
 	 * @return void
9672 9672
 	 */
9673
-	public static function autoClearHistoryAfterStore( $autoClear = TRUE )
9673
+	public static function autoClearHistoryAfterStore($autoClear = TRUE)
9674 9674
 	{
9675 9675
 		self::$autoClearHistoryAfterStore = (boolean) $autoClear;
9676 9676
 	}
@@ -9683,13 +9683,13 @@  discard block
 block discarded – undo
9683 9683
 	 *
9684 9684
 	 * @return OODBBean
9685 9685
 	 */
9686
-	protected function unboxIfNeeded( $bean )
9686
+	protected function unboxIfNeeded($bean)
9687 9687
 	{
9688
-		if ( $bean instanceof SimpleModel ) {
9688
+		if ($bean instanceof SimpleModel) {
9689 9689
 			$bean = $bean->unbox();
9690 9690
 		}
9691
-		if ( !( $bean instanceof OODBBean ) ) {
9692
-			throw new RedException( 'OODB Store requires a bean, got: ' . gettype( $bean ) );
9691
+		if (!($bean instanceof OODBBean)) {
9692
+			throw new RedException('OODB Store requires a bean, got: '.gettype($bean));
9693 9693
 		}
9694 9694
 
9695 9695
 		return $bean;
@@ -9730,13 +9730,13 @@  discard block
 block discarded – undo
9730 9730
 	 * @param QueryWriter   $writer writer
9731 9731
 	 * @param array|boolean $frozen mode of operation: TRUE (frozen), FALSE (default, fluid) or ARRAY (chilled)
9732 9732
 	 */
9733
-	public function __construct( QueryWriter $writer, $frozen = FALSE )
9733
+	public function __construct(QueryWriter $writer, $frozen = FALSE)
9734 9734
 	{
9735
-		if ( $writer instanceof QueryWriter ) {
9735
+		if ($writer instanceof QueryWriter) {
9736 9736
 			$this->writer = $writer;
9737 9737
 		}
9738 9738
 
9739
-		$this->freeze( $frozen );
9739
+		$this->freeze($frozen);
9740 9740
 	}
9741 9741
 
9742 9742
 	/**
@@ -9752,32 +9752,32 @@  discard block
 block discarded – undo
9752 9752
 	 *
9753 9753
 	 * @return void
9754 9754
 	 */
9755
-	public function freeze( $toggle )
9755
+	public function freeze($toggle)
9756 9756
 	{
9757
-		if ( is_array( $toggle ) ) {
9757
+		if (is_array($toggle)) {
9758 9758
 			$this->chillList = $toggle;
9759 9759
 			$this->isFrozen  = FALSE;
9760 9760
 		} else {
9761 9761
 			$this->isFrozen = (boolean) $toggle;
9762 9762
 		}
9763 9763
 
9764
-		if ( $this->isFrozen ) {
9765
-			if ( !$this->frozenRepository ) {
9766
-				$this->frozenRepository = new FrozenRepo( $this, $this->writer );
9764
+		if ($this->isFrozen) {
9765
+			if (!$this->frozenRepository) {
9766
+				$this->frozenRepository = new FrozenRepo($this, $this->writer);
9767 9767
 			}
9768 9768
 
9769 9769
 			$this->repository = $this->frozenRepository;
9770 9770
 
9771 9771
 		} else {
9772
-			if ( !$this->fluidRepository ) {
9773
-				$this->fluidRepository = new FluidRepo( $this, $this->writer );
9772
+			if (!$this->fluidRepository) {
9773
+				$this->fluidRepository = new FluidRepo($this, $this->writer);
9774 9774
 			}
9775 9775
 
9776 9776
 			$this->repository = $this->fluidRepository;
9777 9777
 		}
9778 9778
 
9779
-		if ( count( self::$sqlFilters ) ) {
9780
-			AQueryWriter::setSQLFilters( self::$sqlFilters, ( !$this->isFrozen ) );
9779
+		if (count(self::$sqlFilters)) {
9780
+			AQueryWriter::setSQLFilters(self::$sqlFilters, (!$this->isFrozen));
9781 9781
 		}
9782 9782
 
9783 9783
 	}
@@ -9807,9 +9807,9 @@  discard block
 block discarded – undo
9807 9807
 	 *
9808 9808
 	 * @return boolean
9809 9809
 	 */
9810
-	public function isChilled( $type )
9810
+	public function isChilled($type)
9811 9811
 	{
9812
-		return (boolean) ( in_array( $type, $this->chillList ) );
9812
+		return (boolean) (in_array($type, $this->chillList));
9813 9813
 	}
9814 9814
 
9815 9815
 	/**
@@ -9827,14 +9827,14 @@  discard block
 block discarded – undo
9827 9827
 	 *
9828 9828
 	 * @return OODBBean
9829 9829
 	 */
9830
-	public function dispense( $type, $number = 1, $alwaysReturnArray = FALSE )
9830
+	public function dispense($type, $number = 1, $alwaysReturnArray = FALSE)
9831 9831
 	{
9832
-		if ( $number < 1 ) {
9833
-			if ( $alwaysReturnArray ) return array();
9832
+		if ($number < 1) {
9833
+			if ($alwaysReturnArray) return array();
9834 9834
 			return NULL;
9835 9835
 		}
9836 9836
 
9837
-		return $this->repository->dispense( $type, $number, $alwaysReturnArray );
9837
+		return $this->repository->dispense($type, $number, $alwaysReturnArray);
9838 9838
 	}
9839 9839
 
9840 9840
 	/**
@@ -9845,7 +9845,7 @@  discard block
 block discarded – undo
9845 9845
 	 *
9846 9846
 	 * @return void
9847 9847
 	 */
9848
-	public function setBeanHelper( BeanHelper $beanhelper )
9848
+	public function setBeanHelper(BeanHelper $beanhelper)
9849 9849
 	{
9850 9850
 		$this->beanhelper = $beanhelper;
9851 9851
 	}
@@ -9870,9 +9870,9 @@  discard block
 block discarded – undo
9870 9870
 	 *
9871 9871
 	 * @return void
9872 9872
 	 */
9873
-	public function check( OODBBean $bean )
9873
+	public function check(OODBBean $bean)
9874 9874
 	{
9875
-		$this->repository->check( $bean );
9875
+		$this->repository->check($bean);
9876 9876
 	}
9877 9877
 
9878 9878
 	/**
@@ -9901,9 +9901,9 @@  discard block
 block discarded – undo
9901 9901
 	 *
9902 9902
 	 * @return array
9903 9903
 	 */
9904
-	public function find( $type, $conditions = array(), $sql = NULL, $bindings = array() )
9904
+	public function find($type, $conditions = array(), $sql = NULL, $bindings = array())
9905 9905
 	{
9906
-		return $this->repository->find( $type, $conditions, $sql, $bindings );
9906
+		return $this->repository->find($type, $conditions, $sql, $bindings);
9907 9907
 	}
9908 9908
 
9909 9909
 	/**
@@ -9915,9 +9915,9 @@  discard block
 block discarded – undo
9915 9915
 	 *
9916 9916
 	 * @return BeanCollection
9917 9917
 	 */
9918
-	public function findCollection(  $type, $sql = NULL, $bindings = array() )
9918
+	public function findCollection($type, $sql = NULL, $bindings = array())
9919 9919
 	{
9920
-		return $this->repository->findCollection( $type, $sql, $bindings );
9920
+		return $this->repository->findCollection($type, $sql, $bindings);
9921 9921
 	}
9922 9922
 
9923 9923
 	/**
@@ -9930,9 +9930,9 @@  discard block
 block discarded – undo
9930 9930
 	 *
9931 9931
 	 * @return boolean
9932 9932
 	 */
9933
-	public function tableExists( $table )
9933
+	public function tableExists($table)
9934 9934
 	{
9935
-		return $this->repository->tableExists( $table );
9935
+		return $this->repository->tableExists($table);
9936 9936
 	}
9937 9937
 
9938 9938
 	/**
@@ -9955,11 +9955,11 @@  discard block
 block discarded – undo
9955 9955
 	 *
9956 9956
 	 * @return integer|string
9957 9957
 	 */
9958
-	public function store( $bean )
9958
+	public function store($bean)
9959 9959
 	{
9960
-		$bean = $this->unboxIfNeeded( $bean );
9961
-		$id = $this->repository->store( $bean );
9962
-		if ( self::$autoClearHistoryAfterStore ) {
9960
+		$bean = $this->unboxIfNeeded($bean);
9961
+		$id = $this->repository->store($bean);
9962
+		if (self::$autoClearHistoryAfterStore) {
9963 9963
 				$bean->clearHistory();
9964 9964
 		}
9965 9965
 		return $id;
@@ -9987,9 +9987,9 @@  discard block
 block discarded – undo
9987 9987
 	 *
9988 9988
 	 * @return OODBBean
9989 9989
 	 */
9990
-	public function load( $type, $id )
9990
+	public function load($type, $id)
9991 9991
 	{
9992
-		return $this->repository->load( $type, $id );
9992
+		return $this->repository->load($type, $id);
9993 9993
 	}
9994 9994
 
9995 9995
 	/**
@@ -10001,10 +10001,10 @@  discard block
 block discarded – undo
10001 10001
 	 *
10002 10002
 	 * @return void
10003 10003
 	 */
10004
-	public function trash( $bean )
10004
+	public function trash($bean)
10005 10005
 	{
10006
-		$bean = $this->unboxIfNeeded( $bean );
10007
-		return $this->repository->trash( $bean );
10006
+		$bean = $this->unboxIfNeeded($bean);
10007
+		return $this->repository->trash($bean);
10008 10008
 	}
10009 10009
 
10010 10010
 	/**
@@ -10021,9 +10021,9 @@  discard block
 block discarded – undo
10021 10021
 	 *
10022 10022
 	 * @return array
10023 10023
 	 */
10024
-	public function batch( $type, $ids )
10024
+	public function batch($type, $ids)
10025 10025
 	{
10026
-		return $this->repository->batch( $type, $ids );
10026
+		return $this->repository->batch($type, $ids);
10027 10027
 	}
10028 10028
 
10029 10029
 	/**
@@ -10038,9 +10038,9 @@  discard block
 block discarded – undo
10038 10038
 	 *
10039 10039
 	 * @return array
10040 10040
 	 */
10041
-	public function convertToBeans( $type, $rows, $mask = NULL )
10041
+	public function convertToBeans($type, $rows, $mask = NULL)
10042 10042
 	{
10043
-		return $this->repository->convertToBeans( $type, $rows, $mask );
10043
+		return $this->repository->convertToBeans($type, $rows, $mask);
10044 10044
 	}
10045 10045
 
10046 10046
 	/**
@@ -10054,9 +10054,9 @@  discard block
 block discarded – undo
10054 10054
 	 *
10055 10055
 	 * @return integer
10056 10056
 	 */
10057
-	public function count( $type, $addSQL = '', $bindings = array() )
10057
+	public function count($type, $addSQL = '', $bindings = array())
10058 10058
 	{
10059
-		return $this->repository->count( $type, $addSQL, $bindings );
10059
+		return $this->repository->count($type, $addSQL, $bindings);
10060 10060
 	}
10061 10061
 
10062 10062
 	/**
@@ -10066,9 +10066,9 @@  discard block
 block discarded – undo
10066 10066
 	 *
10067 10067
 	 * @return boolean
10068 10068
 	 */
10069
-	public function wipe( $type )
10069
+	public function wipe($type)
10070 10070
 	{
10071
-		return $this->repository->wipe( $type );
10071
+		return $this->repository->wipe($type);
10072 10072
 	}
10073 10073
 
10074 10074
 	/**
@@ -10080,8 +10080,8 @@  discard block
 block discarded – undo
10080 10080
 	 */
10081 10081
 	public function getAssociationManager()
10082 10082
 	{
10083
-		if ( !isset( $this->assocManager ) ) {
10084
-			throw new RedException( 'No association manager available.' );
10083
+		if (!isset($this->assocManager)) {
10084
+			throw new RedException('No association manager available.');
10085 10085
 		}
10086 10086
 
10087 10087
 		return $this->assocManager;
@@ -10096,7 +10096,7 @@  discard block
 block discarded – undo
10096 10096
 	 *
10097 10097
 	 * @return void
10098 10098
 	 */
10099
-	public function setAssociationManager( AssociationManager $assocManager )
10099
+	public function setAssociationManager(AssociationManager $assocManager)
10100 10100
 	{
10101 10101
 		$this->assocManager = $assocManager;
10102 10102
 	}
@@ -10125,16 +10125,16 @@  discard block
 block discarded – undo
10125 10125
 	 *
10126 10126
 	 * @return void
10127 10127
 	 */
10128
-	public function bindFunc( $mode, $field, $function )
10128
+	public function bindFunc($mode, $field, $function)
10129 10129
 	{
10130
-		list( $type, $property ) = explode( '.', $field );
10130
+		list($type, $property) = explode('.', $field);
10131 10131
 		$mode = ($mode === 'write') ? QueryWriter::C_SQLFILTER_WRITE : QueryWriter::C_SQLFILTER_READ;
10132 10132
 
10133
-		if ( !isset( self::$sqlFilters[$mode] ) ) self::$sqlFilters[$mode] = array();
10134
-		if ( !isset( self::$sqlFilters[$mode][$type] ) ) self::$sqlFilters[$mode][$type] = array();
10133
+		if (!isset(self::$sqlFilters[$mode])) self::$sqlFilters[$mode] = array();
10134
+		if (!isset(self::$sqlFilters[$mode][$type])) self::$sqlFilters[$mode][$type] = array();
10135 10135
 
10136
-		if ( is_null( $function ) ) {
10137
-			unset( self::$sqlFilters[$mode][$type][$property] );
10136
+		if (is_null($function)) {
10137
+			unset(self::$sqlFilters[$mode][$type][$property]);
10138 10138
 		} else {
10139 10139
 			if ($mode === QueryWriter::C_SQLFILTER_WRITE) {
10140 10140
 				self::$sqlFilters[$mode][$type][$property] = $function.'(?)';
@@ -10143,7 +10143,7 @@  discard block
 block discarded – undo
10143 10143
 			}
10144 10144
 		}
10145 10145
 
10146
-		AQueryWriter::setSQLFilters( self::$sqlFilters, ( !$this->isFrozen ) );
10146
+		AQueryWriter::setSQLFilters(self::$sqlFilters, (!$this->isFrozen));
10147 10147
 	}
10148 10148
 }
10149 10149
 }
@@ -10217,7 +10217,7 @@  discard block
 block discarded – undo
10217 10217
 	 * @param DBAdapter   $adapter Database Adapter
10218 10218
 	 * @param QueryWriter $writer  Query Writer
10219 10219
 	 */
10220
-	public function __construct( OODB $oodb, Adapter $adapter, QueryWriter $writer )
10220
+	public function __construct(OODB $oodb, Adapter $adapter, QueryWriter $writer)
10221 10221
 	{
10222 10222
 		$this->oodb    = $oodb;
10223 10223
 		$this->adapter = $adapter;
@@ -10352,7 +10352,7 @@  discard block
 block discarded – undo
10352 10352
 	 *
10353 10353
 	 * @param ToolBox $toolbox
10354 10354
 	 */
10355
-	public function __construct( ToolBox $toolbox )
10355
+	public function __construct(ToolBox $toolbox)
10356 10356
 	{
10357 10357
 		$this->toolbox = $toolbox;
10358 10358
 		$this->redbean = $toolbox->getRedBean();
@@ -10378,20 +10378,20 @@  discard block
 block discarded – undo
10378 10378
 	 *
10379 10379
 	 * @return array
10380 10380
 	 */
10381
-	public static function map($parentName,$childName) {
10381
+	public static function map($parentName, $childName) {
10382 10382
 		return array(
10383 10383
 			'a' => $parentName,
10384 10384
 			'b' => $childName,
10385
-			'matcher' => function( $parent, $child ) use ( $parentName, $childName ) {
10386
-				$propertyName = 'own' . ucfirst( $childName );
10385
+			'matcher' => function($parent, $child) use ($parentName, $childName) {
10386
+				$propertyName = 'own'.ucfirst($childName);
10387 10387
 				if (!isset($parent[$propertyName])) {
10388 10388
 					$parent->noLoad()->{$propertyName} = array();
10389 10389
 				}
10390 10390
 				$property = "{$parentName}ID";
10391
-				return ( $child->$property == $parent->id );
10391
+				return ($child->$property == $parent->id);
10392 10392
 			},
10393
-			'do' => function( $parent, $child ) use ( $childName ) {
10394
-				$list = 'own'.ucfirst( $childName ).'List';
10393
+			'do' => function($parent, $child) use ($childName) {
10394
+				$list = 'own'.ucfirst($childName).'List';
10395 10395
 				$parent->noLoad()->{$list}[$child->id] = $child;
10396 10396
 			}
10397 10397
 		);
@@ -10416,27 +10416,27 @@  discard block
 block discarded – undo
10416 10416
 	*
10417 10417
 	* @return array
10418 10418
 	*/
10419
-	public static function nmMap( $parentName, $childName )
10419
+	public static function nmMap($parentName, $childName)
10420 10420
 	{
10421 10421
 		$types = array($parentName, $childName);
10422
-		sort( $types );
10423
-		$link = implode( '_', $types );
10422
+		sort($types);
10423
+		$link = implode('_', $types);
10424 10424
 		return array(
10425 10425
 			'a' => $parentName,
10426 10426
 			'b' => $childName,
10427
-			'matcher' => function( $parent, $child, $beans ) use ( $parentName, $childName, $link ) {
10428
-				$propertyName = 'shared' . ucfirst( $childName );
10427
+			'matcher' => function($parent, $child, $beans) use ($parentName, $childName, $link) {
10428
+				$propertyName = 'shared'.ucfirst($childName);
10429 10429
 				if (!isset($parent[$propertyName])) {
10430 10430
 					$parent->noLoad()->{$propertyName} = array();
10431 10431
 				}
10432
-				foreach( $beans[$link] as $linkBean ) {
10433
-					if ( $linkBean["{$parentName}ID"] == $parent->id && $linkBean["{$childName}ID"] == $child->id ) {
10432
+				foreach ($beans[$link] as $linkBean) {
10433
+					if ($linkBean["{$parentName}ID"] == $parent->id && $linkBean["{$childName}ID"] == $child->id) {
10434 10434
 						return true;
10435 10435
 					}
10436 10436
 				}
10437 10437
 			},
10438
-			'do' => function( $parent, $child ) use ( $childName ) {
10439
-				$list = 'shared'.ucfirst( $childName ).'List';
10438
+			'do' => function($parent, $child) use ($childName) {
10439
+				$list = 'shared'.ucfirst($childName).'List';
10440 10440
 				$parent->noLoad()->{$list}[$child->id] = $child;
10441 10441
 			}
10442 10442
 		);
@@ -10455,15 +10455,15 @@  discard block
 block discarded – undo
10455 10455
 	 *
10456 10456
 	 * @return array
10457 10457
 	 */
10458
-	public function find( $type, $sql = NULL, $bindings = array() )
10458
+	public function find($type, $sql = NULL, $bindings = array())
10459 10459
 	{
10460
-		if ( !is_array( $bindings ) ) {
10460
+		if (!is_array($bindings)) {
10461 10461
 			throw new RedException(
10462
-				'Expected array, ' . gettype( $bindings ) . ' given.'
10462
+				'Expected array, '.gettype($bindings).' given.'
10463 10463
 			);
10464 10464
 		}
10465 10465
 
10466
-		return $this->redbean->find( $type, array(), $sql, $bindings );
10466
+		return $this->redbean->find($type, array(), $sql, $bindings);
10467 10467
 	}
10468 10468
 
10469 10469
 	/**
@@ -10481,10 +10481,10 @@  discard block
 block discarded – undo
10481 10481
 	 *
10482 10482
 	 * @return array
10483 10483
 	 */
10484
-	public function findAndExport( $type, $sql = NULL, $bindings = array() )
10484
+	public function findAndExport($type, $sql = NULL, $bindings = array())
10485 10485
 	{
10486 10486
 		$arr = array();
10487
-		foreach ( $this->find( $type, $sql, $bindings ) as $key => $item ) {
10487
+		foreach ($this->find($type, $sql, $bindings) as $key => $item) {
10488 10488
 			$arr[] = $item->export();
10489 10489
 		}
10490 10490
 
@@ -10504,17 +10504,17 @@  discard block
 block discarded – undo
10504 10504
 	 *
10505 10505
 	 * @return OODBBean|NULL
10506 10506
 	 */
10507
-	public function findOne( $type, $sql = NULL, $bindings = array() )
10507
+	public function findOne($type, $sql = NULL, $bindings = array())
10508 10508
 	{
10509
-		$sql = $this->toolbox->getWriter()->glueLimitOne( $sql );
10509
+		$sql = $this->toolbox->getWriter()->glueLimitOne($sql);
10510 10510
 
10511
-		$items = $this->find( $type, $sql, $bindings );
10511
+		$items = $this->find($type, $sql, $bindings);
10512 10512
 
10513
-		if ( empty($items) ) {
10513
+		if (empty($items)) {
10514 10514
 			return NULL;
10515 10515
 		}
10516 10516
 
10517
-		return reset( $items );
10517
+		return reset($items);
10518 10518
 	}
10519 10519
 
10520 10520
 	/**
@@ -10530,15 +10530,15 @@  discard block
 block discarded – undo
10530 10530
 	 *
10531 10531
 	 * @return OODBBean|NULL
10532 10532
 	 */
10533
-	public function findLast( $type, $sql = NULL, $bindings = array() )
10533
+	public function findLast($type, $sql = NULL, $bindings = array())
10534 10534
 	{
10535
-		$items = $this->find( $type, $sql, $bindings );
10535
+		$items = $this->find($type, $sql, $bindings);
10536 10536
 
10537
-		if ( empty($items) ) {
10537
+		if (empty($items)) {
10538 10538
 			return NULL;
10539 10539
 		}
10540 10540
 
10541
-		return end( $items );
10541
+		return end($items);
10542 10542
 	}
10543 10543
 
10544 10544
 	/**
@@ -10554,12 +10554,12 @@  discard block
 block discarded – undo
10554 10554
 	 *
10555 10555
 	 * @return array
10556 10556
 	 */
10557
-	public function findOrDispense( $type, $sql = NULL, $bindings = array() )
10557
+	public function findOrDispense($type, $sql = NULL, $bindings = array())
10558 10558
 	{
10559
-		$foundBeans = $this->find( $type, $sql, $bindings );
10559
+		$foundBeans = $this->find($type, $sql, $bindings);
10560 10560
 
10561
-		if ( empty( $foundBeans ) ) {
10562
-			return array( $this->redbean->dispense( $type ) );
10561
+		if (empty($foundBeans)) {
10562
+			return array($this->redbean->dispense($type));
10563 10563
 		} else {
10564 10564
 			return $foundBeans;
10565 10565
 		}
@@ -10577,9 +10577,9 @@  discard block
 block discarded – undo
10577 10577
 	 *
10578 10578
 	 * @return BeanCollection
10579 10579
 	 */
10580
-	public function findCollection( $type, $sql, $bindings = array() )
10580
+	public function findCollection($type, $sql, $bindings = array())
10581 10581
 	{
10582
-		return $this->redbean->findCollection( $type, $sql, $bindings );
10582
+		return $this->redbean->findCollection($type, $sql, $bindings);
10583 10583
 	}
10584 10584
 
10585 10585
 	/**
@@ -10599,18 +10599,18 @@  discard block
 block discarded – undo
10599 10599
 	 *
10600 10600
 	 * @return OODBBean
10601 10601
 	 */
10602
-	public function findOrCreate( $type, $like = array(), $sql = '' )
10602
+	public function findOrCreate($type, $like = array(), $sql = '')
10603 10603
 	{
10604
-			$sql = $this->toolbox->getWriter()->glueLimitOne( $sql );
10605
-			$beans = $this->findLike( $type, $like, $sql );
10606
-			if ( count( $beans ) ) {
10607
-				$bean = reset( $beans );
10604
+			$sql = $this->toolbox->getWriter()->glueLimitOne($sql);
10605
+			$beans = $this->findLike($type, $like, $sql);
10606
+			if (count($beans)) {
10607
+				$bean = reset($beans);
10608 10608
 				return $bean;
10609 10609
 			}
10610 10610
 
10611
-			$bean = $this->redbean->dispense( $type );
10612
-			$bean->import( $like );
10613
-			$this->redbean->store( $bean );
10611
+			$bean = $this->redbean->dispense($type);
10612
+			$bean->import($like);
10613
+			$this->redbean->store($bean);
10614 10614
 			return $bean;
10615 10615
 	}
10616 10616
 
@@ -10636,9 +10636,9 @@  discard block
 block discarded – undo
10636 10636
 	 *
10637 10637
 	 * @return array
10638 10638
 	 */
10639
-	public function findLike( $type, $conditions = array(), $sql = '', $bindings = array() )
10639
+	public function findLike($type, $conditions = array(), $sql = '', $bindings = array())
10640 10640
 	{
10641
-		return $this->redbean->find( $type, $conditions, $sql, $bindings );
10641
+		return $this->redbean->find($type, $conditions, $sql, $bindings);
10642 10642
 	}
10643 10643
 
10644 10644
 	/**
@@ -10713,74 +10713,74 @@  discard block
 block discarded – undo
10713 10713
 	 *
10714 10714
 	 * @return array
10715 10715
 	 */
10716
-	public function findMulti( $types, $sql = NULL, $bindings = array(), $remappings = array(), $queryTemplate = ' %s.%s AS %s__%s' )
10716
+	public function findMulti($types, $sql = NULL, $bindings = array(), $remappings = array(), $queryTemplate = ' %s.%s AS %s__%s')
10717 10717
 	{
10718
-		if ( !is_array( $types ) ) $types = array_map( 'trim', explode( ',', $types ) );
10719
-		if ( is_null( $sql ) ) {
10718
+		if (!is_array($types)) $types = array_map('trim', explode(',', $types));
10719
+		if (is_null($sql)) {
10720 10720
 			$beans = array();
10721
-			foreach( $types as $type ) $beans[$type] = $this->redbean->find( $type );
10721
+			foreach ($types as $type) $beans[$type] = $this->redbean->find($type);
10722 10722
 		} else {
10723
-			if ( !is_array( $sql ) ) {
10723
+			if (!is_array($sql)) {
10724 10724
 				$writer = $this->toolbox->getWriter();
10725 10725
 				$adapter = $this->toolbox->getDatabaseAdapter();
10726 10726
 
10727 10727
 				//Repair the query, replace book.* with book.id AS book_id etc..
10728
-				foreach( $types as $type ) {
10728
+				foreach ($types as $type) {
10729 10729
 					$regex = "#( (`?{$type}`?)\.\*)#";
10730
-					if ( preg_match( $regex, $sql, $matches ) ) {
10730
+					if (preg_match($regex, $sql, $matches)) {
10731 10731
 						$pattern = $matches[1];
10732 10732
 						$table = $matches[2];
10733 10733
 						$newSelectorArray = array();
10734
-						$columns = $writer->getColumns( $type );
10735
-						foreach( $columns as $column => $definition ) {
10736
-							$newSelectorArray[] = sprintf( $queryTemplate, $table, $column, $type, $column );
10734
+						$columns = $writer->getColumns($type);
10735
+						foreach ($columns as $column => $definition) {
10736
+							$newSelectorArray[] = sprintf($queryTemplate, $table, $column, $type, $column);
10737 10737
 						}
10738
-						$newSelector = implode( ',', $newSelectorArray );
10739
-						$sql = str_replace( $pattern, $newSelector, $sql );
10738
+						$newSelector = implode(',', $newSelectorArray);
10739
+						$sql = str_replace($pattern, $newSelector, $sql);
10740 10740
 					}
10741 10741
 				}
10742 10742
 
10743
-				$rows = $adapter->get( $sql, $bindings );
10743
+				$rows = $adapter->get($sql, $bindings);
10744 10744
 			} else {
10745 10745
 				$rows = $sql;
10746 10746
 			}
10747 10747
 
10748 10748
 			//Gather the bean data from the query results using the prefix
10749 10749
 			$wannaBeans = array();
10750
-			foreach( $types as $type ) {
10750
+			foreach ($types as $type) {
10751 10751
 				$wannaBeans[$type] = array();
10752 10752
 				$prefix            = "{$type}__";
10753
-				foreach( $rows as $rowkey=>$row ) {
10753
+				foreach ($rows as $rowkey=>$row) {
10754 10754
 					$wannaBean = array();
10755
-					foreach( $row as $cell => $value ) {
10756
-						if ( strpos( $cell, $prefix ) === 0 ) {
10757
-							$property = substr( $cell, strlen( $prefix ) );
10758
-							unset( $rows[$rowkey][$cell] );
10755
+					foreach ($row as $cell => $value) {
10756
+						if (strpos($cell, $prefix) === 0) {
10757
+							$property = substr($cell, strlen($prefix));
10758
+							unset($rows[$rowkey][$cell]);
10759 10759
 							$wannaBean[$property] = $value;
10760 10760
 						}
10761 10761
 					}
10762
-					if ( !isset( $wannaBean['id'] ) ) continue;
10763
-					if ( is_null( $wannaBean['id'] ) ) continue;
10762
+					if (!isset($wannaBean['id'])) continue;
10763
+					if (is_null($wannaBean['id'])) continue;
10764 10764
 					$wannaBeans[$type][$wannaBean['id']] = $wannaBean;
10765 10765
 				}
10766 10766
 			}
10767 10767
 
10768 10768
 			//Turn the rows into beans
10769 10769
 			$beans = array();
10770
-			foreach( $wannaBeans as $type => $wannabees ) {
10771
-				$beans[$type] = $this->redbean->convertToBeans( $type, $wannabees );
10770
+			foreach ($wannaBeans as $type => $wannabees) {
10771
+				$beans[$type] = $this->redbean->convertToBeans($type, $wannabees);
10772 10772
 			}
10773 10773
 		}
10774 10774
 
10775 10775
 		//Apply additional re-mappings
10776
-		foreach($remappings as $remapping) {
10776
+		foreach ($remappings as $remapping) {
10777 10777
 			$a       = $remapping['a'];
10778 10778
 			$b       = $remapping['b'];
10779 10779
 			$matcher = $remapping['matcher'];
10780 10780
 			$do      = $remapping['do'];
10781
-			foreach( $beans[$a] as $bean ) {
10782
-				foreach( $beans[$b] as $putBean ) {
10783
-					if ( $matcher( $bean, $putBean, $beans ) ) $do( $bean, $putBean, $beans, $remapping );
10781
+			foreach ($beans[$a] as $bean) {
10782
+				foreach ($beans[$b] as $putBean) {
10783
+					if ($matcher($bean, $putBean, $beans)) $do($bean, $putBean, $beans, $remapping);
10784 10784
 				}
10785 10785
 			}
10786 10786
 		}
@@ -10848,9 +10848,9 @@  discard block
 block discarded – undo
10848 10848
 	 *
10849 10849
 	 * @return void
10850 10850
 	 */
10851
-	private function handleException( \Exception $exception )
10851
+	private function handleException(\Exception $exception)
10852 10852
 	{
10853
-		if ( $this->oodb->isFrozen() || !$this->writer->sqlStateIn( $exception->getSQLState(),
10853
+		if ($this->oodb->isFrozen() || !$this->writer->sqlStateIn($exception->getSQLState(),
10854 10854
 			array(
10855 10855
 				QueryWriter::C_SQLSTATE_NO_SUCH_TABLE,
10856 10856
 				QueryWriter::C_SQLSTATE_NO_SUCH_COLUMN ),
@@ -10873,14 +10873,14 @@  discard block
 block discarded – undo
10873 10873
 	 *
10874 10874
 	 * @return array
10875 10875
 	 */
10876
-	private function relatedRows( $bean, $type, $sql = '', $bindings = array() )
10876
+	private function relatedRows($bean, $type, $sql = '', $bindings = array())
10877 10877
 	{
10878
-		$ids = array( $bean->id );
10879
-		$sourceType = $bean->getMeta( 'type' );
10878
+		$ids = array($bean->id);
10879
+		$sourceType = $bean->getMeta('type');
10880 10880
 		try {
10881
-			return $this->writer->queryRecordRelated( $sourceType, $type, $ids, $sql, $bindings );
10882
-		} catch ( SQLException $exception ) {
10883
-			$this->handleException( $exception );
10881
+			return $this->writer->queryRecordRelated($sourceType, $type, $ids, $sql, $bindings);
10882
+		} catch (SQLException $exception) {
10883
+			$this->handleException($exception);
10884 10884
 			return array();
10885 10885
 		}
10886 10886
 	}
@@ -10897,35 +10897,35 @@  discard block
 block discarded – undo
10897 10897
 	 *
10898 10898
 	 * @return mixed
10899 10899
 	 */
10900
-	protected function associateBeans( OODBBean $bean1, OODBBean $bean2, OODBBean $bean )
10900
+	protected function associateBeans(OODBBean $bean1, OODBBean $bean2, OODBBean $bean)
10901 10901
 	{
10902
-		$type      = $bean->getMeta( 'type' );
10903
-		$property1 = $bean1->getMeta( 'type' ) . '_id';
10904
-		$property2 = $bean2->getMeta( 'type' ) . '_id';
10902
+		$type      = $bean->getMeta('type');
10903
+		$property1 = $bean1->getMeta('type').'_id';
10904
+		$property2 = $bean2->getMeta('type').'_id';
10905 10905
 
10906
-		if ( $property1 == $property2 ) {
10907
-			$property2 = $bean2->getMeta( 'type' ) . '2_id';
10906
+		if ($property1 == $property2) {
10907
+			$property2 = $bean2->getMeta('type').'2_id';
10908 10908
 		}
10909 10909
 
10910
-		$this->oodb->store( $bean1 );
10911
-		$this->oodb->store( $bean2 );
10910
+		$this->oodb->store($bean1);
10911
+		$this->oodb->store($bean2);
10912 10912
 
10913
-		$bean->setMeta( "cast.$property1", "id" );
10914
-		$bean->setMeta( "cast.$property2", "id" );
10915
-		$bean->setMeta( 'sys.buildcommand.unique', array( $property1, $property2 ) );
10913
+		$bean->setMeta("cast.$property1", "id");
10914
+		$bean->setMeta("cast.$property2", "id");
10915
+		$bean->setMeta('sys.buildcommand.unique', array($property1, $property2));
10916 10916
 
10917 10917
 		$bean->$property1 = $bean1->id;
10918 10918
 		$bean->$property2 = $bean2->id;
10919 10919
 
10920
-		$results   = array();
10920
+		$results = array();
10921 10921
 
10922 10922
 		try {
10923
-			$id = $this->oodb->store( $bean );
10923
+			$id = $this->oodb->store($bean);
10924 10924
 			$results[] = $id;
10925
-		} catch ( SQLException $exception ) {
10926
-			if ( !$this->writer->sqlStateIn( $exception->getSQLState(),
10927
-				array( QueryWriter::C_SQLSTATE_INTEGRITY_CONSTRAINT_VIOLATION ),
10928
-				$exception->getDriverDetails() )
10925
+		} catch (SQLException $exception) {
10926
+			if (!$this->writer->sqlStateIn($exception->getSQLState(),
10927
+				array(QueryWriter::C_SQLSTATE_INTEGRITY_CONSTRAINT_VIOLATION),
10928
+				$exception->getDriverDetails())
10929 10929
 			) {
10930 10930
 				throw $exception;
10931 10931
 			}
@@ -10944,7 +10944,7 @@  discard block
 block discarded – undo
10944 10944
 	 *
10945 10945
 	 * @param ToolBox $tools toolbox supplying core RedBeanPHP objects
10946 10946
 	 */
10947
-	public function __construct( ToolBox $tools )
10947
+	public function __construct(ToolBox $tools)
10948 10948
 	{
10949 10949
 		$this->oodb    = $tools->getRedBean();
10950 10950
 		$this->adapter = $tools->getDatabaseAdapter();
@@ -10961,9 +10961,9 @@  discard block
 block discarded – undo
10961 10961
 	 *
10962 10962
 	 * @return string
10963 10963
 	 */
10964
-	public function getTable( $types )
10964
+	public function getTable($types)
10965 10965
 	{
10966
-		return $this->writer->getAssocTable( $types );
10966
+		return $this->writer->getAssocTable($types);
10967 10967
 	}
10968 10968
 
10969 10969
 	/**
@@ -10977,26 +10977,26 @@  discard block
 block discarded – undo
10977 10977
 	 *
10978 10978
 	 * @return array
10979 10979
 	 */
10980
-	public function associate( $beans1, $beans2 )
10980
+	public function associate($beans1, $beans2)
10981 10981
 	{
10982
-		if ( !is_array( $beans1 ) ) {
10983
-			$beans1 = array( $beans1 );
10982
+		if (!is_array($beans1)) {
10983
+			$beans1 = array($beans1);
10984 10984
 		}
10985 10985
 
10986
-		if ( !is_array( $beans2 ) ) {
10987
-			$beans2 = array( $beans2 );
10986
+		if (!is_array($beans2)) {
10987
+			$beans2 = array($beans2);
10988 10988
 		}
10989 10989
 
10990 10990
 		$results = array();
10991
-		foreach ( $beans1 as $bean1 ) {
10992
-			foreach ( $beans2 as $bean2 ) {
10993
-				$table     = $this->getTable( array( $bean1->getMeta( 'type' ), $bean2->getMeta( 'type' ) ) );
10994
-				$bean      = $this->oodb->dispense( $table );
10995
-				$results[] = $this->associateBeans( $bean1, $bean2, $bean );
10991
+		foreach ($beans1 as $bean1) {
10992
+			foreach ($beans2 as $bean2) {
10993
+				$table     = $this->getTable(array($bean1->getMeta('type'), $bean2->getMeta('type')));
10994
+				$bean      = $this->oodb->dispense($table);
10995
+				$results[] = $this->associateBeans($bean1, $bean2, $bean);
10996 10996
 			}
10997 10997
 		}
10998 10998
 
10999
-		return ( count( $results ) > 1 ) ? $results : reset( $results );
10999
+		return (count($results) > 1) ? $results : reset($results);
11000 11000
 	}
11001 11001
 
11002 11002
 	/**
@@ -11012,24 +11012,24 @@  discard block
 block discarded – undo
11012 11012
 	 *
11013 11013
 	 * @return integer
11014 11014
 	 */
11015
-	public function relatedCount( $bean, $type, $sql = NULL, $bindings = array() )
11015
+	public function relatedCount($bean, $type, $sql = NULL, $bindings = array())
11016 11016
 	{
11017
-		if ( !( $bean instanceof OODBBean ) ) {
11017
+		if (!($bean instanceof OODBBean)) {
11018 11018
 			throw new RedException(
11019
-				'Expected array or OODBBean but got:' . gettype( $bean )
11019
+				'Expected array or OODBBean but got:'.gettype($bean)
11020 11020
 			);
11021 11021
 		}
11022 11022
 
11023
-		if ( !$bean->id ) {
11023
+		if (!$bean->id) {
11024 11024
 			return 0;
11025 11025
 		}
11026 11026
 
11027
-		$beanType = $bean->getMeta( 'type' );
11027
+		$beanType = $bean->getMeta('type');
11028 11028
 
11029 11029
 		try {
11030
-			return $this->writer->queryRecordCountRelated( $beanType, $type, $bean->id, $sql, $bindings );
11031
-		} catch ( SQLException $exception ) {
11032
-			$this->handleException( $exception );
11030
+			return $this->writer->queryRecordCountRelated($beanType, $type, $bean->id, $sql, $bindings);
11031
+		} catch (SQLException $exception) {
11032
+			$this->handleException($exception);
11033 11033
 
11034 11034
 			return 0;
11035 11035
 		}
@@ -11050,37 +11050,37 @@  discard block
 block discarded – undo
11050 11050
 	 *
11051 11051
 	 * @return void
11052 11052
 	 */
11053
-	public function unassociate( $beans1, $beans2, $fast = NULL )
11053
+	public function unassociate($beans1, $beans2, $fast = NULL)
11054 11054
 	{
11055
-		$beans1 = ( !is_array( $beans1 ) ) ? array( $beans1 ) : $beans1;
11056
-		$beans2 = ( !is_array( $beans2 ) ) ? array( $beans2 ) : $beans2;
11055
+		$beans1 = (!is_array($beans1)) ? array($beans1) : $beans1;
11056
+		$beans2 = (!is_array($beans2)) ? array($beans2) : $beans2;
11057 11057
 
11058
-		foreach ( $beans1 as $bean1 ) {
11059
-			foreach ( $beans2 as $bean2 ) {
11058
+		foreach ($beans1 as $bean1) {
11059
+			foreach ($beans2 as $bean2) {
11060 11060
 				try {
11061
-					$this->oodb->store( $bean1 );
11062
-					$this->oodb->store( $bean2 );
11061
+					$this->oodb->store($bean1);
11062
+					$this->oodb->store($bean2);
11063 11063
 
11064
-					$type1 = $bean1->getMeta( 'type' );
11065
-					$type2 = $bean2->getMeta( 'type' );
11064
+					$type1 = $bean1->getMeta('type');
11065
+					$type2 = $bean2->getMeta('type');
11066 11066
 
11067
-					$row      = $this->writer->queryRecordLink( $type1, $type2, $bean1->id, $bean2->id );
11068
-					$linkType = $this->getTable( array( $type1, $type2 ) );
11067
+					$row      = $this->writer->queryRecordLink($type1, $type2, $bean1->id, $bean2->id);
11068
+					$linkType = $this->getTable(array($type1, $type2));
11069 11069
 
11070
-					if ( $fast ) {
11071
-						$this->writer->deleteRecord( $linkType, array( 'id' => $row['id'] ) );
11070
+					if ($fast) {
11071
+						$this->writer->deleteRecord($linkType, array('id' => $row['id']));
11072 11072
 
11073 11073
 						return;
11074 11074
 					}
11075 11075
 
11076
-					$beans = $this->oodb->convertToBeans( $linkType, array( $row ) );
11076
+					$beans = $this->oodb->convertToBeans($linkType, array($row));
11077 11077
 
11078
-					if ( count( $beans ) > 0 ) {
11079
-						$bean = reset( $beans );
11080
-						$this->oodb->trash( $bean );
11078
+					if (count($beans) > 0) {
11079
+						$bean = reset($beans);
11080
+						$this->oodb->trash($bean);
11081 11081
 					}
11082
-				} catch ( SQLException $exception ) {
11083
-					$this->handleException( $exception );
11082
+				} catch (SQLException $exception) {
11083
+					$this->handleException($exception);
11084 11084
 				}
11085 11085
 			}
11086 11086
 		}
@@ -11098,13 +11098,13 @@  discard block
 block discarded – undo
11098 11098
 	 *
11099 11099
 	 * @return void
11100 11100
 	 */
11101
-	public function clearRelations( OODBBean $bean, $type )
11101
+	public function clearRelations(OODBBean $bean, $type)
11102 11102
 	{
11103
-		$this->oodb->store( $bean );
11103
+		$this->oodb->store($bean);
11104 11104
 		try {
11105
-			$this->writer->deleteRelations( $bean->getMeta( 'type' ), $type, $bean->id );
11106
-		} catch ( SQLException $exception ) {
11107
-			$this->handleException( $exception );
11105
+			$this->writer->deleteRelations($bean->getMeta('type'), $type, $bean->id);
11106
+		} catch (SQLException $exception) {
11107
+			$this->handleException($exception);
11108 11108
 		}
11109 11109
 	}
11110 11110
 
@@ -11130,20 +11130,20 @@  discard block
 block discarded – undo
11130 11130
 	 *
11131 11131
 	 * @return array
11132 11132
 	 */
11133
-	public function related( $bean, $type, $sql = '', $bindings = array() )
11133
+	public function related($bean, $type, $sql = '', $bindings = array())
11134 11134
 	{
11135
-		$sql   = $this->writer->glueSQLCondition( $sql );
11136
-		$rows  = $this->relatedRows( $bean, $type, $sql, $bindings );
11135
+		$sql   = $this->writer->glueSQLCondition($sql);
11136
+		$rows  = $this->relatedRows($bean, $type, $sql, $bindings);
11137 11137
 		$links = array();
11138 11138
 
11139
-		foreach ( $rows as $key => $row ) {
11140
-			if ( !isset( $links[$row['id']] ) ) $links[$row['id']] = array();
11139
+		foreach ($rows as $key => $row) {
11140
+			if (!isset($links[$row['id']])) $links[$row['id']] = array();
11141 11141
 			$links[$row['id']][] = $row['linked_by'];
11142
-			unset( $rows[$key]['linked_by'] );
11142
+			unset($rows[$key]['linked_by']);
11143 11143
 		}
11144 11144
 
11145
-		$beans = $this->oodb->convertToBeans( $type, $rows );
11146
-		foreach ( $beans as $bean ) $bean->setMeta( 'sys.belongs-to', $links[$bean->id] );
11145
+		$beans = $this->oodb->convertToBeans($type, $rows);
11146
+		foreach ($beans as $bean) $bean->setMeta('sys.belongs-to', $links[$bean->id]);
11147 11147
 
11148 11148
 		return $beans;
11149 11149
 	}
@@ -11206,7 +11206,7 @@  discard block
 block discarded – undo
11206 11206
 	 *
11207 11207
 	 * @return SimpleModel|CustomModel|NULL
11208 11208
 	 */
11209
-	public function getModelForBean( OODBBean $bean );
11209
+	public function getModelForBean(OODBBean $bean);
11210 11210
 }
11211 11211
 }
11212 11212
 
@@ -11250,10 +11250,10 @@  discard block
 block discarded – undo
11250 11250
 	 *
11251 11251
 	 * @return SimpleModel
11252 11252
 	 */
11253
-	public static function factory( $modelClassName )
11253
+	public static function factory($modelClassName)
11254 11254
 	{
11255 11255
 		$factory = self::$factory;
11256
-		return ( $factory ) ? $factory( $modelClassName ) : new $modelClassName();
11256
+		return ($factory) ? $factory($modelClassName) : new $modelClassName();
11257 11257
 	}
11258 11258
 
11259 11259
 	/**
@@ -11264,7 +11264,7 @@  discard block
 block discarded – undo
11264 11264
 	 *
11265 11265
 	 * @return void
11266 11266
 	 */
11267
-	public static function setFactoryFunction( $factory )
11267
+	public static function setFactoryFunction($factory)
11268 11268
 	{
11269 11269
 		self::$factory = $factory;
11270 11270
 	}
@@ -11280,32 +11280,32 @@  discard block
 block discarded – undo
11280 11280
 	/**
11281 11281
 	 * @see BeanHelper::getModelForBean
11282 11282
 	 */
11283
-	public function getModelForBean( OODBBean $bean )
11283
+	public function getModelForBean(OODBBean $bean)
11284 11284
 	{
11285
-		$model     = $bean->getMeta( 'type' );
11286
-		$prefix    = defined( 'REDBEAN_MODEL_PREFIX' ) ? REDBEAN_MODEL_PREFIX : '\\Model_';
11285
+		$model     = $bean->getMeta('type');
11286
+		$prefix    = defined('REDBEAN_MODEL_PREFIX') ? REDBEAN_MODEL_PREFIX : '\\Model_';
11287 11287
 
11288
-		if ( strpos( $model, '_' ) !== FALSE ) {
11289
-			$modelParts = explode( '_', $model );
11288
+		if (strpos($model, '_') !== FALSE) {
11289
+			$modelParts = explode('_', $model);
11290 11290
 			$modelName = '';
11291
-			foreach( $modelParts as $part ) {
11292
-				$modelName .= ucfirst( $part );
11291
+			foreach ($modelParts as $part) {
11292
+				$modelName .= ucfirst($part);
11293 11293
 			}
11294
-			$modelName = $prefix . $modelName;
11295
-			if ( !class_exists( $modelName ) ) {
11296
-				$modelName = $prefix . ucfirst( $model );
11297
-				if ( !class_exists( $modelName ) ) {
11294
+			$modelName = $prefix.$modelName;
11295
+			if (!class_exists($modelName)) {
11296
+				$modelName = $prefix.ucfirst($model);
11297
+				if (!class_exists($modelName)) {
11298 11298
 					return NULL;
11299 11299
 				}
11300 11300
 			}
11301 11301
 		} else {
11302
-			$modelName = $prefix . ucfirst( $model );
11303
-			if ( !class_exists( $modelName ) ) {
11302
+			$modelName = $prefix.ucfirst($model);
11303
+			if (!class_exists($modelName)) {
11304 11304
 				return NULL;
11305 11305
 			}
11306 11306
 		}
11307
-		$obj = self::factory( $modelName );
11308
-		$obj->loadBean( $bean );
11307
+		$obj = self::factory($modelName);
11308
+		$obj->loadBean($bean);
11309 11309
 		return $obj;
11310 11310
 	}
11311 11311
 
@@ -11355,7 +11355,7 @@  discard block
 block discarded – undo
11355 11355
 	 *
11356 11356
 	 * @return void
11357 11357
 	 */
11358
-	public function loadBean( OODBBean $bean )
11358
+	public function loadBean(OODBBean $bean)
11359 11359
 	{
11360 11360
 		$this->bean = $bean;
11361 11361
 	}
@@ -11371,7 +11371,7 @@  discard block
 block discarded – undo
11371 11371
 	 *
11372 11372
 	 * @return mixed
11373 11373
 	 */
11374
-	public function __get( $prop )
11374
+	public function __get($prop)
11375 11375
 	{
11376 11376
 		return $this->bean->$prop;
11377 11377
 	}
@@ -11385,7 +11385,7 @@  discard block
 block discarded – undo
11385 11385
 	 *
11386 11386
 	 * @return void
11387 11387
 	 */
11388
-	public function __set( $prop, $value )
11388
+	public function __set($prop, $value)
11389 11389
 	{
11390 11390
 		$this->bean->$prop = $value;
11391 11391
 	}
@@ -11398,9 +11398,9 @@  discard block
 block discarded – undo
11398 11398
 	 *
11399 11399
 	 * @return boolean
11400 11400
 	 */
11401
-	public function __isset( $key )
11401
+	public function __isset($key)
11402 11402
 	{
11403
-		return isset( $this->bean->$key );
11403
+		return isset($this->bean->$key);
11404 11404
 	}
11405 11405
 
11406 11406
 	/**
@@ -11480,7 +11480,7 @@  discard block
 block discarded – undo
11480 11480
 	 *
11481 11481
 	 * @return void
11482 11482
 	 */
11483
-	public function onEvent( $eventName, $bean )
11483
+	public function onEvent($eventName, $bean)
11484 11484
 	{
11485 11485
 		$bean->$eventName();
11486 11486
 	}
@@ -11508,10 +11508,10 @@  discard block
 block discarded – undo
11508 11508
 	 *
11509 11509
 	 * @return void
11510 11510
 	 */
11511
-	public function attachEventListeners( Observable $observable )
11511
+	public function attachEventListeners(Observable $observable)
11512 11512
 	{
11513
-		foreach ( array( 'update', 'open', 'delete', 'after_delete', 'after_update', 'dispense' ) as $eventID ) {
11514
-			$observable->addEventListener( $eventID, $this );
11513
+		foreach (array('update', 'open', 'delete', 'after_delete', 'after_update', 'dispense') as $eventID) {
11514
+			$observable->addEventListener($eventID, $this);
11515 11515
 		}
11516 11516
 	}
11517 11517
 }
@@ -11567,10 +11567,10 @@  discard block
 block discarded – undo
11567 11567
 	 *
11568 11568
 	 * @return array
11569 11569
 	 */
11570
-	private function extractTagsIfNeeded( $tagList )
11570
+	private function extractTagsIfNeeded($tagList)
11571 11571
 	{
11572
-		if ( $tagList !== FALSE && !is_array( $tagList ) ) {
11573
-			$tags = explode( ',', (string) $tagList );
11572
+		if ($tagList !== FALSE && !is_array($tagList)) {
11573
+			$tags = explode(',', (string) $tagList);
11574 11574
 		} else {
11575 11575
 			$tags = $tagList;
11576 11576
 		}
@@ -11586,12 +11586,12 @@  discard block
 block discarded – undo
11586 11586
 	 *
11587 11587
 	 * @return OODBBean
11588 11588
 	 */
11589
-	protected function findTagByTitle( $title )
11589
+	protected function findTagByTitle($title)
11590 11590
 	{
11591
-		$beans = $this->redbean->find( 'tag', array( 'title' => array( $title ) ) );
11591
+		$beans = $this->redbean->find('tag', array('title' => array($title)));
11592 11592
 
11593
-		if ( $beans ) {
11594
-			$bean = reset( $beans );
11593
+		if ($beans) {
11594
+			$bean = reset($beans);
11595 11595
 
11596 11596
 			return $bean;
11597 11597
 		}
@@ -11606,7 +11606,7 @@  discard block
 block discarded – undo
11606 11606
 	 *
11607 11607
 	 * @param ToolBox $toolbox toolbox object
11608 11608
 	 */
11609
-	public function __construct( ToolBox $toolbox )
11609
+	public function __construct(ToolBox $toolbox)
11610 11610
 	{
11611 11611
 		$this->toolbox = $toolbox;
11612 11612
 		$this->redbean = $toolbox->getRedBean();
@@ -11643,18 +11643,18 @@  discard block
 block discarded – undo
11643 11643
 	 *
11644 11644
 	 * @return boolean
11645 11645
 	 */
11646
-	public function hasTag( $bean, $tags, $all = FALSE )
11646
+	public function hasTag($bean, $tags, $all = FALSE)
11647 11647
 	{
11648
-		$foundtags = $this->tag( $bean );
11648
+		$foundtags = $this->tag($bean);
11649 11649
 
11650
-		$tags = $this->extractTagsIfNeeded( $tags );
11651
-		$same = array_intersect( $tags, $foundtags );
11650
+		$tags = $this->extractTagsIfNeeded($tags);
11651
+		$same = array_intersect($tags, $foundtags);
11652 11652
 
11653
-		if ( $all ) {
11654
-			return ( implode( ',', $same ) === implode( ',', $tags ) );
11653
+		if ($all) {
11654
+			return (implode(',', $same) === implode(',', $tags));
11655 11655
 		}
11656 11656
 
11657
-		return (bool) ( count( $same ) > 0 );
11657
+		return (bool) (count($same) > 0);
11658 11658
 	}
11659 11659
 
11660 11660
 	/**
@@ -11678,13 +11678,13 @@  discard block
 block discarded – undo
11678 11678
 	 *
11679 11679
 	 * @return void
11680 11680
 	 */
11681
-	public function untag( $bean, $tagList )
11681
+	public function untag($bean, $tagList)
11682 11682
 	{
11683
-		$tags = $this->extractTagsIfNeeded( $tagList );
11683
+		$tags = $this->extractTagsIfNeeded($tagList);
11684 11684
 
11685
-		foreach ( $tags as $tag ) {
11686
-			if ( $t = $this->findTagByTitle( $tag ) ) {
11687
-				$this->associationManager->unassociate( $bean, $t );
11685
+		foreach ($tags as $tag) {
11686
+			if ($t = $this->findTagByTitle($tag)) {
11687
+				$this->associationManager->unassociate($bean, $t);
11688 11688
 			}
11689 11689
 		}
11690 11690
 	}
@@ -11714,22 +11714,22 @@  discard block
 block discarded – undo
11714 11714
 	 *
11715 11715
 	 * @return string
11716 11716
 	 */
11717
-	public function tag( OODBBean $bean, $tagList = NULL )
11717
+	public function tag(OODBBean $bean, $tagList = NULL)
11718 11718
 	{
11719
-		if ( is_null( $tagList ) ) {
11719
+		if (is_null($tagList)) {
11720 11720
 
11721 11721
 			$tags = $bean->sharedTag;
11722 11722
 			$foundTags = array();
11723 11723
 
11724
-			foreach ( $tags as $tag ) {
11724
+			foreach ($tags as $tag) {
11725 11725
 				$foundTags[] = $tag->title;
11726 11726
 			}
11727 11727
 
11728 11728
 			return $foundTags;
11729 11729
 		}
11730 11730
 
11731
-		$this->associationManager->clearRelations( $bean, 'tag' );
11732
-		$this->addTags( $bean, $tagList );
11731
+		$this->associationManager->clearRelations($bean, 'tag');
11732
+		$this->addTags($bean, $tagList);
11733 11733
 
11734 11734
 		return $tagList;
11735 11735
 	}
@@ -11755,23 +11755,23 @@  discard block
 block discarded – undo
11755 11755
 	 *
11756 11756
 	 * @return void
11757 11757
 	 */
11758
-	public function addTags( OODBBean $bean, $tagList )
11758
+	public function addTags(OODBBean $bean, $tagList)
11759 11759
 	{
11760
-		$tags = $this->extractTagsIfNeeded( $tagList );
11760
+		$tags = $this->extractTagsIfNeeded($tagList);
11761 11761
 
11762
-		if ( $tagList === FALSE ) {
11762
+		if ($tagList === FALSE) {
11763 11763
 			return;
11764 11764
 		}
11765 11765
 
11766
-		foreach ( $tags as $tag ) {
11767
-			if ( !$t = $this->findTagByTitle( $tag ) ) {
11768
-				$t        = $this->redbean->dispense( 'tag' );
11766
+		foreach ($tags as $tag) {
11767
+			if (!$t = $this->findTagByTitle($tag)) {
11768
+				$t        = $this->redbean->dispense('tag');
11769 11769
 				$t->title = $tag;
11770 11770
 
11771
-				$this->redbean->store( $t );
11771
+				$this->redbean->store($t);
11772 11772
 			}
11773 11773
 
11774
-			$this->associationManager->associate( $bean, $t );
11774
+			$this->associationManager->associate($bean, $t);
11775 11775
 		}
11776 11776
 	}
11777 11777
 
@@ -11804,12 +11804,12 @@  discard block
 block discarded – undo
11804 11804
 	 *
11805 11805
 	 * @return array
11806 11806
 	 */
11807
-	public function tagged( $beanType, $tagList, $sql = '', $bindings = array() )
11807
+	public function tagged($beanType, $tagList, $sql = '', $bindings = array())
11808 11808
 	{
11809
-		$tags       = $this->extractTagsIfNeeded( $tagList );
11810
-		$records    = $this->toolbox->getWriter()->queryTagged( $beanType, $tags, FALSE, $sql, $bindings );
11809
+		$tags       = $this->extractTagsIfNeeded($tagList);
11810
+		$records    = $this->toolbox->getWriter()->queryTagged($beanType, $tags, FALSE, $sql, $bindings);
11811 11811
 
11812
-		return $this->redbean->convertToBeans( $beanType, $records );
11812
+		return $this->redbean->convertToBeans($beanType, $records);
11813 11813
 	}
11814 11814
 
11815 11815
 	/**
@@ -11841,12 +11841,12 @@  discard block
 block discarded – undo
11841 11841
 	 *
11842 11842
 	 * @return array
11843 11843
 	 */
11844
-	public function taggedAll( $beanType, $tagList, $sql = '', $bindings = array() )
11844
+	public function taggedAll($beanType, $tagList, $sql = '', $bindings = array())
11845 11845
 	{
11846
-		$tags  = $this->extractTagsIfNeeded( $tagList );
11847
-		$records    = $this->toolbox->getWriter()->queryTagged( $beanType, $tags, TRUE, $sql, $bindings );
11846
+		$tags = $this->extractTagsIfNeeded($tagList);
11847
+		$records = $this->toolbox->getWriter()->queryTagged($beanType, $tags, TRUE, $sql, $bindings);
11848 11848
 
11849
-		return $this->redbean->convertToBeans( $beanType, $records );
11849
+		return $this->redbean->convertToBeans($beanType, $records);
11850 11850
 	}
11851 11851
 
11852 11852
 	/**
@@ -11861,10 +11861,10 @@  discard block
 block discarded – undo
11861 11861
 	 *
11862 11862
 	 * @return integer
11863 11863
 	 */
11864
-	public function countTaggedAll( $beanType, $tagList, $sql = '', $bindings = array() )
11864
+	public function countTaggedAll($beanType, $tagList, $sql = '', $bindings = array())
11865 11865
 	{
11866
-		$tags  = $this->extractTagsIfNeeded( $tagList );
11867
-		return $this->toolbox->getWriter()->queryCountTagged( $beanType, $tags, TRUE, $sql, $bindings );
11866
+		$tags = $this->extractTagsIfNeeded($tagList);
11867
+		return $this->toolbox->getWriter()->queryCountTagged($beanType, $tags, TRUE, $sql, $bindings);
11868 11868
 	}
11869 11869
 
11870 11870
 	/**
@@ -11879,10 +11879,10 @@  discard block
 block discarded – undo
11879 11879
 	 *
11880 11880
 	 * @return integer
11881 11881
 	 */
11882
-	public function countTagged( $beanType, $tagList, $sql = '', $bindings = array() )
11882
+	public function countTagged($beanType, $tagList, $sql = '', $bindings = array())
11883 11883
 	{
11884
-		$tags  = $this->extractTagsIfNeeded( $tagList );
11885
-		return $this->toolbox->getWriter()->queryCountTagged( $beanType, $tags, FALSE, $sql, $bindings );
11884
+		$tags = $this->extractTagsIfNeeded($tagList);
11885
+		return $this->toolbox->getWriter()->queryCountTagged($beanType, $tags, FALSE, $sql, $bindings);
11886 11886
 	}
11887 11887
 }
11888 11888
 }
@@ -11921,7 +11921,7 @@  discard block
 block discarded – undo
11921 11921
 	 *
11922 11922
 	 * @param ToolBox $toolbox
11923 11923
 	 */
11924
-	public function __construct( ToolBox $toolbox )
11924
+	public function __construct(ToolBox $toolbox)
11925 11925
 	{
11926 11926
 		$this->toolbox = $toolbox;
11927 11927
 	}
@@ -11941,11 +11941,11 @@  discard block
 block discarded – undo
11941 11941
 	 *
11942 11942
 	 * @return array
11943 11943
 	 */
11944
-	public function dispenseLabels( $type, $labels )
11944
+	public function dispenseLabels($type, $labels)
11945 11945
 	{
11946 11946
 		$labelBeans = array();
11947
-		foreach ( $labels as $label ) {
11948
-			$labelBean       = $this->toolbox->getRedBean()->dispense( $type );
11947
+		foreach ($labels as $label) {
11948
+			$labelBean       = $this->toolbox->getRedBean()->dispense($type);
11949 11949
 			$labelBean->name = $label;
11950 11950
 			$labelBeans[]    = $labelBean;
11951 11951
 		}
@@ -11973,15 +11973,15 @@  discard block
 block discarded – undo
11973 11973
 	 *
11974 11974
 	 * @return array
11975 11975
 	 */
11976
-	public function gatherLabels( $beans )
11976
+	public function gatherLabels($beans)
11977 11977
 	{
11978 11978
 		$labels = array();
11979 11979
 
11980
-		foreach ( $beans as $bean ) {
11980
+		foreach ($beans as $bean) {
11981 11981
 			$labels[] = $bean->name;
11982 11982
 		}
11983 11983
 
11984
-		sort( $labels );
11984
+		sort($labels);
11985 11985
 
11986 11986
 		return $labels;
11987 11987
 	}
@@ -12022,16 +12022,16 @@  discard block
 block discarded – undo
12022 12022
 	 *
12023 12023
 	 * @return array|OODBBean
12024 12024
 	 */
12025
-	public function enum( $enum )
12025
+	public function enum($enum)
12026 12026
 	{
12027 12027
 		$oodb = $this->toolbox->getRedBean();
12028 12028
 
12029
-		if ( strpos( $enum, ':' ) === FALSE ) {
12029
+		if (strpos($enum, ':') === FALSE) {
12030 12030
 			$type  = $enum;
12031 12031
 			$value = FALSE;
12032 12032
 		} else {
12033
-			list( $type, $value ) = explode( ':', $enum );
12034
-			$value                = preg_replace( '/\W+/', '_', strtoupper( trim( $value ) ) );
12033
+			list($type, $value) = explode(':', $enum);
12034
+			$value                = preg_replace('/\W+/', '_', strtoupper(trim($value)));
12035 12035
 		}
12036 12036
 
12037 12037
 		/**
@@ -12049,20 +12049,20 @@  discard block
 block discarded – undo
12049 12049
 		 *
12050 12050
 		 *  Also see Github Issue #464
12051 12051
 		 */
12052
-		$values = $oodb->find( $type );
12052
+		$values = $oodb->find($type);
12053 12053
 
12054
-		if ( $value === FALSE ) {
12054
+		if ($value === FALSE) {
12055 12055
 			return $values;
12056 12056
 		}
12057 12057
 
12058
-		foreach( $values as $enumItem ) {
12059
-				if ( $enumItem->name === $value ) return $enumItem;
12058
+		foreach ($values as $enumItem) {
12059
+				if ($enumItem->name === $value) return $enumItem;
12060 12060
 		}
12061 12061
 
12062
-		$newEnumItems = $this->dispenseLabels( $type, array( $value ) );
12063
-		$newEnumItem  = reset( $newEnumItems );
12062
+		$newEnumItems = $this->dispenseLabels($type, array($value));
12063
+		$newEnumItem  = reset($newEnumItems);
12064 12064
 
12065
-		$oodb->store( $newEnumItem );
12065
+		$oodb->store($newEnumItem);
12066 12066
 
12067 12067
 		return $newEnumItem;
12068 12068
 	}
@@ -12215,20 +12215,20 @@  discard block
 block discarded – undo
12215 12215
 	 *
12216 12216
 	 * @return array
12217 12217
 	 */
12218
-	private static function query( $method, $sql, $bindings )
12218
+	private static function query($method, $sql, $bindings)
12219 12219
 	{
12220
-		if ( !self::$redbean->isFrozen() ) {
12220
+		if (!self::$redbean->isFrozen()) {
12221 12221
 			try {
12222
-				$rs = Facade::$adapter->$method( $sql, $bindings );
12223
-			} catch ( SQLException $exception ) {
12224
-				if ( self::$writer->sqlStateIn( $exception->getSQLState(),
12222
+				$rs = Facade::$adapter->$method($sql, $bindings);
12223
+			} catch (SQLException $exception) {
12224
+				if (self::$writer->sqlStateIn($exception->getSQLState(),
12225 12225
 					array(
12226 12226
 						QueryWriter::C_SQLSTATE_NO_SUCH_COLUMN,
12227 12227
 						QueryWriter::C_SQLSTATE_NO_SUCH_TABLE )
12228 12228
 					,$exception->getDriverDetails()
12229 12229
 					)
12230 12230
 				) {
12231
-					return ( $method === 'getCell' ) ? NULL : array();
12231
+					return ($method === 'getCell') ? NULL : array();
12232 12232
 				} else {
12233 12233
 					throw $exception;
12234 12234
 				}
@@ -12236,7 +12236,7 @@  discard block
 block discarded – undo
12236 12236
 
12237 12237
 			return $rs;
12238 12238
 		} else {
12239
-			return Facade::$adapter->$method( $sql, $bindings );
12239
+			return Facade::$adapter->$method($sql, $bindings);
12240 12240
 		}
12241 12241
 	}
12242 12242
 
@@ -12264,12 +12264,12 @@  discard block
 block discarded – undo
12264 12264
 	 */
12265 12265
 	public static function testConnection()
12266 12266
 	{
12267
-		if ( !isset( self::$adapter ) ) return FALSE;
12267
+		if (!isset(self::$adapter)) return FALSE;
12268 12268
 
12269 12269
 		$database = self::$adapter->getDatabase();
12270 12270
 		try {
12271 12271
 			@$database->connect();
12272
-		} catch ( \Exception $e ) {}
12272
+		} catch (\Exception $e) {}
12273 12273
 		return $database->isConnected();
12274 12274
 	}
12275 12275
 
@@ -12306,14 +12306,14 @@  discard block
 block discarded – undo
12306 12306
 	 *
12307 12307
 	 * @return ToolBox
12308 12308
 	 */
12309
-	public static function setup( $dsn = NULL, $username = NULL, $password = NULL, $frozen = FALSE, $partialBeans = FALSE )
12309
+	public static function setup($dsn = NULL, $username = NULL, $password = NULL, $frozen = FALSE, $partialBeans = FALSE)
12310 12310
 	{
12311
-		if ( is_null( $dsn ) ) {
12312
-			$dsn = 'sqlite:/' . sys_get_temp_dir() . '/red.db';
12311
+		if (is_null($dsn)) {
12312
+			$dsn = 'sqlite:/'.sys_get_temp_dir().'/red.db';
12313 12313
 		}
12314 12314
 
12315
-		self::addDatabase( 'default', $dsn, $username, $password, $frozen, $partialBeans );
12316
-		self::selectDatabase( 'default' );
12315
+		self::addDatabase('default', $dsn, $username, $password, $frozen, $partialBeans);
12316
+		self::selectDatabase('default');
12317 12317
 
12318 12318
 		return self::$toolbox;
12319 12319
 	}
@@ -12343,9 +12343,9 @@  discard block
 block discarded – undo
12343 12343
 	 *
12344 12344
 	 * @return void
12345 12345
 	 */
12346
-	public static function setNarrowFieldMode( $mode )
12346
+	public static function setNarrowFieldMode($mode)
12347 12347
 	{
12348
-		AQueryWriter::setNarrowFieldMode( $mode );
12348
+		AQueryWriter::setNarrowFieldMode($mode);
12349 12349
 	}
12350 12350
 
12351 12351
 	/**
@@ -12360,7 +12360,7 @@  discard block
 block discarded – undo
12360 12360
 	 *
12361 12361
 	 * @return void
12362 12362
 	 */
12363
-	public static function setAllowFluidTransactions( $mode )
12363
+	public static function setAllowFluidTransactions($mode)
12364 12364
 	{
12365 12365
 		self::$allowFluidTransactions = $mode;
12366 12366
 	}
@@ -12395,9 +12395,9 @@  discard block
 block discarded – undo
12395 12395
 	 *
12396 12396
 	 * @return mixed
12397 12397
 	 */
12398
-	public static function transaction( $callback )
12398
+	public static function transaction($callback)
12399 12399
 	{
12400
-		return Transaction::transaction( self::$adapter, $callback );
12400
+		return Transaction::transaction(self::$adapter, $callback);
12401 12401
 	}
12402 12402
 
12403 12403
 	/**
@@ -12422,21 +12422,21 @@  discard block
 block discarded – undo
12422 12422
 	 *
12423 12423
 	 * @return void
12424 12424
 	 */
12425
-	public static function addDatabase( $key, $dsn, $user = NULL, $pass = NULL, $frozen = FALSE, $partialBeans = FALSE )
12425
+	public static function addDatabase($key, $dsn, $user = NULL, $pass = NULL, $frozen = FALSE, $partialBeans = FALSE)
12426 12426
 	{
12427
-		if ( isset( self::$toolboxes[$key] ) ) {
12428
-			throw new RedException( 'A database has already been specified for this key.' );
12427
+		if (isset(self::$toolboxes[$key])) {
12428
+			throw new RedException('A database has already been specified for this key.');
12429 12429
 		}
12430 12430
 
12431
-		if ( is_object($dsn) ) {
12432
-			$db  = new RPDO( $dsn );
12431
+		if (is_object($dsn)) {
12432
+			$db = new RPDO($dsn);
12433 12433
 			$dbType = $db->getDatabaseType();
12434 12434
 		} else {
12435
-			$db = new RPDO( $dsn, $user, $pass, TRUE );
12436
-			$dbType = substr( $dsn, 0, strpos( $dsn, ':' ) );
12435
+			$db = new RPDO($dsn, $user, $pass, TRUE);
12436
+			$dbType = substr($dsn, 0, strpos($dsn, ':'));
12437 12437
 		}
12438 12438
 
12439
-		$adapter = new DBAdapter( $db );
12439
+		$adapter = new DBAdapter($db);
12440 12440
 
12441 12441
 		$writers = array(
12442 12442
 			'pgsql'  => 'PostgreSQL',
@@ -12446,20 +12446,20 @@  discard block
 block discarded – undo
12446 12446
 			'sqlsrv' => 'SQLServer',
12447 12447
 		);
12448 12448
 
12449
-		$wkey = trim( strtolower( $dbType ) );
12450
-		if ( !isset( $writers[$wkey] ) ) {
12451
-			$wkey = preg_replace( '/\W/', '' , $wkey );
12452
-			throw new RedException( 'Unsupported database ('.$wkey.').' );
12449
+		$wkey = trim(strtolower($dbType));
12450
+		if (!isset($writers[$wkey])) {
12451
+			$wkey = preg_replace('/\W/', '', $wkey);
12452
+			throw new RedException('Unsupported database ('.$wkey.').');
12453 12453
 		}
12454 12454
 		$writerClass = '\\RedBeanPHP\\QueryWriter\\'.$writers[$wkey];
12455
-		$writer      = new $writerClass( $adapter );
12456
-		$redbean     = new OODB( $writer, $frozen );
12455
+		$writer      = new $writerClass($adapter);
12456
+		$redbean     = new OODB($writer, $frozen);
12457 12457
 		
12458
-		if ( $partialBeans ) {
12459
-			$redbean->getCurrentRepository()->usePartialBeans( $partialBeans );
12458
+		if ($partialBeans) {
12459
+			$redbean->getCurrentRepository()->usePartialBeans($partialBeans);
12460 12460
 		}
12461 12461
 
12462
-		self::$toolboxes[$key] = new ToolBox( $redbean, $adapter, $writer );
12462
+		self::$toolboxes[$key] = new ToolBox($redbean, $adapter, $writer);
12463 12463
 	}
12464 12464
 
12465 12465
 	/**
@@ -12470,11 +12470,11 @@  discard block
 block discarded – undo
12470 12470
 	 * @param string $ca   path certifying agent certificate '/etc/mysql/ssl/ca-cert.pem'
12471 12471
 	 * @param string $id   apply to toolbox (default = 'default')
12472 12472
 	 */
12473
-	public static function useMysqlSSL( $key, $cert, $ca, $id = 'default' ) {
12473
+	public static function useMysqlSSL($key, $cert, $ca, $id = 'default') {
12474 12474
 		$pdo = self::$toolboxes[$id]->getDatabaseAdapter()->getDatabase()->getPDO();
12475
-		$pdo->setAttribute( \PDO::MYSQL_ATTR_SSL_KEY,  $key);
12476
-		$pdo->setAttribute( \PDO::MYSQL_ATTR_SSL_CERT,  $cert);
12477
-		$pdo->setAttribute( \PDO::MYSQL_ATTR_SSL_CA,  $ca);
12475
+		$pdo->setAttribute(\PDO::MYSQL_ATTR_SSL_KEY, $key);
12476
+		$pdo->setAttribute(\PDO::MYSQL_ATTR_SSL_CERT, $cert);
12477
+		$pdo->setAttribute(\PDO::MYSQL_ATTR_SSL_CA, $ca);
12478 12478
 	}
12479 12479
 
12480 12480
 	/**
@@ -12486,9 +12486,9 @@  discard block
 block discarded – undo
12486 12486
 	 *
12487 12487
 	 * @return boolean
12488 12488
 	 */
12489
-	public static function hasDatabase( $key )
12489
+	public static function hasDatabase($key)
12490 12490
 	{
12491
-		return ( isset( self::$toolboxes[$key] ) );
12491
+		return (isset(self::$toolboxes[$key]));
12492 12492
 	}
12493 12493
 
12494 12494
 	/**
@@ -12505,17 +12505,17 @@  discard block
 block discarded – undo
12505 12505
 	 *
12506 12506
 	 * @return boolean
12507 12507
 	 */
12508
-	public static function selectDatabase( $key, $force = FALSE )
12508
+	public static function selectDatabase($key, $force = FALSE)
12509 12509
 	{
12510
-		if ( self::$currentDB === $key && !$force ) {
12510
+		if (self::$currentDB === $key && !$force) {
12511 12511
 			return FALSE;
12512 12512
 		}
12513 12513
 
12514
-		if ( !isset( self::$toolboxes[$key] ) ) {
12515
-			throw new RedException( 'Database not found in registry. Add database using R::addDatabase().' );
12514
+		if (!isset(self::$toolboxes[$key])) {
12515
+			throw new RedException('Database not found in registry. Add database using R::addDatabase().');
12516 12516
 		}
12517 12517
 
12518
-		self::configureFacadeWithToolbox( self::$toolboxes[$key] );
12518
+		self::configureFacadeWithToolbox(self::$toolboxes[$key]);
12519 12519
 		self::$currentDB = $key;
12520 12520
 
12521 12521
 		return TRUE;
@@ -12552,7 +12552,7 @@  discard block
 block discarded – undo
12552 12552
 	 * @return RDefault
12553 12553
 	 * @throws RedException
12554 12554
 	 */
12555
-	public static function debug( $tf = TRUE, $mode = 0 )
12555
+	public static function debug($tf = TRUE, $mode = 0)
12556 12556
 	{
12557 12557
 		if ($mode > 1) {
12558 12558
 			$mode -= 2;
@@ -12561,11 +12561,11 @@  discard block
 block discarded – undo
12561 12561
 			$logger = new RDefault;
12562 12562
 		}
12563 12563
 
12564
-		if ( !isset( self::$adapter ) ) {
12565
-			throw new RedException( 'Use R::setup() first.' );
12564
+		if (!isset(self::$adapter)) {
12565
+			throw new RedException('Use R::setup() first.');
12566 12566
 		}
12567 12567
 		$logger->setMode($mode);
12568
-		self::$adapter->getDatabase()->setDebugMode( $tf, $logger );
12568
+		self::$adapter->getDatabase()->setDebugMode($tf, $logger);
12569 12569
 
12570 12570
 		return $logger;
12571 12571
 	}
@@ -12581,9 +12581,9 @@  discard block
 block discarded – undo
12581 12581
 	 *
12582 12582
 	 * @return void
12583 12583
 	 */
12584
-	public static function fancyDebug( $toggle = TRUE )
12584
+	public static function fancyDebug($toggle = TRUE)
12585 12585
 	{
12586
-		self::debug( $toggle, 2 );
12586
+		self::debug($toggle, 2);
12587 12587
 	}
12588 12588
 
12589 12589
 	/**
@@ -12597,9 +12597,9 @@  discard block
 block discarded – undo
12597 12597
 	*
12598 12598
 	* @return array
12599 12599
 	*/
12600
-	public static function inspect( $type = NULL )
12600
+	public static function inspect($type = NULL)
12601 12601
 	{
12602
-		return ($type === NULL) ? self::$writer->getTables() : self::$writer->getColumns( $type );
12602
+		return ($type === NULL) ? self::$writer->getTables() : self::$writer->getColumns($type);
12603 12603
 	}
12604 12604
 
12605 12605
 	/**
@@ -12636,9 +12636,9 @@  discard block
 block discarded – undo
12636 12636
 	 *
12637 12637
 	 * @return integer|string
12638 12638
 	 */
12639
-	public static function store( $bean )
12639
+	public static function store($bean)
12640 12640
 	{
12641
-		return self::$redbean->store( $bean );
12641
+		return self::$redbean->store($bean);
12642 12642
 	}
12643 12643
 
12644 12644
 	/**
@@ -12652,9 +12652,9 @@  discard block
 block discarded – undo
12652 12652
 	 *
12653 12653
 	 * @param boolean|array $tf mode of operation (TRUE means frozen)
12654 12654
 	 */
12655
-	public static function freeze( $tf = TRUE )
12655
+	public static function freeze($tf = TRUE)
12656 12656
 	{
12657
-		self::$redbean->freeze( $tf );
12657
+		self::$redbean->freeze($tf);
12658 12658
 	}
12659 12659
 
12660 12660
 	/**
@@ -12676,9 +12676,9 @@  discard block
 block discarded – undo
12676 12676
 	 *
12677 12677
 	 * @return OODBBean
12678 12678
 	 */
12679
-	public static function loadMulti( $types, $id )
12679
+	public static function loadMulti($types, $id)
12680 12680
 	{
12681
-		return MultiLoader::load( self::$redbean, $types, $id );
12681
+		return MultiLoader::load(self::$redbean, $types, $id);
12682 12682
 	}
12683 12683
 
12684 12684
 	/**
@@ -12720,10 +12720,10 @@  discard block
 block discarded – undo
12720 12720
 	 *
12721 12721
 	 * @return OODBBean
12722 12722
 	 */
12723
-	public static function load( $type, $id, $snippet = NULL )
12723
+	public static function load($type, $id, $snippet = NULL)
12724 12724
 	{
12725
-		if ( $snippet !== NULL ) self::$writer->setSQLSelectSnippet( $snippet );
12726
-		$bean = self::$redbean->load( $type, $id );
12725
+		if ($snippet !== NULL) self::$writer->setSQLSelectSnippet($snippet);
12726
+		$bean = self::$redbean->load($type, $id);
12727 12727
 		return $bean;
12728 12728
 	}
12729 12729
 
@@ -12746,9 +12746,9 @@  discard block
 block discarded – undo
12746 12746
 	 *
12747 12747
 	 * @return OODBBean
12748 12748
 	 */
12749
-	public static function loadForUpdate( $type, $id )
12749
+	public static function loadForUpdate($type, $id)
12750 12750
 	{
12751
-		return self::load( $type, $id, AQueryWriter::C_SELECT_SNIPPET_FOR_UPDATE );
12751
+		return self::load($type, $id, AQueryWriter::C_SELECT_SNIPPET_FOR_UPDATE);
12752 12752
 	}
12753 12753
 
12754 12754
 	/**
@@ -12781,10 +12781,10 @@  discard block
 block discarded – undo
12781 12781
 	 *
12782 12782
 	 * @return void
12783 12783
 	 */
12784
-	public static function trash( $beanOrType, $id = NULL )
12784
+	public static function trash($beanOrType, $id = NULL)
12785 12785
 	{
12786
-		if ( is_string( $beanOrType ) ) return self::trash( self::load( $beanOrType, $id ) );
12787
-		return self::$redbean->trash( $beanOrType );
12786
+		if (is_string($beanOrType)) return self::trash(self::load($beanOrType, $id));
12787
+		return self::$redbean->trash($beanOrType);
12788 12788
 	}
12789 12789
 
12790 12790
 	/**
@@ -12833,9 +12833,9 @@  discard block
 block discarded – undo
12833 12833
 	 *
12834 12834
 	 * @return array|OODBBean
12835 12835
 	 */
12836
-	public static function dispense( $typeOrBeanArray, $num = 1, $alwaysReturnArray = FALSE )
12836
+	public static function dispense($typeOrBeanArray, $num = 1, $alwaysReturnArray = FALSE)
12837 12837
 	{
12838
-		return DispenseHelper::dispense( self::$redbean, $typeOrBeanArray, $num, $alwaysReturnArray );
12838
+		return DispenseHelper::dispense(self::$redbean, $typeOrBeanArray, $num, $alwaysReturnArray);
12839 12839
 	}
12840 12840
 
12841 12841
 	/**
@@ -12866,9 +12866,9 @@  discard block
 block discarded – undo
12866 12866
 	 *
12867 12867
 	 * @return array
12868 12868
 	 */
12869
-	public static function dispenseAll( $order, $onlyArrays = FALSE )
12869
+	public static function dispenseAll($order, $onlyArrays = FALSE)
12870 12870
 	{
12871
-		return DispenseHelper::dispenseAll( self::$redbean, $order, $onlyArrays );
12871
+		return DispenseHelper::dispenseAll(self::$redbean, $order, $onlyArrays);
12872 12872
 	}
12873 12873
 
12874 12874
 	/**
@@ -12882,10 +12882,10 @@  discard block
 block discarded – undo
12882 12882
 	 *
12883 12883
 	 * @return array
12884 12884
 	 */
12885
-	public static function findOrDispense( $type, $sql = NULL, $bindings = array() )
12885
+	public static function findOrDispense($type, $sql = NULL, $bindings = array())
12886 12886
 	{
12887
-		DispenseHelper::checkType( $type );
12888
-		return self::$finder->findOrDispense( $type, $sql, $bindings );
12887
+		DispenseHelper::checkType($type);
12888
+		return self::$finder->findOrDispense($type, $sql, $bindings);
12889 12889
 	}
12890 12890
 
12891 12891
 	/**
@@ -12897,10 +12897,10 @@  discard block
 block discarded – undo
12897 12897
 	 *
12898 12898
 	 * @return OODBBean
12899 12899
 	 */
12900
-	public static function findOneOrDispense( $type, $sql = NULL, $bindings = array() )
12900
+	public static function findOneOrDispense($type, $sql = NULL, $bindings = array())
12901 12901
 	{
12902
-		DispenseHelper::checkType( $type );
12903
-		$arrayOfBeans = self::findOrDispense( $type, $sql, $bindings );
12902
+		DispenseHelper::checkType($type);
12903
+		$arrayOfBeans = self::findOrDispense($type, $sql, $bindings);
12904 12904
 		return reset($arrayOfBeans);
12905 12905
 	}
12906 12906
 
@@ -12919,9 +12919,9 @@  discard block
 block discarded – undo
12919 12919
 	 *
12920 12920
 	 * @return array
12921 12921
 	 */
12922
-	public static function find( $type, $sql = NULL, $bindings = array() )
12922
+	public static function find($type, $sql = NULL, $bindings = array())
12923 12923
 	{
12924
-		return self::$finder->find( $type, $sql, $bindings );
12924
+		return self::$finder->find($type, $sql, $bindings);
12925 12925
 	}
12926 12926
 
12927 12927
 	/**
@@ -12933,9 +12933,9 @@  discard block
 block discarded – undo
12933 12933
 	 *
12934 12934
 	 * @return array
12935 12935
 	 */
12936
-	public static function findAll( $type, $sql = NULL, $bindings = array() )
12936
+	public static function findAll($type, $sql = NULL, $bindings = array())
12937 12937
 	{
12938
-		return self::$finder->find( $type, $sql, $bindings );
12938
+		return self::$finder->find($type, $sql, $bindings);
12939 12939
 	}
12940 12940
 
12941 12941
 	/**
@@ -12953,9 +12953,9 @@  discard block
 block discarded – undo
12953 12953
 	 *
12954 12954
 	 * @return array
12955 12955
 	 */
12956
-	public static function findAndExport( $type, $sql = NULL, $bindings = array() )
12956
+	public static function findAndExport($type, $sql = NULL, $bindings = array())
12957 12957
 	{
12958
-		return self::$finder->findAndExport( $type, $sql, $bindings );
12958
+		return self::$finder->findAndExport($type, $sql, $bindings);
12959 12959
 	}
12960 12960
 
12961 12961
 	/**
@@ -12967,9 +12967,9 @@  discard block
 block discarded – undo
12967 12967
 	 *
12968 12968
 	 * @return OODBBean|NULL
12969 12969
 	 */
12970
-	public static function findOne( $type, $sql = NULL, $bindings = array() )
12970
+	public static function findOne($type, $sql = NULL, $bindings = array())
12971 12971
 	{
12972
-		return self::$finder->findOne( $type, $sql, $bindings );
12972
+		return self::$finder->findOne($type, $sql, $bindings);
12973 12973
 	}
12974 12974
 
12975 12975
 	/**
@@ -12992,9 +12992,9 @@  discard block
 block discarded – undo
12992 12992
 	 *
12993 12993
 	 * @return OODBBean|NULL
12994 12994
 	 */
12995
-	public static function findLast( $type, $sql = NULL, $bindings = array() )
12995
+	public static function findLast($type, $sql = NULL, $bindings = array())
12996 12996
 	{
12997
-		return self::$finder->findLast( $type, $sql, $bindings );
12997
+		return self::$finder->findLast($type, $sql, $bindings);
12998 12998
 	}
12999 12999
 
13000 13000
 	/**
@@ -13009,9 +13009,9 @@  discard block
 block discarded – undo
13009 13009
 	 *
13010 13010
 	 * @return BeanCollection
13011 13011
 	 */
13012
-	public static function findCollection( $type, $sql = NULL, $bindings = array() )
13012
+	public static function findCollection($type, $sql = NULL, $bindings = array())
13013 13013
 	{
13014
-		return self::$finder->findCollection( $type, $sql, $bindings );
13014
+		return self::$finder->findCollection($type, $sql, $bindings);
13015 13015
 	}
13016 13016
 
13017 13017
 	/**
@@ -13082,9 +13082,9 @@  discard block
 block discarded – undo
13082 13082
 	 *
13083 13083
 	 * @return array
13084 13084
 	 */
13085
-	public static function findMulti( $types, $sql, $bindings = array(), $remappings = array() )
13085
+	public static function findMulti($types, $sql, $bindings = array(), $remappings = array())
13086 13086
 	{
13087
-		return self::$finder->findMulti( $types, $sql, $bindings, $remappings );
13087
+		return self::$finder->findMulti($types, $sql, $bindings, $remappings);
13088 13088
 	}
13089 13089
 
13090 13090
 	/**
@@ -13101,9 +13101,9 @@  discard block
 block discarded – undo
13101 13101
 	 *
13102 13102
 	 * @return array
13103 13103
 	 */
13104
-	public static function batch( $type, $ids )
13104
+	public static function batch($type, $ids)
13105 13105
 	{
13106
-		return self::$redbean->batch( $type, $ids );
13106
+		return self::$redbean->batch($type, $ids);
13107 13107
 	}
13108 13108
 
13109 13109
 	/**
@@ -13117,9 +13117,9 @@  discard block
 block discarded – undo
13117 13117
 	 *
13118 13118
 	 * @return array
13119 13119
 	 */
13120
-	public static function loadAll( $type, $ids )
13120
+	public static function loadAll($type, $ids)
13121 13121
 	{
13122
-		return self::$redbean->batch( $type, $ids );
13122
+		return self::$redbean->batch($type, $ids);
13123 13123
 	}
13124 13124
 
13125 13125
 	/**
@@ -13131,9 +13131,9 @@  discard block
 block discarded – undo
13131 13131
 	 *
13132 13132
 	 * @return integer
13133 13133
 	 */
13134
-	public static function exec( $sql, $bindings = array() )
13134
+	public static function exec($sql, $bindings = array())
13135 13135
 	{
13136
-		return self::query( 'exec', $sql, $bindings );
13136
+		return self::query('exec', $sql, $bindings);
13137 13137
 	}
13138 13138
 
13139 13139
 	/**
@@ -13149,9 +13149,9 @@  discard block
 block discarded – undo
13149 13149
 	 *
13150 13150
 	 * @return array
13151 13151
 	 */
13152
-	public static function getAll( $sql, $bindings = array() )
13152
+	public static function getAll($sql, $bindings = array())
13153 13153
 	{
13154
-		return self::query( 'get', $sql, $bindings );
13154
+		return self::query('get', $sql, $bindings);
13155 13155
 	}
13156 13156
 
13157 13157
 	/**
@@ -13166,9 +13166,9 @@  discard block
 block discarded – undo
13166 13166
 	 *
13167 13167
 	 * @return string
13168 13168
 	 */
13169
-	public static function getCell( $sql, $bindings = array() )
13169
+	public static function getCell($sql, $bindings = array())
13170 13170
 	{
13171
-		return self::query( 'getCell', $sql, $bindings );
13171
+		return self::query('getCell', $sql, $bindings);
13172 13172
 	}
13173 13173
 
13174 13174
 	/**
@@ -13183,9 +13183,9 @@  discard block
 block discarded – undo
13183 13183
 	 *
13184 13184
 	 * @return RedBeanPHP\Cursor\PDOCursor
13185 13185
 	 */
13186
-	public static function getCursor( $sql, $bindings = array() )
13186
+	public static function getCursor($sql, $bindings = array())
13187 13187
 	{
13188
-		return self::query( 'getCursor', $sql, $bindings );
13188
+		return self::query('getCursor', $sql, $bindings);
13189 13189
 	}
13190 13190
 
13191 13191
 	/**
@@ -13200,9 +13200,9 @@  discard block
 block discarded – undo
13200 13200
 	 *
13201 13201
 	 * @return array
13202 13202
 	 */
13203
-	public static function getRow( $sql, $bindings = array() )
13203
+	public static function getRow($sql, $bindings = array())
13204 13204
 	{
13205
-		return self::query( 'getRow', $sql, $bindings );
13205
+		return self::query('getRow', $sql, $bindings);
13206 13206
 	}
13207 13207
 
13208 13208
 	/**
@@ -13217,9 +13217,9 @@  discard block
 block discarded – undo
13217 13217
 	 *
13218 13218
 	 * @return array
13219 13219
 	 */
13220
-	public static function getCol( $sql, $bindings = array() )
13220
+	public static function getCol($sql, $bindings = array())
13221 13221
 	{
13222
-		return self::query( 'getCol', $sql, $bindings );
13222
+		return self::query('getCol', $sql, $bindings);
13223 13223
 	}
13224 13224
 
13225 13225
 	/**
@@ -13236,9 +13236,9 @@  discard block
 block discarded – undo
13236 13236
 	 *
13237 13237
 	 * @return array
13238 13238
 	 */
13239
-	public static function getAssoc( $sql, $bindings = array() )
13239
+	public static function getAssoc($sql, $bindings = array())
13240 13240
 	{
13241
-		return self::query( 'getAssoc', $sql, $bindings );
13241
+		return self::query('getAssoc', $sql, $bindings);
13242 13242
 	}
13243 13243
 
13244 13244
 	/**
@@ -13255,9 +13255,9 @@  discard block
 block discarded – undo
13255 13255
 	 *
13256 13256
 	 * @return array
13257 13257
 	 */
13258
-	public static function getAssocRow( $sql, $bindings = array() )
13258
+	public static function getAssocRow($sql, $bindings = array())
13259 13259
 	{
13260
-		return self::query( 'getAssocRow', $sql, $bindings );
13260
+		return self::query('getAssocRow', $sql, $bindings);
13261 13261
 	}
13262 13262
 
13263 13263
 	/**
@@ -13297,10 +13297,10 @@  discard block
 block discarded – undo
13297 13297
 	 *
13298 13298
 	 * @return array
13299 13299
 	 */
13300
-	public static function dup( $bean, $trail = array(), $pid = FALSE, $filters = array() )
13300
+	public static function dup($bean, $trail = array(), $pid = FALSE, $filters = array())
13301 13301
 	{
13302
-		self::$duplicationManager->setFilters( $filters );
13303
-		return self::$duplicationManager->dup( $bean, $trail, $pid );
13302
+		self::$duplicationManager->setFilters($filters);
13303
+		return self::$duplicationManager->dup($bean, $trail, $pid);
13304 13304
 	}
13305 13305
 
13306 13306
 	/**
@@ -13327,9 +13327,9 @@  discard block
 block discarded – undo
13327 13327
 	 *
13328 13328
 	 * @return array
13329 13329
 	 */
13330
-	public static function duplicate( $bean, $filters = array() )
13330
+	public static function duplicate($bean, $filters = array())
13331 13331
 	{
13332
-		return self::dup( $bean, array(), FALSE, $filters );
13332
+		return self::dup($bean, array(), FALSE, $filters);
13333 13333
 	}
13334 13334
 
13335 13335
 	/**
@@ -13347,9 +13347,9 @@  discard block
 block discarded – undo
13347 13347
 	 *
13348 13348
 	 * @return array
13349 13349
 	 */
13350
-	public static function exportAll( $beans, $parents = FALSE, $filters = array())
13350
+	public static function exportAll($beans, $parents = FALSE, $filters = array())
13351 13351
 	{
13352
-		return self::$duplicationManager->exportAll( $beans, $parents, $filters, self::$exportCaseStyle );
13352
+		return self::$duplicationManager->exportAll($beans, $parents, $filters, self::$exportCaseStyle);
13353 13353
 	}
13354 13354
 
13355 13355
 	/**
@@ -13370,9 +13370,9 @@  discard block
 block discarded – undo
13370 13370
 	 *
13371 13371
 	 * @return void
13372 13372
 	 */
13373
-	public static function useExportCase( $caseStyle = 'default' )
13373
+	public static function useExportCase($caseStyle = 'default')
13374 13374
 	{
13375
-		if ( !in_array( $caseStyle, array( 'default', 'camel', 'dolphin' ) ) ) throw new RedException( 'Invalid case selected.' );
13375
+		if (!in_array($caseStyle, array('default', 'camel', 'dolphin'))) throw new RedException('Invalid case selected.');
13376 13376
 		self::$exportCaseStyle = $caseStyle;
13377 13377
 	}
13378 13378
 
@@ -13414,9 +13414,9 @@  discard block
 block discarded – undo
13414 13414
 	 *
13415 13415
 	 * @return array
13416 13416
 	 */
13417
-	public static function convertToBeans( $type, $rows, $metamask = NULL )
13417
+	public static function convertToBeans($type, $rows, $metamask = NULL)
13418 13418
 	{
13419
-		return self::$redbean->convertToBeans( $type, $rows, $metamask );
13419
+		return self::$redbean->convertToBeans($type, $rows, $metamask);
13420 13420
 	}
13421 13421
 
13422 13422
 	/**
@@ -13428,10 +13428,10 @@  discard block
 block discarded – undo
13428 13428
 	 *
13429 13429
 	 * @return OODBBean
13430 13430
 	 */
13431
-	public static function convertToBean( $type, $row, $metamask = NULL )
13431
+	public static function convertToBean($type, $row, $metamask = NULL)
13432 13432
 	{
13433
-		$beans = self::$redbean->convertToBeans( $type, array( $row ), $metamask );
13434
-		$bean  = reset( $beans );
13433
+		$beans = self::$redbean->convertToBeans($type, array($row), $metamask);
13434
+		$bean  = reset($beans);
13435 13435
 		return $bean;
13436 13436
 	}
13437 13437
 
@@ -13464,9 +13464,9 @@  discard block
 block discarded – undo
13464 13464
 	 *
13465 13465
 	 * @return boolean
13466 13466
 	 */
13467
-	public static function hasTag( $bean, $tags, $all = FALSE )
13467
+	public static function hasTag($bean, $tags, $all = FALSE)
13468 13468
 	{
13469
-		return self::$tagManager->hasTag( $bean, $tags, $all );
13469
+		return self::$tagManager->hasTag($bean, $tags, $all);
13470 13470
 	}
13471 13471
 
13472 13472
 	/**
@@ -13490,9 +13490,9 @@  discard block
 block discarded – undo
13490 13490
 	 *
13491 13491
 	 * @return void
13492 13492
 	 */
13493
-	public static function untag( $bean, $tagList )
13493
+	public static function untag($bean, $tagList)
13494 13494
 	{
13495
-		self::$tagManager->untag( $bean, $tagList );
13495
+		self::$tagManager->untag($bean, $tagList);
13496 13496
 	}
13497 13497
 
13498 13498
 	/**
@@ -13519,9 +13519,9 @@  discard block
 block discarded – undo
13519 13519
 	 *
13520 13520
 	 * @return string
13521 13521
 	 */
13522
-	public static function tag( OODBBean $bean, $tagList = NULL )
13522
+	public static function tag(OODBBean $bean, $tagList = NULL)
13523 13523
 	{
13524
-		return self::$tagManager->tag( $bean, $tagList );
13524
+		return self::$tagManager->tag($bean, $tagList);
13525 13525
 	}
13526 13526
 
13527 13527
 	/**
@@ -13544,9 +13544,9 @@  discard block
 block discarded – undo
13544 13544
 	 *
13545 13545
 	 * @return void
13546 13546
 	 */
13547
-	public static function addTags( OODBBean $bean, $tagList )
13547
+	public static function addTags(OODBBean $bean, $tagList)
13548 13548
 	{
13549
-		self::$tagManager->addTags( $bean, $tagList );
13549
+		self::$tagManager->addTags($bean, $tagList);
13550 13550
 	}
13551 13551
 
13552 13552
 	/**
@@ -13578,9 +13578,9 @@  discard block
 block discarded – undo
13578 13578
 	 *
13579 13579
 	 * @return array
13580 13580
 	 */
13581
-	public static function tagged( $beanType, $tagList, $sql = '', $bindings = array() )
13581
+	public static function tagged($beanType, $tagList, $sql = '', $bindings = array())
13582 13582
 	{
13583
-		return self::$tagManager->tagged( $beanType, $tagList, $sql, $bindings );
13583
+		return self::$tagManager->tagged($beanType, $tagList, $sql, $bindings);
13584 13584
 	}
13585 13585
 
13586 13586
 	/**
@@ -13612,9 +13612,9 @@  discard block
 block discarded – undo
13612 13612
 	 *
13613 13613
 	 * @return array
13614 13614
 	 */
13615
-	public static function taggedAll( $beanType, $tagList, $sql = '', $bindings = array() )
13615
+	public static function taggedAll($beanType, $tagList, $sql = '', $bindings = array())
13616 13616
 	{
13617
-		return self::$tagManager->taggedAll( $beanType, $tagList, $sql, $bindings );
13617
+		return self::$tagManager->taggedAll($beanType, $tagList, $sql, $bindings);
13618 13618
 	}
13619 13619
 
13620 13620
 	/**
@@ -13629,9 +13629,9 @@  discard block
 block discarded – undo
13629 13629
 	 *
13630 13630
 	 * @return integer
13631 13631
 	 */
13632
-	public static function countTaggedAll( $beanType, $tagList, $sql = '', $bindings = array() )
13632
+	public static function countTaggedAll($beanType, $tagList, $sql = '', $bindings = array())
13633 13633
 	{
13634
-		return self::$tagManager->countTaggedAll( $beanType, $tagList, $sql, $bindings );
13634
+		return self::$tagManager->countTaggedAll($beanType, $tagList, $sql, $bindings);
13635 13635
 	}
13636 13636
 
13637 13637
 	/**
@@ -13646,9 +13646,9 @@  discard block
 block discarded – undo
13646 13646
 	 *
13647 13647
 	 * @return integer
13648 13648
 	 */
13649
-	public static function countTagged( $beanType, $tagList, $sql = '', $bindings = array() )
13649
+	public static function countTagged($beanType, $tagList, $sql = '', $bindings = array())
13650 13650
 	{
13651
-		return self::$tagManager->countTagged( $beanType, $tagList, $sql, $bindings );
13651
+		return self::$tagManager->countTagged($beanType, $tagList, $sql, $bindings);
13652 13652
 	}
13653 13653
 
13654 13654
 	/**
@@ -13658,9 +13658,9 @@  discard block
 block discarded – undo
13658 13658
 	 *
13659 13659
 	 * @return boolean
13660 13660
 	 */
13661
-	public static function wipe( $beanType )
13661
+	public static function wipe($beanType)
13662 13662
 	{
13663
-		return Facade::$redbean->wipe( $beanType );
13663
+		return Facade::$redbean->wipe($beanType);
13664 13664
 	}
13665 13665
 
13666 13666
 	/**
@@ -13674,9 +13674,9 @@  discard block
 block discarded – undo
13674 13674
 	 *
13675 13675
 	 * @return integer
13676 13676
 	 */
13677
-	public static function count( $type, $addSQL = '', $bindings = array() )
13677
+	public static function count($type, $addSQL = '', $bindings = array())
13678 13678
 	{
13679
-		return Facade::$redbean->count( $type, $addSQL, $bindings );
13679
+		return Facade::$redbean->count($type, $addSQL, $bindings);
13680 13680
 	}
13681 13681
 
13682 13682
 	/**
@@ -13688,25 +13688,25 @@  discard block
 block discarded – undo
13688 13688
 	 *
13689 13689
 	 * @return ToolBox
13690 13690
 	 */
13691
-	public static function configureFacadeWithToolbox( ToolBox $tb )
13691
+	public static function configureFacadeWithToolbox(ToolBox $tb)
13692 13692
 	{
13693 13693
 		$oldTools                 = self::$toolbox;
13694 13694
 		self::$toolbox            = $tb;
13695 13695
 		self::$writer             = self::$toolbox->getWriter();
13696 13696
 		self::$adapter            = self::$toolbox->getDatabaseAdapter();
13697 13697
 		self::$redbean            = self::$toolbox->getRedBean();
13698
-		self::$finder             = new Finder( self::$toolbox );
13699
-		self::$associationManager = new AssociationManager( self::$toolbox );
13700
-		self::$tree               = new Tree( self::$toolbox );
13701
-		self::$redbean->setAssociationManager( self::$associationManager );
13702
-		self::$labelMaker         = new LabelMaker( self::$toolbox );
13698
+		self::$finder             = new Finder(self::$toolbox);
13699
+		self::$associationManager = new AssociationManager(self::$toolbox);
13700
+		self::$tree               = new Tree(self::$toolbox);
13701
+		self::$redbean->setAssociationManager(self::$associationManager);
13702
+		self::$labelMaker         = new LabelMaker(self::$toolbox);
13703 13703
 		$helper                   = new SimpleModelHelper();
13704
-		$helper->attachEventListeners( self::$redbean );
13704
+		$helper->attachEventListeners(self::$redbean);
13705 13705
 		if (self::$redbean->getBeanHelper() == NULL) {
13706
-			self::$redbean->setBeanHelper( new SimpleFacadeBeanHelper );
13706
+			self::$redbean->setBeanHelper(new SimpleFacadeBeanHelper);
13707 13707
 		}
13708
-		self::$duplicationManager = new DuplicationManager( self::$toolbox );
13709
-		self::$tagManager         = new TagManager( self::$toolbox );
13708
+		self::$duplicationManager = new DuplicationManager(self::$toolbox);
13709
+		self::$tagManager         = new TagManager(self::$toolbox);
13710 13710
 		return $oldTools;
13711 13711
 	}
13712 13712
 
@@ -13746,7 +13746,7 @@  discard block
 block discarded – undo
13746 13746
 	 */
13747 13747
 	public static function begin()
13748 13748
 	{
13749
-		if ( !self::$allowFluidTransactions && !self::$redbean->isFrozen() ) return FALSE;
13749
+		if (!self::$allowFluidTransactions && !self::$redbean->isFrozen()) return FALSE;
13750 13750
 		self::$adapter->startTransaction();
13751 13751
 		return TRUE;
13752 13752
 	}
@@ -13787,7 +13787,7 @@  discard block
 block discarded – undo
13787 13787
 	 */
13788 13788
 	public static function commit()
13789 13789
 	{
13790
-		if ( !self::$allowFluidTransactions && !self::$redbean->isFrozen() ) return FALSE;
13790
+		if (!self::$allowFluidTransactions && !self::$redbean->isFrozen()) return FALSE;
13791 13791
 		self::$adapter->commit();
13792 13792
 		return TRUE;
13793 13793
 	}
@@ -13828,7 +13828,7 @@  discard block
 block discarded – undo
13828 13828
 	 */
13829 13829
 	public static function rollback()
13830 13830
 	{
13831
-		if ( !self::$allowFluidTransactions && !self::$redbean->isFrozen() ) return FALSE;
13831
+		if (!self::$allowFluidTransactions && !self::$redbean->isFrozen()) return FALSE;
13832 13832
 		self::$adapter->rollback();
13833 13833
 		return TRUE;
13834 13834
 	}
@@ -13843,9 +13843,9 @@  discard block
 block discarded – undo
13843 13843
 	 *
13844 13844
 	 * @return array
13845 13845
 	 */
13846
-	public static function getColumns( $table )
13846
+	public static function getColumns($table)
13847 13847
 	{
13848
-		return self::$writer->getColumns( $table );
13848
+		return self::$writer->getColumns($table);
13849 13849
 	}
13850 13850
 
13851 13851
 	/**
@@ -13877,9 +13877,9 @@  discard block
 block discarded – undo
13877 13877
 	 *
13878 13878
 	 * @return string
13879 13879
 	 */
13880
-	public static function genSlots( $array, $template = NULL )
13880
+	public static function genSlots($array, $template = NULL)
13881 13881
 	{
13882
-		return ArrayTool::genSlots( $array, $template );
13882
+		return ArrayTool::genSlots($array, $template);
13883 13883
 	}
13884 13884
 
13885 13885
 	/**
@@ -13898,9 +13898,9 @@  discard block
 block discarded – undo
13898 13898
 	 *
13899 13899
 	 * @return array
13900 13900
 	 */
13901
-	public static function flat( $array, $result = array() )
13901
+	public static function flat($array, $result = array())
13902 13902
 	{
13903
-		return ArrayTool::flat( $array, $result );
13903
+		return ArrayTool::flat($array, $result);
13904 13904
 	}
13905 13905
 
13906 13906
 	/**
@@ -13914,7 +13914,7 @@  discard block
 block discarded – undo
13914 13914
 	 */
13915 13915
 	public static function nuke()
13916 13916
 	{
13917
-		if ( !self::$redbean->isFrozen() ) {
13917
+		if (!self::$redbean->isFrozen()) {
13918 13918
 			self::$writer->wipeAll();
13919 13919
 		}
13920 13920
 	}
@@ -13929,11 +13929,11 @@  discard block
 block discarded – undo
13929 13929
 	 *
13930 13930
 	 * @return array
13931 13931
 	 */
13932
-	public static function storeAll( $beans )
13932
+	public static function storeAll($beans)
13933 13933
 	{
13934 13934
 		$ids = array();
13935
-		foreach ( $beans as $bean ) {
13936
-			$ids[] = self::store( $bean );
13935
+		foreach ($beans as $bean) {
13936
+			$ids[] = self::store($bean);
13937 13937
 		}
13938 13938
 		return $ids;
13939 13939
 	}
@@ -13947,10 +13947,10 @@  discard block
 block discarded – undo
13947 13947
 	 *
13948 13948
 	 * @return void
13949 13949
 	 */
13950
-	public static function trashAll( $beans )
13950
+	public static function trashAll($beans)
13951 13951
 	{
13952
-		foreach ( $beans as $bean ) {
13953
-			self::trash( $bean );
13952
+		foreach ($beans as $bean) {
13953
+			self::trash($bean);
13954 13954
 		}
13955 13955
 	}
13956 13956
 
@@ -13969,9 +13969,9 @@  discard block
 block discarded – undo
13969 13969
 	 *
13970 13970
 	 * @return void
13971 13971
 	 */
13972
-	public static function trashBatch( $type, $ids )
13972
+	public static function trashBatch($type, $ids)
13973 13973
 	{
13974
-		self::trashAll( self::batch( $type, $ids ) );
13974
+		self::trashAll(self::batch($type, $ids));
13975 13975
 	}
13976 13976
 
13977 13977
 	/**
@@ -13997,12 +13997,12 @@  discard block
 block discarded – undo
13997 13997
 	 *
13998 13998
 	 * @return int
13999 13999
 	 */
14000
-	public static function hunt( $type, $sqlSnippet = NULL, $bindings = array() )
14000
+	public static function hunt($type, $sqlSnippet = NULL, $bindings = array())
14001 14001
 	{
14002 14002
 		$numberOfTrashedBeans = 0;
14003
-		$beans = self::findCollection( $type, $sqlSnippet, $bindings );
14004
-		while( $bean = $beans->next() ) {
14005
-			self::trash( $bean );
14003
+		$beans = self::findCollection($type, $sqlSnippet, $bindings);
14004
+		while ($bean = $beans->next()) {
14005
+			self::trash($bean);
14006 14006
 			$numberOfTrashedBeans++;
14007 14007
 		}
14008 14008
 		return $numberOfTrashedBeans;
@@ -14023,9 +14023,9 @@  discard block
 block discarded – undo
14023 14023
 	 *
14024 14024
 	 * @return void
14025 14025
 	 */
14026
-	public static function useWriterCache( $yesNo )
14026
+	public static function useWriterCache($yesNo)
14027 14027
 	{
14028
-		self::getWriter()->setUseCache( $yesNo );
14028
+		self::getWriter()->setUseCache($yesNo);
14029 14029
 	}
14030 14030
 
14031 14031
 	/**
@@ -14039,9 +14039,9 @@  discard block
 block discarded – undo
14039 14039
 	 *
14040 14040
 	 * @return array
14041 14041
 	 */
14042
-	public static function dispenseLabels( $type, $labels )
14042
+	public static function dispenseLabels($type, $labels)
14043 14043
 	{
14044
-		return self::$labelMaker->dispenseLabels( $type, $labels );
14044
+		return self::$labelMaker->dispenseLabels($type, $labels);
14045 14045
 	}
14046 14046
 
14047 14047
 	/**
@@ -14075,9 +14075,9 @@  discard block
 block discarded – undo
14075 14075
 	 *
14076 14076
 	 * @return array|OODBBean
14077 14077
 	 */
14078
-	public static function enum( $enum )
14078
+	public static function enum($enum)
14079 14079
 	{
14080
-		return self::$labelMaker->enum( $enum );
14080
+		return self::$labelMaker->enum($enum);
14081 14081
 	}
14082 14082
 
14083 14083
 	/**
@@ -14090,9 +14090,9 @@  discard block
 block discarded – undo
14090 14090
 	 *
14091 14091
 	 * @return array
14092 14092
 	 */
14093
-	public static function gatherLabels( $beans )
14093
+	public static function gatherLabels($beans)
14094 14094
 	{
14095
-		return self::$labelMaker->gatherLabels( $beans );
14095
+		return self::$labelMaker->gatherLabels($beans);
14096 14096
 	}
14097 14097
 
14098 14098
 	/**
@@ -14113,7 +14113,7 @@  discard block
 block discarded – undo
14113 14113
 	 */
14114 14114
 	public static function close()
14115 14115
 	{
14116
-		if ( isset( self::$adapter ) ) {
14116
+		if (isset(self::$adapter)) {
14117 14117
 			self::$adapter->close();
14118 14118
 		}
14119 14119
 	}
@@ -14126,13 +14126,13 @@  discard block
 block discarded – undo
14126 14126
 	 *
14127 14127
 	 * @return string
14128 14128
 	 */
14129
-	public static function isoDate( $time = NULL )
14129
+	public static function isoDate($time = NULL)
14130 14130
 	{
14131
-		if ( !$time ) {
14131
+		if (!$time) {
14132 14132
 			$time = time();
14133 14133
 		}
14134 14134
 
14135
-		return @date( 'Y-m-d', $time );
14135
+		return @date('Y-m-d', $time);
14136 14136
 	}
14137 14137
 
14138 14138
 	/**
@@ -14144,10 +14144,10 @@  discard block
 block discarded – undo
14144 14144
 	 *
14145 14145
 	 * @return string
14146 14146
 	 */
14147
-	public static function isoDateTime( $time = NULL )
14147
+	public static function isoDateTime($time = NULL)
14148 14148
 	{
14149
-		if ( !$time ) $time = time();
14150
-		return @date( 'Y-m-d H:i:s', $time );
14149
+		if (!$time) $time = time();
14150
+		return @date('Y-m-d H:i:s', $time);
14151 14151
 	}
14152 14152
 
14153 14153
 	/**
@@ -14159,7 +14159,7 @@  discard block
 block discarded – undo
14159 14159
 	 *
14160 14160
 	 * @return void
14161 14161
 	 */
14162
-	public static function setDatabaseAdapter( Adapter $adapter )
14162
+	public static function setDatabaseAdapter(Adapter $adapter)
14163 14163
 	{
14164 14164
 		self::$adapter = $adapter;
14165 14165
 	}
@@ -14174,7 +14174,7 @@  discard block
 block discarded – undo
14174 14174
 	 *
14175 14175
 	 * @return void
14176 14176
 	 */
14177
-	public static function setWriter( QueryWriter $writer )
14177
+	public static function setWriter(QueryWriter $writer)
14178 14178
 	{
14179 14179
 		self::$writer = $writer;
14180 14180
 	}
@@ -14187,7 +14187,7 @@  discard block
 block discarded – undo
14187 14187
 	 *
14188 14188
 	 * @param OODB $redbean Object Database for facade to use
14189 14189
 	 */
14190
-	public static function setRedBean( OODB $redbean )
14190
+	public static function setRedBean(OODB $redbean)
14191 14191
 	{
14192 14192
 		self::$redbean = $redbean;
14193 14193
 	}
@@ -14220,10 +14220,10 @@  discard block
 block discarded – undo
14220 14220
 	public static function getPDO()
14221 14221
 	{
14222 14222
 		$databaseAdapter = self::getDatabaseAdapter();
14223
-		if ( is_null( $databaseAdapter ) ) return NULL;
14223
+		if (is_null($databaseAdapter)) return NULL;
14224 14224
 		$database = $databaseAdapter->getDatabase();
14225
-		if ( is_null( $database ) ) return NULL;
14226
-		if ( !method_exists( $database, 'getPDO' ) ) return NULL;
14225
+		if (is_null($database)) return NULL;
14226
+		if (!method_exists($database, 'getPDO')) return NULL;
14227 14227
 		return $database->getPDO();
14228 14228
 	}
14229 14229
 
@@ -14289,7 +14289,7 @@  discard block
 block discarded – undo
14289 14289
 	 */
14290 14290
 	public static function getExtractedToolbox()
14291 14291
 	{
14292
-		return array( self::$redbean, self::$adapter, self::$writer, self::$toolbox );
14292
+		return array(self::$redbean, self::$adapter, self::$writer, self::$toolbox);
14293 14293
 	}
14294 14294
 
14295 14295
 	/**
@@ -14300,9 +14300,9 @@  discard block
 block discarded – undo
14300 14300
 	 *
14301 14301
 	 * @return void
14302 14302
 	 */
14303
-	public static function renameAssociation( $from, $to = NULL )
14303
+	public static function renameAssociation($from, $to = NULL)
14304 14304
 	{
14305
-		AQueryWriter::renameAssociation( $from, $to );
14305
+		AQueryWriter::renameAssociation($from, $to);
14306 14306
 	}
14307 14307
 
14308 14308
 	/**
@@ -14316,10 +14316,10 @@  discard block
 block discarded – undo
14316 14316
 	 *
14317 14317
 	 * @return array
14318 14318
 	 */
14319
-	public static function beansToArray( $beans )
14319
+	public static function beansToArray($beans)
14320 14320
 	{
14321 14321
 		$list = array();
14322
-		foreach( $beans as $bean ) $list[] = $bean->export();
14322
+		foreach ($beans as $bean) $list[] = $bean->export();
14323 14323
 		return $list;
14324 14324
 	}
14325 14325
 
@@ -14351,9 +14351,9 @@  discard block
 block discarded – undo
14351 14351
 	 *
14352 14352
 	 * @return array
14353 14353
 	 */
14354
-	public static function setErrorHandlingFUSE( $mode, $func = NULL )
14354
+	public static function setErrorHandlingFUSE($mode, $func = NULL)
14355 14355
 	{
14356
-		return OODBBean::setErrorHandlingFUSE( $mode, $func );
14356
+		return OODBBean::setErrorHandlingFUSE($mode, $func);
14357 14357
 	}
14358 14358
 
14359 14359
 	/**
@@ -14378,9 +14378,9 @@  discard block
 block discarded – undo
14378 14378
 	 *
14379 14379
 	 * @return array
14380 14380
 	 */
14381
-	public static function dump( $data )
14381
+	public static function dump($data)
14382 14382
 	{
14383
-		return Dump::dump( $data );
14383
+		return Dump::dump($data);
14384 14384
 	}
14385 14385
 
14386 14386
 	/**
@@ -14406,9 +14406,9 @@  discard block
 block discarded – undo
14406 14406
 	 *
14407 14407
 	 * @return void
14408 14408
 	 */
14409
-	public static function bindFunc( $mode, $field, $function )
14409
+	public static function bindFunc($mode, $field, $function)
14410 14410
 	{
14411
-		self::$redbean->bindFunc( $mode, $field, $function );
14411
+		self::$redbean->bindFunc($mode, $field, $function);
14412 14412
 	}
14413 14413
 
14414 14414
 	/**
@@ -14447,9 +14447,9 @@  discard block
 block discarded – undo
14447 14447
 	 *
14448 14448
 	 * @return void
14449 14449
 	 */
14450
-	public static function aliases( $list )
14450
+	public static function aliases($list)
14451 14451
 	{
14452
-		OODBBean::aliases( $list );
14452
+		OODBBean::aliases($list);
14453 14453
 	}
14454 14454
 
14455 14455
 	/**
@@ -14465,9 +14465,9 @@  discard block
 block discarded – undo
14465 14465
 	 *
14466 14466
 	 * @return OODBBean
14467 14467
 	 */
14468
-	public static function findOrCreate( $type, $like = array(), $sql = '' )
14468
+	public static function findOrCreate($type, $like = array(), $sql = '')
14469 14469
 	{
14470
-		return self::$finder->findOrCreate( $type, $like, $sql = '' );
14470
+		return self::$finder->findOrCreate($type, $like, $sql = '');
14471 14471
 	}
14472 14472
 
14473 14473
 	/**
@@ -14484,9 +14484,9 @@  discard block
 block discarded – undo
14484 14484
 	 *
14485 14485
 	 * @return array
14486 14486
 	 */
14487
-	public static function findLike( $type, $like = array(), $sql = '', $bindings = array() )
14487
+	public static function findLike($type, $like = array(), $sql = '', $bindings = array())
14488 14488
 	{
14489
-		return self::$finder->findLike( $type, $like, $sql, $bindings );
14489
+		return self::$finder->findLike($type, $like, $sql, $bindings);
14490 14490
 	}
14491 14491
 
14492 14492
 	/**
@@ -14520,7 +14520,7 @@  discard block
 block discarded – undo
14520 14520
 	 */
14521 14521
 	public static function startLogging()
14522 14522
 	{
14523
-		self::debug( TRUE, RDefault::C_LOGGER_ARRAY );
14523
+		self::debug(TRUE, RDefault::C_LOGGER_ARRAY);
14524 14524
 	}
14525 14525
 
14526 14526
 	/**
@@ -14557,7 +14557,7 @@  discard block
 block discarded – undo
14557 14557
 	 */
14558 14558
 	public static function stopLogging()
14559 14559
 	{
14560
-		self::debug( FALSE );
14560
+		self::debug(FALSE);
14561 14561
 	}
14562 14562
 
14563 14563
 	/**
@@ -14669,9 +14669,9 @@  discard block
 block discarded – undo
14669 14669
 	 *
14670 14670
 	 * @return void
14671 14671
 	 */
14672
-	public static function setAutoResolve( $automatic = TRUE )
14672
+	public static function setAutoResolve($automatic = TRUE)
14673 14673
 	{
14674
-		OODBBean::setAutoResolve( (boolean) $automatic );
14674
+		OODBBean::setAutoResolve((boolean) $automatic);
14675 14675
 	}
14676 14676
 
14677 14677
 	/**
@@ -14688,9 +14688,9 @@  discard block
 block discarded – undo
14688 14688
 	 *
14689 14689
 	 * @return mixed
14690 14690
 	 */
14691
-	public static function usePartialBeans( $yesNoBeans )
14691
+	public static function usePartialBeans($yesNoBeans)
14692 14692
 	{
14693
-		return self::$redbean->getCurrentRepository()->usePartialBeans( $yesNoBeans );
14693
+		return self::$redbean->getCurrentRepository()->usePartialBeans($yesNoBeans);
14694 14694
 	}
14695 14695
 
14696 14696
 	/**
@@ -14721,10 +14721,10 @@  discard block
 block discarded – undo
14721 14721
 	 *
14722 14722
 	 * @return void
14723 14723
 	 */
14724
-	public static function csv( $sql = '', $bindings = array(), $columns = NULL, $path = '/tmp/redexport_%s.csv', $output = TRUE )
14724
+	public static function csv($sql = '', $bindings = array(), $columns = NULL, $path = '/tmp/redexport_%s.csv', $output = TRUE)
14725 14725
 	{
14726
-		$quickExport = new QuickExport( self::$toolbox );
14727
-		$quickExport->csv( $sql, $bindings, $columns, $path, $output );
14726
+		$quickExport = new QuickExport(self::$toolbox);
14727
+		$quickExport->csv($sql, $bindings, $columns, $path, $output);
14728 14728
 	}
14729 14729
 
14730 14730
 	/**
@@ -14757,9 +14757,9 @@  discard block
 block discarded – undo
14757 14757
 	 *
14758 14758
 	 * @return mixed
14759 14759
 	 */
14760
-	public static function matchUp( $type, $sql, $bindings = array(), $onFoundDo = NULL, $onNotFoundDo = NULL, &$bean = NULL 	) {
14761
-		$matchUp = new MatchUp( self::$toolbox );
14762
-		return $matchUp->matchUp( $type, $sql, $bindings, $onFoundDo, $onNotFoundDo, $bean );
14760
+	public static function matchUp($type, $sql, $bindings = array(), $onFoundDo = NULL, $onNotFoundDo = NULL, &$bean = NULL) {
14761
+		$matchUp = new MatchUp(self::$toolbox);
14762
+		return $matchUp->matchUp($type, $sql, $bindings, $onFoundDo, $onNotFoundDo, $bean);
14763 14763
 	}
14764 14764
 
14765 14765
 	/**
@@ -14780,7 +14780,7 @@  discard block
 block discarded – undo
14780 14780
 	 */
14781 14781
 	public static function getLook()
14782 14782
 	{
14783
-		return new Look( self::$toolbox );
14783
+		return new Look(self::$toolbox);
14784 14784
 	}
14785 14785
 
14786 14786
 	/**
@@ -14830,9 +14830,9 @@  discard block
 block discarded – undo
14830 14830
 	 *
14831 14831
 	 * @return string
14832 14832
 	 */
14833
-	public static function look( $sql, $bindings = array(), $keys = array( 'selected', 'id', 'name' ), $template = '<option %s value="%s">%s</option>', $filter = 'trim', $glue = '' )
14833
+	public static function look($sql, $bindings = array(), $keys = array('selected', 'id', 'name'), $template = '<option %s value="%s">%s</option>', $filter = 'trim', $glue = '')
14834 14834
 	{
14835
-		return self::getLook()->look( $sql, $bindings, $keys, $template, $filter, $glue );
14835
+		return self::getLook()->look($sql, $bindings, $keys, $template, $filter, $glue);
14836 14836
 	}
14837 14837
 
14838 14838
 	/**
@@ -14867,10 +14867,10 @@  discard block
 block discarded – undo
14867 14867
 	 *
14868 14868
 	 * @return array
14869 14869
 	 */
14870
-	public static function diff( $bean, $other, $filters = array( 'created', 'modified' ), $pattern = '%s.%s.%s' )
14870
+	public static function diff($bean, $other, $filters = array('created', 'modified'), $pattern = '%s.%s.%s')
14871 14871
 	{
14872
-		$diff = new Diff( self::$toolbox );
14873
-		return $diff->diff( $bean, $other, $filters, $pattern );
14872
+		$diff = new Diff(self::$toolbox);
14873
+		return $diff->diff($bean, $other, $filters, $pattern);
14874 14874
 	}
14875 14875
 
14876 14876
 	/**
@@ -14884,7 +14884,7 @@  discard block
 block discarded – undo
14884 14884
 	 *
14885 14885
 	 * @return void
14886 14886
 	 */
14887
-	public static function addToolBoxWithKey( $key, ToolBox $toolbox )
14887
+	public static function addToolBoxWithKey($key, ToolBox $toolbox)
14888 14888
 	{
14889 14889
 		self::$toolboxes[$key] = $toolbox;
14890 14890
 	}
@@ -14902,9 +14902,9 @@  discard block
 block discarded – undo
14902 14902
 	 *
14903 14903
 	 * @return boolean
14904 14904
 	 */
14905
-	public static function removeToolBoxByKey( $key )
14905
+	public static function removeToolBoxByKey($key)
14906 14906
 	{
14907
-		if ( !array_key_exists( $key, self::$toolboxes ) ) {
14907
+		if (!array_key_exists($key, self::$toolboxes)) {
14908 14908
 			return FALSE;
14909 14909
 		}
14910 14910
 		return TRUE;
@@ -14918,9 +14918,9 @@  discard block
 block discarded – undo
14918 14918
 	 *
14919 14919
 	 * @return ToolBox|NULL
14920 14920
 	 */
14921
-	public static function getToolBoxByKey( $key )
14921
+	public static function getToolBoxByKey($key)
14922 14922
 	{
14923
-		if ( !array_key_exists( $key, self::$toolboxes ) ) {
14923
+		if (!array_key_exists($key, self::$toolboxes)) {
14924 14924
 			return NULL;
14925 14925
 		}
14926 14926
 		return self::$toolboxes[$key];
@@ -14962,10 +14962,10 @@  discard block
 block discarded – undo
14962 14962
 	 *
14963 14963
 	 * @return void
14964 14964
 	 */
14965
-	public static function useJSONFeatures( $flag )
14965
+	public static function useJSONFeatures($flag)
14966 14966
 	{
14967
-		AQueryWriter::useJSONColumns( $flag );
14968
-		OODBBean::convertArraysToJSON( $flag );
14967
+		AQueryWriter::useJSONColumns($flag);
14968
+		OODBBean::convertArraysToJSON($flag);
14969 14969
 	}
14970 14970
 
14971 14971
 	/**
@@ -14987,9 +14987,9 @@  discard block
 block discarded – undo
14987 14987
 	 * @param string   $sql      optional SQL snippet
14988 14988
 	 * @param array    $bindings SQL snippet parameter bindings
14989 14989
 	 */
14990
-	public static function children( OODBBean $bean, $sql = NULL, $bindings = array() )
14990
+	public static function children(OODBBean $bean, $sql = NULL, $bindings = array())
14991 14991
 	{
14992
-		return self::$tree->children( $bean, $sql, $bindings );
14992
+		return self::$tree->children($bean, $sql, $bindings);
14993 14993
 	}
14994 14994
 
14995 14995
 	/**
@@ -15011,9 +15011,9 @@  discard block
 block discarded – undo
15011 15011
 	 * @param string   $sql      optional SQL snippet
15012 15012
 	 * @param array    $bindings SQL snippet parameter bindings
15013 15013
 	 */
15014
-	public static function parents( OODBBean $bean, $sql = NULL, $bindings = array() )
15014
+	public static function parents(OODBBean $bean, $sql = NULL, $bindings = array())
15015 15015
 	{
15016
-		return self::$tree->parents( $bean, $sql, $bindings );
15016
+		return self::$tree->parents($bean, $sql, $bindings);
15017 15017
 	}
15018 15018
 
15019 15019
 	/**
@@ -15025,8 +15025,8 @@  discard block
 block discarded – undo
15025 15025
 	 *
15026 15026
 	 * @return boolean
15027 15027
 	 */
15028
-	public static function noNuke( $yesNo ) {
15029
-		return AQueryWriter::forbidNuke( $yesNo );
15028
+	public static function noNuke($yesNo) {
15029
+		return AQueryWriter::forbidNuke($yesNo);
15030 15030
 	}
15031 15031
 
15032 15032
 	/**
@@ -15040,7 +15040,7 @@  discard block
 block discarded – undo
15040 15040
 	 *
15041 15041
 	 * @return void
15042 15042
 	 */
15043
-	public static function useFeatureSet( $label ) {
15043
+	public static function useFeatureSet($label) {
15044 15044
 		return Feature::feature($label);
15045 15045
 	}
15046 15046
 
@@ -15067,10 +15067,10 @@  discard block
 block discarded – undo
15067 15067
 	 *
15068 15068
 	 * @return void
15069 15069
 	 */
15070
-	public static function ext( $pluginName, $callable )
15070
+	public static function ext($pluginName, $callable)
15071 15071
 	{
15072
-		if ( !ctype_alnum( $pluginName ) ) {
15073
-			throw new RedException( 'Plugin name may only contain alphanumeric characters.' );
15072
+		if (!ctype_alnum($pluginName)) {
15073
+			throw new RedException('Plugin name may only contain alphanumeric characters.');
15074 15074
 		}
15075 15075
 		self::$plugins[$pluginName] = $callable;
15076 15076
 	}
@@ -15084,15 +15084,15 @@  discard block
 block discarded – undo
15084 15084
 	 *
15085 15085
 	 * @return mixed
15086 15086
 	 */
15087
-	public static function __callStatic( $pluginName, $params )
15087
+	public static function __callStatic($pluginName, $params)
15088 15088
 	{
15089
-		if ( !ctype_alnum( $pluginName) ) {
15090
-			throw new RedException( 'Plugin name may only contain alphanumeric characters.' );
15089
+		if (!ctype_alnum($pluginName)) {
15090
+			throw new RedException('Plugin name may only contain alphanumeric characters.');
15091 15091
 		}
15092
-		if ( !isset( self::$plugins[$pluginName] ) ) {
15093
-			throw new RedException( 'Plugin \''.$pluginName.'\' does not exist, add this plugin using: R::ext(\''.$pluginName.'\')' );
15092
+		if (!isset(self::$plugins[$pluginName])) {
15093
+			throw new RedException('Plugin \''.$pluginName.'\' does not exist, add this plugin using: R::ext(\''.$pluginName.'\')');
15094 15094
 		}
15095
-		return call_user_func_array( self::$plugins[$pluginName], $params );
15095
+		return call_user_func_array(self::$plugins[$pluginName], $params);
15096 15096
 	}
15097 15097
 }
15098 15098
 
@@ -15175,12 +15175,12 @@  discard block
 block discarded – undo
15175 15175
 	 *
15176 15176
 	 * @return void
15177 15177
 	 */
15178
-	private function copySharedBeans( OODBBean $copy, $shared, $beans )
15178
+	private function copySharedBeans(OODBBean $copy, $shared, $beans)
15179 15179
 	{
15180 15180
 		$copy->$shared = array();
15181 15181
 
15182
-		foreach ( $beans as $subBean ) {
15183
-			array_push( $copy->$shared, $subBean );
15182
+		foreach ($beans as $subBean) {
15183
+			array_push($copy->$shared, $subBean);
15184 15184
 		}
15185 15185
 	}
15186 15186
 
@@ -15197,11 +15197,11 @@  discard block
 block discarded – undo
15197 15197
 	 *
15198 15198
 	 * @return void
15199 15199
 	 */
15200
-	private function copyOwnBeans( OODBBean $copy, $owned, $beans, $trail, $preserveIDs )
15200
+	private function copyOwnBeans(OODBBean $copy, $owned, $beans, $trail, $preserveIDs)
15201 15201
 	{
15202 15202
 		$copy->$owned = array();
15203
-		foreach ( $beans as $subBean ) {
15204
-			array_push( $copy->$owned, $this->duplicate( $subBean, $trail, $preserveIDs ) );
15203
+		foreach ($beans as $subBean) {
15204
+			array_push($copy->$owned, $this->duplicate($subBean, $trail, $preserveIDs));
15205 15205
 		}
15206 15206
 	}
15207 15207
 
@@ -15214,14 +15214,14 @@  discard block
 block discarded – undo
15214 15214
 	 *
15215 15215
 	 * @return OODBBean
15216 15216
 	 */
15217
-	private function createCopy( OODBBean $bean )
15217
+	private function createCopy(OODBBean $bean)
15218 15218
 	{
15219
-		$type = $bean->getMeta( 'type' );
15219
+		$type = $bean->getMeta('type');
15220 15220
 
15221
-		$copy = $this->redbean->dispense( $type );
15222
-		$copy->setMeta( 'sys.dup-from-id', $bean->id );
15223
-		$copy->setMeta( 'sys.old-id', $bean->id );
15224
-		$copy->importFrom( $bean );
15221
+		$copy = $this->redbean->dispense($type);
15222
+		$copy->setMeta('sys.dup-from-id', $bean->id);
15223
+		$copy->setMeta('sys.old-id', $bean->id);
15224
+		$copy->importFrom($bean);
15225 15225
 		$copy->id = 0;
15226 15226
 
15227 15227
 		return $copy;
@@ -15237,12 +15237,12 @@  discard block
 block discarded – undo
15237 15237
 	 *
15238 15238
 	 * @return boolean
15239 15239
 	 */
15240
-	private function inTrailOrAdd( &$trail, OODBBean $bean )
15240
+	private function inTrailOrAdd(&$trail, OODBBean $bean)
15241 15241
 	{
15242
-		$type = $bean->getMeta( 'type' );
15243
-		$key  = $type . $bean->getID();
15242
+		$type = $bean->getMeta('type');
15243
+		$key  = $type.$bean->getID();
15244 15244
 
15245
-		if ( isset( $trail[$key] ) ) {
15245
+		if (isset($trail[$key])) {
15246 15246
 			return TRUE;
15247 15247
 		}
15248 15248
 
@@ -15261,12 +15261,12 @@  discard block
 block discarded – undo
15261 15261
 	 *
15262 15262
 	 * @return array
15263 15263
 	 */
15264
-	private function getListNames( $typeName )
15264
+	private function getListNames($typeName)
15265 15265
 	{
15266
-		$owned  = 'own' . ucfirst( $typeName );
15267
-		$shared = 'shared' . ucfirst( $typeName );
15266
+		$owned  = 'own'.ucfirst($typeName);
15267
+		$shared = 'shared'.ucfirst($typeName);
15268 15268
 
15269
-		return array( $owned, $shared );
15269
+		return array($owned, $shared);
15270 15270
 	}
15271 15271
 
15272 15272
 	/**
@@ -15278,9 +15278,9 @@  discard block
 block discarded – undo
15278 15278
 	 *
15279 15279
 	 * @return boolean
15280 15280
 	 */
15281
-	protected function hasOwnList( $type, $target )
15281
+	protected function hasOwnList($type, $target)
15282 15282
 	{
15283
-		return isset( $this->columns[$target][$type . '_id'] );
15283
+		return isset($this->columns[$target][$type.'_id']);
15284 15284
 	}
15285 15285
 
15286 15286
 	/**
@@ -15292,9 +15292,9 @@  discard block
 block discarded – undo
15292 15292
 	 *
15293 15293
 	 * @return boolean
15294 15294
 	 */
15295
-	protected function hasSharedList( $type, $target )
15295
+	protected function hasSharedList($type, $target)
15296 15296
 	{
15297
-		return in_array( AQueryWriter::getAssocTableFormat( array( $type, $target ) ), $this->tables );
15297
+		return in_array(AQueryWriter::getAssocTableFormat(array($type, $target)), $this->tables);
15298 15298
 	}
15299 15299
 
15300 15300
 	/**
@@ -15306,37 +15306,37 @@  discard block
 block discarded – undo
15306 15306
 	 *
15307 15307
 	 * @return OODBBean
15308 15308
 	 */
15309
-	protected function duplicate( OODBBean $bean, $trail = array(), $preserveIDs = FALSE )
15309
+	protected function duplicate(OODBBean $bean, $trail = array(), $preserveIDs = FALSE)
15310 15310
 	{
15311
-		if ( $this->inTrailOrAdd( $trail, $bean ) ) return $bean;
15311
+		if ($this->inTrailOrAdd($trail, $bean)) return $bean;
15312 15312
 
15313
-		$type = $bean->getMeta( 'type' );
15313
+		$type = $bean->getMeta('type');
15314 15314
 
15315
-		$copy = $this->createCopy( $bean );
15316
-		foreach ( $this->tables as $table ) {
15315
+		$copy = $this->createCopy($bean);
15316
+		foreach ($this->tables as $table) {
15317 15317
 
15318
-			if ( !empty( $this->filters ) ) {
15319
-				if ( !in_array( $table, $this->filters ) ) continue;
15318
+			if (!empty($this->filters)) {
15319
+				if (!in_array($table, $this->filters)) continue;
15320 15320
 			}
15321 15321
 
15322
-			list( $owned, $shared ) = $this->getListNames( $table );
15322
+			list($owned, $shared) = $this->getListNames($table);
15323 15323
 
15324
-			if ( $this->hasSharedList( $type, $table ) ) {
15325
-				if ( $beans = $bean->$shared ) {
15326
-					$this->copySharedBeans( $copy, $shared, $beans );
15324
+			if ($this->hasSharedList($type, $table)) {
15325
+				if ($beans = $bean->$shared) {
15326
+					$this->copySharedBeans($copy, $shared, $beans);
15327 15327
 				}
15328
-			} elseif ( $this->hasOwnList( $type, $table ) ) {
15329
-				if ( $beans = $bean->$owned ) {
15330
-					$this->copyOwnBeans( $copy, $owned, $beans, $trail, $preserveIDs );
15328
+			} elseif ($this->hasOwnList($type, $table)) {
15329
+				if ($beans = $bean->$owned) {
15330
+					$this->copyOwnBeans($copy, $owned, $beans, $trail, $preserveIDs);
15331 15331
 				}
15332 15332
 
15333
-				$copy->setMeta( 'sys.shadow.' . $owned, NULL );
15333
+				$copy->setMeta('sys.shadow.'.$owned, NULL);
15334 15334
 			}
15335 15335
 
15336
-			$copy->setMeta( 'sys.shadow.' . $shared, NULL );
15336
+			$copy->setMeta('sys.shadow.'.$shared, NULL);
15337 15337
 		}
15338 15338
 
15339
-		$copy->id = ( $preserveIDs ) ? $bean->id : $copy->id;
15339
+		$copy->id = ($preserveIDs) ? $bean->id : $copy->id;
15340 15340
 
15341 15341
 		return $copy;
15342 15342
 	}
@@ -15347,7 +15347,7 @@  discard block
 block discarded – undo
15347 15347
 	 *
15348 15348
 	 * @param ToolBox $toolbox
15349 15349
 	 */
15350
-	public function __construct( ToolBox $toolbox )
15350
+	public function __construct(ToolBox $toolbox)
15351 15351
 	{
15352 15352
 		$this->toolbox            = $toolbox;
15353 15353
 		$this->redbean            = $toolbox->getRedBean();
@@ -15363,18 +15363,18 @@  discard block
 block discarded – undo
15363 15363
 	 *
15364 15364
 	 * @return array
15365 15365
 	 */
15366
-	public function camelfy( $array, $dolphinMode = FALSE ) {
15366
+	public function camelfy($array, $dolphinMode = FALSE) {
15367 15367
 		$newArray = array();
15368
-		foreach( $array as $key => $element ) {
15369
-			$newKey = preg_replace_callback( '/_(\w)/', function( &$matches ){
15370
-				return strtoupper( $matches[1] );
15368
+		foreach ($array as $key => $element) {
15369
+			$newKey = preg_replace_callback('/_(\w)/', function(&$matches) {
15370
+				return strtoupper($matches[1]);
15371 15371
 			}, $key);
15372 15372
 
15373
-			if ( $dolphinMode ) {
15374
-				$newKey = preg_replace( '/(\w)Id$/', '$1ID', $newKey );
15373
+			if ($dolphinMode) {
15374
+				$newKey = preg_replace('/(\w)Id$/', '$1ID', $newKey);
15375 15375
 			}
15376 15376
 
15377
-			$newArray[$newKey] = ( is_array($element) ) ? $this->camelfy( $element, $dolphinMode ) : $element;
15377
+			$newArray[$newKey] = (is_array($element)) ? $this->camelfy($element, $dolphinMode) : $element;
15378 15378
 		}
15379 15379
 		return $newArray;
15380 15380
 	}
@@ -15400,10 +15400,10 @@  discard block
 block discarded – undo
15400 15400
 	 *
15401 15401
 	 * @return void
15402 15402
 	 */
15403
-	public function setTables( $tables )
15403
+	public function setTables($tables)
15404 15404
 	{
15405
-		foreach ( $tables as $key => $value ) {
15406
-			if ( is_numeric( $key ) ) {
15405
+		foreach ($tables as $key => $value) {
15406
+			if (is_numeric($key)) {
15407 15407
 				$this->tables[] = $value;
15408 15408
 			} else {
15409 15409
 				$this->tables[]      = $key;
@@ -15434,7 +15434,7 @@  discard block
 block discarded – undo
15434 15434
 	 *
15435 15435
 	 * @param boolean $yesNo TRUE to use caching, FALSE otherwise
15436 15436
 	 */
15437
-	public function setCacheTables( $yesNo )
15437
+	public function setCacheTables($yesNo)
15438 15438
 	{
15439 15439
 		$this->cacheTables = $yesNo;
15440 15440
 	}
@@ -15450,10 +15450,10 @@  discard block
 block discarded – undo
15450 15450
 	 *
15451 15451
 	 * @return void
15452 15452
 	 */
15453
-	public function setFilters( $filters )
15453
+	public function setFilters($filters)
15454 15454
 	{
15455
-		if ( !is_array( $filters ) ) {
15456
-			$filters = array( $filters );
15455
+		if (!is_array($filters)) {
15456
+			$filters = array($filters);
15457 15457
 		}
15458 15458
 
15459 15459
 		$this->filters = $filters;
@@ -15484,21 +15484,21 @@  discard block
 block discarded – undo
15484 15484
 	 *
15485 15485
 	 * @return OODBBean
15486 15486
 	 */
15487
-	public function dup( OODBBean $bean, $trail = array(), $preserveIDs = FALSE )
15487
+	public function dup(OODBBean $bean, $trail = array(), $preserveIDs = FALSE)
15488 15488
 	{
15489
-		if ( !count( $this->tables ) ) {
15489
+		if (!count($this->tables)) {
15490 15490
 			$this->tables = $this->toolbox->getWriter()->getTables();
15491 15491
 		}
15492 15492
 
15493
-		if ( !count( $this->columns ) ) {
15494
-			foreach ( $this->tables as $table ) {
15495
-				$this->columns[$table] = $this->toolbox->getWriter()->getColumns( $table );
15493
+		if (!count($this->columns)) {
15494
+			foreach ($this->tables as $table) {
15495
+				$this->columns[$table] = $this->toolbox->getWriter()->getColumns($table);
15496 15496
 			}
15497 15497
 		}
15498 15498
 
15499
-		$rs = $this->duplicate( ( clone $bean ), $trail, $preserveIDs );
15499
+		$rs = $this->duplicate((clone $bean), $trail, $preserveIDs);
15500 15500
 
15501
-		if ( !$this->cacheTables ) {
15501
+		if (!$this->cacheTables) {
15502 15502
 			$this->tables  = array();
15503 15503
 			$this->columns = array();
15504 15504
 		}
@@ -15539,19 +15539,19 @@  discard block
 block discarded – undo
15539 15539
 	 *
15540 15540
 	 * @return array
15541 15541
 	 */
15542
-	public function exportAll( $beans, $parents = FALSE, $filters = array(), $caseStyle = 'snake')
15542
+	public function exportAll($beans, $parents = FALSE, $filters = array(), $caseStyle = 'snake')
15543 15543
 	{
15544 15544
 		$array = array();
15545
-		if ( !is_array( $beans ) ) {
15546
-			$beans = array( $beans );
15545
+		if (!is_array($beans)) {
15546
+			$beans = array($beans);
15547 15547
 		}
15548
-		foreach ( $beans as $bean ) {
15549
-			$this->setFilters( $filters );
15550
-			$duplicate = $this->dup( $bean, array(), TRUE );
15551
-			$array[]   = $duplicate->export( FALSE, $parents, FALSE, $filters );
15548
+		foreach ($beans as $bean) {
15549
+			$this->setFilters($filters);
15550
+			$duplicate = $this->dup($bean, array(), TRUE);
15551
+			$array[]   = $duplicate->export(FALSE, $parents, FALSE, $filters);
15552 15552
 		}
15553
-		if ( $caseStyle === 'camel' ) $array = $this->camelfy( $array );
15554
-		if ( $caseStyle === 'dolphin' ) $array = $this->camelfy( $array, TRUE );
15553
+		if ($caseStyle === 'camel') $array = $this->camelfy($array);
15554
+		if ($caseStyle === 'dolphin') $array = $this->camelfy($array, TRUE);
15555 15555
 		return $array;
15556 15556
 	}
15557 15557
 }
@@ -15613,10 +15613,10 @@  discard block
 block discarded – undo
15613 15613
 	 *
15614 15614
 	 * @return string
15615 15615
 	 */
15616
-	public static function genSlots( $array, $template = NULL )
15616
+	public static function genSlots($array, $template = NULL)
15617 15617
 	{
15618
-		$str = count( $array ) ? implode( ',', array_fill( 0, count( $array ), '?' ) ) : '';
15619
-		return ( is_null( $template ) ||  $str === '' ) ? $str : sprintf( $template, $str );
15618
+		$str = count($array) ? implode(',', array_fill(0, count($array), '?')) : '';
15619
+		return (is_null($template) || $str === '') ? $str : sprintf($template, $str);
15620 15620
 	}
15621 15621
 
15622 15622
 	/**
@@ -15635,10 +15635,10 @@  discard block
 block discarded – undo
15635 15635
 	 *
15636 15636
 	 * @return array
15637 15637
 	 */
15638
-	public static function flat( $array, $result = array() )
15638
+	public static function flat($array, $result = array())
15639 15639
 	{		
15640
-		foreach( $array as $value ) {
15641
-			if ( is_array( $value ) ) $result = self::flat( $value, $result );
15640
+		foreach ($array as $value) {
15641
+			if (is_array($value)) $result = self::flat($value, $result);
15642 15642
 			else $result[] = $value;
15643 15643
 		}
15644 15644
 		return $result;
@@ -15682,7 +15682,7 @@  discard block
 block discarded – undo
15682 15682
 	 *
15683 15683
 	 * @return void
15684 15684
 	 */
15685
-	public static function setEnforceNamingPolicy( $yesNo )
15685
+	public static function setEnforceNamingPolicy($yesNo)
15686 15686
 	{
15687 15687
 		self::$enforceNamingPolicy = (boolean) $yesNo;
15688 15688
 	}
@@ -15717,10 +15717,10 @@  discard block
 block discarded – undo
15717 15717
 	 *
15718 15718
 	 * @return void
15719 15719
 	 */
15720
-	public static function checkType( $type )
15720
+	public static function checkType($type)
15721 15721
 	{
15722
-		if ( !preg_match( '/^[a-z0-9]+$/', $type ) ) {
15723
-			throw new RedException( 'Invalid type: ' . $type );
15722
+		if (!preg_match('/^[a-z0-9]+$/', $type)) {
15723
+			throw new RedException('Invalid type: '.$type);
15724 15724
 		}
15725 15725
 	}
15726 15726
 
@@ -15770,36 +15770,36 @@  discard block
 block discarded – undo
15770 15770
 	 *
15771 15771
 	 * @return array|OODBBean
15772 15772
 	 */
15773
-	public static function dispense( OODB $oodb, $typeOrBeanArray, $num = 1, $alwaysReturnArray = FALSE ) {
15773
+	public static function dispense(OODB $oodb, $typeOrBeanArray, $num = 1, $alwaysReturnArray = FALSE) {
15774 15774
 
15775
-		if ( is_array($typeOrBeanArray) ) {
15775
+		if (is_array($typeOrBeanArray)) {
15776 15776
 
15777
-			if ( !isset( $typeOrBeanArray['_type'] ) ) {
15777
+			if (!isset($typeOrBeanArray['_type'])) {
15778 15778
 				$list = array();
15779
-				foreach( $typeOrBeanArray as $beanArray ) {
15779
+				foreach ($typeOrBeanArray as $beanArray) {
15780 15780
 					if ( 
15781
-						!( is_array( $beanArray ) 
15782
-						&& isset( $beanArray['_type'] ) ) ) {
15783
-						throw new RedException( 'Invalid Array Bean' );
15781
+						!(is_array($beanArray) 
15782
+						&& isset($beanArray['_type'])) ) {
15783
+						throw new RedException('Invalid Array Bean');
15784 15784
 					}
15785 15785
 				}
15786
-				foreach( $typeOrBeanArray as $beanArray ) $list[] = self::dispense( $oodb, $beanArray );
15786
+				foreach ($typeOrBeanArray as $beanArray) $list[] = self::dispense($oodb, $beanArray);
15787 15787
 				return $list;
15788 15788
 			}
15789 15789
 
15790 15790
 			$import = $typeOrBeanArray;
15791 15791
 			$type = $import['_type'];
15792
-			unset( $import['_type'] );
15792
+			unset($import['_type']);
15793 15793
 		} else {
15794 15794
 			$type = $typeOrBeanArray;
15795 15795
 		}
15796 15796
 
15797
-		if (self::$enforceNamingPolicy) self::checkType( $type );
15797
+		if (self::$enforceNamingPolicy) self::checkType($type);
15798 15798
 
15799
-		$beanOrBeans = $oodb->dispense( $type, $num, $alwaysReturnArray );
15799
+		$beanOrBeans = $oodb->dispense($type, $num, $alwaysReturnArray);
15800 15800
 
15801
-		if ( isset( $import ) ) {
15802
-			$beanOrBeans->import( $import );
15801
+		if (isset($import)) {
15802
+			$beanOrBeans->import($import);
15803 15803
 		}
15804 15804
 
15805 15805
 		return $beanOrBeans;
@@ -15835,19 +15835,19 @@  discard block
 block discarded – undo
15835 15835
 	 *
15836 15836
 	 * @return array
15837 15837
 	 */
15838
-	public static function dispenseAll( OODB $oodb, $order, $onlyArrays = FALSE )
15838
+	public static function dispenseAll(OODB $oodb, $order, $onlyArrays = FALSE)
15839 15839
 	{
15840 15840
 		$list = array();
15841 15841
 
15842
-		foreach( explode( ',', $order ) as $order ) {
15843
-			if ( strpos( $order, '*' ) !== FALSE ) {
15844
-				list( $type, $amount ) = explode( '*', $order );
15842
+		foreach (explode(',', $order) as $order) {
15843
+			if (strpos($order, '*') !== FALSE) {
15844
+				list($type, $amount) = explode('*', $order);
15845 15845
 			} else {
15846 15846
 				$type   = $order;
15847 15847
 				$amount = 1;
15848 15848
 			}
15849 15849
 
15850
-			$list[] = self::dispense( $oodb, $type, $amount, $onlyArrays );
15850
+			$list[] = self::dispense($oodb, $type, $amount, $onlyArrays);
15851 15851
 		}
15852 15852
 
15853 15853
 		return $list;
@@ -15903,21 +15903,21 @@  discard block
 block discarded – undo
15903 15903
 	 *
15904 15904
 	 * @return array
15905 15905
 	 */
15906
-	public static function dump( $data )
15906
+	public static function dump($data)
15907 15907
 	{
15908 15908
 		$array = array();
15909
-		if ( $data instanceof OODBBean ) {
15910
-			$str = strval( $data );
15909
+		if ($data instanceof OODBBean) {
15910
+			$str = strval($data);
15911 15911
 			if (strlen($str) > 35) {
15912
-				$beanStr = substr( $str, 0, 35 ).'... ';
15912
+				$beanStr = substr($str, 0, 35).'... ';
15913 15913
 			} else {
15914 15914
 				$beanStr = $str;
15915 15915
 			}
15916 15916
 			return $beanStr;
15917 15917
 		}
15918
-		if ( is_array( $data ) ) {
15919
-			foreach( $data as $key => $item ) {
15920
-				$array[$key] = self::dump( $item );
15918
+		if (is_array($data)) {
15919
+			foreach ($data as $key => $item) {
15920
+				$array[$key] = self::dump($item);
15921 15921
 			}
15922 15922
 		}
15923 15923
 		return $array;
@@ -15971,18 +15971,18 @@  discard block
 block discarded – undo
15971 15971
 	 *
15972 15972
 	 * @return OODBBean
15973 15973
 	 */
15974
-	public static function load( OODB $oodb, $types, $id )
15974
+	public static function load(OODB $oodb, $types, $id)
15975 15975
 	{
15976
-		if ( is_string( $types ) ) {
15977
-			$types = explode( ',', $types );
15976
+		if (is_string($types)) {
15977
+			$types = explode(',', $types);
15978 15978
 		}
15979 15979
 
15980
-		if ( !is_array( $types ) ) {
15980
+		if (!is_array($types)) {
15981 15981
 			return array();
15982 15982
 		}
15983 15983
 
15984
-		foreach ( $types as $k => $typeItem ) {
15985
-			$types[$k] = $oodb->load( $typeItem, $id );
15984
+		foreach ($types as $k => $typeItem) {
15985
+			$types[$k] = $oodb->load($typeItem, $id);
15986 15986
 		}
15987 15987
 
15988 15988
 		return $types;
@@ -16050,27 +16050,27 @@  discard block
 block discarded – undo
16050 16050
 	 *
16051 16051
 	 * @return mixed
16052 16052
 	 */
16053
-	public static function transaction( Adapter $adapter, $callback )
16053
+	public static function transaction(Adapter $adapter, $callback)
16054 16054
 	{
16055
-		if ( !is_callable( $callback ) ) {
16056
-			throw new RedException( 'R::transaction needs a valid callback.' );
16055
+		if (!is_callable($callback)) {
16056
+			throw new RedException('R::transaction needs a valid callback.');
16057 16057
 		}
16058 16058
 
16059 16059
 		static $depth = 0;
16060 16060
 		$result = null;
16061 16061
 		try {
16062
-			if ( $depth == 0 ) {
16062
+			if ($depth == 0) {
16063 16063
 				$adapter->startTransaction();
16064 16064
 			}
16065 16065
 			$depth++;
16066
-			$result = call_user_func( $callback ); //maintain 5.2 compatibility
16066
+			$result = call_user_func($callback); //maintain 5.2 compatibility
16067 16067
 			$depth--;
16068
-			if ( $depth == 0 ) {
16068
+			if ($depth == 0) {
16069 16069
 				$adapter->commit();
16070 16070
 			}
16071
-		} catch ( \Exception $exception ) {
16071
+		} catch (\Exception $exception) {
16072 16072
 			$depth--;
16073
-			if ( $depth == 0 ) {
16073
+			if ($depth == 0) {
16074 16074
 				$adapter->rollback();
16075 16075
 			}
16076 16076
 			throw $exception;
@@ -16119,7 +16119,7 @@  discard block
 block discarded – undo
16119 16119
 	 *
16120 16120
 	 * @param ToolBox $toolbox
16121 16121
 	 */
16122
-	public function __construct( ToolBox $toolbox )
16122
+	public function __construct(ToolBox $toolbox)
16123 16123
 	{
16124 16124
 		$this->toolbox = $toolbox;
16125 16125
 	}
@@ -16127,20 +16127,20 @@  discard block
 block discarded – undo
16127 16127
 	/**
16128 16128
 	 * Makes csv() testable.
16129 16129
 	 */
16130
-	public static function operation( $name, $arg1, $arg2 = TRUE ) {
16130
+	public static function operation($name, $arg1, $arg2 = TRUE) {
16131 16131
 		$out = '';
16132
-		switch( $name ) {
16132
+		switch ($name) {
16133 16133
 			case 'test':
16134 16134
 				self::$test = (boolean) $arg1;
16135 16135
 				break;
16136 16136
 			case 'header':
16137
-				$out = ( self::$test ) ? $arg1 : header( $arg1, $arg2 );
16137
+				$out = (self::$test) ? $arg1 : header($arg1, $arg2);
16138 16138
 				break;
16139 16139
 			case 'readfile':
16140
-				$out = ( self::$test ) ? file_get_contents( $arg1 ) : readfile( $arg1 );
16140
+				$out = (self::$test) ? file_get_contents($arg1) : readfile($arg1);
16141 16141
 				break;
16142 16142
 			case 'exit':
16143
-				$out = ( self::$test ) ? 'exit' : exit();
16143
+				$out = (self::$test) ? 'exit' : exit();
16144 16144
 				break;
16145 16145
 		}
16146 16146
 		return $out;
@@ -16174,28 +16174,28 @@  discard block
 block discarded – undo
16174 16174
 	 *
16175 16175
 	 * @return void
16176 16176
 	 */
16177
-	public function csv( $sql = '', $bindings = array(), $columns = NULL, $path = '/tmp/redexport_%s.csv', $output = TRUE, $options = array(',','"','\\') )
16177
+	public function csv($sql = '', $bindings = array(), $columns = NULL, $path = '/tmp/redexport_%s.csv', $output = TRUE, $options = array(',', '"', '\\'))
16178 16178
 	{
16179
-		list( $delimiter, $enclosure, $escapeChar ) = $options;
16180
-		$path = sprintf( $path, date('Ymd_his') );
16181
-		$handle = fopen( $path, 'w' );
16182
-		if ($columns) if (PHP_VERSION_ID>=505040) fputcsv($handle, $columns, $delimiter, $enclosure, $escapeChar ); else fputcsv($handle, $columns, $delimiter, $enclosure );
16183
-		$cursor = $this->toolbox->getDatabaseAdapter()->getCursor( $sql, $bindings );
16184
-		while( $row = $cursor->getNextItem() ) {
16185
-			if (PHP_VERSION_ID>=505040) fputcsv($handle, $row, $delimiter, $enclosure, $escapeChar ); else fputcsv($handle, $row, $delimiter, $enclosure );
16179
+		list($delimiter, $enclosure, $escapeChar) = $options;
16180
+		$path = sprintf($path, date('Ymd_his'));
16181
+		$handle = fopen($path, 'w');
16182
+		if ($columns) if (PHP_VERSION_ID >= 505040) fputcsv($handle, $columns, $delimiter, $enclosure, $escapeChar); else fputcsv($handle, $columns, $delimiter, $enclosure);
16183
+		$cursor = $this->toolbox->getDatabaseAdapter()->getCursor($sql, $bindings);
16184
+		while ($row = $cursor->getNextItem()) {
16185
+			if (PHP_VERSION_ID >= 505040) fputcsv($handle, $row, $delimiter, $enclosure, $escapeChar); else fputcsv($handle, $row, $delimiter, $enclosure);
16186 16186
 		}
16187 16187
 		fclose($handle);
16188
-		if ( $output ) {
16188
+		if ($output) {
16189 16189
 			$file = basename($path);
16190
-			$out = self::operation('header',"Pragma: public");
16191
-			$out .= self::operation('header',"Expires: 0");
16192
-			$out .= self::operation('header',"Cache-Control: must-revalidate, post-check=0, pre-check=0");
16193
-			$out .= self::operation('header',"Cache-Control: private", FALSE );
16194
-			$out .= self::operation('header',"Content-Type: text/csv");
16195
-			$out .= self::operation('header',"Content-Disposition: attachment; filename={$file}" );
16196
-			$out .= self::operation('header',"Content-Transfer-Encoding: binary");
16197
-			$out .= self::operation('readfile',$path );
16198
-			@unlink( $path );
16190
+			$out = self::operation('header', "Pragma: public");
16191
+			$out .= self::operation('header', "Expires: 0");
16192
+			$out .= self::operation('header', "Cache-Control: must-revalidate, post-check=0, pre-check=0");
16193
+			$out .= self::operation('header', "Cache-Control: private", FALSE);
16194
+			$out .= self::operation('header', "Content-Type: text/csv");
16195
+			$out .= self::operation('header', "Content-Disposition: attachment; filename={$file}");
16196
+			$out .= self::operation('header', "Content-Transfer-Encoding: binary");
16197
+			$out .= self::operation('readfile', $path);
16198
+			@unlink($path);
16199 16199
 			self::operation('exit', FALSE);
16200 16200
 			return $out;
16201 16201
 		}
@@ -16241,7 +16241,7 @@  discard block
 block discarded – undo
16241 16241
 	 *
16242 16242
 	 * @param ToolBox $toolbox
16243 16243
 	 */
16244
-	public function __construct( ToolBox $toolbox )
16244
+	public function __construct(ToolBox $toolbox)
16245 16245
 	{
16246 16246
 		$this->toolbox = $toolbox;
16247 16247
 	}
@@ -16276,32 +16276,32 @@  discard block
 block discarded – undo
16276 16276
 	 *
16277 16277
 	 * @return mixed
16278 16278
 	 */
16279
-	public function matchUp( $type, $sql, $bindings = array(), $onFoundDo = NULL, $onNotFoundDo = NULL, &$bean = NULL )
16279
+	public function matchUp($type, $sql, $bindings = array(), $onFoundDo = NULL, $onNotFoundDo = NULL, &$bean = NULL)
16280 16280
 	{
16281
-		$finder = new Finder( $this->toolbox );
16281
+		$finder = new Finder($this->toolbox);
16282 16282
 		$oodb   = $this->toolbox->getRedBean();
16283
-		$bean = $finder->findOne( $type, $sql, $bindings );
16284
-		if ( $bean && $onFoundDo ) {
16285
-			foreach( $onFoundDo as $property => $value ) {
16286
-				if ( function_exists('is_callable') && is_callable( $value ) ) {
16287
-					$bean[$property] = call_user_func_array( $value, array( $bean ) );
16283
+		$bean = $finder->findOne($type, $sql, $bindings);
16284
+		if ($bean && $onFoundDo) {
16285
+			foreach ($onFoundDo as $property => $value) {
16286
+				if (function_exists('is_callable') && is_callable($value)) {
16287
+					$bean[$property] = call_user_func_array($value, array($bean));
16288 16288
 				} else {
16289 16289
 					$bean[$property] = $value;
16290 16290
 				}
16291 16291
 			}
16292
-			$oodb->store( $bean );
16292
+			$oodb->store($bean);
16293 16293
 			return TRUE;
16294 16294
 		}
16295
-		if ( $onNotFoundDo ) {
16296
-			$bean = $oodb->dispense( $type );
16297
-			foreach( $onNotFoundDo as $property => $value ) {
16298
-				if ( function_exists('is_callable') && is_callable( $value ) ) {
16299
-					$bean[$property] = call_user_func_array( $value, array( $bean ) );
16295
+		if ($onNotFoundDo) {
16296
+			$bean = $oodb->dispense($type);
16297
+			foreach ($onNotFoundDo as $property => $value) {
16298
+				if (function_exists('is_callable') && is_callable($value)) {
16299
+					$bean[$property] = call_user_func_array($value, array($bean));
16300 16300
 				} else {
16301 16301
 					$bean[$property] = $value;
16302 16302
 				}
16303 16303
 			}
16304
-			$oodb->store( $bean );
16304
+			$oodb->store($bean);
16305 16305
 			return FALSE;
16306 16306
 		}
16307 16307
 		return NULL;
@@ -16344,7 +16344,7 @@  discard block
 block discarded – undo
16344 16344
 	 *
16345 16345
 	 * @param ToolBox $toolbox
16346 16346
 	 */
16347
-	public function __construct( ToolBox $toolbox )
16347
+	public function __construct(ToolBox $toolbox)
16348 16348
 	{
16349 16349
 		$this->toolbox = $toolbox;
16350 16350
 	}
@@ -16396,23 +16396,23 @@  discard block
 block discarded – undo
16396 16396
 	 *
16397 16397
 	 * @return string
16398 16398
 	 */
16399
-	public function look( $sql, $bindings = array(), $keys = array( 'selected', 'id', 'name' ), $template = '<option %s value="%s">%s</option>', $filter = 'trim', $glue = '' )
16399
+	public function look($sql, $bindings = array(), $keys = array('selected', 'id', 'name'), $template = '<option %s value="%s">%s</option>', $filter = 'trim', $glue = '')
16400 16400
 	{
16401 16401
 		$adapter = $this->toolbox->getDatabaseAdapter();
16402 16402
 		$lines = array();
16403
-		$rows = $adapter->get( $sql, $bindings );
16404
-		foreach( $rows as $row ) {
16403
+		$rows = $adapter->get($sql, $bindings);
16404
+		foreach ($rows as $row) {
16405 16405
 			$values = array();
16406
-			foreach( $keys as $key ) {
16406
+			foreach ($keys as $key) {
16407 16407
 				if (!empty($filter)) {
16408
-					$values[] = call_user_func_array( $filter, array( $row[$key] ) );
16408
+					$values[] = call_user_func_array($filter, array($row[$key]));
16409 16409
 				} else {
16410 16410
 					$values[] = $row[$key];
16411 16411
 				}
16412 16412
 			}
16413
-			$lines[] = vsprintf( $template, $values );
16413
+			$lines[] = vsprintf($template, $values);
16414 16414
 		}
16415
-		$string = implode( $glue, $lines );
16415
+		$string = implode($glue, $lines);
16416 16416
 		return $string;
16417 16417
 	}
16418 16418
 }
@@ -16453,7 +16453,7 @@  discard block
 block discarded – undo
16453 16453
 	 *
16454 16454
 	 * @param ToolBox $toolbox
16455 16455
 	 */
16456
-	public function __construct( ToolBox $toolbox )
16456
+	public function __construct(ToolBox $toolbox)
16457 16457
 	{
16458 16458
 		$this->toolbox = $toolbox;
16459 16459
 	}
@@ -16490,30 +16490,30 @@  discard block
 block discarded – undo
16490 16490
 	 *
16491 16491
 	 * @return array
16492 16492
 	 */
16493
-	public function diff( $beans, $others, $filters = array( 'created', 'modified' ), $format = '%s.%s.%s', $type = NULL )
16493
+	public function diff($beans, $others, $filters = array('created', 'modified'), $format = '%s.%s.%s', $type = NULL)
16494 16494
 	{
16495 16495
 		$diff = array();
16496
-		if ( !is_array( $beans ) ) $beans = array( $beans );
16497
-		if ( !is_array( $others ) ) $others = array( $others );
16498
-		foreach( $beans as $bean ) {
16499
-			if ( !is_object( $bean ) ) continue;
16500
-			if ( !( $bean instanceof OODBBean ) ) continue;
16501
-			if ( $type == NULL ) $type = $bean->getMeta( 'type' );
16502
-			foreach( $others as $other ) {
16503
-				if ( !is_object( $other ) ) continue;
16504
-				if ( !( $other instanceof OODBBean ) ) continue;
16505
-				if ( $other->id == $bean->id ) {
16506
-					foreach( $bean as $property => $value ) {
16507
-						if ( in_array( $property, $filters ) ) continue;
16508
-						$key = vsprintf( $format, array( $type, $bean->id, $property ) );
16496
+		if (!is_array($beans)) $beans = array($beans);
16497
+		if (!is_array($others)) $others = array($others);
16498
+		foreach ($beans as $bean) {
16499
+			if (!is_object($bean)) continue;
16500
+			if (!($bean instanceof OODBBean)) continue;
16501
+			if ($type == NULL) $type = $bean->getMeta('type');
16502
+			foreach ($others as $other) {
16503
+				if (!is_object($other)) continue;
16504
+				if (!($other instanceof OODBBean)) continue;
16505
+				if ($other->id == $bean->id) {
16506
+					foreach ($bean as $property => $value) {
16507
+						if (in_array($property, $filters)) continue;
16508
+						$key = vsprintf($format, array($type, $bean->id, $property));
16509 16509
 						$compare = $other->{$property};
16510
-						if ( !is_object( $value ) && !is_array( $value ) ) {
16511
-							if ( $value != $compare ) {
16512
-								$diff[$key] = array( $value, $compare );
16510
+						if (!is_object($value) && !is_array($value)) {
16511
+							if ($value != $compare) {
16512
+								$diff[$key] = array($value, $compare);
16513 16513
 							}
16514 16514
 							continue;
16515 16515
 						} else {
16516
-							$diff = array_merge( $diff, $this->diff( $value, $compare, $filters, $format, $key ) );
16516
+							$diff = array_merge($diff, $this->diff($value, $compare, $filters, $format, $key));
16517 16517
 							continue;
16518 16518
 						}
16519 16519
 					}
@@ -16570,7 +16570,7 @@  discard block
 block discarded – undo
16570 16570
 	 *
16571 16571
 	 * @param ToolBox $toolbox toolbox
16572 16572
 	 */
16573
-	public function __construct( ToolBox $toolbox )
16573
+	public function __construct(ToolBox $toolbox)
16574 16574
 	{
16575 16575
 		$this->toolbox = $toolbox;
16576 16576
 		$this->writer  = $toolbox->getWriter();
@@ -16590,14 +16590,14 @@  discard block
 block discarded – undo
16590 16590
 	 *
16591 16591
 	 * @return array
16592 16592
 	 */
16593
-	public function children( OODBBean $bean, $sql = NULL, $bindings = array() )
16593
+	public function children(OODBBean $bean, $sql = NULL, $bindings = array())
16594 16594
 	{
16595 16595
 		$type = $bean->getMeta('type');
16596 16596
 		$id   = $bean->id;
16597 16597
 
16598
-		$rows = $this->writer->queryRecursiveCommonTableExpression( $type, $id, FALSE, $sql, $bindings );
16598
+		$rows = $this->writer->queryRecursiveCommonTableExpression($type, $id, FALSE, $sql, $bindings);
16599 16599
 
16600
-		return $this->oodb->convertToBeans( $type, $rows );
16600
+		return $this->oodb->convertToBeans($type, $rows);
16601 16601
 	}
16602 16602
 	
16603 16603
 	/**
@@ -16613,14 +16613,14 @@  discard block
 block discarded – undo
16613 16613
 	 *
16614 16614
 	 * @return array
16615 16615
 	 */
16616
-	public function parents( OODBBean $bean, $sql = NULL, $bindings = array() )
16616
+	public function parents(OODBBean $bean, $sql = NULL, $bindings = array())
16617 16617
 	{
16618 16618
 		$type = $bean->getMeta('type');
16619 16619
 		$id   = $bean->id;
16620 16620
 
16621
-		$rows = $this->writer->queryRecursiveCommonTableExpression( $type, $id, TRUE, $sql, $bindings );
16621
+		$rows = $this->writer->queryRecursiveCommonTableExpression($type, $id, TRUE, $sql, $bindings);
16622 16622
 
16623
-		return $this->oodb->convertToBeans( $type, $rows );		
16623
+		return $this->oodb->convertToBeans($type, $rows);		
16624 16624
 	}	
16625 16625
 }
16626 16626
 }
@@ -16657,23 +16657,23 @@  discard block
 block discarded – undo
16657 16657
 	 *
16658 16658
 	 * @return void
16659 16659
 	 */
16660
-	public static function feature( $label ) {
16661
-		switch( $label ) {
16660
+	public static function feature($label) {
16661
+		switch ($label) {
16662 16662
 			case "novice/latest":
16663
-				R::noNuke( TRUE );
16664
-				R::setAutoResolve( TRUE );
16663
+				R::noNuke(TRUE);
16664
+				R::setAutoResolve(TRUE);
16665 16665
 				break;
16666 16666
 			case "latest":
16667
-				R::noNuke( FALSE );
16668
-				R::setAutoResolve( TRUE );
16667
+				R::noNuke(FALSE);
16668
+				R::setAutoResolve(TRUE);
16669 16669
 				break;
16670 16670
 			case "novice/5.3":
16671
-				R::noNuke( TRUE );
16672
-				R::setAutoResolve( TRUE );
16671
+				R::noNuke(TRUE);
16672
+				R::setAutoResolve(TRUE);
16673 16673
 				break;
16674 16674
 			case "5.3":
16675
-				R::noNuke( FALSE );
16676
-				R::setAutoResolve( TRUE );
16675
+				R::noNuke(FALSE);
16676
+				R::setAutoResolve(TRUE);
16677 16677
 				break;
16678 16678
 			default:
16679 16679
 				throw new \Exception("Unknown feature set label.");
@@ -16714,7 +16714,7 @@  discard block
 block discarded – undo
16714 16714
 class RedBean_SimpleModel extends \RedBeanPHP\SimpleModel {};
16715 16715
 
16716 16716
 if (!class_exists('R')) {
16717
-	class R extends \RedBeanPHP\Facade{};
16717
+	class R extends \RedBeanPHP\Facade {};
16718 16718
 }
16719 16719
 
16720 16720
 
@@ -16753,7 +16753,7 @@  discard block
 block discarded – undo
16753 16753
 
16754 16754
 	function EID($enumName)
16755 16755
 	{
16756
-		return \RedBeanPHP\Facade::enum( $enumName )->id;
16756
+		return \RedBeanPHP\Facade::enum($enumName)->id;
16757 16757
 	}
16758 16758
 
16759 16759
 }
@@ -16766,33 +16766,33 @@  discard block
 block discarded – undo
16766 16766
  *
16767 16767
  * @return void
16768 16768
  */
16769
-if ( !function_exists( 'dmp' ) ) {
16769
+if (!function_exists('dmp')) {
16770 16770
 
16771
-	function dmp( $list )
16771
+	function dmp($list)
16772 16772
 	{
16773
-		print_r( \RedBeanPHP\Facade::dump( $list ) );
16773
+		print_r(\RedBeanPHP\Facade::dump($list));
16774 16774
 	}
16775 16775
 }
16776 16776
 
16777 16777
 /**
16778 16778
  * Function alias for R::genSlots().
16779 16779
  */
16780
-if ( !function_exists( 'genslots' ) ) {
16780
+if (!function_exists('genslots')) {
16781 16781
 
16782
-	function genslots( $slots, $tpl = NULL )
16782
+	function genslots($slots, $tpl = NULL)
16783 16783
 	{
16784
-		return \RedBeanPHP\Facade::genSlots( $slots, $tpl );
16784
+		return \RedBeanPHP\Facade::genSlots($slots, $tpl);
16785 16785
 	}
16786 16786
 }
16787 16787
 
16788 16788
 /**
16789 16789
  * Function alias for R::flat().
16790 16790
  */
16791
-if ( !function_exists( 'array_flatten' ) ) {
16791
+if (!function_exists('array_flatten')) {
16792 16792
 
16793
-	function array_flatten( $array )
16793
+	function array_flatten($array)
16794 16794
 	{
16795
-		return \RedBeanPHP\Facade::flat( $array );
16795
+		return \RedBeanPHP\Facade::flat($array);
16796 16796
 	}
16797 16797
 }
16798 16798
 
Please login to merge, or discard this patch.
OctaORM.php 1 patch
Spacing   +176 added lines, -176 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-class OctaORM{
2
+class OctaORM {
3 3
 
4 4
     protected $redbean;
5 5
     protected $db_field;
@@ -29,19 +29,19 @@  discard block
 block discarded – undo
29 29
     var $num_rows;
30 30
     var $result;
31 31
 
32
-    public function __construct($db){
32
+    public function __construct($db) {
33 33
         include_once('RedBean.php');
34 34
         $this->redbean = new R();
35 35
         $this->db_field = $db;
36 36
 
37
-        if(!$this->redbean->testConnection()){
37
+        if (!$this->redbean->testConnection()) {
38 38
             $conn = $this->initiate_database_connection($db);
39 39
             $this->redbean->setup(/** @scrutinizer ignore-type */ $conn);
40
-            $this->redbean->useFeatureSet( 'novice/latest' );
40
+            $this->redbean->useFeatureSet('novice/latest');
41 41
         }
42 42
     }
43 43
 
44
-    public function initiate_database_connection($db){
44
+    public function initiate_database_connection($db) {
45 45
         $DB_HOST = $db['hostname'];
46 46
         $DB_USERNAME = $db['username'];
47 47
         $DB_PASSWORD = $db['password'];
@@ -52,24 +52,24 @@  discard block
 block discarded – undo
52 52
 
53 53
         $DB_con->exec("CREATE DATABASE IF NOT EXISTS $DB_NAME;");
54 54
 
55
-        $DB_con = new PDO("mysql:host={$DB_HOST};dbname={$DB_NAME}",$DB_USERNAME,$DB_PASSWORD);
55
+        $DB_con = new PDO("mysql:host={$DB_HOST};dbname={$DB_NAME}", $DB_USERNAME, $DB_PASSWORD);
56 56
         $DB_con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
57 57
         return $DB_con;
58 58
     }
59 59
 
60
-    public function insert_id(){
60
+    public function insert_id() {
61 61
         return $this->last_id;
62 62
     }
63 63
 
64
-    public function last_query(){
64
+    public function last_query() {
65 65
         return $this->last_query;
66 66
     }
67 67
 
68
-    public function insert($array,$table){
68
+    public function insert($array, $table) {
69 69
         $data = $this->redbean->dispense($table);
70 70
 
71
-        if($array){
72
-            foreach($array as $key=>$row){
71
+        if ($array) {
72
+            foreach ($array as $key=>$row) {
73 73
                 $data->$key = $row;
74 74
             }
75 75
         }
@@ -78,28 +78,28 @@  discard block
 block discarded – undo
78 78
         return ($this->last_id) ? true : false;
79 79
     }
80 80
 
81
-    public function insert_batch($array,$table){
81
+    public function insert_batch($array, $table) {
82 82
         $data = array();
83 83
 
84
-        if($array){
85
-            foreach($array as $key_ib=>$row_ib){
84
+        if ($array) {
85
+            foreach ($array as $key_ib=>$row_ib) {
86 86
 
87
-                $data[$key_ib]=$this->redbean->dispense($table);
87
+                $data[$key_ib] = $this->redbean->dispense($table);
88 88
                 $table_fields = [];
89 89
                 $table_fields_val = [];
90 90
 
91
-                if($row_ib){
92
-                    foreach($row_ib as $row=>$val){
91
+                if ($row_ib) {
92
+                    foreach ($row_ib as $row=>$val) {
93 93
                         $table_fields[] = $row;
94 94
                         $table_fields_val[] = $val;
95 95
                     }
96 96
 
97
-                    if($table_fields && $table_fields_val){
98
-                        foreach($table_fields as $key=>$row){
97
+                    if ($table_fields && $table_fields_val) {
98
+                        foreach ($table_fields as $key=>$row) {
99 99
                             $data[$key_ib]->$row = $table_fields_val[$key];
100 100
                         }
101 101
 
102
-                    }else{
102
+                    } else {
103 103
                         return false;
104 104
                     }
105 105
                 }
@@ -110,11 +110,11 @@  discard block
 block discarded – undo
110 110
         return ($result) ? true : false;
111 111
     }
112 112
 
113
-    public function update($table,$array,$id){
113
+    public function update($table, $array, $id) {
114 114
         $data = $this->redbean->load($table, $id);
115 115
 
116
-        if($array){
117
-            foreach($array as $key=>$row){
116
+        if ($array) {
117
+            foreach ($array as $key=>$row) {
118 118
                 $data->$key = $row;
119 119
             }
120 120
         }
@@ -123,33 +123,33 @@  discard block
 block discarded – undo
123 123
         return true;
124 124
     }
125 125
 
126
-    public function update_batch($table,$array,$where){
127
-        if($array){
128
-            foreach($array as $key_ub=>$row_ub){
126
+    public function update_batch($table, $array, $where) {
127
+        if ($array) {
128
+            foreach ($array as $key_ub=>$row_ub) {
129 129
                 $where_key = '';
130 130
                 $table_fields = [];
131 131
                 $table_fields_val = [];
132 132
 
133
-                if($row_ub){
134
-                    foreach($row_ub as $row=>$val){
133
+                if ($row_ub) {
134
+                    foreach ($row_ub as $row=>$val) {
135 135
 
136
-                        if($row === $where){
136
+                        if ($row === $where) {
137 137
                             $where_key = $val;
138 138
                         }
139 139
 
140
-                        if($row !== $where){
140
+                        if ($row !== $where) {
141 141
                             $table_fields[] = $row;
142 142
                             $table_fields_val[] = $val;
143 143
                         }
144 144
                     }
145 145
 
146 146
                     $data = $this->redbean->load($table, $where_key);
147
-                    if($table_fields && $table_fields_val){
148
-                        foreach($table_fields as $key=>$row){
147
+                    if ($table_fields && $table_fields_val) {
148
+                        foreach ($table_fields as $key=>$row) {
149 149
                             $data->$row = $table_fields_val[$key];
150 150
                         }
151 151
 
152
-                    }else{
152
+                    } else {
153 153
                         return false;
154 154
                     }
155 155
 
@@ -161,32 +161,32 @@  discard block
 block discarded – undo
161 161
         return true;
162 162
     }
163 163
 
164
-    public function delete($table,$id){
165
-        if($id){
166
-            if(is_array($id)){
167
-                foreach($id as $key=>$row){
168
-                    $this->redbean->trash($table,$row);
164
+    public function delete($table, $id) {
165
+        if ($id) {
166
+            if (is_array($id)) {
167
+                foreach ($id as $key=>$row) {
168
+                    $this->redbean->trash($table, $row);
169 169
                 }
170 170
 
171 171
                 return true;
172 172
 
173
-            }else{
174
-                $this->redbean->trash($table,$id);
173
+            } else {
174
+                $this->redbean->trash($table, $id);
175 175
                 return true;
176 176
             }
177 177
         }
178 178
     }
179 179
 
180
-    public function delete_all($table){
180
+    public function delete_all($table) {
181 181
         $result = $this->redbean->wipe($table);
182 182
         return ($result) ? true : false;
183 183
     }
184 184
 
185
-    public function select($data){
185
+    public function select($data) {
186 186
         $reset = [];
187
-        if($data){
188
-            foreach($data as $key=>$row){
189
-                array_push($reset,$row);
187
+        if ($data) {
188
+            foreach ($data as $key=>$row) {
189
+                array_push($reset, $row);
190 190
             }
191 191
         }
192 192
 
@@ -194,25 +194,25 @@  discard block
 block discarded – undo
194 194
         return $this->select;
195 195
     }
196 196
 
197
-    public function where($data=null,$match=null){
197
+    public function where($data = null, $match = null) {
198 198
         $tmp_where = '';
199 199
         $arr_check = false;
200
-        if($data){
201
-            if(is_array($data)){
200
+        if ($data) {
201
+            if (is_array($data)) {
202 202
                 end($data);
203 203
                 $last_element = key($data);
204 204
 
205
-                if($data){
205
+                if ($data) {
206 206
                     $arr_check = true;
207
-                    foreach($data as $key=>$row){
208
-                        if($key == $last_element){
207
+                    foreach ($data as $key=>$row) {
208
+                        if ($key == $last_element) {
209 209
                             $tmp_where .= $key."='".$row."'";
210
-                        }else{
210
+                        } else {
211 211
                             $tmp_where .= $key."='".$row."' AND ";
212 212
                         }
213 213
                     }
214 214
                 }
215
-            }else{
215
+            } else {
216 216
                 $arr_check = false;
217 217
                 $tmp_where = "WHERE ".$data."='".$match."'";
218 218
             }
@@ -221,25 +221,25 @@  discard block
 block discarded – undo
221 221
         $this->where = ($arr_check) ? "WHERE ".$tmp_where : $tmp_where;
222 222
     }
223 223
 
224
-    public function or_where($data=null,$match=null){
224
+    public function or_where($data = null, $match = null) {
225 225
         $tmp_or_where = '';
226 226
         $arr_check = false;
227
-        if($data){
228
-            if(is_array($data)){
227
+        if ($data) {
228
+            if (is_array($data)) {
229 229
                 end($data);
230 230
                 $last_element = key($data);
231 231
                 $arr_check = true;
232 232
 
233
-                if($data){
234
-                    foreach($data as $key=>$row){
235
-                        if($key == $last_element){
233
+                if ($data) {
234
+                    foreach ($data as $key=>$row) {
235
+                        if ($key == $last_element) {
236 236
                             $tmp_or_where .= $key."='".$row."'";
237
-                        }else{
237
+                        } else {
238 238
                             $tmp_or_where .= $key."='".$row."' AND ";
239 239
                         }
240 240
                     }
241 241
                 }
242
-            }else{
242
+            } else {
243 243
                 $arr_check = false;
244 244
                 $tmp_or_where = "OR ".$data."='".$match."'";
245 245
             }
@@ -248,14 +248,14 @@  discard block
 block discarded – undo
248 248
         $this->or_where = ($arr_check) ? "OR ".$tmp_or_where : $tmp_or_where;
249 249
     }
250 250
 
251
-    public function where_in($field,$data){
251
+    public function where_in($field, $data) {
252 252
         $where_in_fields = '';
253 253
         $last_key = end(array_keys($data));
254
-        if($data){
255
-            foreach($data as $key=>$row){
256
-                if($key == $last_key){
254
+        if ($data) {
255
+            foreach ($data as $key=>$row) {
256
+                if ($key == $last_key) {
257 257
                     $where_in_fields .= $row;
258
-                }else{
258
+                } else {
259 259
                     $where_in_fields .= $row.",";
260 260
                 }
261 261
             }
@@ -264,14 +264,14 @@  discard block
 block discarded – undo
264 264
         $this->where_in = 'WHERE '.$field.' IN ('.$where_in_fields.')';
265 265
     }
266 266
 
267
-    public function or_where_in($field,$data){
267
+    public function or_where_in($field, $data) {
268 268
         $where_in_fields = '';
269 269
         $last_key = end(array_keys($data));
270
-        if($data){
271
-            foreach($data as $key=>$row){
272
-                if($key == $last_key){
270
+        if ($data) {
271
+            foreach ($data as $key=>$row) {
272
+                if ($key == $last_key) {
273 273
                     $where_in_fields .= $row;
274
-                }else{
274
+                } else {
275 275
                     $where_in_fields .= $row.",";
276 276
                 }
277 277
             }
@@ -280,14 +280,14 @@  discard block
 block discarded – undo
280 280
         $this->or_where_in = 'OR '.$field.' IN ('.$where_in_fields.')';
281 281
     }
282 282
 
283
-    public function where_not_in($field,$data){
283
+    public function where_not_in($field, $data) {
284 284
         $where_in_fields = '';
285 285
         $last_key = end(array_keys($data));
286
-        if($data){
287
-            foreach($data as $key=>$row){
288
-                if($key == $last_key){
286
+        if ($data) {
287
+            foreach ($data as $key=>$row) {
288
+                if ($key == $last_key) {
289 289
                     $where_in_fields .= $row;
290
-                }else{
290
+                } else {
291 291
                     $where_in_fields .= $row.",";
292 292
                 }
293 293
             }
@@ -296,14 +296,14 @@  discard block
 block discarded – undo
296 296
         $this->where_not_in = 'WHERE '.$field.' NOT IN ('.$where_in_fields.')';
297 297
     }
298 298
 
299
-    public function or_where_not_in($field,$data){
299
+    public function or_where_not_in($field, $data) {
300 300
         $where_in_fields = '';
301 301
         $last_key = end(array_keys($data));
302
-        if($data){
303
-            foreach($data as $key=>$row){
304
-                if($key == $last_key){
302
+        if ($data) {
303
+            foreach ($data as $key=>$row) {
304
+                if ($key == $last_key) {
305 305
                     $where_in_fields .= $row;
306
-                }else{
306
+                } else {
307 307
                     $where_in_fields .= $row.",";
308 308
                 }
309 309
             }
@@ -312,25 +312,25 @@  discard block
 block discarded – undo
312 312
         $this->or_where_not_in = 'OR '.$field.' NOT IN ('.$where_in_fields.')';
313 313
     }
314 314
 
315
-    public function like($data=null,$match=null){
315
+    public function like($data = null, $match = null) {
316 316
         $tmp_like = '';
317 317
         $arr_check = false;
318
-        if($data){
319
-            if(is_array($data)){
318
+        if ($data) {
319
+            if (is_array($data)) {
320 320
                 end($data);
321 321
                 $last_element = key($data);
322 322
 
323
-                if($data){
323
+                if ($data) {
324 324
                     $arr_check = true;
325
-                    foreach($data as $key=>$row){
326
-                        if($key == $last_element){
325
+                    foreach ($data as $key=>$row) {
326
+                        if ($key == $last_element) {
327 327
                             $tmp_like .= $key." LIKE '%".$row."%'";
328
-                        }else{
328
+                        } else {
329 329
                             $tmp_like .= $key." LIKE '%".$row."%' AND ";
330 330
                         }
331 331
                     }
332 332
                 }
333
-            }else{
333
+            } else {
334 334
                 $arr_check = false;
335 335
                 $tmp_like = "WHERE ".$data." LIKE '%".$match."%'";
336 336
             }
@@ -340,23 +340,23 @@  discard block
 block discarded – undo
340 340
         $this->like = ($arr_check) ? $tmp_like : "WHERE ".$tmp_like;
341 341
     }
342 342
 
343
-    public function or_like($data=null,$match=null){
343
+    public function or_like($data = null, $match = null) {
344 344
         $tmp_or_like = '';
345
-        if($data){
346
-            if(is_array($data)){
345
+        if ($data) {
346
+            if (is_array($data)) {
347 347
                 end($data);
348 348
                 $last_element = key($data);
349 349
 
350
-                if($data){
351
-                    foreach($data as $key=>$row){
352
-                        if($key == $last_element){
350
+                if ($data) {
351
+                    foreach ($data as $key=>$row) {
352
+                        if ($key == $last_element) {
353 353
                             $tmp_or_like .= "OR ".$key." LIKE '%".$row."%'";
354
-                        }else{
354
+                        } else {
355 355
                             $tmp_or_like .= "OR ".$key." LIKE '%".$row."%' AND ";
356 356
                         }
357 357
                     }
358 358
                 }
359
-            }else{
359
+            } else {
360 360
                 $tmp_or_like = "OR ".$data." LIKE '%".$match."%'";
361 361
             }
362 362
         }
@@ -364,25 +364,25 @@  discard block
 block discarded – undo
364 364
         $this->or_like = $tmp_or_like;
365 365
     }
366 366
 
367
-    public function not_like($data=null,$match=null){
367
+    public function not_like($data = null, $match = null) {
368 368
         $tmp_like = '';
369 369
         $arr_check = false;
370
-        if($data){
371
-            if(is_array($data)){
370
+        if ($data) {
371
+            if (is_array($data)) {
372 372
                 end($data);
373 373
                 $last_element = key($data);
374 374
 
375
-                if($data){
375
+                if ($data) {
376 376
                     $arr_check = true;
377
-                    foreach($data as $key=>$row){
378
-                        if($key == $last_element){
377
+                    foreach ($data as $key=>$row) {
378
+                        if ($key == $last_element) {
379 379
                             $tmp_like .= $key." NOT LIKE '%".$row."%'";
380
-                        }else{
380
+                        } else {
381 381
                             $tmp_like .= $key." NOT LIKE '%".$row."%' AND ";
382 382
                         }
383 383
                     }
384 384
                 }
385
-            }else{
385
+            } else {
386 386
                 $arr_check = false;
387 387
                 $tmp_like = "WHERE ".$data." NOT LIKE '%".$match."%'";
388 388
             }
@@ -392,23 +392,23 @@  discard block
 block discarded – undo
392 392
         $this->like = ($arr_check) ? "WHERE ".$tmp_like : $tmp_like;
393 393
     }
394 394
 
395
-    public function or_not_like($data=null,$match=null){
395
+    public function or_not_like($data = null, $match = null) {
396 396
         $tmp_or_like = '';
397
-        if($data){
398
-            if(is_array($data)){
397
+        if ($data) {
398
+            if (is_array($data)) {
399 399
                 end($data);
400 400
                 $last_element = key($data);
401 401
 
402
-                if($data){
403
-                    foreach($data as $key=>$row){
404
-                        if($key == $last_element){
402
+                if ($data) {
403
+                    foreach ($data as $key=>$row) {
404
+                        if ($key == $last_element) {
405 405
                             $tmp_or_like .= "OR ".$key." NOT LIKE '%".$row."%'";
406
-                        }else{
406
+                        } else {
407 407
                             $tmp_or_like .= "OR ".$key." NOT LIKE '%".$row."%' AND ";
408 408
                         }
409 409
                     }
410 410
                 }
411
-            }else{
411
+            } else {
412 412
                 $tmp_or_like = "OR ".$data." NOT LIKE '%".$match."%'";
413 413
             }
414 414
         }
@@ -416,25 +416,25 @@  discard block
 block discarded – undo
416 416
         $this->or_like = $tmp_or_like;
417 417
     }
418 418
 
419
-    public function order_by($field,$sort){
419
+    public function order_by($field, $sort) {
420 420
         $this->order_by = $field.' '.$sort;
421 421
     }
422 422
 
423
-    public function join($table,$joint,$join_type="INNER"){
423
+    public function join($table, $joint, $join_type = "INNER") {
424 424
         $this->join = $join_type.' JOIN '.$table.' ON '.$joint;
425 425
     }
426 426
 
427
-    public function group_by($field){
427
+    public function group_by($field) {
428 428
         $this->group_by = 'GROUP BY '.$field;
429 429
     }
430 430
 
431
-    public function get($table=null,$limit=null,$offset=null){
431
+    public function get($table = null, $limit = null, $offset = null) {
432 432
         $this->table = $table;
433 433
         $this->limit = $limit;
434 434
         $this->offset = $offset;
435 435
     }
436 436
 
437
-    public function clear_global_var(){
437
+    public function clear_global_var() {
438 438
         $this->select = '';
439 439
         $this->where = '';
440 440
         $this->or_where = '';
@@ -457,10 +457,10 @@  discard block
 block discarded – undo
457 457
         $this->result = '';
458 458
     }
459 459
 
460
-    public function row(){
460
+    public function row() {
461 461
         /*init var*/
462 462
         $result = [];
463
-        $select = ($this->select) ? implode(',',$this->select) : '*';
463
+        $select = ($this->select) ? implode(',', $this->select) : '*';
464 464
         $order_by = ($this->order_by) ? 'ORDER BY '.$this->order_by : '';
465 465
         $join = ($this->join) ? $this->join : '';
466 466
         $group_by = ($this->group_by) ? $this->group_by : '';
@@ -484,8 +484,8 @@  discard block
 block discarded – undo
484 484
         $this->row = "SELECT {$select} FROM {$table} {$join} {$where} {$or_where} {$where_in} {$or_where_in} {$where_not_in} {$or_where_not_in} {$like} {$or_like} {$not_like} {$or_not_like} {$group_by} {$order_by} {$limit} {$offset}";
485 485
         $this->last_query = $this->row;
486 486
         $data = $this->redbean->getRow($this->row);
487
-        if($data){
488
-            foreach($data as $key=>$row){
487
+        if ($data) {
488
+            foreach ($data as $key=>$row) {
489 489
                 $result[$key] = $row;
490 490
             }
491 491
         }
@@ -497,10 +497,10 @@  discard block
 block discarded – undo
497 497
         return $result;
498 498
     }
499 499
 
500
-    public function num_rows(){
500
+    public function num_rows() {
501 501
         /*init var*/
502
-        $result = 0;#array();
503
-        $select = ($this->select) ? implode(',',$this->select) : '*';
502
+        $result = 0; #array();
503
+        $select = ($this->select) ? implode(',', $this->select) : '*';
504 504
         $order_by = ($this->order_by) ? 'ORDER BY '.$this->order_by : '';
505 505
         $join = ($this->join) ? $this->join : '';
506 506
         $group_by = ($this->group_by) ? $this->group_by : '';
@@ -533,10 +533,10 @@  discard block
 block discarded – undo
533 533
         return $result;
534 534
     }
535 535
 
536
-    public function result(){
536
+    public function result() {
537 537
         /*init var*/
538 538
         $result = array();
539
-        $select = ($this->select) ? implode(',',$this->select) : '*';
539
+        $select = ($this->select) ? implode(',', $this->select) : '*';
540 540
         $order_by = ($this->order_by) ? 'ORDER BY '.$this->order_by : '';
541 541
         $join = ($this->join) ? $this->join : '';
542 542
         $group_by = ($this->group_by) ? $this->group_by : '';
@@ -562,9 +562,9 @@  discard block
 block discarded – undo
562 562
         $this->result = "SELECT {$select} FROM {$table} {$join} {$where} {$or_where} {$where_in} {$or_where_in} {$where_not_in} {$or_where_not_in} {$like} {$or_like} {$not_like} {$or_not_like} {$group_by} {$order_by} {$limit} {$offset}";
563 563
         $this->last_query = $this->result;
564 564
         $data = $this->redbean->getAll($this->result);
565
-        if($data){
566
-            foreach($data as $key=>$row){
567
-                $result[$key] = (object)$row;
565
+        if ($data) {
566
+            foreach ($data as $key=>$row) {
567
+                $result[$key] = (object) $row;
568 568
             }
569 569
         }
570 570
 
@@ -576,146 +576,146 @@  discard block
 block discarded – undo
576 576
     }
577 577
 
578 578
     /*Database*/
579
-    public function wipe($beanType){
579
+    public function wipe($beanType) {
580 580
         $result = $this->redbean->wipe($beanType);
581 581
         return ($result) ? $result : false;
582 582
     }
583 583
 
584
-    public function dispense($data){
584
+    public function dispense($data) {
585 585
         $result = $this->redbean->dispense($data);
586 586
         return ($result) ? true : false;
587 587
     }
588 588
 
589
-    public function store($data){
589
+    public function store($data) {
590 590
         $result = $this->redbean->store($data);
591 591
         return ($result) ? true : false;
592 592
     }
593 593
 
594
-    public function inspect($data){
595
-        if($data){
596
-            if(is_array($data)){
594
+    public function inspect($data) {
595
+        if ($data) {
596
+            if (is_array($data)) {
597 597
 
598 598
                 $result = array();
599
-                foreach($data as $key=>$row){
600
-                    $result[$key]=$this->redbean->inspect($row);
599
+                foreach ($data as $key=>$row) {
600
+                    $result[$key] = $this->redbean->inspect($row);
601 601
                 }
602 602
 
603 603
                 return ($result) ? $result : false;
604 604
 
605
-            }else{
605
+            } else {
606 606
                 $this->redbean->inspect($data);
607 607
                 return true;
608 608
             }
609 609
         }
610 610
     }
611 611
 
612
-    public function get_all_tables(){
612
+    public function get_all_tables() {
613 613
         $result = $this->redbean->inspect();
614 614
         return ($result) ? $result : false;
615 615
     }
616 616
 
617
-    public function select_database($db_name){
617
+    public function select_database($db_name) {
618 618
         $result = $this->redbean->selectDatabase($db_name);
619 619
         return ($result) ? true : false;
620 620
     }
621 621
 
622
-    public function set_database(){
622
+    public function set_database() {
623 623
         $this->redbean->selectDatabase('default');
624 624
         return true;
625 625
     }
626 626
 
627
-    public function begin(){
627
+    public function begin() {
628 628
         $result = $this->redbean->begin();
629 629
         return ($result) ? true : false;
630 630
     }
631 631
 
632
-    public function commit(){
632
+    public function commit() {
633 633
         $result = $this->redbean->commit();
634 634
         return ($result) ? true : false;
635 635
     }
636 636
 
637
-    public function roll_back(){
637
+    public function roll_back() {
638 638
         $result = $this->redbean->rollback();
639 639
         return ($result) ? true : false;
640 640
     }
641 641
 
642
-    public function get_query_count(){
642
+    public function get_query_count() {
643 643
         $this->redbean->getQueryCount();
644 644
         return true;
645 645
     }
646 646
 
647
-    public function get_logs(){
647
+    public function get_logs() {
648 648
         $this->redbean->getLogs();
649 649
         return true;
650 650
     }
651 651
 
652 652
     /*querying*/
653
-    public function exec($data){
653
+    public function exec($data) {
654 654
         $this->redbean->exec($data);
655 655
         return true;
656 656
     }
657 657
 
658
-    public function get_all($table){
658
+    public function get_all($table) {
659 659
         $result = $this->redbean->getAll($table);
660 660
         return ($result) ? $result : false;
661 661
     }
662 662
 
663
-    public function get_row($data){
663
+    public function get_row($data) {
664 664
         $result = $this->redbean->getRow($data);
665 665
         return ($result) ? $result : false;
666 666
     }
667 667
 
668
-    public function get_column($data){
668
+    public function get_column($data) {
669 669
         $result = $this->redbean->getCol($data);
670 670
         return ($result) ? $result : false;
671 671
     }
672 672
 
673
-    public function get_cell($data){
673
+    public function get_cell($data) {
674 674
         $result = $this->redbean->getCell($data);
675 675
         return ($result) ? $result : false;
676 676
     }
677 677
 
678
-    public function get_assoc($data){
678
+    public function get_assoc($data) {
679 679
         $result = $this->redbean->getAssoc($data);
680 680
         return ($result) ? $result : false;
681 681
     }
682 682
 
683
-    public function get_inserted_id(){
683
+    public function get_inserted_id() {
684 684
         $result = $this->redbean->getInsertID();
685 685
         return ($result) ? $result : false;
686 686
     }
687 687
 
688
-    public function convert_to_beans($type,$rows,$metamask=null){
689
-        $result = $this->redbean->convertToBeans( $type, $rows, $metamask );
688
+    public function convert_to_beans($type, $rows, $metamask = null) {
689
+        $result = $this->redbean->convertToBeans($type, $rows, $metamask);
690 690
         return ($result) ? $result : false;
691 691
     }
692 692
 
693 693
     /*Data Tools*/
694
-    public function match_up($type, $sql, $bindings = array(), $onFoundDo = NULL, $onNotFoundDo = NULL, &$bean = NULL){
694
+    public function match_up($type, $sql, $bindings = array(), $onFoundDo = NULL, $onNotFoundDo = NULL, &$bean = NULL) {
695 695
         $result = $this->redbean->matchUp($type, $sql, $bindings, $onFoundDo, $onNotFoundDo, $bean);
696 696
         return ($result) ? $result : false;
697 697
     }
698 698
 
699
-    public function find_all($table){
699
+    public function find_all($table) {
700 700
         $this->redbean->findAll($table);
701 701
         return true;
702 702
     }
703 703
 
704
-    public function find($type,$sql,$bindings){
705
-        $result = $this->redbean->find($type,$sql,$bindings);
704
+    public function find($type, $sql, $bindings) {
705
+        $result = $this->redbean->find($type, $sql, $bindings);
706 706
         return ($result) ? $result : false;
707 707
     }
708 708
 
709 709
     /*Fluid and Frozen*/
710
-    public function freeze($data=null){
711
-        if($data){
710
+    public function freeze($data = null) {
711
+        if ($data) {
712 712
             $data = array();
713
-            foreach($data as $key=>$row){
713
+            foreach ($data as $key=>$row) {
714 714
                 $data[$key] = $row;
715 715
             }
716 716
 
717 717
             $this->redbean->freeze($data);
718
-        }else{
718
+        } else {
719 719
             $this->redbean->freeze(TRUE);
720 720
         }
721 721
         return true;
@@ -723,50 +723,50 @@  discard block
 block discarded – undo
723 723
 
724 724
     /*Debugging*/
725 725
     /*value "true", "false"*/
726
-    public function debug($tf = TRUE, $mode = 0){
727
-        $this->redbean->debug($tf,$mode);
726
+    public function debug($tf = TRUE, $mode = 0) {
727
+        $this->redbean->debug($tf, $mode);
728 728
         return true;
729 729
     }
730 730
 
731
-    public function dump($data){
731
+    public function dump($data) {
732 732
         $this->redbean->dump($data);
733 733
         return true;
734 734
     }
735 735
 
736
-    public function test_connection(){
736
+    public function test_connection() {
737 737
         $this->redbean->testConnection();
738 738
         return true;
739 739
     }
740 740
 
741 741
     /*Aliases*/
742
-    public function load($oodb, $types, $id){
742
+    public function load($oodb, $types, $id) {
743 743
         $this->redbean->load($oodb, $types, $id);
744 744
         return true;
745 745
     }
746 746
 
747 747
     /*Count*/
748
-    public function count($type, $addSQL = '', $bindings = array()){
749
-        $result = $this->redbean->count($type,$addSQL,$bindings);
748
+    public function count($type, $addSQL = '', $bindings = array()) {
749
+        $result = $this->redbean->count($type, $addSQL, $bindings);
750 750
         return ($result) ? $result : false;
751 751
     }
752 752
 
753 753
     /*Labels, Enums, Tags*/
754
-    public function dispense_labels($type,$labels){
755
-        $result = $this->redbean->dispenseLabels($type,$labels);
754
+    public function dispense_labels($type, $labels) {
755
+        $result = $this->redbean->dispenseLabels($type, $labels);
756 756
         return ($result) ? $result : false;
757 757
     }
758 758
 
759
-    public function gather_labels($beans){
759
+    public function gather_labels($beans) {
760 760
         $result = $this->redbean->gatherLabels($beans);
761 761
         return ($result) ? $result : false;
762 762
     }
763 763
 
764
-    public function enum($enum){
764
+    public function enum($enum) {
765 765
         $result = $this->redbean->enum($enum);
766 766
         return ($result) ? $result : false;
767 767
     }
768 768
 
769
-    public function tag($bean, $tagList){
769
+    public function tag($bean, $tagList) {
770 770
         $result = $this->redbean->tag($bean, $tagList);
771 771
         return ($result) ? $result : false;
772 772
     }
Please login to merge, or discard this patch.