diff --git a/framework/BaseYii.php b/framework/BaseYii.php index 67b259ac37..f3ec0d7333 100644 --- a/framework/BaseYii.php +++ b/framework/BaseYii.php @@ -347,7 +347,7 @@ class BaseYii } elseif (is_array($type)) { throw new InvalidConfigException('Object configuration must be an array containing a "class" element.'); } else { - throw new InvalidConfigException("Unsupported configuration type: " . gettype($type)); + throw new InvalidConfigException('Unsupported configuration type: ' . gettype($type)); } } diff --git a/framework/base/Application.php b/framework/base/Application.php index cdcb5774c2..c864327a64 100644 --- a/framework/base/Application.php +++ b/framework/base/Application.php @@ -287,10 +287,10 @@ abstract class Application extends Module if (isset($extension['bootstrap'])) { $component = Yii::createObject($extension['bootstrap']); if ($component instanceof BootstrapInterface) { - Yii::trace("Bootstrap with " . get_class($component) . '::bootstrap()', __METHOD__); + Yii::trace('Bootstrap with ' . get_class($component) . '::bootstrap()', __METHOD__); $component->bootstrap($this); } else { - Yii::trace("Bootstrap with " . get_class($component), __METHOD__); + Yii::trace('Bootstrap with ' . get_class($component), __METHOD__); } } } @@ -311,10 +311,10 @@ abstract class Application extends Module } if ($component instanceof BootstrapInterface) { - Yii::trace("Bootstrap with " . get_class($component) . '::bootstrap()', __METHOD__); + Yii::trace('Bootstrap with ' . get_class($component) . '::bootstrap()', __METHOD__); $component->bootstrap($this); } else { - Yii::trace("Bootstrap with " . get_class($component), __METHOD__); + Yii::trace('Bootstrap with ' . get_class($component), __METHOD__); } } } diff --git a/framework/base/Controller.php b/framework/base/Controller.php index 7f11fa649e..aef46e9844 100644 --- a/framework/base/Controller.php +++ b/framework/base/Controller.php @@ -122,7 +122,7 @@ class Controller extends Component implements ViewContextInterface throw new InvalidRouteException('Unable to resolve the request: ' . $this->getUniqueId() . '/' . $id); } - Yii::trace("Route to run: " . $action->getUniqueId(), __METHOD__); + Yii::trace('Route to run: ' . $action->getUniqueId(), __METHOD__); if (Yii::$app->requestedAction === null) { Yii::$app->requestedAction = $action; diff --git a/framework/base/Widget.php b/framework/base/Widget.php index 8281902b49..7282d34e8a 100644 --- a/framework/base/Widget.php +++ b/framework/base/Widget.php @@ -73,10 +73,10 @@ class Widget extends Component implements ViewContextInterface echo $widget->run(); return $widget; } else { - throw new InvalidCallException("Expecting end() of " . get_class($widget) . ", found " . get_called_class()); + throw new InvalidCallException('Expecting end() of ' . get_class($widget) . ', found ' . get_called_class()); } } else { - throw new InvalidCallException("Unexpected " . get_called_class() . '::end() call. A matching begin() is not found.'); + throw new InvalidCallException('Unexpected ' . get_called_class() . '::end() call. A matching begin() is not found.'); } } diff --git a/framework/caching/DbDependency.php b/framework/caching/DbDependency.php index e5c16768bd..3488b21075 100644 --- a/framework/caching/DbDependency.php +++ b/framework/caching/DbDependency.php @@ -49,7 +49,7 @@ class DbDependency extends Dependency { $db = Instance::ensure($this->db, Connection::className()); if ($this->sql === null) { - throw new InvalidConfigException("DbDependency::sql must be set."); + throw new InvalidConfigException('DbDependency::sql must be set.'); } if ($db->enableQueryCache) { diff --git a/framework/console/ErrorHandler.php b/framework/console/ErrorHandler.php index 9fe3a97b11..712a7a57ce 100644 --- a/framework/console/ErrorHandler.php +++ b/framework/console/ErrorHandler.php @@ -40,7 +40,7 @@ class ErrorHandler extends \yii\base\ErrorHandler $message = $this->formatMessage('Exception'); } $message .= $this->formatMessage(" '" . get_class($exception) . "'", [Console::BOLD, Console::FG_BLUE]) - . " with message " . $this->formatMessage("'{$exception->getMessage()}'", [Console::BOLD]) //. "\n" + . ' with message ' . $this->formatMessage("'{$exception->getMessage()}'", [Console::BOLD]) //. "\n" . "\n\nin " . dirname($exception->getFile()) . DIRECTORY_SEPARATOR . $this->formatMessage(basename($exception->getFile()), [Console::BOLD]) . ':' . $this->formatMessage($exception->getLine(), [Console::BOLD, Console::FG_YELLOW]) . "\n"; if ($exception instanceof \yii\db\Exception && !empty($exception->errorInfo)) { diff --git a/framework/console/controllers/AssetController.php b/framework/console/controllers/AssetController.php index f63c297e10..1e95a83bde 100644 --- a/framework/console/controllers/AssetController.php +++ b/framework/console/controllers/AssetController.php @@ -248,7 +248,7 @@ class AssetController extends Controller $this->loadDependency($dependencyBundle, $result); $result[$name] = $dependencyBundle; } elseif ($result[$name] === false) { - throw new Exception("A circular dependency is detected for bundle '{$name}': " . $this->composeCircularDependencyTrace($name, $result) . "."); + throw new Exception("A circular dependency is detected for bundle '{$name}': " . $this->composeCircularDependencyTrace($name, $result) . '.'); } } } @@ -425,7 +425,7 @@ class AssetController extends Controller unset($registered[$name]); $registered[$name] = $bundle; } elseif ($registered[$name] === false) { - throw new Exception("A circular dependency is detected for target '{$name}': " . $this->composeCircularDependencyTrace($name, $registered) . "."); + throw new Exception("A circular dependency is detected for target '{$name}': " . $this->composeCircularDependencyTrace($name, $registered) . '.'); } } diff --git a/framework/console/controllers/BaseMigrateController.php b/framework/console/controllers/BaseMigrateController.php index 94352c3399..22b8dafc79 100644 --- a/framework/console/controllers/BaseMigrateController.php +++ b/framework/console/controllers/BaseMigrateController.php @@ -124,7 +124,7 @@ abstract class BaseMigrateController extends Controller } $this->stdout("\n"); - if ($this->confirm('Apply the above ' . ($n === 1 ? 'migration' : 'migrations') . "?")) { + if ($this->confirm('Apply the above ' . ($n === 1 ? 'migration' : 'migrations') . '?')) { foreach ($migrations as $migration) { if (!$this->migrateUp($migration)) { $this->stdout("\nMigration failed. The rest of the migrations are canceled.\n", Console::FG_RED); @@ -159,7 +159,7 @@ abstract class BaseMigrateController extends Controller } else { $limit = (int) $limit; if ($limit < 1) { - throw new Exception("The step argument must be greater than 0."); + throw new Exception('The step argument must be greater than 0.'); } } @@ -180,7 +180,7 @@ abstract class BaseMigrateController extends Controller } $this->stdout("\n"); - if ($this->confirm('Revert the above ' . ($n === 1 ? 'migration' : 'migrations') . "?")) { + if ($this->confirm('Revert the above ' . ($n === 1 ? 'migration' : 'migrations') . '?')) { foreach ($migrations as $migration) { if (!$this->migrateDown($migration)) { $this->stdout("\nMigration failed. The rest of the migrations are canceled.\n", Console::FG_RED); @@ -217,7 +217,7 @@ abstract class BaseMigrateController extends Controller } else { $limit = (int) $limit; if ($limit < 1) { - throw new Exception("The step argument must be greater than 0."); + throw new Exception('The step argument must be greater than 0.'); } } @@ -238,7 +238,7 @@ abstract class BaseMigrateController extends Controller } $this->stdout("\n"); - if ($this->confirm('Redo the above ' . ($n === 1 ? 'migration' : 'migrations') . "?")) { + if ($this->confirm('Redo the above ' . ($n === 1 ? 'migration' : 'migrations') . '?')) { foreach ($migrations as $migration) { if (!$this->migrateDown($migration)) { $this->stdout("\nMigration failed. The rest of the migrations are canceled.\n", Console::FG_RED); @@ -377,7 +377,7 @@ abstract class BaseMigrateController extends Controller } else { $limit = (int) $limit; if ($limit < 1) { - throw new Exception("The limit must be greater than 0."); + throw new Exception('The limit must be greater than 0.'); } } @@ -421,7 +421,7 @@ abstract class BaseMigrateController extends Controller } else { $limit = (int) $limit; if ($limit < 1) { - throw new Exception("The limit must be greater than 0."); + throw new Exception('The limit must be greater than 0.'); } } @@ -462,7 +462,7 @@ abstract class BaseMigrateController extends Controller public function actionCreate($name) { if (!preg_match('/^\w+$/', $name)) { - throw new Exception("The migration name should contain letters, digits and/or underscore characters only."); + throw new Exception('The migration name should contain letters, digits and/or underscore characters only.'); } $name = 'm' . gmdate('ymd_His') . '_' . $name; @@ -492,12 +492,12 @@ abstract class BaseMigrateController extends Controller if ($migration->up() !== false) { $this->addMigrationHistory($class); $time = microtime(true) - $start; - $this->stdout("*** applied $class (time: " . sprintf("%.3f", $time) . "s)\n\n", Console::FG_GREEN); + $this->stdout("*** applied $class (time: " . sprintf('%.3f', $time) . "s)\n\n", Console::FG_GREEN); return true; } else { $time = microtime(true) - $start; - $this->stdout("*** failed to apply $class (time: " . sprintf("%.3f", $time) . "s)\n\n", Console::FG_RED); + $this->stdout("*** failed to apply $class (time: " . sprintf('%.3f', $time) . "s)\n\n", Console::FG_RED); return false; } @@ -520,13 +520,13 @@ abstract class BaseMigrateController extends Controller if ($migration->down() !== false) { $this->removeMigrationHistory($class); $time = microtime(true) - $start; - $this->stdout("*** reverted $class (time: " . sprintf("%.3f", $time) . "s)\n\n", Console::FG_GREEN); + $this->stdout("*** reverted $class (time: " . sprintf('%.3f', $time) . "s)\n\n", Console::FG_GREEN); return true; } else { $time = microtime(true) - $start; - $this->stdout("*** failed to revert $class (time: " . sprintf("%.3f", $time) . "s)\n\n", Console::FG_RED); + $this->stdout("*** failed to revert $class (time: " . sprintf('%.3f', $time) . "s)\n\n", Console::FG_RED); return false; } diff --git a/framework/console/controllers/CacheController.php b/framework/console/controllers/CacheController.php index 850b489387..0435dc23f9 100644 --- a/framework/console/controllers/CacheController.php +++ b/framework/console/controllers/CacheController.php @@ -67,7 +67,7 @@ class CacheController extends Controller $cachesInput = func_get_args(); if (empty($cachesInput)) { - throw new Exception("You should specify cache components names"); + throw new Exception('You should specify cache components names'); } $caches = $this->findCaches($cachesInput); @@ -210,7 +210,7 @@ class CacheController extends Controller $this->stdout("The following cache components were processed:\n\n", Console::FG_YELLOW); foreach ($caches as $cache) { - $this->stdout("\t* " . $cache['name'] ." (" . $cache['class'] . ")", Console::FG_GREEN); + $this->stdout("\t* " . $cache['name'] .' (' . $cache['class'] . ')', Console::FG_GREEN); if (!$cache['is_flushed']) { $this->stdout(" - not flushed\n", Console::FG_RED); diff --git a/framework/console/controllers/FixtureController.php b/framework/console/controllers/FixtureController.php index 6fc9b77f0f..b52b54eb48 100644 --- a/framework/console/controllers/FixtureController.php +++ b/framework/console/controllers/FixtureController.php @@ -94,7 +94,7 @@ class FixtureController extends Controller if ($fixturesInput === []) { $this->stdout($this->getHelpSummary() . "\n"); - $helpCommand = Console::ansiFormat("yii help fixture", [Console::FG_CYAN]); + $helpCommand = Console::ansiFormat('yii help fixture', [Console::FG_CYAN]); $this->stdout("Use $helpCommand to get usage info.\n"); return self::EXIT_CODE_NORMAL; diff --git a/framework/console/controllers/HelpController.php b/framework/console/controllers/HelpController.php index 977a5969a1..ed57fd2c0a 100644 --- a/framework/console/controllers/HelpController.php +++ b/framework/console/controllers/HelpController.php @@ -397,7 +397,7 @@ class HelpController extends Controller } else { $defaultValue = var_export($defaultValue, true); } - $doc = "$type (defaults to " . $defaultValue . ")"; + $doc = "$type (defaults to " . $defaultValue . ')'; } else { $doc = $type; } @@ -405,7 +405,7 @@ class HelpController extends Controller if ($doc === '') { $doc = $comment; } elseif ($comment !== '') { - $doc .= "\n" . preg_replace("/^/m", " ", $comment); + $doc .= "\n" . preg_replace('/^/m', ' ', $comment); } $name = $required ? "$name (required)" : $name; diff --git a/framework/console/controllers/MessageController.php b/framework/console/controllers/MessageController.php index 4c5ddfc450..7b77d9ed77 100644 --- a/framework/console/controllers/MessageController.php +++ b/framework/console/controllers/MessageController.php @@ -112,7 +112,7 @@ class MessageController extends Controller } } if (empty($config['languages'])) { - throw new Exception("Languages cannot be empty."); + throw new Exception('Languages cannot be empty.'); } $files = FileHelper::findFiles(realpath($config['sourcePath']), $config); @@ -203,7 +203,7 @@ class MessageController extends Controller } $obsolete = array_keys($obsolete); - $this->stdout("Inserting new messages..."); + $this->stdout('Inserting new messages...'); $savedFlag = false; foreach ($new as $category => $msgs) { @@ -219,7 +219,7 @@ class MessageController extends Controller } $this->stdout($savedFlag ? "saved.\n" : "Nothing new...skipped.\n"); - $this->stdout($removeUnused ? "Deleting obsoleted messages..." : "Updating obsoleted messages..."); + $this->stdout($removeUnused ? 'Deleting obsoleted messages...' : 'Updating obsoleted messages...'); if (empty($obsolete)) { $this->stdout("Nothing obsoleted...skipped.\n"); diff --git a/framework/db/ActiveRecord.php b/framework/db/ActiveRecord.php index 98778a72cc..b9ac57edce 100644 --- a/framework/db/ActiveRecord.php +++ b/framework/db/ActiveRecord.php @@ -295,7 +295,7 @@ class ActiveRecord extends BaseActiveRecord if ($schema !== null) { return $schema; } else { - throw new InvalidConfigException("The table does not exist: " . static::tableName()); + throw new InvalidConfigException('The table does not exist: ' . static::tableName()); } } diff --git a/framework/db/Migration.php b/framework/db/Migration.php index 6197bf9abb..d118ce2ece 100644 --- a/framework/db/Migration.php +++ b/framework/db/Migration.php @@ -97,7 +97,7 @@ class Migration extends Component implements MigrationInterface } $transaction->commit(); } catch (\Exception $e) { - echo "Exception: " . $e->getMessage() . ' (' . $e->getFile() . ':' . $e->getLine() . ")\n"; + echo 'Exception: ' . $e->getMessage() . ' (' . $e->getFile() . ':' . $e->getLine() . ")\n"; echo $e->getTraceAsString() . "\n"; $transaction->rollBack(); @@ -125,7 +125,7 @@ class Migration extends Component implements MigrationInterface } $transaction->commit(); } catch (\Exception $e) { - echo "Exception: " . $e->getMessage() . ' (' . $e->getFile() . ':' . $e->getLine() . ")\n"; + echo 'Exception: ' . $e->getMessage() . ' (' . $e->getFile() . ':' . $e->getLine() . ")\n"; echo $e->getTraceAsString() . "\n"; $transaction->rollBack(); @@ -173,7 +173,7 @@ class Migration extends Component implements MigrationInterface echo " > execute SQL: $sql ..."; $time = microtime(true); $this->db->createCommand($sql)->bindValues($params)->execute(); - echo " done (time: " . sprintf('%.3f', microtime(true) - $time) . "s)\n"; + echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; } /** @@ -187,7 +187,7 @@ class Migration extends Component implements MigrationInterface echo " > insert into $table ..."; $time = microtime(true); $this->db->createCommand()->insert($table, $columns)->execute(); - echo " done (time: " . sprintf('%.3f', microtime(true) - $time) . "s)\n"; + echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; } /** @@ -202,7 +202,7 @@ class Migration extends Component implements MigrationInterface echo " > insert into $table ..."; $time = microtime(true); $this->db->createCommand()->batchInsert($table, $columns, $rows)->execute(); - echo " done (time: " . sprintf('%.3f', microtime(true) - $time) . "s)\n"; + echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; } /** @@ -219,7 +219,7 @@ class Migration extends Component implements MigrationInterface echo " > update $table ..."; $time = microtime(true); $this->db->createCommand()->update($table, $columns, $condition, $params)->execute(); - echo " done (time: " . sprintf('%.3f', microtime(true) - $time) . "s)\n"; + echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; } /** @@ -234,7 +234,7 @@ class Migration extends Component implements MigrationInterface echo " > delete from $table ..."; $time = microtime(true); $this->db->createCommand()->delete($table, $condition, $params)->execute(); - echo " done (time: " . sprintf('%.3f', microtime(true) - $time) . "s)\n"; + echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; } /** @@ -258,7 +258,7 @@ class Migration extends Component implements MigrationInterface echo " > create table $table ..."; $time = microtime(true); $this->db->createCommand()->createTable($table, $columns, $options)->execute(); - echo " done (time: " . sprintf('%.3f', microtime(true) - $time) . "s)\n"; + echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; } /** @@ -271,7 +271,7 @@ class Migration extends Component implements MigrationInterface echo " > rename table $table to $newName ..."; $time = microtime(true); $this->db->createCommand()->renameTable($table, $newName)->execute(); - echo " done (time: " . sprintf('%.3f', microtime(true) - $time) . "s)\n"; + echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; } /** @@ -283,7 +283,7 @@ class Migration extends Component implements MigrationInterface echo " > drop table $table ..."; $time = microtime(true); $this->db->createCommand()->dropTable($table)->execute(); - echo " done (time: " . sprintf('%.3f', microtime(true) - $time) . "s)\n"; + echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; } /** @@ -295,7 +295,7 @@ class Migration extends Component implements MigrationInterface echo " > truncate table $table ..."; $time = microtime(true); $this->db->createCommand()->truncateTable($table)->execute(); - echo " done (time: " . sprintf('%.3f', microtime(true) - $time) . "s)\n"; + echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; } /** @@ -311,7 +311,7 @@ class Migration extends Component implements MigrationInterface echo " > add column $column $type to table $table ..."; $time = microtime(true); $this->db->createCommand()->addColumn($table, $column, $type)->execute(); - echo " done (time: " . sprintf('%.3f', microtime(true) - $time) . "s)\n"; + echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; } /** @@ -324,7 +324,7 @@ class Migration extends Component implements MigrationInterface echo " > drop column $column from table $table ..."; $time = microtime(true); $this->db->createCommand()->dropColumn($table, $column)->execute(); - echo " done (time: " . sprintf('%.3f', microtime(true) - $time) . "s)\n"; + echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; } /** @@ -338,7 +338,7 @@ class Migration extends Component implements MigrationInterface echo " > rename column $name in table $table to $newName ..."; $time = microtime(true); $this->db->createCommand()->renameColumn($table, $name, $newName)->execute(); - echo " done (time: " . sprintf('%.3f', microtime(true) - $time) . "s)\n"; + echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; } /** @@ -354,7 +354,7 @@ class Migration extends Component implements MigrationInterface echo " > alter column $column in table $table to $type ..."; $time = microtime(true); $this->db->createCommand()->alterColumn($table, $column, $type)->execute(); - echo " done (time: " . sprintf('%.3f', microtime(true) - $time) . "s)\n"; + echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; } /** @@ -366,10 +366,10 @@ class Migration extends Component implements MigrationInterface */ public function addPrimaryKey($name, $table, $columns) { - echo " > add primary key $name on $table (" . (is_array($columns) ? implode(',', $columns) : $columns).") ..."; + echo " > add primary key $name on $table (" . (is_array($columns) ? implode(',', $columns) : $columns) . ') ...'; $time = microtime(true); $this->db->createCommand()->addPrimaryKey($name, $table, $columns)->execute(); - echo " done (time: " . sprintf('%.3f', microtime(true) - $time) . "s)\n"; + echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; } /** @@ -382,7 +382,7 @@ class Migration extends Component implements MigrationInterface echo " > drop primary key $name ..."; $time = microtime(true); $this->db->createCommand()->dropPrimaryKey($name, $table)->execute(); - echo " done (time: " . sprintf('%.3f', microtime(true) - $time) . "s)\n"; + echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; } /** @@ -398,10 +398,10 @@ class Migration extends Component implements MigrationInterface */ public function addForeignKey($name, $table, $columns, $refTable, $refColumns, $delete = null, $update = null) { - echo " > add foreign key $name: $table (" . implode(',', (array) $columns) . ") references $refTable (" . implode(',', (array) $refColumns) . ") ..."; + echo " > add foreign key $name: $table (" . implode(',', (array) $columns) . ") references $refTable (" . implode(',', (array) $refColumns) . ') ...'; $time = microtime(true); $this->db->createCommand()->addForeignKey($name, $table, $columns, $refTable, $refColumns, $delete, $update)->execute(); - echo " done (time: " . sprintf('%.3f', microtime(true) - $time) . "s)\n"; + echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; } /** @@ -414,7 +414,7 @@ class Migration extends Component implements MigrationInterface echo " > drop foreign key $name from table $table ..."; $time = microtime(true); $this->db->createCommand()->dropForeignKey($name, $table)->execute(); - echo " done (time: " . sprintf('%.3f', microtime(true) - $time) . "s)\n"; + echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; } /** @@ -428,10 +428,10 @@ class Migration extends Component implements MigrationInterface */ public function createIndex($name, $table, $columns, $unique = false) { - echo " > create" . ($unique ? ' unique' : '') . " index $name on $table (" . implode(',', (array) $columns) . ") ..."; + echo ' > create' . ($unique ? ' unique' : '') . " index $name on $table (" . implode(',', (array) $columns) . ') ...'; $time = microtime(true); $this->db->createCommand()->createIndex($name, $table, $columns, $unique)->execute(); - echo " done (time: " . sprintf('%.3f', microtime(true) - $time) . "s)\n"; + echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; } /** @@ -444,6 +444,6 @@ class Migration extends Component implements MigrationInterface echo " > drop index $name ..."; $time = microtime(true); $this->db->createCommand()->dropIndex($name, $table)->execute(); - echo " done (time: " . sprintf('%.3f', microtime(true) - $time) . "s)\n"; + echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; } } diff --git a/framework/db/QueryBuilder.php b/framework/db/QueryBuilder.php index 6d7d5d1acf..cce28161d1 100644 --- a/framework/db/QueryBuilder.php +++ b/framework/db/QueryBuilder.php @@ -34,7 +34,7 @@ class QueryBuilder extends \yii\base\Object * @var string the separator between different fragments of a SQL statement. * Defaults to an empty space. This is mainly used by [[build()]] when generating a SQL statement. */ - public $separator = " "; + public $separator = ' '; /** * @var array the abstract column types mapped to physical column types. * This is mainly used to support creating/modifying tables using DB-independent data type specifications. @@ -322,7 +322,7 @@ class QueryBuilder extends \yii\base\Object $cols[] = "\t" . $type; } } - $sql = "CREATE TABLE " . $this->db->quoteTableName($table) . " (\n" . implode(",\n", $cols) . "\n)"; + $sql = 'CREATE TABLE ' . $this->db->quoteTableName($table) . " (\n" . implode(",\n", $cols) . "\n)"; return $options === null ? $sql : $sql . ' ' . $options; } @@ -345,7 +345,7 @@ class QueryBuilder extends \yii\base\Object */ public function dropTable($table) { - return "DROP TABLE " . $this->db->quoteTableName($table); + return 'DROP TABLE ' . $this->db->quoteTableName($table); } /** @@ -389,7 +389,7 @@ class QueryBuilder extends \yii\base\Object */ public function truncateTable($table) { - return "TRUNCATE TABLE " . $this->db->quoteTableName($table); + return 'TRUNCATE TABLE ' . $this->db->quoteTableName($table); } /** @@ -416,8 +416,8 @@ class QueryBuilder extends \yii\base\Object */ public function dropColumn($table, $column) { - return "ALTER TABLE " . $this->db->quoteTableName($table) - . " DROP COLUMN " . $this->db->quoteColumnName($column); + return 'ALTER TABLE ' . $this->db->quoteTableName($table) + . ' DROP COLUMN ' . $this->db->quoteColumnName($column); } /** @@ -429,9 +429,9 @@ class QueryBuilder extends \yii\base\Object */ public function renameColumn($table, $oldName, $newName) { - return "ALTER TABLE " . $this->db->quoteTableName($table) - . " RENAME COLUMN " . $this->db->quoteColumnName($oldName) - . " TO " . $this->db->quoteColumnName($newName); + return 'ALTER TABLE ' . $this->db->quoteTableName($table) + . ' RENAME COLUMN ' . $this->db->quoteColumnName($oldName) + . ' TO ' . $this->db->quoteColumnName($newName); } /** diff --git a/framework/db/cubrid/QueryBuilder.php b/framework/db/cubrid/QueryBuilder.php index 5633fb2422..4fbf9a39ef 100644 --- a/framework/db/cubrid/QueryBuilder.php +++ b/framework/db/cubrid/QueryBuilder.php @@ -63,7 +63,7 @@ class QueryBuilder extends \yii\db\QueryBuilder $value = (int) $value; } - return "ALTER TABLE " . $this->db->schema->quoteTableName($tableName) . " AUTO_INCREMENT=$value;"; + return 'ALTER TABLE ' . $this->db->schema->quoteTableName($tableName) . " AUTO_INCREMENT=$value;"; } elseif ($table === null) { throw new InvalidParamException("Table not found: $tableName"); } else { diff --git a/framework/db/mysql/Schema.php b/framework/db/mysql/Schema.php index 916708cd26..1948f78693 100644 --- a/framework/db/mysql/Schema.php +++ b/framework/db/mysql/Schema.php @@ -61,7 +61,7 @@ class Schema extends \yii\db\Schema */ public function quoteSimpleTableName($name) { - return strpos($name, "`") !== false ? $name : "`" . $name . "`"; + return strpos($name, '`') !== false ? $name : "`$name`"; } /** @@ -72,7 +72,7 @@ class Schema extends \yii\db\Schema */ public function quoteSimpleColumnName($name) { - return strpos($name, '`') !== false || $name === '*' ? $name : '`' . $name . '`'; + return strpos($name, '`') !== false || $name === '*' ? $name : "`$name`"; } /** diff --git a/framework/db/oci/Schema.php b/framework/db/oci/Schema.php index 465e423d9c..99152ed448 100644 --- a/framework/db/oci/Schema.php +++ b/framework/db/oci/Schema.php @@ -291,11 +291,11 @@ SQL; $name = $row['CONSTRAINT_NAME']; if (!isset($constraints[$name])) { $constraints[$name] = [ - 'tableName' => $row["TABLE_REF"], + 'tableName' => $row['TABLE_REF'], 'columns' => [], ]; } - $constraints[$name]['columns'][$row["COLUMN_NAME"]] = $row["COLUMN_REF"]; + $constraints[$name]['columns'][$row['COLUMN_NAME']] = $row['COLUMN_REF']; } foreach ($constraints as $constraint) { $table->foreignKeys[] = array_merge([$constraint['tableName']], $constraint['columns']); diff --git a/framework/db/pgsql/Schema.php b/framework/db/pgsql/Schema.php index dee6c00646..9711c600fd 100644 --- a/framework/db/pgsql/Schema.php +++ b/framework/db/pgsql/Schema.php @@ -411,7 +411,7 @@ SQL; $column->defaultValue = bindec(trim($column->defaultValue, 'B\'')); } elseif (preg_match("/^'(.*?)'::/", $column->defaultValue, $matches)) { $column->defaultValue = $matches[1]; - } elseif (preg_match("/^(.*?)::/", $column->defaultValue, $matches)) { + } elseif (preg_match('/^(.*?)::/', $column->defaultValue, $matches)) { $column->defaultValue = $column->phpTypecast($matches[1]); } else { $column->defaultValue = $column->phpTypecast($column->defaultValue); diff --git a/framework/db/sqlite/QueryBuilder.php b/framework/db/sqlite/QueryBuilder.php index 723fdc9d72..ab4c034da4 100644 --- a/framework/db/sqlite/QueryBuilder.php +++ b/framework/db/sqlite/QueryBuilder.php @@ -163,7 +163,7 @@ class QueryBuilder extends \yii\db\QueryBuilder */ public function truncateTable($table) { - return "DELETE FROM " . $this->db->quoteTableName($table); + return 'DELETE FROM ' . $this->db->quoteTableName($table); } /** diff --git a/framework/db/sqlite/Schema.php b/framework/db/sqlite/Schema.php index 2e28896281..443d3be909 100644 --- a/framework/db/sqlite/Schema.php +++ b/framework/db/sqlite/Schema.php @@ -67,7 +67,7 @@ class Schema extends \yii\db\Schema */ public function quoteSimpleTableName($name) { - return strpos($name, "`") !== false ? $name : "`" . $name . "`"; + return strpos($name, '`') !== false ? $name : "`$name`"; } /** @@ -78,7 +78,7 @@ class Schema extends \yii\db\Schema */ public function quoteSimpleColumnName($name) { - return strpos($name, '`') !== false || $name === '*' ? $name : '`' . $name . '`'; + return strpos($name, '`') !== false || $name === '*' ? $name : "`$name`"; } /** @@ -130,7 +130,7 @@ class Schema extends \yii\db\Schema */ protected function findColumns($table) { - $sql = "PRAGMA table_info(" . $this->quoteSimpleTableName($table->name) . ')'; + $sql = 'PRAGMA table_info(' . $this->quoteSimpleTableName($table->name) . ')'; $columns = $this->db->createCommand($sql)->queryAll(); if (empty($columns)) { return false; @@ -157,7 +157,7 @@ class Schema extends \yii\db\Schema */ protected function findConstraints($table) { - $sql = "PRAGMA foreign_key_list(" . $this->quoteSimpleTableName($table->name) . ')'; + $sql = 'PRAGMA foreign_key_list(' . $this->quoteSimpleTableName($table->name) . ')'; $keys = $this->db->createCommand($sql)->queryAll(); foreach ($keys as $key) { $id = (int) $key['id']; @@ -186,13 +186,13 @@ class Schema extends \yii\db\Schema */ public function findUniqueIndexes($table) { - $sql = "PRAGMA index_list(" . $this->quoteSimpleTableName($table->name) . ')'; + $sql = 'PRAGMA index_list(' . $this->quoteSimpleTableName($table->name) . ')'; $indexes = $this->db->createCommand($sql)->queryAll(); $uniqueIndexes = []; foreach ($indexes as $index) { $indexName = $index['name']; - $indexInfo = $this->db->createCommand("PRAGMA index_info(" . $this->quoteValue($index['name']) . ")")->queryAll(); + $indexInfo = $this->db->createCommand('PRAGMA index_info(' . $this->quoteValue($index['name']) . ')')->queryAll(); if ($index['unique']) { $uniqueIndexes[$indexName] = []; @@ -272,10 +272,10 @@ class Schema extends \yii\db\Schema { switch ($level) { case Transaction::SERIALIZABLE: - $this->db->createCommand("PRAGMA read_uncommitted = False;")->execute(); + $this->db->createCommand('PRAGMA read_uncommitted = False;')->execute(); break; case Transaction::READ_UNCOMMITTED: - $this->db->createCommand("PRAGMA read_uncommitted = True;")->execute(); + $this->db->createCommand('PRAGMA read_uncommitted = True;')->execute(); break; default: throw new NotSupportedException(get_class($this) . ' only supports transaction isolation levels READ UNCOMMITTED and SERIALIZABLE.'); diff --git a/framework/di/Container.php b/framework/di/Container.php index 9b29a2f8c4..39372136dd 100644 --- a/framework/di/Container.php +++ b/framework/di/Container.php @@ -171,7 +171,7 @@ class Container extends Component } elseif (is_object($definition)) { return $this->_singletons[$class] = $definition; } else { - throw new InvalidConfigException("Unexpected object definition type: " . gettype($definition)); + throw new InvalidConfigException('Unexpected object definition type: ' . gettype($definition)); } if (array_key_exists($class, $this->_singletons)) { diff --git a/framework/grid/GridView.php b/framework/grid/GridView.php index 4e7d22b1fc..5ca8c17288 100644 --- a/framework/grid/GridView.php +++ b/framework/grid/GridView.php @@ -307,7 +307,7 @@ class GridView extends BaseListView public function renderSection($name) { switch ($name) { - case "{errors}": + case '{errors}': return $this->renderErrors(); default: return parent::renderSection($name); diff --git a/framework/helpers/BaseConsole.php b/framework/helpers/BaseConsole.php index 33811423ba..cfc75c71aa 100644 --- a/framework/helpers/BaseConsole.php +++ b/framework/helpers/BaseConsole.php @@ -130,7 +130,7 @@ class BaseConsole */ public static function scrollUp($lines = 1) { - echo "\033[" . (int) $lines . "S"; + echo "\033[" . (int) $lines . 'S'; } /** @@ -140,7 +140,7 @@ class BaseConsole */ public static function scrollDown($lines = 1) { - echo "\033[" . (int) $lines . "T"; + echo "\033[" . (int) $lines . 'T'; } /** @@ -287,7 +287,7 @@ class BaseConsole { $code = implode(';', $format); - return "\033[0m" . ($code !== '' ? "\033[" . $code . "m" : '') . $string . "\033[0m"; + return "\033[0m" . ($code !== '' ? "\033[" . $code . 'm' : '') . $string . "\033[0m"; } /** @@ -840,13 +840,13 @@ class BaseConsole public static function select($prompt, $options = []) { top: - static::stdout("$prompt [" . implode(',', array_keys($options)) . ",?]: "); + static::stdout("$prompt [" . implode(',', array_keys($options)) . ',?]: '); $input = static::stdin(); if ($input === '?') { foreach ($options as $key => $value) { static::output(" $key - $value"); } - static::output(" ? - Show help"); + static::output(' ? - Show help'); goto top; } elseif (!array_key_exists($input, $options)) { goto top; @@ -947,7 +947,7 @@ class BaseConsole $width -= static::ansiStrlen($prefix); $percent = ($total == 0) ? 1 : $done / $total; - $info = sprintf("%d%% (%d/%d)", $percent * 100, $done, $total); + $info = sprintf('%d%% (%d/%d)', $percent * 100, $done, $total); if ($done > $total || $done == 0) { self::$_progressEta = null; @@ -978,10 +978,10 @@ class BaseConsole $percent = 1; } $bar = floor($percent * $width); - $status = str_repeat("=", $bar); + $status = str_repeat('=', $bar); if ($bar < $width) { - $status .= ">"; - $status .= str_repeat(" ", $width - $bar - 1); + $status .= '>'; + $status .= str_repeat(' ', $width - $bar - 1); } static::stdout("\r$prefix" . "[$status] $info"); } diff --git a/framework/helpers/BaseHtml.php b/framework/helpers/BaseHtml.php index 66a57303e4..c6ece8c02c 100644 --- a/framework/helpers/BaseHtml.php +++ b/framework/helpers/BaseHtml.php @@ -226,7 +226,7 @@ class BaseHtml return self::wrapIntoCondition(static::tag('link', '', $options), $condition); } elseif (isset($options['noscript']) && $options['noscript'] === true) { unset($options['noscript']); - return ""; + return ''; } else { return static::tag('link', '', $options); } @@ -1153,10 +1153,10 @@ class BaseHtml if (empty($lines)) { // still render the placeholder for client-side validation use - $content = "