@@ -24,22 +24,22 @@ |
||
24 | 24 | { |
25 | 25 | public function setStringValue($value): ?string |
26 | 26 | { |
27 | - return mb_convert_encoding($value??'', DB::$encoding, 'auto'); // normalize encoding to ASCII |
|
27 | + return mb_convert_encoding($value ?? '', DB::$encoding, 'auto'); // normalize encoding to ASCII |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | public function setBooleanValue($value): bool |
31 | 31 | { |
32 | - return (bool)$value; |
|
32 | + return (bool) $value; |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | public function setDecimalValue($value): ?float |
36 | 36 | { |
37 | - return is_null($value) ? null : (float)preg_replace('/[^-\d.]/', '', $value); |
|
37 | + return is_null($value) ? null : (float) preg_replace('/[^-\d.]/', '', $value); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | public function setIntegerValue($value): ?int |
41 | 41 | { |
42 | - return is_null($value) ? null : (int)preg_replace('/[^-\d]/', '', $value); |
|
42 | + return is_null($value) ? null : (int) preg_replace('/[^-\d]/', '', $value); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | public function setTimestampValue($value): ?string |
@@ -91,8 +91,8 @@ discard block |
||
91 | 91 | |
92 | 92 | |
93 | 93 | /** |
94 | - * @var array $validators Validation checks |
|
95 | - */ |
|
94 | + * @var array $validators Validation checks |
|
95 | + */ |
|
96 | 96 | public static $validators = []; |
97 | 97 | |
98 | 98 | /** |
@@ -1115,7 +1115,7 @@ discard block |
||
1115 | 1115 | $attributeMappedClassFields[$property->getName()] = []; |
1116 | 1116 | } |
1117 | 1117 | } |
1118 | - } |
|
1118 | + } |
|
1119 | 1119 | } |
1120 | 1120 | return $attributeMappedClassFields; |
1121 | 1121 | } |
@@ -725,11 +725,11 @@ discard block |
||
725 | 725 | |
726 | 726 | // create new or update existing |
727 | 727 | if ($this->_isPhantom) { |
728 | - DB::nonQuery((new Insert())->setTable(static::$tableName)->set($set), null, [static::class,'handleException']); |
|
728 | + DB::nonQuery((new Insert())->setTable(static::$tableName)->set($set), null, [static::class, 'handleException']); |
|
729 | 729 | $primaryKey = $this->getPrimaryKey(); |
730 | 730 | $insertID = DB::insertID(); |
731 | 731 | $fields = static::getClassFields(); |
732 | - if ( ($fields[$primaryKey]['type'] ?? false) === 'integer') { |
|
732 | + if (($fields[$primaryKey]['type'] ?? false) === 'integer') { |
|
733 | 733 | $insertID = intval($insertID); |
734 | 734 | } |
735 | 735 | $this->_record[$primaryKey] = $insertID; |
@@ -739,7 +739,7 @@ discard block |
||
739 | 739 | } elseif (count($set)) { |
740 | 740 | DB::nonQuery((new Update())->setTable(static::$tableName)->set($set)->where( |
741 | 741 | sprintf('`%s` = %u', static::_cn($this->getPrimaryKey()), $this->getPrimaryKeyValue()) |
742 | - ), null, [static::class,'handleException']); |
|
742 | + ), null, [static::class, 'handleException']); |
|
743 | 743 | |
744 | 744 | $this->_isUpdated = true; |
745 | 745 | } |
@@ -771,7 +771,7 @@ discard block |
||
771 | 771 | $recordValues = $this->_prepareRecordValues(); |
772 | 772 | $set = static::_mapValuesToSet($recordValues); |
773 | 773 | |
774 | - DB::nonQuery((new Insert())->setTable(static::getHistoryTable())->set($set), null, [static::class,'handleException']); |
|
774 | + DB::nonQuery((new Insert())->setTable(static::getHistoryTable())->set($set), null, [static::class, 'handleException']); |
|
775 | 775 | } |
776 | 776 | } |
777 | 777 | |
@@ -786,7 +786,7 @@ discard block |
||
786 | 786 | */ |
787 | 787 | public static function delete($id) |
788 | 788 | { |
789 | - DB::nonQuery((new Delete())->setTable(static::$tableName)->where(sprintf('`%s` = %u', static::_cn(static::$primaryKey ? static::$primaryKey : 'ID'), $id)), null, [static::class,'handleException']); |
|
789 | + DB::nonQuery((new Delete())->setTable(static::$tableName)->where(sprintf('`%s` = %u', static::_cn(static::$primaryKey ? static::$primaryKey : 'ID'), $id)), null, [static::class, 'handleException']); |
|
790 | 790 | |
791 | 791 | return DB::affectedRows() > 0; |
792 | 792 | } |
@@ -839,7 +839,7 @@ discard block |
||
839 | 839 | { |
840 | 840 | static::init(); |
841 | 841 | if (!static::fieldExists($field)) { |
842 | - throw new Exception('getColumnName called on nonexisting column: ' . get_called_class().'->'.$field); |
|
842 | + throw new Exception('getColumnName called on nonexisting column: '.get_called_class().'->'.$field); |
|
843 | 843 | } |
844 | 844 | |
845 | 845 | return static::$_classFields[get_called_class()][$field]['columnName']; |
@@ -1006,7 +1006,7 @@ discard block |
||
1006 | 1006 | // clear buffer (required for the next query to work without running fetchAll first |
1007 | 1007 | $Statement->closeCursor(); |
1008 | 1008 | |
1009 | - return $Connection->query((string)$query); // now the query should finish with no error |
|
1009 | + return $Connection->query((string) $query); // now the query should finish with no error |
|
1010 | 1010 | } else { |
1011 | 1011 | return DB::handleException($e, $query, $queryLog); |
1012 | 1012 | } |
@@ -1094,20 +1094,20 @@ discard block |
||
1094 | 1094 | { |
1095 | 1095 | $attributeMappedClassFields = []; |
1096 | 1096 | $properties = (new ReflectionClass(static::class))->getProperties(); |
1097 | - if(!empty($properties)) { |
|
1097 | + if (!empty($properties)) { |
|
1098 | 1098 | foreach ($properties as $property) { |
1099 | 1099 | if ($property->isProtected()) { |
1100 | 1100 | |
1101 | 1101 | // skip these because they are built in |
1102 | - if (in_array($property->getName(),[ |
|
1103 | - '_classFields','_classRelationships','_classBeforeSave','_classAfterSave','_fieldsDefined','_relationshipsDefined','_eventsDefined','_record','_validator' |
|
1104 | - ,'_validationErrors','_isDirty','_isValid','fieldSetMapper','_convertedValues','_originalValues','_isPhantom','_wasPhantom','_isNew','_isUpdated','_relatedObjects' |
|
1102 | + if (in_array($property->getName(), [ |
|
1103 | + '_classFields', '_classRelationships', '_classBeforeSave', '_classAfterSave', '_fieldsDefined', '_relationshipsDefined', '_eventsDefined', '_record', '_validator' |
|
1104 | + ,'_validationErrors', '_isDirty', '_isValid', 'fieldSetMapper', '_convertedValues', '_originalValues', '_isPhantom', '_wasPhantom', '_isNew', '_isUpdated', '_relatedObjects' |
|
1105 | 1105 | ])) { |
1106 | 1106 | continue; |
1107 | 1107 | } |
1108 | 1108 | |
1109 | 1109 | if ($attributes = $property->getAttributes()) { |
1110 | - foreach($attributes as $attribute) { |
|
1110 | + foreach ($attributes as $attribute) { |
|
1111 | 1111 | $attributeMappedClassFields[$property->getName()] = $attribute->getArguments(); |
1112 | 1112 | } |
1113 | 1113 | } else { |
@@ -1280,7 +1280,7 @@ discard block |
||
1280 | 1280 | case 'boolean': |
1281 | 1281 | { |
1282 | 1282 | if (!isset($this->_convertedValues[$field])) { |
1283 | - $this->_convertedValues[$field] = (bool)$value; |
|
1283 | + $this->_convertedValues[$field] = (bool) $value; |
|
1284 | 1284 | } |
1285 | 1285 | |
1286 | 1286 | return $this->_convertedValues[$field]; |
@@ -1516,7 +1516,7 @@ discard block |
||
1516 | 1516 | foreach ($order as $key => $value) { |
1517 | 1517 | if (is_string($key)) { |
1518 | 1518 | $columnName = static::_cn($key); |
1519 | - $direction = strtoupper($value)=='DESC' ? 'DESC' : 'ASC'; |
|
1519 | + $direction = strtoupper($value) == 'DESC' ? 'DESC' : 'ASC'; |
|
1520 | 1520 | } else { |
1521 | 1521 | $columnName = static::_cn($value); |
1522 | 1522 | $direction = 'ASC'; |