@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | */ |
118 | 118 | public function getCondition() |
119 | 119 | { |
120 | - return isset($this->_relation[3])?$this->_relation[3]:null; |
|
120 | + return isset($this->_relation[3]) ? $this->_relation[3] : null; |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function getParameters() |
128 | 128 | { |
129 | - return isset($this->_relation[4])?$this->_relation[4]:[]; |
|
129 | + return isset($this->_relation[4]) ? $this->_relation[4] : []; |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -112,8 +112,7 @@ discard block |
||
112 | 112 | if(count($collections[$hash]) > 1) |
113 | 113 | throw new TActiveRecordException('ar_belongs_to_multiple_result'); |
114 | 114 | $source->$prop = $collections[$hash][0]; |
115 | - } |
|
116 | - else |
|
115 | + } else |
|
117 | 116 | $source->$prop = null; |
118 | 117 | } |
119 | 118 | |
@@ -130,8 +129,9 @@ discard block |
||
130 | 129 | $fkObject->save(); |
131 | 130 | $source = $this->getSourceRecord(); |
132 | 131 | $fkeys = $this->findForeignKeys($source, $fkObject); |
133 | - foreach($fkeys as $srcKey => $fKey) |
|
134 | - $source->setColumnValue($srcKey, $fkObject->getColumnValue($fKey)); |
|
132 | + foreach($fkeys as $srcKey => $fKey) { |
|
133 | + $source->setColumnValue($srcKey, $fkObject->getColumnValue($fKey)); |
|
134 | + } |
|
135 | 135 | return true; |
136 | 136 | } |
137 | 137 | return false; |
@@ -59,8 +59,9 @@ discard block |
||
59 | 59 | protected function getRecordPropertyValues($record) |
60 | 60 | { |
61 | 61 | $data = []; |
62 | - foreach($this->getTableInfo()->getColumns() as $name => $column) |
|
63 | - $data[] = $record->getColumnValue($name); |
|
62 | + foreach($this->getTableInfo()->getColumns() as $name => $column) { |
|
63 | + $data[] = $record->getColumnValue($name); |
|
64 | + } |
|
64 | 65 | return $data; |
65 | 66 | } |
66 | 67 | |
@@ -132,8 +133,7 @@ discard block |
||
132 | 133 | if($this->_record === null) |
133 | 134 | throw new TConfigurationException('scaffold_invalid_record_pk', |
134 | 135 | $this->getRecordClass(), $pk); |
135 | - } |
|
136 | - else |
|
136 | + } else |
|
137 | 137 | { |
138 | 138 | $class = $this->getRecordClass(); |
139 | 139 | if($class !== null) |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | { |
18 | 18 | protected function createControl($container, $column, $record) |
19 | 19 | { |
20 | - $dbtype = trim(str_replace(['unsigned', 'zerofill'], ['','',], strtolower($column->getDbType()))); |
|
20 | + $dbtype = trim(str_replace(['unsigned', 'zerofill'], ['', '', ], strtolower($column->getDbType()))); |
|
21 | 21 | switch($dbtype) |
22 | 22 | { |
23 | 23 | case 'date': |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | |
47 | 47 | protected function getControlValue($container, $column, $record) |
48 | 48 | { |
49 | - $dbtype = trim(str_replace(['unsigned', 'zerofill'], ['','',], strtolower($column->getDbType()))); |
|
49 | + $dbtype = trim(str_replace(['unsigned', 'zerofill'], ['', '', ], strtolower($column->getDbType()))); |
|
50 | 50 | switch($dbtype) |
51 | 51 | { |
52 | 52 | case 'date': |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | protected function getIntBooleanValue($container, $column, $record) |
80 | 80 | { |
81 | 81 | if($column->getColumnSize() == 1) |
82 | - return (int)$container->findControl(self::DEFAULT_ID)->getChecked(); |
|
82 | + return (int) $container->findControl(self::DEFAULT_ID)->getChecked(); |
|
83 | 83 | else |
84 | 84 | return $this->getDefaultControlValue($container, $column, $record); |
85 | 85 | } |
@@ -93,8 +93,9 @@ discard block |
||
93 | 93 | $years = []; |
94 | 94 | $current = intval(@date('Y')); |
95 | 95 | $from = $current - 10; $to = $current + 10; |
96 | - for($i = $from; $i <= $to; $i++) |
|
97 | - $years[$i] = $i; |
|
96 | + for($i = $from; $i <= $to; $i++) { |
|
97 | + $years[$i] = $i; |
|
98 | + } |
|
98 | 99 | $control->setDataSource($years); |
99 | 100 | $control->setSelectedValue(empty($value) ? $current : $value); |
100 | 101 | $control->setCssClass('year-dropdown'); |
@@ -169,9 +170,13 @@ discard block |
||
169 | 170 | { |
170 | 171 | $value = $this->getRecordPropertyValue($column, $record); |
171 | 172 | $hours = []; |
172 | - for($i = 0;$i < 24;$i++) $hours[] = str_pad($i, 2, '0', STR_PAD_LEFT); |
|
173 | + for($i = 0;$i < 24;$i++) { |
|
174 | + $hours[] = str_pad($i, 2, '0', STR_PAD_LEFT); |
|
175 | + } |
|
173 | 176 | $mins = []; |
174 | - for($i = 0;$i < 60;$i++) $mins[] = str_pad($i, 2, '0', STR_PAD_LEFT); |
|
177 | + for($i = 0;$i < 60;$i++) { |
|
178 | + $mins[] = str_pad($i, 2, '0', STR_PAD_LEFT); |
|
179 | + } |
|
175 | 180 | $hour = intval(@date('H')); |
176 | 181 | $min = intval(@date('i')); |
177 | 182 | $sec = intval(@date('s')); |
@@ -169,9 +169,9 @@ discard block |
||
169 | 169 | { |
170 | 170 | $value = $this->getRecordPropertyValue($column, $record); |
171 | 171 | $hours = []; |
172 | - for($i = 0;$i < 24;$i++) $hours[] = str_pad($i, 2, '0', STR_PAD_LEFT); |
|
172 | + for($i = 0; $i < 24; $i++) $hours[] = str_pad($i, 2, '0', STR_PAD_LEFT); |
|
173 | 173 | $mins = []; |
174 | - for($i = 0;$i < 60;$i++) $mins[] = str_pad($i, 2, '0', STR_PAD_LEFT); |
|
174 | + for($i = 0; $i < 60; $i++) $mins[] = str_pad($i, 2, '0', STR_PAD_LEFT); |
|
175 | 175 | $hour = intval(@date('H')); |
176 | 176 | $min = intval(@date('i')); |
177 | 177 | $sec = intval(@date('s')); |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | $scontrol->setSelectedValue(intval($sec)); |
211 | 211 | $container->Controls[] = $scontrol; |
212 | 212 | |
213 | - return [$hcontrol,$mcontrol,$scontrol]; |
|
213 | + return [$hcontrol, $mcontrol, $scontrol]; |
|
214 | 214 | } |
215 | 215 | |
216 | 216 |
@@ -129,7 +129,7 @@ |
||
129 | 129 | public function setGatewayClass($value) |
130 | 130 | { |
131 | 131 | $this->_gateway = null; |
132 | - $this->_gatewayClass = (string)$value; |
|
132 | + $this->_gatewayClass = (string) $value; |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -56,7 +56,7 @@ |
||
56 | 56 | * @var TActiveRecordInvalidFinderResult |
57 | 57 | * @since 3.1.5 |
58 | 58 | */ |
59 | - private $_invalidFinderResult = TActiveRecordInvalidFinderResult::Null; |
|
59 | + private $_invalidFinderResult = TActiveRecordInvalidFinderResult::null; |
|
60 | 60 | |
61 | 61 | /** |
62 | 62 | * @return ICache application cache. |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | $class = new ReflectionClass($className); |
295 | 295 | $relations = []; |
296 | 296 | foreach($class->getStaticPropertyValue('RELATIONS') as $key => $value) |
297 | - $relations[strtolower($key)] = [$key,$value]; |
|
297 | + $relations[strtolower($key)] = [$key, $value]; |
|
298 | 298 | self::$_relations[$className] = $relations; |
299 | 299 | } |
300 | 300 | } |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | { |
496 | 496 | if(func_num_args() > 1) |
497 | 497 | $keys = func_get_args(); |
498 | - return $this->getRecordGateway()->deleteRecordsByPk($this, (array)$keys); |
|
498 | + return $this->getRecordGateway()->deleteRecordsByPk($this, (array) $keys); |
|
499 | 499 | } |
500 | 500 | |
501 | 501 | /** |
@@ -647,7 +647,7 @@ discard block |
||
647 | 647 | { |
648 | 648 | if(func_num_args() > 1) |
649 | 649 | $keys = func_get_args(); |
650 | - $result = $this->getRecordGateway()->findRecordsByPks($this, (array)$keys); |
|
650 | + $result = $this->getRecordGateway()->findRecordsByPks($this, (array) $keys); |
|
651 | 651 | return $this->populateObjects($result); |
652 | 652 | } |
653 | 653 | |
@@ -1010,7 +1010,7 @@ discard block |
||
1010 | 1010 | { |
1011 | 1011 | $className = get_class($this); |
1012 | 1012 | $property = strtolower($property); |
1013 | - return isset(self::$_relations[$className][$property])?self::$_relations[$className][$property]:null; |
|
1013 | + return isset(self::$_relations[$className][$property]) ?self::$_relations[$className][$property] : null; |
|
1014 | 1014 | } |
1015 | 1015 | |
1016 | 1016 | /** |
@@ -1037,9 +1037,9 @@ discard block |
||
1037 | 1037 | * @return array of column name and column values |
1038 | 1038 | * @since 3.2.4 |
1039 | 1039 | */ |
1040 | - public function toArray(){ |
|
1040 | + public function toArray() { |
|
1041 | 1041 | $result = []; |
1042 | - foreach($this->getRecordTableInfo()->getLowerCaseColumnNames() as $columnName){ |
|
1042 | + foreach($this->getRecordTableInfo()->getLowerCaseColumnNames() as $columnName) { |
|
1043 | 1043 | $result[$columnName] = $this->getColumnValue($columnName); |
1044 | 1044 | } |
1045 | 1045 | |
@@ -1051,7 +1051,7 @@ discard block |
||
1051 | 1051 | * @return JSON |
1052 | 1052 | * @since 3.2.4 |
1053 | 1053 | */ |
1054 | - public function toJSON(){ |
|
1054 | + public function toJSON() { |
|
1055 | 1055 | return json_encode($this->toArray()); |
1056 | 1056 | } |
1057 | 1057 | } |
1058 | 1058 | \ No newline at end of file |
@@ -293,8 +293,9 @@ discard block |
||
293 | 293 | { |
294 | 294 | $class = new ReflectionClass($className); |
295 | 295 | $relations = []; |
296 | - foreach($class->getStaticPropertyValue('RELATIONS') as $key => $value) |
|
297 | - $relations[strtolower($key)] = [$key,$value]; |
|
296 | + foreach($class->getStaticPropertyValue('RELATIONS') as $key => $value) { |
|
297 | + $relations[strtolower($key)] = [$key,$value]; |
|
298 | + } |
|
298 | 299 | self::$_relations[$className] = $relations; |
299 | 300 | } |
300 | 301 | } |
@@ -309,8 +310,9 @@ discard block |
||
309 | 310 | $data = get_object_vars($data); |
310 | 311 | if(!is_array($data)) |
311 | 312 | throw new TActiveRecordException('ar_data_invalid', get_class($this)); |
312 | - foreach($data as $name => $value) |
|
313 | - $this->setColumnValue($name, $value); |
|
313 | + foreach($data as $name => $value) { |
|
314 | + $this->setColumnValue($name, $value); |
|
315 | + } |
|
314 | 316 | } |
315 | 317 | |
316 | 318 | |
@@ -431,14 +433,12 @@ discard block |
||
431 | 433 | $this->_recordState = self::STATE_LOADED; |
432 | 434 | return true; |
433 | 435 | } |
434 | - } |
|
435 | - elseif($this->_recordState === self::STATE_LOADED) |
|
436 | + } elseif($this->_recordState === self::STATE_LOADED) |
|
436 | 437 | { |
437 | 438 | $this->onUpdate($param); |
438 | 439 | if($param->getIsValid() && $gateway->update($this)) |
439 | 440 | return true; |
440 | - } |
|
441 | - else |
|
441 | + } else |
|
442 | 442 | throw new TActiveRecordException('ar_save_invalid', get_class($this)); |
443 | 443 | |
444 | 444 | return false; |
@@ -461,8 +461,7 @@ discard block |
||
461 | 461 | $this->_recordState = self::STATE_DELETED; |
462 | 462 | return true; |
463 | 463 | } |
464 | - } |
|
465 | - else |
|
464 | + } else |
|
466 | 465 | throw new TActiveRecordException('ar_delete_invalid', get_class($this)); |
467 | 466 | |
468 | 467 | return false; |
@@ -539,8 +538,9 @@ discard block |
||
539 | 538 | protected function populateObjects($reader) |
540 | 539 | { |
541 | 540 | $result = []; |
542 | - foreach($reader as $data) |
|
543 | - $result[] = $this->populateObject($data); |
|
541 | + foreach($reader as $data) { |
|
542 | + $result[] = $this->populateObject($data); |
|
543 | + } |
|
544 | 544 | return $result; |
545 | 545 | } |
546 | 546 | |
@@ -729,8 +729,7 @@ discard block |
||
729 | 729 | { |
730 | 730 | $criteria = $this->getRecordCriteria(count($args) > 0 ? $args[0] : null, array_slice($args, 1)); |
731 | 731 | return $context->getRelationHandler($criteria); |
732 | - } |
|
733 | - else |
|
732 | + } else |
|
734 | 733 | return null; |
735 | 734 | } |
736 | 735 | |
@@ -749,8 +748,7 @@ discard block |
||
749 | 748 | { |
750 | 749 | list($property, $relation) = $definition; |
751 | 750 | return new TActiveRecordRelationContext($this, $property, $relation); |
752 | - } |
|
753 | - else |
|
751 | + } else |
|
754 | 752 | return null; |
755 | 753 | } |
756 | 754 | |
@@ -833,8 +831,7 @@ discard block |
||
833 | 831 | { |
834 | 832 | $property = $method[4] === '_' ? substr($method, 5) : substr($method, 4); |
835 | 833 | return $this->getRelationHandler($property, $args); |
836 | - } |
|
837 | - elseif($findOne = strncasecmp($method, 'findby', 6) === 0) |
|
834 | + } elseif($findOne = strncasecmp($method, 'findby', 6) === 0) |
|
838 | 835 | $condition = $method[6] === '_' ? substr($method, 7) : substr($method, 6); |
839 | 836 | elseif(strncasecmp($method, 'findallby', 9) === 0) |
840 | 837 | $condition = $method[9] === '_' ? substr($method, 10) : substr($method, 9); |
@@ -900,8 +897,7 @@ discard block |
||
900 | 897 | { |
901 | 898 | $useArgs = !is_array($parameters) && is_array($args); |
902 | 899 | return new TActiveRecordCriteria($criteria, $useArgs ? $args : $parameters); |
903 | - } |
|
904 | - elseif($criteria instanceof TSqlCriteria) |
|
900 | + } elseif($criteria instanceof TSqlCriteria) |
|
905 | 901 | return $criteria; |
906 | 902 | else |
907 | 903 | return new TActiveRecordCriteria(); |
@@ -65,17 +65,18 @@ |
||
65 | 65 | if(isset($xml['database']) && is_array($xml['database'])) |
66 | 66 | { |
67 | 67 | $db = $this->getDbConnection(); |
68 | - foreach($xml['database'] as $name => $value) |
|
69 | - $db->setSubProperty($name, $value); |
|
68 | + foreach($xml['database'] as $name => $value) { |
|
69 | + $db->setSubProperty($name, $value); |
|
70 | + } |
|
70 | 71 | } |
71 | - } |
|
72 | - else |
|
72 | + } else |
|
73 | 73 | { |
74 | 74 | if($prop = $xml->getElementByTagName('database')) |
75 | 75 | { |
76 | 76 | $db = $this->getDbConnection(); |
77 | - foreach($prop->getAttributes() as $name => $value) |
|
78 | - $db->setSubproperty($name, $value); |
|
77 | + foreach($prop->getAttributes() as $name => $value) { |
|
78 | + $db->setSubproperty($name, $value); |
|
79 | + } |
|
79 | 80 | } |
80 | 81 | } |
81 | 82 | } |
@@ -138,12 +138,12 @@ |
||
138 | 138 | public function __sleep() |
139 | 139 | { |
140 | 140 | $exprops = []; $cn = 'TParameterProperty'; |
141 | - if ($this->_typeHandler === null) $exprops[] = "\0$cn\0_typeHandler"; |
|
142 | - if ($this->_type === null) $exprops[] = "\0$cn\0_type"; |
|
143 | - if ($this->_column === null) $exprops[] = "\0$cn\0_column"; |
|
144 | - if ($this->_dbType === null) $exprops[] = "\0$cn\0_dbType"; |
|
145 | - if ($this->_property === null) $exprops[] = "\0$cn\0_property"; |
|
146 | - if ($this->_nullValue === null) $exprops[] = "\0$cn\0_nullValue"; |
|
141 | + if($this->_typeHandler === null) $exprops[] = "\0$cn\0_typeHandler"; |
|
142 | + if($this->_type === null) $exprops[] = "\0$cn\0_type"; |
|
143 | + if($this->_column === null) $exprops[] = "\0$cn\0_column"; |
|
144 | + if($this->_dbType === null) $exprops[] = "\0$cn\0_dbType"; |
|
145 | + if($this->_property === null) $exprops[] = "\0$cn\0_property"; |
|
146 | + if($this->_nullValue === null) $exprops[] = "\0$cn\0_nullValue"; |
|
147 | 147 | return array_diff(parent::__sleep(), $exprops); |
148 | 148 | } |
149 | 149 | } |