Test Failed
Push — master ( 980d37...083cc5 )
by Melquecedec
03:33
created
RedBean.php 1 patch
Braces   +367 added lines, -125 removed lines patch added patch discarded remove patch
@@ -82,7 +82,9 @@  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 ) {
86
+		    return;
87
+		}
86 88
 
87 89
 		foreach ( func_get_args() as $argument ) {
88 90
 			if ( is_array( $argument ) ) {
@@ -100,7 +102,9 @@  discard block
 block discarded – undo
100 102
 				}
101 103
 			}
102 104
 
103
-			if ( $this->mode === self::C_LOGGER_ECHO ) echo "<br>" . PHP_EOL;
105
+			if ( $this->mode === self::C_LOGGER_ECHO ) {
106
+			    echo "<br>" . PHP_EOL;
107
+			}
104 108
 		}
105 109
 	}
106 110
 
@@ -161,7 +165,9 @@  discard block
 block discarded – undo
161 165
 	{
162 166
 		$found = array();
163 167
 		foreach( $this->logs as $logEntry ) {
164
-			if ( strpos( $logEntry, $needle ) !== FALSE ) $found[] = $logEntry;
168
+			if ( strpos( $logEntry, $needle ) !== FALSE ) {
169
+			    $found[] = $logEntry;
170
+			}
165 171
 		}
166 172
 		return $found;
167 173
 	}
@@ -252,7 +258,9 @@  discard block
 block discarded – undo
252 258
 	 */
253 259
 	protected function fillInValue( $value )
254 260
 	{
255
-		if ( is_null( $value ) ) $value = 'NULL';
261
+		if ( is_null( $value ) ) {
262
+		    $value = 'NULL';
263
+		}
256 264
 
257 265
 		$value = strval( $value );
258 266
 		if ( strlen( $value ) > ( $this->strLen ) ) {
@@ -290,7 +298,9 @@  discard block
 block discarded – undo
290 298
 				$highlight = TRUE;
291 299
 			}
292 300
 			if (PHP_SAPI === 'cli' && !self::$noCLI) {
293
-				if ($highlight) echo "\e[91m";
301
+				if ($highlight) {
302
+				    echo "\e[91m";
303
+				}
294 304
 				echo $str, PHP_EOL;
295 305
 				echo "\e[39m";
296 306
 			} else {
@@ -365,7 +375,9 @@  discard block
 block discarded – undo
365 375
 	 */
366 376
 	public function log()
367 377
 	{
368
-		if ( func_num_args() < 1 ) return;
378
+		if ( func_num_args() < 1 ) {
379
+		    return;
380
+		}
369 381
 
370 382
 		$sql = func_get_arg( 0 );
371 383
 
@@ -770,7 +782,9 @@  discard block
 block discarded – undo
770 782
 			//Unfortunately the code field is supposed to be int by default (php)
771 783
 			//So we need a property to convey the SQL State code.
772 784
 			$err = $e->getMessage();
773
-			if ( $this->loggingEnabled && $this->logger ) $this->logger->log( 'An error occurred: ' . $err );
785
+			if ( $this->loggingEnabled && $this->logger ) {
786
+			    $this->logger->log( 'An error occurred: ' . $err );
787
+			}
774 788
 			$exception = new SQL( $err, 0, $e );
775 789
 			$exception->setSQLState( $e->getCode() );
776 790
 			$exception->setDriverDetails( $e->errorInfo );
@@ -945,8 +959,9 @@  discard block
 block discarded – undo
945 959
 	 */
946 960
 	public function getMysqlEncoding( $retCol = FALSE )
947 961
 	{
948
-		if( $retCol )
949
-			return array( 'charset' => $this->mysqlCharset, 'collate' => $this->mysqlCollate );
962
+		if( $retCol ) {
963
+					return array( 'charset' => $this->mysqlCharset, 'collate' => $this->mysqlCollate );
964
+		}
950 965
 		return $this->mysqlCharset;
951 966
 	}
952 967
 
@@ -978,7 +993,9 @@  discard block
 block discarded – undo
978 993
 	 */
979 994
 	public function setMaxIntBind( $max )
980 995
 	{
981
-		if ( !is_integer( $max ) ) throw new RedException( 'Parameter has to be integer.' );
996
+		if ( !is_integer( $max ) ) {
997
+		    throw new RedException( 'Parameter has to be integer.' );
998
+		}
982 999
 		$oldMax = $this->max;
983 1000
 		$this->max = $max;
984 1001
 		return $oldMax;
@@ -995,7 +1012,9 @@  discard block
 block discarded – undo
995 1012
 	 */
996 1013
 	public function connect()
997 1014
 	{
998
-		if ( $this->isConnected ) return;
1015
+		if ( $this->isConnected ) {
1016
+		    return;
1017
+		}
999 1018
 		try {
1000 1019
 			$user = $this->connectInfo['user'];
1001 1020
 			$pass = $this->connectInfo['pass'];
@@ -1624,7 +1643,9 @@  discard block
 block discarded – undo
1624 1643
 			&& $mode !== self::C_ERR_EXCEPTION
1625 1644
 			&& $mode !== self::C_ERR_FUNC
1626 1645
 			&& $mode !== self::C_ERR_FATAL
1627
-		) throw new \Exception( 'Invalid error mode selected' );
1646
+		) {
1647
+		    throw new \Exception( 'Invalid error mode selected' );
1648
+		}
1628 1649
 
1629 1650
 		if ( $mode === self::C_ERR_FUNC && !is_callable( $func ) ) {
1630 1651
 			throw new \Exception( 'Invalid error handler' );
@@ -1729,7 +1750,9 @@  discard block
 block discarded – undo
1729 1750
 	public static function setMetaAll( $beans, $property, $value )
1730 1751
 	{
1731 1752
 		foreach( $beans as $bean ) {
1732
-			if ( $bean instanceof OODBBean ) $bean->__info[ $property ] = $value;
1753
+			if ( $bean instanceof OODBBean ) {
1754
+			    $bean->__info[ $property ] = $value;
1755
+			}
1733 1756
 			if ( $property == 'type' && !empty($bean->beanHelper)) {
1734 1757
 				$bean->__info['model'] = $bean->beanHelper->getModelForBean( $bean );
1735 1758
 			}
@@ -2103,7 +2126,9 @@  discard block
 block discarded – undo
2103 2126
 		$arr = array();
2104 2127
 		if ( $parents ) {
2105 2128
 			foreach ( $this as $key => $value ) {
2106
-				if ( substr( $key, -3 ) != '_id' ) continue;
2129
+				if ( substr( $key, -3 ) != '_id' ) {
2130
+				    continue;
2131
+				}
2107 2132
 
2108 2133
 				$prop = substr( $key, 0, strlen( $key ) - 3 );
2109 2134
 				$this->$prop;
@@ -2115,12 +2140,16 @@  discard block
 block discarded – undo
2115 2140
 				$vn = array();
2116 2141
 
2117 2142
 				foreach ( $value as $i => $b ) {
2118
-					if ( !( $b instanceof OODBBean ) ) continue;
2143
+					if ( !( $b instanceof OODBBean ) ) {
2144
+					    continue;
2145
+					}
2119 2146
 					$vn[] = $b->export( $meta, FALSE, FALSE, $filters );
2120 2147
 					$value = $vn;
2121 2148
 				}
2122 2149
 			} 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;
2150
+					if ( !in_array( strtolower( $value->getMeta( 'type' ) ), $filters ) ) {
2151
+					    continue;
2152
+					}
2124 2153
 				}
2125 2154
 				$value = $value->export( $meta, $parents, FALSE, $filters );
2126 2155
 			}
@@ -2216,7 +2245,9 @@  discard block
 block discarded – undo
2216 2245
 		}
2217 2246
 		unset( $this->properties[$property] );
2218 2247
 		$shadowKey = 'sys.shadow.'.$property;
2219
-		if ( isset( $this->__info[ $shadowKey ] ) ) unset( $this->__info[$shadowKey] );
2248
+		if ( isset( $this->__info[ $shadowKey ] ) ) {
2249
+		    unset( $this->__info[$shadowKey] );
2250
+		}
2220 2251
 		//also clear modifiers
2221 2252
 		$this->clearModifiers();
2222 2253
 		return;
@@ -2398,7 +2429,9 @@  discard block
 block discarded – undo
2398 2429
 	{
2399 2430
 		static $beautifulColumns = array();
2400 2431
 
2401
-		if ( ctype_lower( $property ) ) return $property;
2432
+		if ( ctype_lower( $property ) ) {
2433
+		    return $property;
2434
+		}
2402 2435
 		if (
2403 2436
 			( strpos( $property, 'own' ) === 0 && ctype_upper( substr( $property, 3, 1 ) ) )
2404 2437
 			|| ( strpos( $property, 'xown' ) === 0 && ctype_upper( substr( $property, 4, 1 ) ) )
@@ -3073,7 +3106,9 @@  discard block
 block discarded – undo
3073 3106
 		}
3074 3107
 
3075 3108
 		if ( !is_null( $maxDepth ) ) {
3076
-			if ( !$maxDepth-- ) return $this;
3109
+			if ( !$maxDepth-- ) {
3110
+			    return $this;
3111
+			}
3077 3112
 		}
3078 3113
 
3079 3114
 		$oldFetchType = $this->fetchType;
@@ -3083,9 +3118,13 @@  discard block
 block discarded – undo
3083 3118
 
3084 3119
 		$beans = $this->$property;
3085 3120
 
3086
-		if ( $beans === NULL ) return $this;
3121
+		if ( $beans === NULL ) {
3122
+		    return $this;
3123
+		}
3087 3124
 
3088
-		if ( !is_array( $beans ) ) $beans = array( $beans );
3125
+		if ( !is_array( $beans ) ) {
3126
+		    $beans = array( $beans );
3127
+		}
3089 3128
 
3090 3129
 		foreach( $beans as $bean ) {
3091 3130
 			$function( $bean );
@@ -3311,11 +3350,17 @@  discard block
 block discarded – undo
3311 3350
 	 */
3312 3351
 	public function hasListChanged( $property )
3313 3352
 	{
3314
-		if ( !array_key_exists( $property, $this->properties ) ) return FALSE;
3353
+		if ( !array_key_exists( $property, $this->properties ) ) {
3354
+		    return FALSE;
3355
+		}
3315 3356
 		$diffAdded = array_diff_assoc( $this->properties[$property], $this->__info['sys.shadow.'.$property] );
3316
-		if ( count( $diffAdded ) ) return TRUE;
3357
+		if ( count( $diffAdded ) ) {
3358
+		    return TRUE;
3359
+		}
3317 3360
 		$diffMissing = array_diff_assoc( $this->__info['sys.shadow.'.$property], $this->properties[$property] );
3318
-		if ( count( $diffMissing ) ) return TRUE;
3361
+		if ( count( $diffMissing ) ) {
3362
+		    return TRUE;
3363
+		}
3319 3364
 		return FALSE;
3320 3365
 	}
3321 3366
 
@@ -3645,11 +3690,19 @@  discard block
 block discarded – undo
3645 3690
 		$this->via = NULL;
3646 3691
 		$ids = $beanIndex = $references = array();
3647 3692
 
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.');
3693
+		if ( strlen( $list ) < 4 ) {
3694
+		    throw new RedException('Invalid own-list.');
3695
+		}
3696
+		if ( strpos( $list, 'own') !== 0 ) {
3697
+		    throw new RedException('Only own-lists can be aggregated.');
3698
+		}
3699
+		if ( !ctype_upper( substr( $list, 3, 1 ) ) ) {
3700
+		    throw new RedException('Invalid own-list.');
3701
+		}
3651 3702
 
3652
-		if ( is_null( $type ) ) $type = $property;
3703
+		if ( is_null( $type ) ) {
3704
+		    $type = $property;
3705
+		}
3653 3706
 
3654 3707
 		foreach( $this->$list as $bean ) {
3655 3708
 			$field = $property . '_id';
@@ -4207,7 +4260,9 @@  discard block
 block discarded – undo
4207 4260
 		$assoc = array();
4208 4261
 		
4209 4262
 		foreach ( $rows as $row ) {
4210
-			if ( empty( $row ) ) continue;
4263
+			if ( empty( $row ) ) {
4264
+			    continue;
4265
+			}
4211 4266
 
4212 4267
 			$key   = array_shift( $row );
4213 4268
 			switch ( count( $row ) ) {
@@ -4245,7 +4300,9 @@  discard block
 block discarded – undo
4245 4300
 	{
4246 4301
 		$this->sql = $sql;
4247 4302
 
4248
-		if ( !$noSignal ) $this->signal( 'sql_exec', $this );
4303
+		if ( !$noSignal ) {
4304
+		    $this->signal( 'sql_exec', $this );
4305
+		}
4249 4306
 
4250 4307
 		return $this->db->GetOne( $sql, $bindings );
4251 4308
 	}
@@ -5304,7 +5361,9 @@  discard block
 block discarded – undo
5304 5361
 	public static function renameAssociation( $from, $to = NULL )
5305 5362
 	{
5306 5363
 		if ( is_array( $from ) ) {
5307
-			foreach ( $from as $key => $value ) self::$renames[$key] = $value;
5364
+			foreach ( $from as $key => $value ) {
5365
+			    self::$renames[$key] = $value;
5366
+			}
5308 5367
 
5309 5368
 			return;
5310 5369
 		}
@@ -5491,7 +5550,9 @@  discard block
 block discarded – undo
5491 5550
 	private function putResultInCache( $cacheTag, $key, $values )
5492 5551
 	{
5493 5552
 		if ( isset( $this->cache[$cacheTag] ) ) {
5494
-			if ( count( $this->cache[$cacheTag] ) > $this->maxCacheSizePerType ) array_shift( $this->cache[$cacheTag] );
5553
+			if ( count( $this->cache[$cacheTag] ) > $this->maxCacheSizePerType ) {
5554
+			    array_shift( $this->cache[$cacheTag] );
5555
+			}
5495 5556
 		} else {
5496 5557
 			$this->cache[$cacheTag] = array();
5497 5558
 		}
@@ -5524,17 +5585,22 @@  discard block
 block discarded – undo
5524 5585
 
5525 5586
 		$sqlConditions = array();
5526 5587
 		foreach ( $conditions as $column => $values ) {
5527
-			if ( $values === NULL ) continue;
5588
+			if ( $values === NULL ) {
5589
+			    continue;
5590
+			}
5528 5591
 
5529 5592
 			if ( is_array( $values ) ) {
5530
-				if ( empty( $values ) ) continue;
5593
+				if ( empty( $values ) ) {
5594
+				    continue;
5595
+				}
5531 5596
 			} else {
5532 5597
 				$values = array( $values );
5533 5598
 			}
5534 5599
 
5535 5600
 			$checkOODB = reset( $values );
5536
-			if ( $checkOODB instanceof OODBBean && $checkOODB->getMeta( 'type' ) === $column && substr( $column, -3 ) != '_id' )
5537
-				$column = $column . '_id';
5601
+			if ( $checkOODB instanceof OODBBean && $checkOODB->getMeta( 'type' ) === $column && substr( $column, -3 ) != '_id' ) {
5602
+							$column = $column . '_id';
5603
+			}
5538 5604
 
5539 5605
 
5540 5606
 			$sql = $this->esc( $column );
@@ -5577,7 +5643,9 @@  discard block
 block discarded – undo
5577 5643
 		}
5578 5644
 
5579 5645
 		$addSql = $this->glueSQLCondition( $addSql, !empty( $sqlConditions ) ? QueryWriter::C_GLUE_AND : NULL );
5580
-		if ( $addSql ) $sql .= $addSql;
5646
+		if ( $addSql ) {
5647
+		    $sql .= $addSql;
5648
+		}
5581 5649
 
5582 5650
 		return $sql;
5583 5651
 	}
@@ -5647,7 +5715,9 @@  discard block
 block discarded – undo
5647 5715
 		}
5648 5716
 
5649 5717
 		foreach( $map as $key ) {
5650
-			if ( $key['from'] === $property ) return $key;
5718
+			if ( $key['from'] === $property ) {
5719
+			    return $key;
5720
+			}
5651 5721
 		}
5652 5722
 		return NULL;
5653 5723
 	}
@@ -5860,7 +5930,9 @@  discard block
 block discarded – undo
5860 5930
 			$result = $this->adapter->getCell( "INSERT INTO $table (id) VALUES($default) $suffix" );
5861 5931
 		}
5862 5932
 
5863
-		if ( $suffix ) return $result;
5933
+		if ( $suffix ) {
5934
+		    return $result;
5935
+		}
5864 5936
 
5865 5937
 		$last_id = $this->adapter->getInsertID();
5866 5938
 
@@ -6016,8 +6088,9 @@  discard block
 block discarded – undo
6016 6088
 	 */
6017 6089
 	public function writeJoin( $type, $targetType, $leftRight = 'LEFT' )
6018 6090
 	{
6019
-		if ( $leftRight !== 'LEFT' && $leftRight !== 'RIGHT' && $leftRight !== 'INNER' )
6020
-			throw new RedException( 'Invalid JOIN.' );
6091
+		if ( $leftRight !== 'LEFT' && $leftRight !== 'RIGHT' && $leftRight !== 'INNER' ) {
6092
+					throw new RedException( 'Invalid JOIN.' );
6093
+		}
6021 6094
 
6022 6095
 		$table = $this->esc( $type );
6023 6096
 		$targetTable = $this->esc( $targetType );
@@ -6418,7 +6491,9 @@  discard block
 block discarded – undo
6418 6491
 	 */
6419 6492
 	public function widenColumn( $type, $property, $dataType )
6420 6493
 	{
6421
-		if ( !isset($this->typeno_sqltype[$dataType]) ) return FALSE;
6494
+		if ( !isset($this->typeno_sqltype[$dataType]) ) {
6495
+		    return FALSE;
6496
+		}
6422 6497
 
6423 6498
 		$table   = $this->esc( $type );
6424 6499
 		$column  = $this->esc( $property );
@@ -6527,7 +6602,9 @@  discard block
 block discarded – undo
6527 6602
 		foreach( $keys as $key ) {
6528 6603
 			if (
6529 6604
 				$key['from'] === $field
6530
-			) return $key['table'];
6605
+			) {
6606
+			    return $key['table'];
6607
+			}
6531 6608
 		}
6532 6609
 		return NULL;
6533 6610
 	}
@@ -6760,8 +6837,12 @@  discard block
 block discarded – undo
6760 6837
 	{
6761 6838
 		$this->svalue = $value;
6762 6839
 
6763
-		if ( is_null( $value ) ) return MySQL::C_DATATYPE_BOOL;
6764
-		if ( $value === INF ) return MySQL::C_DATATYPE_TEXT7;
6840
+		if ( is_null( $value ) ) {
6841
+		    return MySQL::C_DATATYPE_BOOL;
6842
+		}
6843
+		if ( $value === INF ) {
6844
+		    return MySQL::C_DATATYPE_TEXT7;
6845
+		}
6765 6846
 
6766 6847
 		if ( $flagSpecial ) {
6767 6848
 			if ( preg_match( '/^-?\d+\.\d{2}$/', $value ) ) {
@@ -6792,7 +6873,9 @@  discard block
 block discarded – undo
6792 6873
 			return MySQL::C_DATATYPE_BOOL;
6793 6874
 		}
6794 6875
 
6795
-		if ( is_float( $value ) ) return self::C_DATATYPE_DOUBLE;
6876
+		if ( is_float( $value ) ) {
6877
+		    return self::C_DATATYPE_DOUBLE;
6878
+		}
6796 6879
 
6797 6880
 		if ( !$this->startsWithZeros( $value ) ) {
6798 6881
 
@@ -6849,7 +6932,9 @@  discard block
 block discarded – undo
6849 6932
 	{
6850 6933
 		$tableNoQ = $this->esc( $type, TRUE );
6851 6934
 		$columns = array();
6852
-		foreach( $properties as $key => $column ) $columns[$key] = $this->esc( $column );
6935
+		foreach( $properties as $key => $column ) {
6936
+		    $columns[$key] = $this->esc( $column );
6937
+		}
6853 6938
 		$table = $this->esc( $type );
6854 6939
 		sort( $columns ); // Else we get multiple indexes due to order-effects
6855 6940
 		$name = 'UQ_' . sha1( implode( ',', $columns ) );
@@ -6895,7 +6980,9 @@  discard block
 block discarded – undo
6895 6980
 		$targetFieldNoQ = $this->esc( $targetProperty, TRUE );
6896 6981
 		$tableNoQ = $this->esc( $type, TRUE );
6897 6982
 		$fieldNoQ = $this->esc( $property, TRUE );
6898
-		if ( !is_null( $this->getForeignKeyForTypeProperty( $tableNoQ, $fieldNoQ ) ) ) return FALSE;
6983
+		if ( !is_null( $this->getForeignKeyForTypeProperty( $tableNoQ, $fieldNoQ ) ) ) {
6984
+		    return FALSE;
6985
+		}
6899 6986
 
6900 6987
 		//Widen the column if it's incapable of representing a foreign key (at least INT).
6901 6988
 		$columns = $this->getColumns( $tableNoQ );
@@ -6945,7 +7032,9 @@  discard block
 block discarded – undo
6945 7032
 	 */
6946 7033
 	public function wipeAll()
6947 7034
 	{
6948
-		if (AQueryWriter::$noNuke) throw new \Exception('The nuke() command has been disabled using noNuke() or R::feature(novice/...).');
7035
+		if (AQueryWriter::$noNuke) {
7036
+		    throw new \Exception('The nuke() command has been disabled using noNuke() or R::feature(novice/...).');
7037
+		}
6949 7038
 		$this->adapter->exec( 'SET FOREIGN_KEY_CHECKS = 0;' );
6950 7039
 
6951 7040
 		foreach ( $this->getTables() as $t ) {
@@ -7052,7 +7141,9 @@  discard block
 block discarded – undo
7052 7141
 
7053 7142
 		$oldColumnNames = array_keys( $this->getColumns( $table ) );
7054 7143
 
7055
-		foreach ( $oldColumnNames as $k => $v ) $oldColumnNames[$k] = "`$v`";
7144
+		foreach ( $oldColumnNames as $k => $v ) {
7145
+		    $oldColumnNames[$k] = "`$v`";
7146
+		}
7056 7147
 
7057 7148
 		$q[] = "CREATE TEMPORARY TABLE tmp_backup(" . implode( ",", $oldColumnNames ) . ");";
7058 7149
 		$q[] = "INSERT INTO tmp_backup SELECT * FROM `$table`;";
@@ -7078,16 +7169,22 @@  discard block
 block discarded – undo
7078 7169
 		foreach ( $tableMap['indexes'] as $name => $index ) {
7079 7170
 			if ( strpos( $name, 'UQ_' ) === 0 ) {
7080 7171
 				$cols = explode( '__', substr( $name, strlen( 'UQ_' . $table ) ) );
7081
-				foreach ( $cols as $k => $v ) $cols[$k] = "`$v`";
7172
+				foreach ( $cols as $k => $v ) {
7173
+				    $cols[$k] = "`$v`";
7174
+				}
7082 7175
 				$q[] = "CREATE UNIQUE INDEX $name ON `$table` (" . implode( ',', $cols ) . ")";
7083
-			} else $q[] = "CREATE INDEX $name ON `$table` ({$index['name']}) ";
7176
+			} else {
7177
+			    $q[] = "CREATE INDEX $name ON `$table` ({$index['name']}) ";
7178
+			}
7084 7179
 		}
7085 7180
 
7086 7181
 		$q[] = "INSERT INTO `$table` SELECT * FROM tmp_backup;";
7087 7182
 		$q[] = "DROP TABLE tmp_backup;";
7088 7183
 		$q[] = "PRAGMA foreign_keys = 1 ";
7089 7184
 
7090
-		foreach ( $q as $sq ) $this->adapter->exec( $sq );
7185
+		foreach ( $q as $sq ) {
7186
+		    $this->adapter->exec( $sq );
7187
+		}
7091 7188
 	}
7092 7189
 
7093 7190
 	/**
@@ -7133,9 +7230,13 @@  discard block
 block discarded – undo
7133 7230
 		$targetColumn    = $this->esc( $targetProperty, TRUE );
7134 7231
 
7135 7232
 		$tables = $this->getTables();
7136
-		if ( !in_array( $targetTable, $tables ) ) return FALSE;
7233
+		if ( !in_array( $targetTable, $tables ) ) {
7234
+		    return FALSE;
7235
+		}
7137 7236
 
7138
-		if ( !is_null( $this->getForeignKeyForTypeProperty( $table, $column ) ) ) return FALSE;
7237
+		if ( !is_null( $this->getForeignKeyForTypeProperty( $table, $column ) ) ) {
7238
+		    return FALSE;
7239
+		}
7139 7240
 		$t = $this->getTable( $table );
7140 7241
 		$consSQL = ( $constraint ? 'CASCADE' : 'SET NULL' );
7141 7242
 		$label   = 'from_' . $column . '_to_table_' . $targetTable . '_col_' . $targetColumn;
@@ -7242,14 +7343,24 @@  discard block
 block discarded – undo
7242 7343
 	{
7243 7344
 		$this->svalue = $value;
7244 7345
 
7245
-		if ( $value === NULL ) return self::C_DATATYPE_INTEGER;
7246
-		if ( $value === INF ) return self::C_DATATYPE_TEXT;
7346
+		if ( $value === NULL ) {
7347
+		    return self::C_DATATYPE_INTEGER;
7348
+		}
7349
+		if ( $value === INF ) {
7350
+		    return self::C_DATATYPE_TEXT;
7351
+		}
7247 7352
 
7248
-		if ( $this->startsWithZeros( $value ) ) return self::C_DATATYPE_TEXT;
7353
+		if ( $this->startsWithZeros( $value ) ) {
7354
+		    return self::C_DATATYPE_TEXT;
7355
+		}
7249 7356
 
7250
-		if ( $value === TRUE || $value === FALSE )  return self::C_DATATYPE_INTEGER;
7357
+		if ( $value === TRUE || $value === FALSE ) {
7358
+		    return self::C_DATATYPE_INTEGER;
7359
+		}
7251 7360
 
7252
-		if ( is_numeric( $value ) && ( intval( $value ) == $value ) && $value < 2147483648 && $value > -2147483648 ) return self::C_DATATYPE_INTEGER;
7361
+		if ( is_numeric( $value ) && ( intval( $value ) == $value ) && $value < 2147483648 && $value > -2147483648 ) {
7362
+		    return self::C_DATATYPE_INTEGER;
7363
+		}
7253 7364
 
7254 7365
 		if ( ( is_numeric( $value ) && $value < 2147483648 && $value > -2147483648)
7255 7366
 			|| preg_match( '/\d{4}\-\d\d\-\d\d/', $value )
@@ -7326,7 +7437,9 @@  discard block
 block discarded – undo
7326 7437
 		$columnsRaw = $this->adapter->get( "PRAGMA table_info('$table')" );
7327 7438
 
7328 7439
 		$columns    = array();
7329
-		foreach ( $columnsRaw as $r ) $columns[$r['name']] = $r['type'];
7440
+		foreach ( $columnsRaw as $r ) {
7441
+		    $columns[$r['name']] = $r['type'];
7442
+		}
7330 7443
 
7331 7444
 		return $columns;
7332 7445
 	}
@@ -7373,7 +7486,9 @@  discard block
 block discarded – undo
7373 7486
 	public function addIndex( $type, $name, $column )
7374 7487
 	{
7375 7488
 		$columns = $this->getColumns( $type );
7376
-		if ( !isset( $columns[$column] ) ) return FALSE;
7489
+		if ( !isset( $columns[$column] ) ) {
7490
+		    return FALSE;
7491
+		}
7377 7492
 
7378 7493
 		$table  = $this->esc( $type );
7379 7494
 		$name   = preg_replace( '/\W/', '', $name );
@@ -7412,7 +7527,9 @@  discard block
 block discarded – undo
7412 7527
 	 */
7413 7528
 	public function wipeAll()
7414 7529
 	{
7415
-		if (AQueryWriter::$noNuke) throw new \Exception('The nuke() command has been disabled using noNuke() or R::feature(novice/...).');
7530
+		if (AQueryWriter::$noNuke) {
7531
+		    throw new \Exception('The nuke() command has been disabled using noNuke() or R::feature(novice/...).');
7532
+		}
7416 7533
 		$this->adapter->exec( 'PRAGMA foreign_keys = 0 ' );
7417 7534
 
7418 7535
 		foreach ( $this->getTables() as $t ) {
@@ -7663,7 +7780,9 @@  discard block
 block discarded – undo
7663 7780
 	{
7664 7781
 		$this->svalue = $value;
7665 7782
 
7666
-		if ( $value === INF ) return self::C_DATATYPE_TEXT;
7783
+		if ( $value === INF ) {
7784
+		    return self::C_DATATYPE_TEXT;
7785
+		}
7667 7786
 
7668 7787
 		if ( $flagSpecial && $value ) {
7669 7788
 			if ( preg_match( '/^\d{4}\-\d\d-\d\d$/', $value ) ) {
@@ -7702,9 +7821,13 @@  discard block
 block discarded – undo
7702 7821
 			}
7703 7822
 		}
7704 7823
 
7705
-		if ( is_float( $value ) ) return self::C_DATATYPE_DOUBLE;
7824
+		if ( is_float( $value ) ) {
7825
+		    return self::C_DATATYPE_DOUBLE;
7826
+		}
7706 7827
 
7707
-		if ( $this->startsWithZeros( $value ) ) return self::C_DATATYPE_TEXT;
7828
+		if ( $this->startsWithZeros( $value ) ) {
7829
+		    return self::C_DATATYPE_TEXT;
7830
+		}
7708 7831
 
7709 7832
 		if ( $value === FALSE || $value === TRUE || $value === NULL || ( is_numeric( $value )
7710 7833
 				&& AQueryWriter::canBeTreatedAsInt( $value )
@@ -7726,7 +7849,9 @@  discard block
 block discarded – undo
7726 7849
 	{
7727 7850
 		$r = ( isset( $this->sqltype_typeno[$typedescription] ) ) ? $this->sqltype_typeno[$typedescription] : 99;
7728 7851
 
7729
-		if ( $includeSpecials ) return $r;
7852
+		if ( $includeSpecials ) {
7853
+		    return $r;
7854
+		}
7730 7855
 
7731 7856
 		if ( $r >= QueryWriter::C_DATATYPE_RANGE_SPECIAL ) {
7732 7857
 			return self::C_DATATYPE_SPECIFIED;
@@ -7758,7 +7883,9 @@  discard block
 block discarded – undo
7758 7883
 	{
7759 7884
 		$tableNoQ = $this->esc( $type, TRUE );
7760 7885
 		$columns = array();
7761
-		foreach( $properties as $key => $column ) $columns[$key] = $this->esc( $column );
7886
+		foreach( $properties as $key => $column ) {
7887
+		    $columns[$key] = $this->esc( $column );
7888
+		}
7762 7889
 		$table = $this->esc( $type );
7763 7890
 		sort( $columns ); //else we get multiple indexes due to order-effects
7764 7891
 		$name = "UQ_" . sha1( $table . implode( ',', $columns ) );
@@ -7814,7 +7941,9 @@  discard block
 block discarded – undo
7814 7941
 		$targetField = $this->esc( $targetProperty );
7815 7942
 		$tableNoQ = $this->esc( $type, TRUE );
7816 7943
 		$fieldNoQ = $this->esc( $property, TRUE );
7817
-		if ( !is_null( $this->getForeignKeyForTypeProperty( $tableNoQ, $fieldNoQ ) ) ) return FALSE;
7944
+		if ( !is_null( $this->getForeignKeyForTypeProperty( $tableNoQ, $fieldNoQ ) ) ) {
7945
+		    return FALSE;
7946
+		}
7818 7947
 		try{
7819 7948
 			$delRule = ( $isDep ? 'CASCADE' : 'SET NULL' );
7820 7949
 			$this->adapter->exec( "ALTER TABLE {$table}
@@ -7831,13 +7960,15 @@  discard block
 block discarded – undo
7831 7960
 	 */
7832 7961
 	public function wipeAll()
7833 7962
 	{
7834
-		if (AQueryWriter::$noNuke) throw new \Exception('The nuke() command has been disabled using noNuke() or R::feature(novice/...).');
7963
+		if (AQueryWriter::$noNuke) {
7964
+		    throw new \Exception('The nuke() command has been disabled using noNuke() or R::feature(novice/...).');
7965
+		}
7835 7966
 		$this->adapter->exec( 'SET CONSTRAINTS ALL DEFERRED' );
7836 7967
 
7837 7968
 		foreach ( $this->getTables() as $t ) {
7838 7969
 			$t = $this->esc( $t );
7839 7970
 			//Some plugins (PostGIS have unremovable tables/views), avoid exceptions.
7840
-			try { $this->adapter->exec( "DROP TABLE IF EXISTS $t CASCADE " ); }catch( \Exception $e ) {}
7971
+			try { $this->adapter->exec( "DROP TABLE IF EXISTS $t CASCADE " ); } catch( \Exception $e ) {}
7841 7972
 		}
7842 7973
 
7843 7974
 		$this->adapter->exec( 'SET CONSTRAINTS ALL IMMEDIATE' );
@@ -7914,7 +8045,9 @@  discard block
 block discarded – undo
7914 8045
 		$column          = $this->esc( $property );
7915 8046
 		$columnNoQ       = $this->esc( $property, TRUE );
7916 8047
 		$targetColumn    = $this->esc( $targetProperty );
7917
-		if ( !is_null( $this->getForeignKeyForTypeProperty( $tableNoQ, $columnNoQ ) ) ) return FALSE;
8048
+		if ( !is_null( $this->getForeignKeyForTypeProperty( $tableNoQ, $columnNoQ ) ) ) {
8049
+		    return FALSE;
8050
+		}
7918 8051
 		$needsToDropFK   = FALSE;
7919 8052
 		$casc = ( $isDep ? 'CASCADE' : 'SET NULL' );
7920 8053
 		$sql  = "ALTER TABLE $table ADD CONSTRAINT FOREIGN KEY($column) REFERENCES $targetTable($targetColumn) ON DELETE $casc ";
@@ -7932,11 +8065,15 @@  discard block
 block discarded – undo
7932 8065
 	protected function getKeyMapForType( $type  )
7933 8066
 	{
7934 8067
 		$sqlCode = $this->adapter->get("SHOW CREATE TABLE `{$type}`");
7935
-		if (!isset($sqlCode[0])) return array();
8068
+		if (!isset($sqlCode[0])) {
8069
+		    return array();
8070
+		}
7936 8071
 		$matches = array();
7937 8072
 		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 8073
 		$list = array();
7939
-		if (!isset($matches[0])) return $list;
8074
+		if (!isset($matches[0])) {
8075
+		    return $list;
8076
+		}
7940 8077
 		$max = count($matches[0]);
7941 8078
 		for($i = 0; $i < $max; $i++) {
7942 8079
 			$label = $this->makeFKLabel( $matches[2][$i], $matches[3][$i], 'id' );
@@ -8134,7 +8271,9 @@  discard block
 block discarded – undo
8134 8271
 	{
8135 8272
 		$tableNoQ = $this->esc( $type, TRUE );
8136 8273
 		$columns = array();
8137
-		foreach( $properties as $key => $column ) $columns[$key] = $this->esc( $column );
8274
+		foreach( $properties as $key => $column ) {
8275
+		    $columns[$key] = $this->esc( $column );
8276
+		}
8138 8277
 		$table = $this->esc( $type );
8139 8278
 		sort( $columns ); // else we get multiple indexes due to order-effects
8140 8279
 		$name = 'UQ_' . sha1( implode( ',', $columns ) );
@@ -8188,7 +8327,9 @@  discard block
 block discarded – undo
8188 8327
 	 */
8189 8328
 	public function wipeAll()
8190 8329
 	{
8191
-		if (AQueryWriter::$noNuke) throw new \Exception('The nuke() command has been disabled using noNuke() or R::feature(novice/...).');
8330
+		if (AQueryWriter::$noNuke) {
8331
+		    throw new \Exception('The nuke() command has been disabled using noNuke() or R::feature(novice/...).');
8332
+		}
8192 8333
 		foreach ( $this->getTables() as $t ) {
8193 8334
 			foreach ( $this->getKeyMapForType( $t ) as $k ) {
8194 8335
 				$this->adapter->exec( "ALTER TABLE \"$t\" DROP FOREIGN KEY \"{$k['name']}\"" );
@@ -8219,7 +8360,9 @@  discard block
 block discarded – undo
8219 8360
 		foreach( $keys as $key ) {
8220 8361
 			if (
8221 8362
 				$key['from'] === $field
8222
-			) return $key['table'];
8363
+			) {
8364
+			    return $key['table'];
8365
+			}
8223 8366
 		}
8224 8367
 		return NULL;
8225 8368
 	}
@@ -8545,7 +8688,9 @@  discard block
 block discarded – undo
8545 8688
 
8546 8689
 			$myFieldLink = $bean->getMeta( 'type' ) . '_id';
8547 8690
 			$alias = $bean->getMeta( 'sys.alias.' . $trash->getMeta( 'type' ) );
8548
-			if ( $alias ) $myFieldLink = $alias . '_id';
8691
+			if ( $alias ) {
8692
+			    $myFieldLink = $alias . '_id';
8693
+			}
8549 8694
 
8550 8695
 			if ( $trash->getMeta( 'sys.garbage' ) === TRUE ) {
8551 8696
 				$this->trash( $trash );
@@ -8635,7 +8780,9 @@  discard block
 block discarded – undo
8635 8780
 			$this->store( $value );
8636 8781
 		}
8637 8782
 		$id = $value->id;
8638
-		if ($bean->$linkField != $id) $bean->$linkField = $id;
8783
+		if ($bean->$linkField != $id) {
8784
+		    $bean->$linkField = $id;
8785
+		}
8639 8786
 		$bean->setMeta( 'cast.' . $linkField, 'id' );
8640 8787
 		$embeddedBeans[$linkField] = $value;
8641 8788
 		unset( $bean->$property );
@@ -8878,7 +9025,9 @@  discard block
 block discarded – undo
8878 9025
 	public function convertToBeans( $type, $rows, $mask = NULL )
8879 9026
 	{
8880 9027
 		$masklen = 0;
8881
-		if ( $mask !== NULL ) $masklen = mb_strlen( $mask );
9028
+		if ( $mask !== NULL ) {
9029
+		    $masklen = mb_strlen( $mask );
9030
+		}
8882 9031
 
8883 9032
 		$collection                  = array();
8884 9033
 		$this->stash[$this->nesting] = array();
@@ -9184,7 +9333,9 @@  discard block
 block discarded – undo
9184 9333
 
9185 9334
 				$myFieldLink = $beanType . '_id';
9186 9335
 				$alias = $bean->getMeta( 'sys.alias.' . $addition->getMeta( 'type' ) );
9187
-				if ( $alias ) $myFieldLink = $alias . '_id';
9336
+				if ( $alias ) {
9337
+				    $myFieldLink = $alias . '_id';
9338
+				}
9188 9339
 
9189 9340
 				$addition->$myFieldLink = $bean->id;
9190 9341
 				$addition->setMeta( 'cast.' . $myFieldLink, 'id' );
@@ -9229,7 +9380,9 @@  discard block
 block discarded – undo
9229 9380
 
9230 9381
 			$columnCache = NULL;
9231 9382
 			foreach ( $bean as $property => $value ) {
9232
-				if ( $partial && !in_array( $property, $mask ) ) continue;
9383
+				if ( $partial && !in_array( $property, $mask ) ) {
9384
+				    continue;
9385
+				}
9233 9386
 				if ( $property !== 'id' ) {
9234 9387
 					$this->modifySchema( $bean, $property, $value, $columnCache );
9235 9388
 				}
@@ -9448,7 +9601,9 @@  discard block
 block discarded – undo
9448 9601
 			}
9449 9602
 
9450 9603
 			foreach( $properties as $key => $value ) {
9451
-				if ( $partial && !in_array( $key, $mask ) ) continue;
9604
+				if ( $partial && !in_array( $key, $mask ) ) {
9605
+				    continue;
9606
+				}
9452 9607
 				$updateValues[] = array( $k1 => $key, $k2 => $value );
9453 9608
 			}
9454 9609
 			$bean->id = $this->writer->updateRecord( $table, $updateValues, $id );
@@ -9485,7 +9640,9 @@  discard block
 block discarded – undo
9485 9640
 
9486 9641
 				$myFieldLink = $beanType . '_id';
9487 9642
 				$alias = $bean->getMeta( 'sys.alias.' . $addition->getMeta( 'type' ) );
9488
-				if ( $alias ) $myFieldLink = $alias . '_id';
9643
+				if ( $alias ) {
9644
+				    $myFieldLink = $alias . '_id';
9645
+				}
9489 9646
 
9490 9647
 				$addition->$myFieldLink = $bean->id;
9491 9648
 				$addition->setMeta( 'cast.' . $myFieldLink, 'id' );
@@ -9830,7 +9987,9 @@  discard block
 block discarded – undo
9830 9987
 	public function dispense( $type, $number = 1, $alwaysReturnArray = FALSE )
9831 9988
 	{
9832 9989
 		if ( $number < 1 ) {
9833
-			if ( $alwaysReturnArray ) return array();
9990
+			if ( $alwaysReturnArray ) {
9991
+			    return array();
9992
+			}
9834 9993
 			return NULL;
9835 9994
 		}
9836 9995
 
@@ -10130,8 +10289,12 @@  discard block
 block discarded – undo
10130 10289
 		list( $type, $property ) = explode( '.', $field );
10131 10290
 		$mode = ($mode === 'write') ? QueryWriter::C_SQLFILTER_WRITE : QueryWriter::C_SQLFILTER_READ;
10132 10291
 
10133
-		if ( !isset( self::$sqlFilters[$mode] ) ) self::$sqlFilters[$mode] = array();
10134
-		if ( !isset( self::$sqlFilters[$mode][$type] ) ) self::$sqlFilters[$mode][$type] = array();
10292
+		if ( !isset( self::$sqlFilters[$mode] ) ) {
10293
+		    self::$sqlFilters[$mode] = array();
10294
+		}
10295
+		if ( !isset( self::$sqlFilters[$mode][$type] ) ) {
10296
+		    self::$sqlFilters[$mode][$type] = array();
10297
+		}
10135 10298
 
10136 10299
 		if ( is_null( $function ) ) {
10137 10300
 			unset( self::$sqlFilters[$mode][$type][$property] );
@@ -10715,10 +10878,14 @@  discard block
 block discarded – undo
10715 10878
 	 */
10716 10879
 	public function findMulti( $types, $sql = NULL, $bindings = array(), $remappings = array(), $queryTemplate = ' %s.%s AS %s__%s' )
10717 10880
 	{
10718
-		if ( !is_array( $types ) ) $types = array_map( 'trim', explode( ',', $types ) );
10881
+		if ( !is_array( $types ) ) {
10882
+		    $types = array_map( 'trim', explode( ',', $types ) );
10883
+		}
10719 10884
 		if ( is_null( $sql ) ) {
10720 10885
 			$beans = array();
10721
-			foreach( $types as $type ) $beans[$type] = $this->redbean->find( $type );
10886
+			foreach( $types as $type ) {
10887
+			    $beans[$type] = $this->redbean->find( $type );
10888
+			}
10722 10889
 		} else {
10723 10890
 			if ( !is_array( $sql ) ) {
10724 10891
 				$writer = $this->toolbox->getWriter();
@@ -10759,8 +10926,12 @@  discard block
 block discarded – undo
10759 10926
 							$wannaBean[$property] = $value;
10760 10927
 						}
10761 10928
 					}
10762
-					if ( !isset( $wannaBean['id'] ) ) continue;
10763
-					if ( is_null( $wannaBean['id'] ) ) continue;
10929
+					if ( !isset( $wannaBean['id'] ) ) {
10930
+					    continue;
10931
+					}
10932
+					if ( is_null( $wannaBean['id'] ) ) {
10933
+					    continue;
10934
+					}
10764 10935
 					$wannaBeans[$type][$wannaBean['id']] = $wannaBean;
10765 10936
 				}
10766 10937
 			}
@@ -10780,7 +10951,9 @@  discard block
 block discarded – undo
10780 10951
 			$do      = $remapping['do'];
10781 10952
 			foreach( $beans[$a] as $bean ) {
10782 10953
 				foreach( $beans[$b] as $putBean ) {
10783
-					if ( $matcher( $bean, $putBean, $beans ) ) $do( $bean, $putBean, $beans, $remapping );
10954
+					if ( $matcher( $bean, $putBean, $beans ) ) {
10955
+					    $do( $bean, $putBean, $beans, $remapping );
10956
+					}
10784 10957
 				}
10785 10958
 			}
10786 10959
 		}
@@ -11137,13 +11310,17 @@  discard block
 block discarded – undo
11137 11310
 		$links = array();
11138 11311
 
11139 11312
 		foreach ( $rows as $key => $row ) {
11140
-			if ( !isset( $links[$row['id']] ) ) $links[$row['id']] = array();
11313
+			if ( !isset( $links[$row['id']] ) ) {
11314
+			    $links[$row['id']] = array();
11315
+			}
11141 11316
 			$links[$row['id']][] = $row['linked_by'];
11142 11317
 			unset( $rows[$key]['linked_by'] );
11143 11318
 		}
11144 11319
 
11145 11320
 		$beans = $this->oodb->convertToBeans( $type, $rows );
11146
-		foreach ( $beans as $bean ) $bean->setMeta( 'sys.belongs-to', $links[$bean->id] );
11321
+		foreach ( $beans as $bean ) {
11322
+		    $bean->setMeta( 'sys.belongs-to', $links[$bean->id] );
11323
+		}
11147 11324
 
11148 11325
 		return $beans;
11149 11326
 	}
@@ -12056,7 +12233,9 @@  discard block
 block discarded – undo
12056 12233
 		}
12057 12234
 
12058 12235
 		foreach( $values as $enumItem ) {
12059
-				if ( $enumItem->name === $value ) return $enumItem;
12236
+				if ( $enumItem->name === $value ) {
12237
+				    return $enumItem;
12238
+				}
12060 12239
 		}
12061 12240
 
12062 12241
 		$newEnumItems = $this->dispenseLabels( $type, array( $value ) );
@@ -12264,7 +12443,9 @@  discard block
 block discarded – undo
12264 12443
 	 */
12265 12444
 	public static function testConnection()
12266 12445
 	{
12267
-		if ( !isset( self::$adapter ) ) return FALSE;
12446
+		if ( !isset( self::$adapter ) ) {
12447
+		    return FALSE;
12448
+		}
12268 12449
 
12269 12450
 		$database = self::$adapter->getDatabase();
12270 12451
 		try {
@@ -12722,7 +12903,9 @@  discard block
 block discarded – undo
12722 12903
 	 */
12723 12904
 	public static function load( $type, $id, $snippet = NULL )
12724 12905
 	{
12725
-		if ( $snippet !== NULL ) self::$writer->setSQLSelectSnippet( $snippet );
12906
+		if ( $snippet !== NULL ) {
12907
+		    self::$writer->setSQLSelectSnippet( $snippet );
12908
+		}
12726 12909
 		$bean = self::$redbean->load( $type, $id );
12727 12910
 		return $bean;
12728 12911
 	}
@@ -12783,7 +12966,9 @@  discard block
 block discarded – undo
12783 12966
 	 */
12784 12967
 	public static function trash( $beanOrType, $id = NULL )
12785 12968
 	{
12786
-		if ( is_string( $beanOrType ) ) return self::trash( self::load( $beanOrType, $id ) );
12969
+		if ( is_string( $beanOrType ) ) {
12970
+		    return self::trash( self::load( $beanOrType, $id ) );
12971
+		}
12787 12972
 		return self::$redbean->trash( $beanOrType );
12788 12973
 	}
12789 12974
 
@@ -13372,7 +13557,9 @@  discard block
 block discarded – undo
13372 13557
 	 */
13373 13558
 	public static function useExportCase( $caseStyle = 'default' )
13374 13559
 	{
13375
-		if ( !in_array( $caseStyle, array( 'default', 'camel', 'dolphin' ) ) ) throw new RedException( 'Invalid case selected.' );
13560
+		if ( !in_array( $caseStyle, array( 'default', 'camel', 'dolphin' ) ) ) {
13561
+		    throw new RedException( 'Invalid case selected.' );
13562
+		}
13376 13563
 		self::$exportCaseStyle = $caseStyle;
13377 13564
 	}
13378 13565
 
@@ -13746,7 +13933,9 @@  discard block
 block discarded – undo
13746 13933
 	 */
13747 13934
 	public static function begin()
13748 13935
 	{
13749
-		if ( !self::$allowFluidTransactions && !self::$redbean->isFrozen() ) return FALSE;
13936
+		if ( !self::$allowFluidTransactions && !self::$redbean->isFrozen() ) {
13937
+		    return FALSE;
13938
+		}
13750 13939
 		self::$adapter->startTransaction();
13751 13940
 		return TRUE;
13752 13941
 	}
@@ -13787,7 +13976,9 @@  discard block
 block discarded – undo
13787 13976
 	 */
13788 13977
 	public static function commit()
13789 13978
 	{
13790
-		if ( !self::$allowFluidTransactions && !self::$redbean->isFrozen() ) return FALSE;
13979
+		if ( !self::$allowFluidTransactions && !self::$redbean->isFrozen() ) {
13980
+		    return FALSE;
13981
+		}
13791 13982
 		self::$adapter->commit();
13792 13983
 		return TRUE;
13793 13984
 	}
@@ -13828,7 +14019,9 @@  discard block
 block discarded – undo
13828 14019
 	 */
13829 14020
 	public static function rollback()
13830 14021
 	{
13831
-		if ( !self::$allowFluidTransactions && !self::$redbean->isFrozen() ) return FALSE;
14022
+		if ( !self::$allowFluidTransactions && !self::$redbean->isFrozen() ) {
14023
+		    return FALSE;
14024
+		}
13832 14025
 		self::$adapter->rollback();
13833 14026
 		return TRUE;
13834 14027
 	}
@@ -14146,7 +14339,9 @@  discard block
 block discarded – undo
14146 14339
 	 */
14147 14340
 	public static function isoDateTime( $time = NULL )
14148 14341
 	{
14149
-		if ( !$time ) $time = time();
14342
+		if ( !$time ) {
14343
+		    $time = time();
14344
+		}
14150 14345
 		return @date( 'Y-m-d H:i:s', $time );
14151 14346
 	}
14152 14347
 
@@ -14220,10 +14415,16 @@  discard block
 block discarded – undo
14220 14415
 	public static function getPDO()
14221 14416
 	{
14222 14417
 		$databaseAdapter = self::getDatabaseAdapter();
14223
-		if ( is_null( $databaseAdapter ) ) return NULL;
14418
+		if ( is_null( $databaseAdapter ) ) {
14419
+		    return NULL;
14420
+		}
14224 14421
 		$database = $databaseAdapter->getDatabase();
14225
-		if ( is_null( $database ) ) return NULL;
14226
-		if ( !method_exists( $database, 'getPDO' ) ) return NULL;
14422
+		if ( is_null( $database ) ) {
14423
+		    return NULL;
14424
+		}
14425
+		if ( !method_exists( $database, 'getPDO' ) ) {
14426
+		    return NULL;
14427
+		}
14227 14428
 		return $database->getPDO();
14228 14429
 	}
14229 14430
 
@@ -14319,7 +14520,9 @@  discard block
 block discarded – undo
14319 14520
 	public static function beansToArray( $beans )
14320 14521
 	{
14321 14522
 		$list = array();
14322
-		foreach( $beans as $bean ) $list[] = $bean->export();
14523
+		foreach( $beans as $bean ) {
14524
+		    $list[] = $bean->export();
14525
+		}
14323 14526
 		return $list;
14324 14527
 	}
14325 14528
 
@@ -15308,7 +15511,9 @@  discard block
 block discarded – undo
15308 15511
 	 */
15309 15512
 	protected function duplicate( OODBBean $bean, $trail = array(), $preserveIDs = FALSE )
15310 15513
 	{
15311
-		if ( $this->inTrailOrAdd( $trail, $bean ) ) return $bean;
15514
+		if ( $this->inTrailOrAdd( $trail, $bean ) ) {
15515
+		    return $bean;
15516
+		}
15312 15517
 
15313 15518
 		$type = $bean->getMeta( 'type' );
15314 15519
 
@@ -15316,7 +15521,9 @@  discard block
 block discarded – undo
15316 15521
 		foreach ( $this->tables as $table ) {
15317 15522
 
15318 15523
 			if ( !empty( $this->filters ) ) {
15319
-				if ( !in_array( $table, $this->filters ) ) continue;
15524
+				if ( !in_array( $table, $this->filters ) ) {
15525
+				    continue;
15526
+				}
15320 15527
 			}
15321 15528
 
15322 15529
 			list( $owned, $shared ) = $this->getListNames( $table );
@@ -15550,8 +15757,12 @@  discard block
 block discarded – undo
15550 15757
 			$duplicate = $this->dup( $bean, array(), TRUE );
15551 15758
 			$array[]   = $duplicate->export( FALSE, $parents, FALSE, $filters );
15552 15759
 		}
15553
-		if ( $caseStyle === 'camel' ) $array = $this->camelfy( $array );
15554
-		if ( $caseStyle === 'dolphin' ) $array = $this->camelfy( $array, TRUE );
15760
+		if ( $caseStyle === 'camel' ) {
15761
+		    $array = $this->camelfy( $array );
15762
+		}
15763
+		if ( $caseStyle === 'dolphin' ) {
15764
+		    $array = $this->camelfy( $array, TRUE );
15765
+		}
15555 15766
 		return $array;
15556 15767
 	}
15557 15768
 }
@@ -15638,8 +15849,11 @@  discard block
 block discarded – undo
15638 15849
 	public static function flat( $array, $result = array() )
15639 15850
 	{		
15640 15851
 		foreach( $array as $value ) {
15641
-			if ( is_array( $value ) ) $result = self::flat( $value, $result );
15642
-			else $result[] = $value;
15852
+			if ( is_array( $value ) ) {
15853
+			    $result = self::flat( $value, $result );
15854
+			} else {
15855
+			    $result[] = $value;
15856
+			}
15643 15857
 		}
15644 15858
 		return $result;
15645 15859
 	}
@@ -15783,7 +15997,9 @@  discard block
 block discarded – undo
15783 15997
 						throw new RedException( 'Invalid Array Bean' );
15784 15998
 					}
15785 15999
 				}
15786
-				foreach( $typeOrBeanArray as $beanArray ) $list[] = self::dispense( $oodb, $beanArray );
16000
+				foreach( $typeOrBeanArray as $beanArray ) {
16001
+				    $list[] = self::dispense( $oodb, $beanArray );
16002
+				}
15787 16003
 				return $list;
15788 16004
 			}
15789 16005
 
@@ -15794,7 +16010,9 @@  discard block
 block discarded – undo
15794 16010
 			$type = $typeOrBeanArray;
15795 16011
 		}
15796 16012
 
15797
-		if (self::$enforceNamingPolicy) self::checkType( $type );
16013
+		if (self::$enforceNamingPolicy) {
16014
+		    self::checkType( $type );
16015
+		}
15798 16016
 
15799 16017
 		$beanOrBeans = $oodb->dispense( $type, $num, $alwaysReturnArray );
15800 16018
 
@@ -16179,10 +16397,18 @@  discard block
 block discarded – undo
16179 16397
 		list( $delimiter, $enclosure, $escapeChar ) = $options;
16180 16398
 		$path = sprintf( $path, date('Ymd_his') );
16181 16399
 		$handle = fopen( $path, 'w' );
16182
-		if ($columns) if (PHP_VERSION_ID>=505040) fputcsv($handle, $columns, $delimiter, $enclosure, $escapeChar ); else fputcsv($handle, $columns, $delimiter, $enclosure );
16400
+		if ($columns) {
16401
+		    if (PHP_VERSION_ID>=505040) fputcsv($handle, $columns, $delimiter, $enclosure, $escapeChar );
16402
+		} else {
16403
+		    fputcsv($handle, $columns, $delimiter, $enclosure );
16404
+		}
16183 16405
 		$cursor = $this->toolbox->getDatabaseAdapter()->getCursor( $sql, $bindings );
16184 16406
 		while( $row = $cursor->getNextItem() ) {
16185
-			if (PHP_VERSION_ID>=505040) fputcsv($handle, $row, $delimiter, $enclosure, $escapeChar ); else fputcsv($handle, $row, $delimiter, $enclosure );
16407
+			if (PHP_VERSION_ID>=505040) {
16408
+			    fputcsv($handle, $row, $delimiter, $enclosure, $escapeChar );
16409
+			} else {
16410
+			    fputcsv($handle, $row, $delimiter, $enclosure );
16411
+			}
16186 16412
 		}
16187 16413
 		fclose($handle);
16188 16414
 		if ( $output ) {
@@ -16493,18 +16719,34 @@  discard block
 block discarded – undo
16493 16719
 	public function diff( $beans, $others, $filters = array( 'created', 'modified' ), $format = '%s.%s.%s', $type = NULL )
16494 16720
 	{
16495 16721
 		$diff = array();
16496
-		if ( !is_array( $beans ) ) $beans = array( $beans );
16497
-		if ( !is_array( $others ) ) $others = array( $others );
16722
+		if ( !is_array( $beans ) ) {
16723
+		    $beans = array( $beans );
16724
+		}
16725
+		if ( !is_array( $others ) ) {
16726
+		    $others = array( $others );
16727
+		}
16498 16728
 		foreach( $beans as $bean ) {
16499
-			if ( !is_object( $bean ) ) continue;
16500
-			if ( !( $bean instanceof OODBBean ) ) continue;
16501
-			if ( $type == NULL ) $type = $bean->getMeta( 'type' );
16729
+			if ( !is_object( $bean ) ) {
16730
+			    continue;
16731
+			}
16732
+			if ( !( $bean instanceof OODBBean ) ) {
16733
+			    continue;
16734
+			}
16735
+			if ( $type == NULL ) {
16736
+			    $type = $bean->getMeta( 'type' );
16737
+			}
16502 16738
 			foreach( $others as $other ) {
16503
-				if ( !is_object( $other ) ) continue;
16504
-				if ( !( $other instanceof OODBBean ) ) continue;
16739
+				if ( !is_object( $other ) ) {
16740
+				    continue;
16741
+				}
16742
+				if ( !( $other instanceof OODBBean ) ) {
16743
+				    continue;
16744
+				}
16505 16745
 				if ( $other->id == $bean->id ) {
16506 16746
 					foreach( $bean as $property => $value ) {
16507
-						if ( in_array( $property, $filters ) ) continue;
16747
+						if ( in_array( $property, $filters ) ) {
16748
+						    continue;
16749
+						}
16508 16750
 						$key = vsprintf( $format, array( $type, $bean->id, $property ) );
16509 16751
 						$compare = $other->{$property};
16510 16752
 						if ( !is_object( $value ) && !is_array( $value ) ) {
Please login to merge, or discard this patch.
OctaORM.php 1 patch
Braces   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
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
                 }
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
                             $data->$row = $table_fields_val[$key];
150 150
                         }
151 151
 
152
-                    }else{
152
+                    } else{
153 153
                         return false;
154 154
                     }
155 155
 
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 
171 171
                 return true;
172 172
 
173
-            }else{
173
+            } else{
174 174
                 $this->redbean->trash($table,$id);
175 175
                 return true;
176 176
             }
@@ -207,12 +207,12 @@  discard block
 block discarded – undo
207 207
                     foreach($data as $key=>$row){
208 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
             }
@@ -234,12 +234,12 @@  discard block
 block discarded – undo
234 234
                     foreach($data as $key=>$row){
235 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
             }
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
             foreach($data as $key=>$row){
256 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
             }
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
             foreach($data as $key=>$row){
272 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
             }
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
             foreach($data as $key=>$row){
288 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
             }
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
             foreach($data as $key=>$row){
304 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
             }
@@ -325,12 +325,12 @@  discard block
 block discarded – undo
325 325
                     foreach($data as $key=>$row){
326 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
             }
@@ -351,12 +351,12 @@  discard block
 block discarded – undo
351 351
                     foreach($data as $key=>$row){
352 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
         }
@@ -377,12 +377,12 @@  discard block
 block discarded – undo
377 377
                     foreach($data as $key=>$row){
378 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
             }
@@ -403,12 +403,12 @@  discard block
 block discarded – undo
403 403
                     foreach($data as $key=>$row){
404 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
         }
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
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
             }
@@ -715,7 +715,7 @@  discard block
 block discarded – undo
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;
Please login to merge, or discard this patch.