@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | { |
| 36 | 36 | $this->ApplicationPath = $Path; |
| 37 | 37 | |
| 38 | - if (php_sapi_name()!=='cli') { |
|
| 38 | + if (php_sapi_name() !== 'cli') { |
|
| 39 | 39 | $this->Path = new Path($_SERVER['REQUEST_URI']); |
| 40 | 40 | } |
| 41 | 41 | |
@@ -46,9 +46,9 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | public function config($Label) |
| 48 | 48 | { |
| 49 | - $Config = $this->ApplicationPath . '/config/' . $Label . '.php'; |
|
| 49 | + $Config = $this->ApplicationPath.'/config/'.$Label.'.php'; |
|
| 50 | 50 | if (!file_exists($Config)) { |
| 51 | - throw new \Exception($Config . ' not found in '.static::class.'::config()'); |
|
| 51 | + throw new \Exception($Config.' not found in '.static::class.'::config()'); |
|
| 52 | 52 | } |
| 53 | 53 | return require $Config; |
| 54 | 54 | } |
@@ -93,8 +93,8 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | |
| 95 | 95 | /** |
| 96 | - * @var array $validators Validation checks |
|
| 97 | - */ |
|
| 96 | + * @var array $validators Validation checks |
|
| 97 | + */ |
|
| 98 | 98 | public static $validators = []; |
| 99 | 99 | |
| 100 | 100 | /** |
@@ -1134,7 +1134,7 @@ discard block |
||
| 1134 | 1134 | } |
| 1135 | 1135 | } |
| 1136 | 1136 | } |
| 1137 | - } |
|
| 1137 | + } |
|
| 1138 | 1138 | } |
| 1139 | 1139 | return [ |
| 1140 | 1140 | 'fields' => $fields, |
@@ -727,11 +727,11 @@ discard block |
||
| 727 | 727 | |
| 728 | 728 | // create new or update existing |
| 729 | 729 | if ($this->_isPhantom) { |
| 730 | - DB::nonQuery((new Insert())->setTable(static::$tableName)->set($set), null, [static::class,'handleException']); |
|
| 730 | + DB::nonQuery((new Insert())->setTable(static::$tableName)->set($set), null, [static::class, 'handleException']); |
|
| 731 | 731 | $primaryKey = $this->getPrimaryKey(); |
| 732 | 732 | $insertID = DB::insertID(); |
| 733 | 733 | $fields = static::getClassFields(); |
| 734 | - if ( ($fields[$primaryKey]['type'] ?? false) === 'integer') { |
|
| 734 | + if (($fields[$primaryKey]['type'] ?? false) === 'integer') { |
|
| 735 | 735 | $insertID = intval($insertID); |
| 736 | 736 | } |
| 737 | 737 | $this->_record[$primaryKey] = $insertID; |
@@ -741,7 +741,7 @@ discard block |
||
| 741 | 741 | } elseif (count($set)) { |
| 742 | 742 | DB::nonQuery((new Update())->setTable(static::$tableName)->set($set)->where( |
| 743 | 743 | sprintf('`%s` = %u', static::_cn($this->getPrimaryKey()), $this->getPrimaryKeyValue()) |
| 744 | - ), null, [static::class,'handleException']); |
|
| 744 | + ), null, [static::class, 'handleException']); |
|
| 745 | 745 | |
| 746 | 746 | $this->_isUpdated = true; |
| 747 | 747 | } |
@@ -773,7 +773,7 @@ discard block |
||
| 773 | 773 | $recordValues = $this->_prepareRecordValues(); |
| 774 | 774 | $set = static::_mapValuesToSet($recordValues); |
| 775 | 775 | |
| 776 | - DB::nonQuery((new Insert())->setTable(static::getHistoryTable())->set($set), null, [static::class,'handleException']); |
|
| 776 | + DB::nonQuery((new Insert())->setTable(static::getHistoryTable())->set($set), null, [static::class, 'handleException']); |
|
| 777 | 777 | } |
| 778 | 778 | } |
| 779 | 779 | |
@@ -788,7 +788,7 @@ discard block |
||
| 788 | 788 | */ |
| 789 | 789 | public static function delete($id): bool |
| 790 | 790 | { |
| 791 | - DB::nonQuery((new Delete())->setTable(static::$tableName)->where(sprintf('`%s` = %u', static::_cn(static::$primaryKey ? static::$primaryKey : 'ID'), $id)), null, [static::class,'handleException']); |
|
| 791 | + DB::nonQuery((new Delete())->setTable(static::$tableName)->where(sprintf('`%s` = %u', static::_cn(static::$primaryKey ? static::$primaryKey : 'ID'), $id)), null, [static::class, 'handleException']); |
|
| 792 | 792 | |
| 793 | 793 | return DB::affectedRows() > 0; |
| 794 | 794 | } |
@@ -841,7 +841,7 @@ discard block |
||
| 841 | 841 | { |
| 842 | 842 | static::init(); |
| 843 | 843 | if (!static::fieldExists($field)) { |
| 844 | - throw new Exception('getColumnName called on nonexisting column: ' . get_called_class().'->'.$field); |
|
| 844 | + throw new Exception('getColumnName called on nonexisting column: '.get_called_class().'->'.$field); |
|
| 845 | 845 | } |
| 846 | 846 | |
| 847 | 847 | return static::$_classFields[get_called_class()][$field]['columnName']; |
@@ -1008,7 +1008,7 @@ discard block |
||
| 1008 | 1008 | // clear buffer (required for the next query to work without running fetchAll first |
| 1009 | 1009 | $Statement->closeCursor(); |
| 1010 | 1010 | |
| 1011 | - return $Connection->query((string)$query); // now the query should finish with no error |
|
| 1011 | + return $Connection->query((string) $query); // now the query should finish with no error |
|
| 1012 | 1012 | } else { |
| 1013 | 1013 | return DB::handleException($e, $query, $queryLog); |
| 1014 | 1014 | } |
@@ -1082,7 +1082,7 @@ discard block |
||
| 1082 | 1082 | } |
| 1083 | 1083 | $attributeFields = $class::_definedAttributeFields(); |
| 1084 | 1084 | if (!empty($attributeFields['fields'])) { |
| 1085 | - static::$_classFields[$className] = array_merge(static::$_classFields[$className],$attributeFields['fields']); |
|
| 1085 | + static::$_classFields[$className] = array_merge(static::$_classFields[$className], $attributeFields['fields']); |
|
| 1086 | 1086 | } |
| 1087 | 1087 | if (!empty($attributeFields['relations'])) { |
| 1088 | 1088 | $class::$relationships = $attributeFields['relations']; |
@@ -1101,14 +1101,14 @@ discard block |
||
| 1101 | 1101 | $fields = []; |
| 1102 | 1102 | $relations = []; |
| 1103 | 1103 | $properties = (new ReflectionClass(static::class))->getProperties(); |
| 1104 | - if(!empty($properties)) { |
|
| 1104 | + if (!empty($properties)) { |
|
| 1105 | 1105 | foreach ($properties as $property) { |
| 1106 | 1106 | if ($property->isProtected()) { |
| 1107 | 1107 | |
| 1108 | 1108 | // skip these because they are built in |
| 1109 | - if (in_array($property->getName(),[ |
|
| 1110 | - '_classFields','_classRelationships','_classBeforeSave','_classAfterSave','_fieldsDefined','_relationshipsDefined','_eventsDefined','_record','_validator' |
|
| 1111 | - ,'_validationErrors','_isDirty','_isValid','fieldSetMapper','_convertedValues','_originalValues','_isPhantom','_wasPhantom','_isNew','_isUpdated','_relatedObjects' |
|
| 1109 | + if (in_array($property->getName(), [ |
|
| 1110 | + '_classFields', '_classRelationships', '_classBeforeSave', '_classAfterSave', '_fieldsDefined', '_relationshipsDefined', '_eventsDefined', '_record', '_validator' |
|
| 1111 | + ,'_validationErrors', '_isDirty', '_isValid', 'fieldSetMapper', '_convertedValues', '_originalValues', '_isPhantom', '_wasPhantom', '_isNew', '_isUpdated', '_relatedObjects' |
|
| 1112 | 1112 | ])) { |
| 1113 | 1113 | continue; |
| 1114 | 1114 | } |
@@ -1116,10 +1116,10 @@ discard block |
||
| 1116 | 1116 | $isRelationship = false; |
| 1117 | 1117 | |
| 1118 | 1118 | if ($attributes = $property->getAttributes()) { |
| 1119 | - foreach($attributes as $attribute) { |
|
| 1119 | + foreach ($attributes as $attribute) { |
|
| 1120 | 1120 | $attributeName = $attribute->getName(); |
| 1121 | 1121 | if ($attributeName === Column::class) { |
| 1122 | - $fields[$property->getName()] = array_merge($attribute->getArguments(),['attributeField'=>true]); |
|
| 1122 | + $fields[$property->getName()] = array_merge($attribute->getArguments(), ['attributeField'=>true]); |
|
| 1123 | 1123 | } |
| 1124 | 1124 | |
| 1125 | 1125 | if ($attributeName === Relation::class) { |
@@ -1302,7 +1302,7 @@ discard block |
||
| 1302 | 1302 | case 'boolean': |
| 1303 | 1303 | { |
| 1304 | 1304 | if (!isset($this->_convertedValues[$field])) { |
| 1305 | - $this->_convertedValues[$field] = (bool)$value; |
|
| 1305 | + $this->_convertedValues[$field] = (bool) $value; |
|
| 1306 | 1306 | } |
| 1307 | 1307 | |
| 1308 | 1308 | return $this->_convertedValues[$field]; |
@@ -1538,7 +1538,7 @@ discard block |
||
| 1538 | 1538 | foreach ($order as $key => $value) { |
| 1539 | 1539 | if (is_string($key)) { |
| 1540 | 1540 | $columnName = static::_cn($key); |
| 1541 | - $direction = strtoupper($value)=='DESC' ? 'DESC' : 'ASC'; |
|
| 1541 | + $direction = strtoupper($value) == 'DESC' ? 'DESC' : 'ASC'; |
|
| 1542 | 1542 | } else { |
| 1543 | 1543 | $columnName = static::_cn($value); |
| 1544 | 1544 | $direction = 'ASC'; |