@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | * @param mixed $value |
| 39 | 39 | * @return $this - provide a fluent chainable interface |
| 40 | 40 | */ |
| 41 | - public function where($column, $operator=null, $value=null); |
|
| 41 | + public function where($column, $operator = null, $value = null); |
|
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | 44 | * Add an array of key (column) => values as simple equality filters |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * @param string $column |
| 55 | 55 | * @param string $order - 'ASC' | 'DESC' |
| 56 | 56 | */ |
| 57 | - public function addOrderBy($column, $order='DESC'); |
|
| 57 | + public function addOrderBy($column, $order = 'DESC'); |
|
| 58 | 58 | |
| 59 | 59 | /** |
| 60 | 60 | * Sets the order by clause to existing clause |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | * @param string $column |
| 63 | 63 | * @param string $order - 'ASC' | 'DESC' |
| 64 | 64 | */ |
| 65 | - public function orderBy($column, $order='DESC'); |
|
| 65 | + public function orderBy($column, $order = 'DESC'); |
|
| 66 | 66 | |
| 67 | 67 | /** |
| 68 | 68 | * Add a having clause to the query builder |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * @param mixed $value |
| 75 | 75 | * @return $this - provide a fluent chainable interface |
| 76 | 76 | */ |
| 77 | - public function having($column, $operator=null, $value=null); |
|
| 77 | + public function having($column, $operator = null, $value = null); |
|
| 78 | 78 | |
| 79 | 79 | /** |
| 80 | 80 | * Create an orHaving clause |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | * @param mixed $value |
| 85 | 85 | * @return $this - provide a fluent chainable interface |
| 86 | 86 | */ |
| 87 | - public function orHaving($column, $operator=null, $value=null); |
|
| 87 | + public function orHaving($column, $operator = null, $value = null); |
|
| 88 | 88 | |
| 89 | 89 | /** |
| 90 | 90 | * return information on the current filters applied - for mysql this may be the raw query string - for |
@@ -143,10 +143,10 @@ discard block |
||
| 143 | 143 | * @param string $message - optional message to display in the exception if the fields don't exist |
| 144 | 144 | * @throws \InvalidArgumentException if fields don;t exist on the table |
| 145 | 145 | */ |
| 146 | - public function fieldsMustExist($fields, $message='') |
|
| 146 | + public function fieldsMustExist($fields, $message = '') |
|
| 147 | 147 | { |
| 148 | 148 | $tableName = $this->tableName(); |
| 149 | - foreach($fields as $field) { |
|
| 149 | + foreach ($fields as $field) { |
|
| 150 | 150 | if (!$this->hasAttribute($field)) |
| 151 | 151 | throw new \InvalidArgumentException("No '$field' exists on the '$tableName' table. $message"); |
| 152 | 152 | } |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | */ |
| 292 | 292 | public function hasAttributeGetter($name, &$getter) |
| 293 | 293 | { |
| 294 | - $getter = '__get_' . $name; |
|
| 294 | + $getter = '__get_'.$name; |
|
| 295 | 295 | return method_exists($this, $getter); |
| 296 | 296 | } |
| 297 | 297 | |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | */ |
| 305 | 305 | public function hasAttributeSetter($name, &$setter) |
| 306 | 306 | { |
| 307 | - $setter = '__set_' . $name; |
|
| 307 | + $setter = '__set_'.$name; |
|
| 308 | 308 | return method_exists($this, $setter); |
| 309 | 309 | } |
| 310 | 310 | |
@@ -333,11 +333,11 @@ discard block |
||
| 333 | 333 | } |
| 334 | 334 | // is a string - or lots of string arguments |
| 335 | 335 | // like $this->isDirty('name', 'title'); |
| 336 | - if (! is_array($attributes)) { |
|
| 336 | + if (!is_array($attributes)) { |
|
| 337 | 337 | $attributes = func_get_args(); |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | - foreach($attributes as $attribute) { |
|
| 340 | + foreach ($attributes as $attribute) { |
|
| 341 | 341 | return $this->isAttributeChanged($attribute); |
| 342 | 342 | } |
| 343 | 343 | |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | */ |
| 353 | 353 | public function isClean($attributes = null) |
| 354 | 354 | { |
| 355 | - return ! $this->isDirty(...func_get_args()); |
|
| 355 | + return !$this->isDirty(...func_get_args()); |
|
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | /** |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | * @param boolean $withDeleted |
| 415 | 415 | * @return ActiveQuery |
| 416 | 416 | */ |
| 417 | - public static function query($withDeleted=false) |
|
| 417 | + public static function query($withDeleted = false) |
|
| 418 | 418 | { |
| 419 | 419 | return $withDeleted ? static::findWithDeleted() : static::find(); |
| 420 | 420 | } |
@@ -147,8 +147,9 @@ |
||
| 147 | 147 | { |
| 148 | 148 | $tableName = $this->tableName(); |
| 149 | 149 | foreach($fields as $field) { |
| 150 | - if (!$this->hasAttribute($field)) |
|
| 151 | - throw new \InvalidArgumentException("No '$field' exists on the '$tableName' table. $message"); |
|
| 150 | + if (!$this->hasAttribute($field)) { |
|
| 151 | + throw new \InvalidArgumentException("No '$field' exists on the '$tableName' table. $message"); |
|
| 152 | + } |
|
| 152 | 153 | } |
| 153 | 154 | } |
| 154 | 155 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * @param string $comment |
| 55 | 55 | * @return \yii\db\ColumnSchemaBuilder |
| 56 | 56 | */ |
| 57 | - public function uuid64($comment='A uuid using base 64') |
|
| 57 | + public function uuid64($comment = 'A uuid using base 64') |
|
| 58 | 58 | { |
| 59 | 59 | return $this->getDb()->getSchema() |
| 60 | 60 | ->createColumnSchemaBuilder('char(22) CHARACTER SET latin1 COLLATE latin1_general_cs') |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | echo " > $action ..."; |
| 72 | 72 | $time = microtime(true); |
| 73 | 73 | $function(); |
| 74 | - echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; |
|
| 74 | + echo ' done (time: '.sprintf('%.3f', microtime(true) - $time)."s)\n"; |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | /** |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | } |
| 100 | 100 | foreach ($migrations as $migration) { |
| 101 | 101 | if (!$this->migrateUp($migration)) { |
| 102 | - throw new \Exception('Migration failed : ' . $migration); |
|
| 102 | + throw new \Exception('Migration failed : '.$migration); |
|
| 103 | 103 | } |
| 104 | 104 | } |
| 105 | 105 | } |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | * @param array $applied the set of already applied migrations |
| 135 | 135 | * @return array the set of new migrations to be run |
| 136 | 136 | */ |
| 137 | - private function getNewMigrationsInPath($pathAlias, $applied, $migrationAlias=null) |
|
| 137 | + private function getNewMigrationsInPath($pathAlias, $applied, $migrationAlias = null) |
|
| 138 | 138 | { |
| 139 | 139 | if ($migrationAlias === null) |
| 140 | 140 | $migrationAlias = $pathAlias; |
@@ -146,8 +146,8 @@ discard block |
||
| 146 | 146 | if ($file === '.' || $file === '..') { |
| 147 | 147 | continue; |
| 148 | 148 | } |
| 149 | - $path = $migrationPath . DIRECTORY_SEPARATOR . $file; |
|
| 150 | - $migrationName = $migrationAlias . '/' . str_replace('.php', '', $file); |
|
| 149 | + $path = $migrationPath.DIRECTORY_SEPARATOR.$file; |
|
| 150 | + $migrationName = $migrationAlias.'/'.str_replace('.php', '', $file); |
|
| 151 | 151 | if (is_file($path) && !isset($applied[$migrationName])) { |
| 152 | 152 | $migrations[] = $migrationName; |
| 153 | 153 | } |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | // try migrate up |
| 273 | 273 | $migrations = $this->getNewMigrations(); |
| 274 | 274 | foreach ($migrations as $i => $migration) { |
| 275 | - if (strpos($migration, $version . '_') === 0) { |
|
| 275 | + if (strpos($migration, $version.'_') === 0) { |
|
| 276 | 276 | $this->actionUp($i + 1); |
| 277 | 277 | |
| 278 | 278 | return self::EXIT_CODE_NORMAL; |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | // try migrate down |
| 283 | 283 | $migrations = array_keys($this->getMigrationHistory(null)); |
| 284 | 284 | foreach ($migrations as $i => $migration) { |
| 285 | - if (strpos($migration, $version . '_') === 0) { |
|
| 285 | + if (strpos($migration, $version.'_') === 0) { |
|
| 286 | 286 | if ($i === 0) { |
| 287 | 287 | $this->stdout("Already at '$originalVersion'. Nothing needs to be done.\n", Console::FG_YELLOW); |
| 288 | 288 | } else { |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | /** |
| 339 | 339 | * @inheritdoc |
| 340 | 340 | */ |
| 341 | - public function stdout($message, $color='') |
|
| 341 | + public function stdout($message, $color = '') |
|
| 342 | 342 | { |
| 343 | 343 | echo $message; |
| 344 | 344 | } |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | * @param string $type - can be one of 'info' | 'error' | 'danger' | 'warning' | 'success' |
| 382 | 382 | * @return string / stream |
| 383 | 383 | */ |
| 384 | - public function log($message, $type='info') |
|
| 384 | + public function log($message, $type = 'info') |
|
| 385 | 385 | { |
| 386 | 386 | $colors = [ |
| 387 | 387 | 'info' => Console::FG_BLUE, 'warning' => Console::FG_YELLOW, |
@@ -431,10 +431,10 @@ discard block |
||
| 431 | 431 | foreach ($migrations as $migration) { |
| 432 | 432 | // remove any paths to get the migration itself |
| 433 | 433 | $migrationPart = $migration; |
| 434 | - if (strpos($migration,'/')!==false) |
|
| 435 | - $migrationPart = substr($migration, strrpos($migration,'/')+1); |
|
| 434 | + if (strpos($migration, '/') !== false) |
|
| 435 | + $migrationPart = substr($migration, strrpos($migration, '/') + 1); |
|
| 436 | 436 | |
| 437 | - $parts = explode('_', substr($migrationPart,1)); // remove initial m |
|
| 437 | + $parts = explode('_', substr($migrationPart, 1)); // remove initial m |
|
| 438 | 438 | |
| 439 | 439 | // check it was a migration and has enough parts |
| 440 | 440 | if (count($parts) == 1) { |
@@ -452,10 +452,10 @@ discard block |
||
| 452 | 452 | if (!is_numeric($time) || strlen($time) != 6) |
| 453 | 453 | $time = '000000'; |
| 454 | 454 | // some datetimes are YYYYMMDD and others YYMMDD. Canonicalise these |
| 455 | - if (strlen($date)==6) |
|
| 455 | + if (strlen($date) == 6) |
|
| 456 | 456 | $date = "20$date"; |
| 457 | 457 | // turn this into 'YYYY-MM-DD HH:MM:SS' and then into a timestamp |
| 458 | - $dateTime = substr($date,0,4)."-".substr($date,4,2)."-".substr($date,6,2)." ".substr($time,0,2).":".substr($time,2,2).":".substr($time,4,2); |
|
| 458 | + $dateTime = substr($date, 0, 4)."-".substr($date, 4, 2)."-".substr($date, 6, 2)." ".substr($time, 0, 2).":".substr($time, 2, 2).":".substr($time, 4, 2); |
|
| 459 | 459 | $timestamp = strtotime($dateTime); |
| 460 | 460 | if ($timestamp == false) |
| 461 | 461 | throw new \Exception("Invalid datetime in migration $migration. Date(yyyymmdd)=$date and time(hhmmss)=$time. Please fix."); |
@@ -113,8 +113,9 @@ discard block |
||
| 113 | 113 | public function getNewMigrationsForApp($appName) |
| 114 | 114 | { |
| 115 | 115 | $app = Neon::$app->getApp($appName); |
| 116 | - if ($app === null) |
|
| 117 | - throw new \Exception('No app exists with id "'.$appName.'"'); |
|
| 116 | + if ($app === null) { |
|
| 117 | + throw new \Exception('No app exists with id "'.$appName.'"'); |
|
| 118 | + } |
|
| 118 | 119 | $alias = $app->getClassAlias().'/migrations'; |
| 119 | 120 | $migrationAlias = $app->getMigrationAlias().'/migrations'; |
| 120 | 121 | $applied = []; |
@@ -136,8 +137,9 @@ discard block |
||
| 136 | 137 | */ |
| 137 | 138 | private function getNewMigrationsInPath($pathAlias, $applied, $migrationAlias=null) |
| 138 | 139 | { |
| 139 | - if ($migrationAlias === null) |
|
| 140 | - $migrationAlias = $pathAlias; |
|
| 140 | + if ($migrationAlias === null) { |
|
| 141 | + $migrationAlias = $pathAlias; |
|
| 142 | + } |
|
| 141 | 143 | $migrations = []; |
| 142 | 144 | $migrationPath = Neon::getAlias($pathAlias); |
| 143 | 145 | if (file_exists($migrationPath)) { |
@@ -402,9 +404,7 @@ discard block |
||
| 402 | 404 | $string = $prefix.$message; |
| 403 | 405 | } |
| 404 | 406 | return Console::stdout("$string\n"); |
| 405 | - } |
|
| 406 | - |
|
| 407 | - else { |
|
| 407 | + } else { |
|
| 408 | 408 | return $message; |
| 409 | 409 | } |
| 410 | 410 | } |
@@ -431,15 +431,17 @@ discard block |
||
| 431 | 431 | foreach ($migrations as $migration) { |
| 432 | 432 | // remove any paths to get the migration itself |
| 433 | 433 | $migrationPart = $migration; |
| 434 | - if (strpos($migration,'/')!==false) |
|
| 435 | - $migrationPart = substr($migration, strrpos($migration,'/')+1); |
|
| 434 | + if (strpos($migration,'/')!==false) { |
|
| 435 | + $migrationPart = substr($migration, strrpos($migration,'/')+1); |
|
| 436 | + } |
|
| 436 | 437 | |
| 437 | 438 | $parts = explode('_', substr($migrationPart,1)); // remove initial m |
| 438 | 439 | |
| 439 | 440 | // check it was a migration and has enough parts |
| 440 | 441 | if (count($parts) == 1) { |
| 441 | - if (!is_numeric($parts[0])) |
|
| 442 | - continue; |
|
| 442 | + if (!is_numeric($parts[0])) { |
|
| 443 | + continue; |
|
| 444 | + } |
|
| 443 | 445 | $date = $parts[0]; |
| 444 | 446 | $time = '000000'; |
| 445 | 447 | } else { |
@@ -449,24 +451,28 @@ discard block |
||
| 449 | 451 | |
| 450 | 452 | // some handwritten migrations have bad datetimes |
| 451 | 453 | // capture case where no time has been set or is actually a date |
| 452 | - if (!is_numeric($time) || strlen($time) != 6) |
|
| 453 | - $time = '000000'; |
|
| 454 | + if (!is_numeric($time) || strlen($time) != 6) { |
|
| 455 | + $time = '000000'; |
|
| 456 | + } |
|
| 454 | 457 | // some datetimes are YYYYMMDD and others YYMMDD. Canonicalise these |
| 455 | - if (strlen($date)==6) |
|
| 456 | - $date = "20$date"; |
|
| 458 | + if (strlen($date)==6) { |
|
| 459 | + $date = "20$date"; |
|
| 460 | + } |
|
| 457 | 461 | // turn this into 'YYYY-MM-DD HH:MM:SS' and then into a timestamp |
| 458 | 462 | $dateTime = substr($date,0,4)."-".substr($date,4,2)."-".substr($date,6,2)." ".substr($time,0,2).":".substr($time,2,2).":".substr($time,4,2); |
| 459 | 463 | $timestamp = strtotime($dateTime); |
| 460 | - if ($timestamp == false) |
|
| 461 | - throw new \Exception("Invalid datetime in migration $migration. Date(yyyymmdd)=$date and time(hhmmss)=$time. Please fix."); |
|
| 464 | + if ($timestamp == false) { |
|
| 465 | + throw new \Exception("Invalid datetime in migration $migration. Date(yyyymmdd)=$date and time(hhmmss)=$time. Please fix."); |
|
| 466 | + } |
|
| 462 | 467 | // beware migrations with same timestamp |
| 463 | 468 | $sortableMigrations[$timestamp][] = $migration; |
| 464 | 469 | } |
| 465 | 470 | ksort($sortableMigrations); |
| 466 | 471 | $sortedMigrations = []; |
| 467 | 472 | foreach ($sortableMigrations as $mgs) { |
| 468 | - foreach ($mgs as $mig) |
|
| 469 | - $sortedMigrations[] = $mig; |
|
| 473 | + foreach ($mgs as $mig) { |
|
| 474 | + $sortedMigrations[] = $mig; |
|
| 475 | + } |
|
| 470 | 476 | } |
| 471 | 477 | return $sortedMigrations; |
| 472 | 478 | } |
@@ -42,14 +42,16 @@ |
||
| 42 | 42 | parent::init(); |
| 43 | 43 | // the main config can set this - but it can also be loaded by application settings (and possibly user setting in future) |
| 44 | 44 | $this->dateFormat = setting('settings', 'dateFormat', $this->dateFormat); |
| 45 | - if ($this->dateFormat === 'custom') |
|
| 46 | - $this->dateFormat = setting('settings', 'dateFormatCustom', $this->dateFormat); |
|
| 45 | + if ($this->dateFormat === 'custom') { |
|
| 46 | + $this->dateFormat = setting('settings', 'dateFormatCustom', $this->dateFormat); |
|
| 47 | + } |
|
| 47 | 48 | |
| 48 | 49 | $this->timeFormat = setting('settings', 'timeFormat', $this->timeFormat); |
| 49 | 50 | $this->nullDisplay = setting('settings', 'nullDisplay', $this->nullDisplay); |
| 50 | 51 | $this->datetimeFormat = setting('settings', 'datetimeFormat', $this->datetimeFormat); |
| 51 | - if ($this->datetimeFormat === 'custom') |
|
| 52 | - $this->datetimeFormat = setting('settings', 'datetimeFormatCustom', $this->datetimeFormat); |
|
| 52 | + if ($this->datetimeFormat === 'custom') { |
|
| 53 | + $this->datetimeFormat = setting('settings', 'datetimeFormatCustom', $this->datetimeFormat); |
|
| 54 | + } |
|
| 53 | 55 | } |
| 54 | 56 | |
| 55 | 57 | /** |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | public function getTenantDb() |
| 51 | 51 | { |
| 52 | 52 | // if the application does not support multi tenancy then simply return the main database |
| 53 | - if ( ! neon()->multiTenant || ! $this->isOnMasterDomain()) { |
|
| 53 | + if (!neon()->multiTenant || !$this->isOnMasterDomain()) { |
|
| 54 | 54 | return neon()->get('db'); |
| 55 | 55 | } |
| 56 | 56 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | 'theme.css', |
| 22 | 22 | 'https://fonts.googleapis.com/css?family=Nunito+Sans:200,200i,300,300i,400,400i,600,600i,700,700i' |
| 23 | 23 | ]; |
| 24 | - public $sourcePath = __DIR__ . '/assets'; |
|
| 24 | + public $sourcePath = __DIR__.'/assets'; |
|
| 25 | 25 | public $depends = [ |
| 26 | 26 | 'neon\core\assets\CoreAsset', |
| 27 | 27 | '\yii\bootstrap\BootstrapAsset', |
@@ -30,6 +30,6 @@ discard block |
||
| 30 | 30 | public function init() |
| 31 | 31 | { |
| 32 | 32 | $info = neon()->assetManager->publish($this->sourcePath, $this->publishOptions); |
| 33 | - neon()->view->registerJs('var NEON_THEME_URL = "' . $info[1] . '";', View::POS_HEAD, 'neonThemeData'); |
|
| 33 | + neon()->view->registerJs('var NEON_THEME_URL = "'.$info[1].'";', View::POS_HEAD, 'neonThemeData'); |
|
| 34 | 34 | } |
| 35 | 35 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | 'theme.css', |
| 22 | 22 | 'https://fonts.googleapis.com/css?family=Nunito+Sans:200,200i,300,300i,400,400i,600,600i,700,700i,800,900', |
| 23 | 23 | ]; |
| 24 | - public $sourcePath = __DIR__ . '/assets'; |
|
| 24 | + public $sourcePath = __DIR__.'/assets'; |
|
| 25 | 25 | public $depends = [ |
| 26 | 26 | '\neon\core\assets\CoreAsset', |
| 27 | 27 | '\yii\bootstrap\BootstrapAsset', |
@@ -30,6 +30,6 @@ discard block |
||
| 30 | 30 | public function init() |
| 31 | 31 | { |
| 32 | 32 | $info = neon()->assetManager->publish($this->sourcePath, $this->publishOptions); |
| 33 | - neon()->view->registerJs('var NEON_THEME_URL = "' . $info[1] . '";', View::POS_HEAD, 'neonThemeData'); |
|
| 33 | + neon()->view->registerJs('var NEON_THEME_URL = "'.$info[1].'";', View::POS_HEAD, 'neonThemeData'); |
|
| 34 | 34 | } |
| 35 | 35 | } |
@@ -55,9 +55,9 @@ discard block |
||
| 55 | 55 | { |
| 56 | 56 | $bits = explode(':', $timeString); |
| 57 | 57 | return [ |
| 58 | - 'hh' => Arr::get($bits,0, '00'), |
|
| 59 | - 'mm' => Arr::get($bits,1, '00'), |
|
| 60 | - 'ss' => Arr::get($bits,2, '00') |
|
| 58 | + 'hh' => Arr::get($bits, 0, '00'), |
|
| 59 | + 'mm' => Arr::get($bits, 1, '00'), |
|
| 60 | + 'ss' => Arr::get($bits, 2, '00') |
|
| 61 | 61 | ]; |
| 62 | 62 | } |
| 63 | 63 | |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | /** |
| 126 | 126 | * @inheritdoc |
| 127 | 127 | */ |
| 128 | - public function processAsFilter(IQuery $query, $searchData=null) |
|
| 128 | + public function processAsFilter(IQuery $query, $searchData = null) |
|
| 129 | 129 | { |
| 130 | 130 | $searchData = ($searchData === null) ? $this->getValue() : $searchData; |
| 131 | 131 | if (!empty($searchData)) { |