@@ -98,7 +98,7 @@ |
||
| 98 | 98 | |
| 99 | 99 | // check validator |
| 100 | 100 | if (!is_callable($validator)) { |
| 101 | - throw new Exception('Validator for field ' . $options['id'] . ' is not callable'); |
|
| 101 | + throw new Exception('Validator for field '.$options['id'].' is not callable'); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | throw new \Exception(json_last_error_msg()); |
| 12 | 12 | } |
| 13 | 13 | header('Content-type: application/javascript; charset=utf-8', true); |
| 14 | - echo 'var data = ' . $JSON; |
|
| 14 | + echo 'var data = '.$JSON; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | public static function translateAndRespond($data) |
@@ -84,8 +84,8 @@ |
||
| 84 | 84 | |
| 85 | 85 | |
| 86 | 86 | /** |
| 87 | - * @var array $validators Validation checks |
|
| 88 | - */ |
|
| 87 | + * @var array $validators Validation checks |
|
| 88 | + */ |
|
| 89 | 89 | public static $validators = []; |
| 90 | 90 | |
| 91 | 91 | /** |
@@ -737,7 +737,7 @@ discard block |
||
| 737 | 737 | |
| 738 | 738 | // create new or update existing |
| 739 | 739 | if ($this->_isPhantom) { |
| 740 | - DB::nonQuery((new Insert())->setTable(static::$tableName)->set($set), null, [static::class,'handleException']); |
|
| 740 | + DB::nonQuery((new Insert())->setTable(static::$tableName)->set($set), null, [static::class, 'handleException']); |
|
| 741 | 741 | $primaryKey = $this->getPrimaryKey(); |
| 742 | 742 | $insertID = DB::insertID(); |
| 743 | 743 | $fields = static::getClassFields(); |
@@ -750,8 +750,8 @@ discard block |
||
| 750 | 750 | $this->_isNew = true; |
| 751 | 751 | } elseif (count($set)) { |
| 752 | 752 | DB::nonQuery((new Update())->setTable(static::$tableName)->set($set)->where( |
| 753 | - sprintf('`%s` = %u', static::_cn($this->getPrimaryKey()), (string)$this->getPrimaryKeyValue()) |
|
| 754 | - ), null, [static::class,'handleException']); |
|
| 753 | + sprintf('`%s` = %u', static::_cn($this->getPrimaryKey()), (string) $this->getPrimaryKeyValue()) |
|
| 754 | + ), null, [static::class, 'handleException']); |
|
| 755 | 755 | |
| 756 | 756 | $this->_isUpdated = true; |
| 757 | 757 | } |
@@ -783,11 +783,11 @@ discard block |
||
| 783 | 783 | $recordValues = $this->_prepareRecordValues(); |
| 784 | 784 | $set = static::_mapValuesToSet($recordValues); |
| 785 | 785 | |
| 786 | - DB::nonQuery((new Insert())->setTable(static::getHistoryTable())->set($set), null, [static::class,'handleException']); |
|
| 786 | + DB::nonQuery((new Insert())->setTable(static::getHistoryTable())->set($set), null, [static::class, 'handleException']); |
|
| 787 | 787 | } |
| 788 | 788 | } |
| 789 | 789 | |
| 790 | - return static::delete((string)$this->getPrimaryKeyValue()); |
|
| 790 | + return static::delete((string) $this->getPrimaryKeyValue()); |
|
| 791 | 791 | } |
| 792 | 792 | |
| 793 | 793 | /** |
@@ -798,7 +798,7 @@ discard block |
||
| 798 | 798 | */ |
| 799 | 799 | public static function delete($id): bool |
| 800 | 800 | { |
| 801 | - DB::nonQuery((new Delete())->setTable(static::$tableName)->where(sprintf('`%s` = %u', static::_cn(static::$primaryKey ? static::$primaryKey : 'ID'), $id)), null, [static::class,'handleException']); |
|
| 801 | + DB::nonQuery((new Delete())->setTable(static::$tableName)->where(sprintf('`%s` = %u', static::_cn(static::$primaryKey ? static::$primaryKey : 'ID'), $id)), null, [static::class, 'handleException']); |
|
| 802 | 802 | |
| 803 | 803 | return DB::affectedRows() > 0; |
| 804 | 804 | } |
@@ -851,7 +851,7 @@ discard block |
||
| 851 | 851 | { |
| 852 | 852 | static::init(); |
| 853 | 853 | if (!static::fieldExists($field)) { |
| 854 | - throw new Exception('getColumnName called on nonexisting column: ' . get_called_class().'->'.$field); |
|
| 854 | + throw new Exception('getColumnName called on nonexisting column: '.get_called_class().'->'.$field); |
|
| 855 | 855 | } |
| 856 | 856 | |
| 857 | 857 | return static::$_classFields[get_called_class()][$field]['columnName']; |
@@ -1018,7 +1018,7 @@ discard block |
||
| 1018 | 1018 | // clear buffer (required for the next query to work without running fetchAll first |
| 1019 | 1019 | $Statement->closeCursor(); |
| 1020 | 1020 | |
| 1021 | - return $Connection->query((string)$query); // now the query should finish with no error |
|
| 1021 | + return $Connection->query((string) $query); // now the query should finish with no error |
|
| 1022 | 1022 | } else { |
| 1023 | 1023 | return DB::handleException($e, $query, $queryLog); |
| 1024 | 1024 | } |
@@ -1117,8 +1117,8 @@ discard block |
||
| 1117 | 1117 | |
| 1118 | 1118 | // skip these because they are built in |
| 1119 | 1119 | if (in_array($property->getName(), [ |
| 1120 | - '_classFields','_classRelationships','_classBeforeSave','_classAfterSave','_fieldsDefined','_relationshipsDefined','_eventsDefined','_record','_validator' |
|
| 1121 | - ,'_validationErrors','_isDirty','_isValid','_convertedValues','_originalValues','_isPhantom','_wasPhantom','_isNew','_isUpdated','_relatedObjects' |
|
| 1120 | + '_classFields', '_classRelationships', '_classBeforeSave', '_classAfterSave', '_fieldsDefined', '_relationshipsDefined', '_eventsDefined', '_record', '_validator' |
|
| 1121 | + ,'_validationErrors', '_isDirty', '_isValid', '_convertedValues', '_originalValues', '_isPhantom', '_wasPhantom', '_isNew', '_isUpdated', '_relatedObjects' |
|
| 1122 | 1122 | ])) { |
| 1123 | 1123 | continue; |
| 1124 | 1124 | } |
@@ -1248,7 +1248,7 @@ discard block |
||
| 1248 | 1248 | private function applyNewValue($type, $field, $value) |
| 1249 | 1249 | { |
| 1250 | 1250 | if (!isset($this->_convertedValues[$field])) { |
| 1251 | - if (is_null($value) && !in_array($type, ['set','list'])) { |
|
| 1251 | + if (is_null($value) && !in_array($type, ['set', 'list'])) { |
|
| 1252 | 1252 | unset($this->_convertedValues[$field]); |
| 1253 | 1253 | return null; |
| 1254 | 1254 | } |
@@ -1521,7 +1521,7 @@ discard block |
||
| 1521 | 1521 | foreach ($order as $key => $value) { |
| 1522 | 1522 | if (is_string($key)) { |
| 1523 | 1523 | $columnName = static::_cn($key); |
| 1524 | - $direction = strtoupper($value)=='DESC' ? 'DESC' : 'ASC'; |
|
| 1524 | + $direction = strtoupper($value) == 'DESC' ? 'DESC' : 'ASC'; |
|
| 1525 | 1525 | } else { |
| 1526 | 1526 | $columnName = static::_cn($value); |
| 1527 | 1527 | $direction = 'ASC'; |
@@ -32,8 +32,8 @@ discard block |
||
| 32 | 32 | public static function escape($str) |
| 33 | 33 | { |
| 34 | 34 | return str_replace( |
| 35 | - ["\\", "\x00", "\n", "\r", "'", '"', "\x1a"], |
|
| 36 | - ["\\\\","\\0","\\n", "\\r", "\'", '\"', "\\Z"], |
|
| 35 | + ["\\", "\x00", "\n", "\r", "'", '"', "\x1a"], |
|
| 36 | + ["\\\\", "\\0", "\\n", "\\r", "\'", '\"', "\\Z"], |
|
| 37 | 37 | $str |
| 38 | 38 | ); |
| 39 | 39 | } |
@@ -210,10 +210,10 @@ discard block |
||
| 210 | 210 | return 'year'; |
| 211 | 211 | |
| 212 | 212 | case 'enum': |
| 213 | - return sprintf('enum("%s")', join('","', array_map([static::class,'escape'], $field['values']))); |
|
| 213 | + return sprintf('enum("%s")', join('","', array_map([static::class, 'escape'], $field['values']))); |
|
| 214 | 214 | |
| 215 | 215 | case 'set': |
| 216 | - return sprintf('set("%s")', join('","', array_map([static::class,'escape'], $field['values']))); |
|
| 216 | + return sprintf('set("%s")', join('","', array_map([static::class, 'escape'], $field['values']))); |
|
| 217 | 217 | |
| 218 | 218 | default: |
| 219 | 219 | throw new Exception("getSQLType: unhandled type $field[type]"); |
@@ -113,7 +113,7 @@ |
||
| 113 | 113 | $Session->setFields($sessionData); |
| 114 | 114 | if (function_exists('fastcgi_finish_request')) { |
| 115 | 115 | // @codeCoverageIgnoreStart |
| 116 | - register_shutdown_function(function ($Session) { |
|
| 116 | + register_shutdown_function(function($Session) { |
|
| 117 | 117 | $Session->save(); |
| 118 | 118 | }, $Session); |
| 119 | 119 | // @codeCoverageIgnoreEnd |
@@ -153,7 +153,7 @@ |
||
| 153 | 153 | // save a copy to history table |
| 154 | 154 | $recordValues = $this->_prepareRecordValues(); |
| 155 | 155 | $set = static::_mapValuesToSet($recordValues); |
| 156 | - DB::nonQuery((new Insert())->setTable(static::getHistoryTable())->set($set), null, [static::class,'handleError']); |
|
| 156 | + DB::nonQuery((new Insert())->setTable(static::getHistoryTable())->set($set), null, [static::class, 'handleError']); |
|
| 157 | 157 | } |
| 158 | 158 | } |
| 159 | 159 | } |
@@ -51,7 +51,7 @@ |
||
| 51 | 51 | |
| 52 | 52 | public function __toString(): string |
| 53 | 53 | { |
| 54 | - $expression = ($this->calcFoundRows ? 'SQL_CALC_FOUND_ROWS ' : '') . $this->expression; |
|
| 54 | + $expression = ($this->calcFoundRows ? 'SQL_CALC_FOUND_ROWS ' : '').$this->expression; |
|
| 55 | 55 | |
| 56 | 56 | if (isset($this->tableAlias)) { |
| 57 | 57 | $from = sprintf('`%s` AS `%s`', $this->table, $this->tableAlias); |
@@ -10,6 +10,6 @@ |
||
| 10 | 10 | use Divergence\App as App; |
| 11 | 11 | |
| 12 | 12 | return [ |
| 13 | - 'debug' => file_exists(App::$App->ApplicationPath . '/.debug'), |
|
| 14 | - 'environment' => (file_exists(App::$App->ApplicationPath . '/.dev') ? 'dev' : 'production'), |
|
| 13 | + 'debug' => file_exists(App::$App->ApplicationPath.'/.debug'), |
|
| 14 | + 'environment' => (file_exists(App::$App->ApplicationPath.'/.dev') ? 'dev' : 'production'), |
|
| 15 | 15 | ]; |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | // check access for API response modes |
| 70 | 70 | $this->responseBuilder = JsonBuilder::class; |
| 71 | 71 | |
| 72 | - if (in_array($this->responseBuilder, [JsonBuilder::class,JsonpBuilder::class])) { |
|
| 72 | + if (in_array($this->responseBuilder, [JsonBuilder::class, JsonpBuilder::class])) { |
|
| 73 | 73 | if (!$this->checkAPIAccess()) { |
| 74 | 74 | return $this->throwAPIUnAuthorizedError(); |
| 75 | 75 | } |
@@ -82,8 +82,7 @@ discard block |
||
| 82 | 82 | public function handleRecordsRequest($action = false): ResponseInterface |
| 83 | 83 | { |
| 84 | 84 | switch ($action ? $action : $action = $this->shiftPath()) { |
| 85 | - case 'save': |
|
| 86 | - { |
|
| 85 | + case 'save' : { |
|
| 87 | 86 | return $this->handleMultiSaveRequest(); |
| 88 | 87 | } |
| 89 | 88 | |
@@ -224,9 +223,7 @@ discard block |
||
| 224 | 223 | } |
| 225 | 224 | |
| 226 | 225 | switch ($action ? $action : $action = $this->shiftPath()) { |
| 227 | - case '': |
|
| 228 | - case false: |
|
| 229 | - { |
|
| 226 | + case '' : case false : { |
|
| 230 | 227 | $className = static::$recordClass; |
| 231 | 228 | |
| 232 | 229 | return $this->respond($this->getTemplateName($className::$singularNoun), [ |
@@ -314,7 +311,7 @@ discard block |
||
| 314 | 311 | { |
| 315 | 312 | $className = static::$recordClass; |
| 316 | 313 | |
| 317 | - $this->prepareResponseModeJSON(['POST','PUT']); |
|
| 314 | + $this->prepareResponseModeJSON(['POST', 'PUT']); |
|
| 318 | 315 | |
| 319 | 316 | if (!empty($_REQUEST['data'])) { |
| 320 | 317 | if ($className::fieldExists(key($_REQUEST['data']))) { |
@@ -389,7 +386,7 @@ discard block |
||
| 389 | 386 | { |
| 390 | 387 | $className = static::$recordClass; |
| 391 | 388 | |
| 392 | - $this->prepareResponseModeJSON(['POST','PUT','DELETE']); |
|
| 389 | + $this->prepareResponseModeJSON(['POST', 'PUT', 'DELETE']); |
|
| 393 | 390 | |
| 394 | 391 | if (!empty($_REQUEST['data'])) { |
| 395 | 392 | if ($className::fieldExists(key($_REQUEST['data']))) { |
@@ -453,7 +450,7 @@ discard block |
||
| 453 | 450 | return $this->throwUnauthorizedError(); |
| 454 | 451 | } |
| 455 | 452 | |
| 456 | - if (in_array($_SERVER['REQUEST_METHOD'], ['POST','PUT'])) { |
|
| 453 | + if (in_array($_SERVER['REQUEST_METHOD'], ['POST', 'PUT'])) { |
|
| 457 | 454 | if ($this->responseBuilder === JsonBuilder::class) { |
| 458 | 455 | $_REQUEST = JSON::getRequestData(); |
| 459 | 456 | if (is_array($_REQUEST['data'])) { |
@@ -603,7 +600,7 @@ discard block |
||
| 603 | 600 | |
| 604 | 601 | public function getTemplateName($noun) |
| 605 | 602 | { |
| 606 | - return preg_replace_callback('/\s+([a-zA-Z])/', function ($matches) { |
|
| 603 | + return preg_replace_callback('/\s+([a-zA-Z])/', function($matches) { |
|
| 607 | 604 | return strtoupper($matches[1]); |
| 608 | 605 | }, $noun); |
| 609 | 606 | } |