diff --git a/build/controllers/DevController.php b/build/controllers/DevController.php index d4d0e76..42d8cf6 100644 --- a/build/controllers/DevController.php +++ b/build/controllers/DevController.php @@ -70,14 +70,14 @@ class DevController extends Controller return 1; } - foreach($this->extensions as $ext => $repo) { + foreach ($this->extensions as $ext => $repo) { $ret = $this->actionExt($ext); if ($ret !== 0) { return $ret; } } - foreach($this->apps as $app => $repo) { + foreach ($this->apps as $app => $repo) { $ret = $this->actionApp($app); if ($ret !== 0) { return $ret; @@ -107,7 +107,7 @@ class DevController extends Controller asort($dirs); $oldcwd = getcwd(); - foreach($dirs as $dir) { + foreach ($dirs as $dir) { $displayDir = substr($dir, strlen($base)); $this->stdout("Running '$command' in $displayDir...\n", Console::BOLD); chdir($dir); @@ -252,7 +252,7 @@ class DevController extends Controller $this->unlink($link); } $extensions = $this->findDirs("$dir/vendor/yiisoft"); - foreach($extensions as $ext) { + foreach ($extensions as $ext) { if (is_link($link = "$dir/vendor/yiisoft/yii2-$ext")) { $this->stdout("Removing symlink $link.\n"); $this->unlink($link); @@ -276,7 +276,7 @@ class DevController extends Controller symlink("$base/framework", $link); } $extensions = $this->findDirs("$dir/vendor/yiisoft"); - foreach($extensions as $ext) { + foreach ($extensions as $ext) { if (is_dir($link = "$dir/vendor/yiisoft/yii2-$ext")) { $this->stdout("Removing dir $link.\n"); FileHelper::removeDirectory($link); @@ -359,7 +359,7 @@ class DevController extends Controller } closedir($handle); - foreach($list as $i => $e) { + foreach ($list as $i => $e) { if ($e === 'composer') { // skip composer to not break composer update unset($list[$i]); } diff --git a/build/controllers/MimeTypeController.php b/build/controllers/MimeTypeController.php index 028623c..768aac5 100644 --- a/build/controllers/MimeTypeController.php +++ b/build/controllers/MimeTypeController.php @@ -39,14 +39,14 @@ class MimeTypeController extends Controller $this->stdout("done.\n", Console::FG_GREEN); $this->stdout("generating file $outFile..."); $mimeMap = []; - foreach(explode("\n", $content) as $line) { + foreach (explode("\n", $content) as $line) { $line = trim($line); if (empty($line) || $line[0] == '#') { // skip comments and empty lines continue; } $parts = preg_split('/\s+/', $line); $mime = array_shift($parts); - foreach($parts as $ext) { + foreach ($parts as $ext) { if (!empty($ext)) { $mimeMap[$ext] = $mime; } diff --git a/build/controllers/PhpDocController.php b/build/controllers/PhpDocController.php index f8cee3f..bb01fa5 100644 --- a/build/controllers/PhpDocController.php +++ b/build/controllers/PhpDocController.php @@ -167,8 +167,8 @@ class PhpDocController extends Controller 'tests/', 'vendor/', ]; - foreach($extensionExcept as $ext => $paths) { - foreach($paths as $path) { + foreach ($extensionExcept as $ext => $paths) { + foreach ($paths as $path) { $except[] = "/extensions/$ext$path"; } } @@ -184,7 +184,7 @@ class PhpDocController extends Controller } if (isset($extensionExcept[$extension])) { - foreach($extensionExcept[$extension] as $path) { + foreach ($extensionExcept[$extension] as $path) { $except[] = $path; } } @@ -255,7 +255,7 @@ class PhpDocController extends Controller $namespace = false; $namespaceLine = ''; $contentAfterNamespace = false; - foreach($lines as $i => $line) { + foreach ($lines as $i => $line) { $line = trim($line); if (!empty($line)) { if (strncmp($line, 'namespace', 9) === 0) { @@ -269,7 +269,7 @@ class PhpDocController extends Controller } if ($namespace !== false && $contentAfterNamespace !== false) { - while($contentAfterNamespace > 0) { + while ($contentAfterNamespace > 0) { array_shift($lines); $contentAfterNamespace--; } @@ -297,7 +297,7 @@ class PhpDocController extends Controller $listIndent = ''; $tag = false; $indent = ''; - foreach($lines as $i => $line) { + foreach ($lines as $i => $line) { if (preg_match('~^(\s*)/\*\*$~', $line, $matches)) { $docBlock = true; $indent = $matches[1]; @@ -348,8 +348,8 @@ class PhpDocController extends Controller { return preg_replace_callback('~@(param|return) ([\w\\|]+)~i', function($matches) { $types = explode('|', $matches[2]); - foreach($types as $i => $type) { - switch($type){ + foreach ($types as $i => $type) { + switch ($type) { case 'integer': $types[$i] = 'int'; break; case 'boolean': $types[$i] = 'bool'; break; } @@ -367,7 +367,7 @@ class PhpDocController extends Controller // remove blank lines between properties $skip = true; $level = 0; - foreach($lines as $i => $line) { + foreach ($lines as $i => $line) { if (strpos($line, 'class ') !== false) { $skip = false; } @@ -402,7 +402,7 @@ class PhpDocController extends Controller $skip = true; $level = 0; // track array properties $property = ''; - foreach($lines as $i => $line) { + foreach ($lines as $i => $line) { if (strpos($line, 'class ') !== false) { $skip = false; } @@ -428,10 +428,10 @@ class PhpDocController extends Controller $endofPrivate = $i; $property = 'Private'; $level = 0; - } elseif (substr($line,0 , 6) === 'const ') { + } elseif (substr($line, 0, 6) === 'const ') { $endofConst = $i; $property = false; - } elseif (substr($line,0 , 4) === 'use ') { + } elseif (substr($line, 0, 4) === 'use ') { $endofUse = $i; $property = false; } elseif (!empty($line) && $line[0] === '*') { @@ -447,7 +447,7 @@ class PhpDocController extends Controller } $endofAll = false; - foreach(['Private', 'Protected', 'Public', 'Const', 'Use'] as $var) { + foreach (['Private', 'Protected', 'Public', 'Const', 'Use'] as $var) { if (${'endof'.$var} !== false) { $endofAll = ${'endof'.$var}; break; @@ -456,7 +456,7 @@ class PhpDocController extends Controller // $this->checkPropertyOrder($lineInfo); $result = []; - foreach($lines as $i => $line) { + foreach ($lines as $i => $line) { $result[] = $line; if (!($propertiesOnly && $i === $endofAll)) { if ($i === $endofUse || $i === $endofConst || $i === $endofPublic || @@ -753,7 +753,7 @@ class PhpDocController extends Controller // example: yii\di\ServiceLocator setComponents() is not recognized in the whole but in // a part of the class. $parts = $split ? explode("\n\n", $subject) : [$subject]; - foreach($parts as $part) { + foreach ($parts as $part) { preg_match_all($pattern . 'suU', $part, $matches, PREG_SET_ORDER); foreach ($matches as &$set) { foreach ($set as $i => $match) diff --git a/build/controllers/ReleaseController.php b/build/controllers/ReleaseController.php index dd3987c..06674a3 100644 --- a/build/controllers/ReleaseController.php +++ b/build/controllers/ReleaseController.php @@ -105,7 +105,7 @@ class ReleaseController extends Controller } if ($this->update) { - foreach($items as $item) { + foreach ($items as $item) { $this->stdout("fetching tags for $item..."); if ($item === 'framework') { $this->gitFetchTags("{$this->basePath}"); @@ -126,7 +126,7 @@ class ReleaseController extends Controller // print version table $w = $this->minWidth(array_keys($versions)); $this->stdout(str_repeat(' ', $w + 2) . "Current Version Next Version\n", Console::BOLD); - foreach($versions as $ext => $version) { + foreach ($versions as $ext => $version) { $this->stdout($ext . str_repeat(' ', $w + 3 - mb_strlen($ext)) . $version . ""); $this->stdout(str_repeat(' ', 17 - mb_strlen($version)) . $nextVersions[$ext] . "\n"); } @@ -136,7 +136,7 @@ class ReleaseController extends Controller private function minWidth($a) { $w = 1; - foreach($a as $s) { + foreach ($a as $s) { if (($l = mb_strlen($s)) > $w) { $w = $l; } @@ -199,7 +199,7 @@ class ReleaseController extends Controller if ($this->version !== null) { // if a version is explicitly given $newVersions = []; - foreach($versions as $k => $v) { + foreach ($versions as $k => $v) { $newVersions[$k] = $this->version; } } else { @@ -230,7 +230,7 @@ class ReleaseController extends Controller return 1; } - foreach($what as $ext) { + foreach ($what as $ext) { if ($ext === 'framework') { $this->releaseFramework("{$this->basePath}/framework", $newVersions['framework']); } elseif (strncmp('app-', $ext, 4) === 0) { @@ -264,7 +264,7 @@ class ReleaseController extends Controller $versions = $this->getCurrentVersions($what); $this->stdout("You are about to generate packages for the following things:\n\n"); - foreach($what as $ext) { + foreach ($what as $ext) { if (strncmp('app-', $ext, 4) === 0) { $this->stdout(" - "); $this->stdout(substr($ext, 4), Console::FG_RED); @@ -289,7 +289,7 @@ class ReleaseController extends Controller return 1; } - foreach($what as $ext) { + foreach ($what as $ext) { if ($ext === 'framework') { throw new Exception('Can not package framework.'); } elseif (strncmp('app-', $ext, 4) === 0) { @@ -334,7 +334,7 @@ class ReleaseController extends Controller protected function printWhat(array $what, $newVersions, $versions) { - foreach($what as $ext) { + foreach ($what as $ext) { if (strncmp('app-', $ext, 4) === 0) { $this->stdout(" - "); $this->stdout(substr($ext, 4), Console::FG_RED); @@ -353,7 +353,7 @@ class ReleaseController extends Controller protected function printWhatUrls(array $what, $oldVersions) { - foreach($what as $ext) { + foreach ($what as $ext) { if ($ext === 'framework') { $this->stdout("framework: https://github.com/yiisoft/yii2-framework/compare/{$oldVersions[$ext]}...master\n"); $this->stdout("app-basic: https://github.com/yiisoft/yii2-app-basic/compare/{$oldVersions[$ext]}...master\n"); @@ -372,7 +372,7 @@ class ReleaseController extends Controller */ protected function validateWhat(array $what, $limit = [], $ensureGitClean = true) { - foreach($what as $w) { + foreach ($what as $w) { if (strncmp('app-', $w, 4) === 0) { if (!empty($limit) && !in_array('app', $limit)) { throw new Exception("Only the following types are allowed: ".implode(', ', $limit)."\n"); @@ -460,7 +460,7 @@ class ReleaseController extends Controller $this->runGit("git diff --color", $frameworkPath); $this->stdout("\n\n\nCheck whether the above diff is okay, if not you may change things as needed before continuing.\n"); $this->stdout("You may abort the program with Ctrl + C and reset the changes by running `git checkout -- .` in the repo.\n\n"); - } while(!$this->confirm("Type `yes` to continue, `no` to view git diff again. Continue?")); + } while (!$this->confirm("Type `yes` to continue, `no` to view git diff again. Continue?")); $this->stdout("\n\n"); $this->stdout(" **** RELEASE TIME! ****\n", Console::FG_YELLOW, Console::BOLD); @@ -581,7 +581,7 @@ class ReleaseController extends Controller $this->runGit("git diff --color", $path); $this->stdout("\n\n\nCheck whether the above diff is okay, if not you may change things as needed before continuing.\n"); $this->stdout("You may abort the program with Ctrl + C and reset the changes by running `git checkout -- .` in the repo.\n\n"); - } while(!$this->confirm("Type `yes` to continue, `no` to view git diff again. Continue?")); + } while (!$this->confirm("Type `yes` to continue, `no` to view git diff again. Continue?")); $this->stdout("\n\n"); $this->stdout(" **** RELEASE TIME! ****\n", Console::FG_YELLOW, Console::BOLD); @@ -633,7 +633,7 @@ class ReleaseController extends Controller protected function setAppAliases($app, $path) { $this->_oldAlias = Yii::getAlias('@app'); - switch($app) { + switch ($app) { case 'basic': Yii::setAlias('@app', $path); break; @@ -699,7 +699,7 @@ class ReleaseController extends Controller $this->runGit("git diff --color", $path); $this->stdout("\n\n\nCheck whether the above diff is okay, if not you may change things as needed before continuing.\n"); $this->stdout("You may abort the program with Ctrl + C and reset the changes by running `git checkout -- .` in the repo.\n\n"); - } while(!$this->confirm("Type `yes` to continue, `no` to view git diff again. Continue?")); + } while (!$this->confirm("Type `yes` to continue, `no` to view git diff again. Continue?")); $this->stdout("\n\n"); $this->stdout(" **** RELEASE TIME! ****\n", Console::FG_YELLOW, Console::BOLD); @@ -825,7 +825,7 @@ class ReleaseController extends Controller { $headline = "\n$version under development\n"; $headline .= str_repeat('-', strlen($headline) - 2) . "\n\n- no changes in this release.\n"; - foreach($this->getChangelogs($what) as $file) { + foreach ($this->getChangelogs($what) as $file) { $lines = explode("\n", file_get_contents($file)); $hl = [ array_shift($lines), @@ -839,7 +839,7 @@ class ReleaseController extends Controller protected function resortChangelogs($what, $version) { - foreach($this->getChangelogs($what) as $file) { + foreach ($this->getChangelogs($what) as $file) { // split the file into relevant parts list($start, $changelog, $end) = $this->splitChangelog($file, $version); $changelog = $this->resortChangelog($changelog); @@ -860,7 +860,7 @@ class ReleaseController extends Controller $end = []; $state = 'start'; - foreach($lines as $l => $line) { + foreach ($lines as $l => $line) { // starting from the changelogs headline if (isset($lines[$l-2]) && strpos($lines[$l-2], $version) !== false && isset($lines[$l-1]) && strncmp($lines[$l-1], '---', 3) === 0) { @@ -886,7 +886,7 @@ class ReleaseController extends Controller protected function resortChangelog($changelog) { // cleanup whitespace - foreach($changelog as $i => $line) { + foreach ($changelog as $i => $line) { $changelog[$i] = rtrim($line); } $changelog = array_filter($changelog); @@ -926,7 +926,7 @@ class ReleaseController extends Controller protected function getExtensionChangelogs($what) { return array_filter(glob($this->basePath . '/extensions/*/CHANGELOG.md'), function($elem) use ($what) { - foreach($what as $ext) { + foreach ($what as $ext) { if (strpos($elem, "extensions/$ext/CHANGELOG.md") !== false) { return true; } @@ -979,7 +979,7 @@ class ReleaseController extends Controller protected function sed($pattern, $replace, $files) { - foreach((array) $files as $file) { + foreach ((array) $files as $file) { file_put_contents($file, preg_replace($pattern, $replace, file_get_contents($file))); } } @@ -987,7 +987,7 @@ class ReleaseController extends Controller protected function getCurrentVersions(array $what) { $versions = []; - foreach($what as $ext) { + foreach ($what as $ext) { if ($ext === 'framework') { chdir("{$this->basePath}/framework"); } elseif (strncmp('app-', $ext, 4) === 0) { @@ -1011,13 +1011,13 @@ class ReleaseController extends Controller protected function getNextVersions(array $versions, $type) { - foreach($versions as $k => $v) { + foreach ($versions as $k => $v) { if (empty($v)) { $versions[$k] = '2.0.0'; continue; } $parts = explode('.', $v); - switch($type) { + switch ($type) { case self::MINOR: $parts[1]++; $parts[2] = 0; diff --git a/build/controllers/TranslationController.php b/build/controllers/TranslationController.php index 75a4d7d..433c842 100644 --- a/build/controllers/TranslationController.php +++ b/build/controllers/TranslationController.php @@ -47,7 +47,7 @@ class TranslationController extends Controller $errors = $this->checkFiles($translatedFilePath); $diff = empty($errors) ? $this->getDiff($translatedFilePath, $sourceFilePath) : ''; - if(!empty($diff)) { + if (!empty($diff)) { $errors[] = 'Translation outdated.'; } @@ -68,7 +68,7 @@ class TranslationController extends Controller $translatedFilePath = $translationPath . '/' . $fileinfo->getFilename(); $errors = $this->checkFiles(null, $translatedFilePath); - if(!empty($errors)) { + if (!empty($errors)) { $results[$fileinfo->getFilename()]['errors'] = $errors; } } diff --git a/build/controllers/Utf8Controller.php b/build/controllers/Utf8Controller.php index 3465843..4cf3cbd 100644 --- a/build/controllers/Utf8Controller.php +++ b/build/controllers/Utf8Controller.php @@ -39,14 +39,14 @@ class Utf8Controller extends Controller ]); } - foreach($files as $file) { + foreach ($files as $file) { $content = file_get_contents($file); $chars = preg_split('//u', $content, null, PREG_SPLIT_NO_EMPTY); $line = 1; $pos = 0; - foreach($chars as $c) { + foreach ($chars as $c) { $ord = $this->unicodeOrd($c); diff --git a/build/controllers/views/translation/report_html.php b/build/controllers/views/translation/report_html.php index c12a4d6..53e57a1 100644 --- a/build/controllers/views/translation/report_html.php +++ b/build/controllers/views/translation/report_html.php @@ -36,9 +36,9 @@ use yii\helpers\Html;
  • Translation:
  • - $result): ?> + $result): ?>

    - +

    diff --git a/framework/db/ActiveRecord.php b/framework/db/ActiveRecord.php index 3c1942a..212277d 100644 --- a/framework/db/ActiveRecord.php +++ b/framework/db/ActiveRecord.php @@ -205,7 +205,7 @@ class ActiveRecord extends BaseActiveRecord * * ```php * $models = Customer::find()->where('status = 2')->all(); - * foreach($models as $model) { + * foreach ($models as $model) { * $model->status = 1; * $model->update(false); // skipping validation as no user input is involved * } @@ -276,7 +276,7 @@ class ActiveRecord extends BaseActiveRecord * * ```php * $models = Customer::find()->where('status = 3')->all(); - * foreach($models as $model) { + * foreach ($models as $model) { * $model->delete(); * } * ``` diff --git a/framework/di/Instance.php b/framework/di/Instance.php index 6a5e567..b4d6dea 100644 --- a/framework/di/Instance.php +++ b/framework/di/Instance.php @@ -130,7 +130,7 @@ class Instance if ($reference instanceof self) { try { $component = $reference->get($container); - } catch(\ReflectionException $e) { + } catch (\ReflectionException $e) { throw new InvalidConfigException('Failed to instantiate component or class "' . $reference->id . '".', 0, $e); } if ($type === null || $component instanceof $type) { diff --git a/framework/validators/UniqueValidator.php b/framework/validators/UniqueValidator.php index 2b15821..0a7c868 100644 --- a/framework/validators/UniqueValidator.php +++ b/framework/validators/UniqueValidator.php @@ -173,7 +173,7 @@ class UniqueValidator extends Validator $dbModel = reset($models); $pks = $targetClass::primaryKey(); $pk = []; - foreach($pks as $pkAttribute) { + foreach ($pks as $pkAttribute) { $pk[$pkAttribute] = $dbModel[$pkAttribute]; } $exists = ($pk != $model->getOldPrimaryKey(true)); @@ -247,7 +247,7 @@ class UniqueValidator extends Validator $attributeCombo = []; $valueCombo = []; foreach ($this->targetAttribute as $key => $value) { - if(is_int($key)) { + if (is_int($key)) { $attributeCombo[] = $model->getAttributeLabel($value); $valueCombo[] = '"' . $model->$value . '"'; } else { diff --git a/tests/framework/base/ModelTest.php b/tests/framework/base/ModelTest.php index 726bfc2..351e07d 100644 --- a/tests/framework/base/ModelTest.php +++ b/tests/framework/base/ModelTest.php @@ -480,7 +480,7 @@ class WriteOnlyModel extends Model public function rules() { return [ - [['password'],'safe'], + [['password'], 'safe'], ]; } diff --git a/tests/framework/console/controllers/CacheControllerTest.php b/tests/framework/console/controllers/CacheControllerTest.php index ccdf935..44dd310 100644 --- a/tests/framework/console/controllers/CacheControllerTest.php +++ b/tests/framework/console/controllers/CacheControllerTest.php @@ -58,7 +58,7 @@ class CacheControllerTest extends TestCase ], ]); - if(isset($config['fixture'])) { + if (isset($config['fixture'])) { Yii::$app->db->open(); $lines = explode(';', file_get_contents($config['fixture'])); foreach ($lines as $line) { diff --git a/tests/framework/db/ActiveRecordTest.php b/tests/framework/db/ActiveRecordTest.php index ec77411..89b0b30 100644 --- a/tests/framework/db/ActiveRecordTest.php +++ b/tests/framework/db/ActiveRecordTest.php @@ -1053,7 +1053,7 @@ abstract class ActiveRecordTest extends DatabaseTestCase $this->assertEquals(2, count($order->booksWithNullFKViaTable)); $orderItemCount = $orderItemsWithNullFKClass::find()->count(); $this->assertEquals(5, $itemClass::find()->count()); - $order->unlinkAll('booksWithNullFKViaTable',false); + $order->unlinkAll('booksWithNullFKViaTable', false); $this->assertEquals(0, count($order->booksWithNullFKViaTable)); $this->assertEquals(2,$orderItemsWithNullFKClass::find()->where(['AND', ['item_id' => [1, 2]], ['order_id' => null]])->count()); $this->assertEquals($orderItemCount, $orderItemsWithNullFKClass::find()->count()); @@ -1186,7 +1186,7 @@ abstract class ActiveRecordTest extends DatabaseTestCase ->all(); $this->assertCount(2, $aggregation); $this->assertContainsOnlyInstancesOf(Customer::className(), $aggregation); - foreach($aggregation as $item) { + foreach ($aggregation as $item) { if ($item->status == 1) { $this->assertEquals(183, $item->sumTotal); } elseif ($item->status == 2) { @@ -1227,7 +1227,7 @@ abstract class ActiveRecordTest extends DatabaseTestCase ->all(); $this->assertCount(3, $aggregation); $this->assertContainsOnlyInstancesOf(OrderItem::className(), $aggregation); - foreach($aggregation as $item) { + foreach ($aggregation as $item) { if ($item->order_id == 1) { $this->assertEquals(70, $item->subtotal); } elseif ($item->order_id == 2) { diff --git a/tests/framework/db/CommandTest.php b/tests/framework/db/CommandTest.php index 5ce2ae2..fb107bd 100644 --- a/tests/framework/db/CommandTest.php +++ b/tests/framework/db/CommandTest.php @@ -463,7 +463,7 @@ SQL; $db = $this->getConnection(); $db->createCommand('DELETE FROM {{order_with_null_fk}}')->execute(); - switch($this->driverName){ + switch ($this->driverName) { case 'pgsql': $expression = "EXTRACT(YEAR FROM TIMESTAMP 'now')"; break; @@ -531,7 +531,7 @@ SQL; { $db = $this->getConnection(); - if($db->getSchema()->getTableSchema('testCreateTable') !== null){ + if ($db->getSchema()->getTableSchema('testCreateTable') !== null) { $db->createCommand()->dropTable('testCreateTable')->execute(); } @@ -545,13 +545,13 @@ SQL; public function testAlterTable() { - if ($this->driverName === 'sqlite'){ + if ($this->driverName === 'sqlite') { $this->markTestSkipped('Sqlite does not support alterTable'); } $db = $this->getConnection(); - if($db->getSchema()->getTableSchema('testAlterTable') !== null){ + if ($db->getSchema()->getTableSchema('testAlterTable') !== null) { $db->createCommand()->dropTable('testAlterTable')->execute(); } @@ -596,7 +596,7 @@ SQL; $fromTableName = 'type'; $toTableName = 'new_type'; - if($db->getSchema()->getTableSchema($toTableName) !== null){ + if ($db->getSchema()->getTableSchema($toTableName) !== null) { $db->createCommand()->dropTable($toTableName)->execute(); } diff --git a/tests/framework/db/QueryBuilderTest.php b/tests/framework/db/QueryBuilderTest.php index 1defde6..96308dc 100644 --- a/tests/framework/db/QueryBuilderTest.php +++ b/tests/framework/db/QueryBuilderTest.php @@ -1145,7 +1145,7 @@ abstract class QueryBuilderTest extends DatabaseTestCase } // adjust dbms specific escaping - foreach($conditions as $i => $condition) { + foreach ($conditions as $i => $condition) { $conditions[$i][1] = $this->replaceQuotes($condition[1]); } return $conditions; @@ -1193,7 +1193,7 @@ abstract class QueryBuilderTest extends DatabaseTestCase ]; // adjust dbms specific escaping - foreach($conditions as $i => $condition) { + foreach ($conditions as $i => $condition) { $conditions[$i][1] = $this->replaceQuotes($condition[1]); } return $conditions; @@ -1464,7 +1464,7 @@ abstract class QueryBuilderTest extends DatabaseTestCase $this->assertEquals([ 'id' => 1, 'abc' => 'abc', - ],$params); + ], $params); // simple subquery $subquery = "(SELECT * FROM user WHERE account_id = accounts.id)"; @@ -1697,7 +1697,7 @@ abstract class QueryBuilderTest extends DatabaseTestCase ]; // adjust dbms specific escaping - foreach($conditions as $i => $condition) { + foreach ($conditions as $i => $condition) { $conditions[$i][1] = $this->replaceQuotes($condition[1]); if (!empty($this->likeEscapeCharSql)) { preg_match_all('/(?PLIKE.+?)( AND| OR|$)/', $conditions[$i][1], $matches, PREG_SET_ORDER); diff --git a/tests/framework/db/SchemaTest.php b/tests/framework/db/SchemaTest.php index 959f9b6..4ee6cef 100644 --- a/tests/framework/db/SchemaTest.php +++ b/tests/framework/db/SchemaTest.php @@ -24,7 +24,7 @@ abstract class SchemaTest extends DatabaseTestCase public function testGetTableNames($pdoAttributes) { $connection = $this->getConnection(); - foreach($pdoAttributes as $name => $value) { + foreach ($pdoAttributes as $name => $value) { $connection->pdo->setAttribute($name, $value); } /* @var $schema Schema */ @@ -47,7 +47,7 @@ abstract class SchemaTest extends DatabaseTestCase public function testGetTableSchemas($pdoAttributes) { $connection = $this->getConnection(); - foreach($pdoAttributes as $name => $value) { + foreach ($pdoAttributes as $name => $value) { $connection->pdo->setAttribute($name, $value); } /* @var $schema Schema */ @@ -364,7 +364,7 @@ abstract class SchemaTest extends DatabaseTestCase sort($colNames); $this->assertEquals($expectedColNames, $colNames); - foreach($table->columns as $name => $column) { + foreach ($table->columns as $name => $column) { $expected = $columns[$name]; $this->assertSame($expected['dbType'], $column->dbType, "dbType of column $name does not match. type is $column->type, dbType is $column->dbType."); $this->assertSame($expected['phpType'], $column->phpType, "phpType of column $name does not match. type is $column->type, dbType is $column->dbType."); @@ -396,7 +396,7 @@ abstract class SchemaTest extends DatabaseTestCase try { $db->createCommand()->dropTable('uniqueIndex')->execute(); - } catch(\Exception $e) { + } catch (\Exception $e) { } $db->createCommand()->createTable('uniqueIndex', [ 'somecol' => 'string', diff --git a/tests/framework/di/ContainerTest.php b/tests/framework/di/ContainerTest.php index fe632a8..920103c 100644 --- a/tests/framework/di/ContainerTest.php +++ b/tests/framework/di/ContainerTest.php @@ -159,11 +159,11 @@ class ContainerTest extends TestCase $this->assertEquals(['ok', 'yii\validators\NumberValidator', 'value_of_c'], $result); // use native php function - $this->assertEquals(Yii::$container->invoke('trim',[' M2792684 ']), 'M2792684'); + $this->assertEquals(Yii::$container->invoke('trim', [' M2792684 ']), 'M2792684'); // use helper function $array = ['M36', 'D426', 'Y2684']; - $this->assertFalse(Yii::$container->invoke(['yii\helpers\ArrayHelper', 'isAssociative'],[$array])); + $this->assertFalse(Yii::$container->invoke(['yii\helpers\ArrayHelper', 'isAssociative'], [$array])); $myFunc = function (\yii\console\Request $request, \yii\console\Response $response) { diff --git a/tests/framework/grid/ActionColumnTest.php b/tests/framework/grid/ActionColumnTest.php index a40812d..ce551b2 100644 --- a/tests/framework/grid/ActionColumnTest.php +++ b/tests/framework/grid/ActionColumnTest.php @@ -69,7 +69,7 @@ class ActionColumnTest extends \yiiunit\TestCase //test visible button (condition is callback) $column->visibleButtons = [ - 'update' => function($model, $key, $index){return $model['id'] == 1;} + 'update' => function($model, $key, $index) {return $model['id'] == 1;} ]; $columnContents = $column->renderDataCell(['id' => 1], 1, 0); $this->assertContains('update_button', $columnContents); @@ -83,7 +83,7 @@ class ActionColumnTest extends \yiiunit\TestCase //test invisible button (condition is callback) $column->visibleButtons = [ - 'update' => function($model, $key, $index){return $model['id'] != 1;} + 'update' => function($model, $key, $index) {return $model['id'] != 1;} ]; $columnContents = $column->renderDataCell(['id' => 1], 1, 0); $this->assertNotContains('update_button', $columnContents); diff --git a/tests/framework/i18n/FormatterDateTest.php b/tests/framework/i18n/FormatterDateTest.php index f4ee601..354f854 100644 --- a/tests/framework/i18n/FormatterDateTest.php +++ b/tests/framework/i18n/FormatterDateTest.php @@ -548,7 +548,7 @@ class FormatterDateTest extends TestCase $utc = new \DateTimeZone('UTC'); $berlin = new \DateTimeZone('Europe/Berlin'); $result = []; - foreach($this->provideTimezones() as $tz) { + foreach ($this->provideTimezones() as $tz) { $result[] = [$tz[0], 1407674460, 1388580060]; $result[] = [$tz[0], '2014-08-10 12:41:00', '2014-01-01 12:41:00']; $result[] = [$tz[0], '2014-08-10 12:41:00 UTC', '2014-01-01 12:41:00 UTC']; diff --git a/tests/framework/log/FileTargetTest.php b/tests/framework/log/FileTargetTest.php index 122fdee..ed7ba16 100644 --- a/tests/framework/log/FileTargetTest.php +++ b/tests/framework/log/FileTargetTest.php @@ -69,7 +69,7 @@ class FileTargetTest extends TestCase $this->assertFalse(file_exists($logFile . '.4')); // exceed max size - for($i = 0; $i < 1024; $i++) { + for ($i = 0; $i < 1024; $i++) { $logger->log(str_repeat('x', 1024), Logger::LEVEL_WARNING); } $logger->flush(true); @@ -89,7 +89,7 @@ class FileTargetTest extends TestCase // second rotate - for($i = 0; $i < 1024; $i++) { + for ($i = 0; $i < 1024; $i++) { $logger->log(str_repeat('x', 1024), Logger::LEVEL_WARNING); } $logger->flush(true); diff --git a/tests/framework/rest/UrlRuleTest.php b/tests/framework/rest/UrlRuleTest.php index 4129235..bf28803 100644 --- a/tests/framework/rest/UrlRuleTest.php +++ b/tests/framework/rest/UrlRuleTest.php @@ -340,7 +340,7 @@ class UrlRuleTest extends TestCase */ public function testCreateUrl($rule, $tests) { - foreach($tests as $test) { + foreach ($tests as $test) { list($params, $expected) = $test; $this->mockWebApplication(); diff --git a/tests/framework/validators/DateValidatorTest.php b/tests/framework/validators/DateValidatorTest.php index 3516e64..2fe6363 100644 --- a/tests/framework/validators/DateValidatorTest.php +++ b/tests/framework/validators/DateValidatorTest.php @@ -235,7 +235,7 @@ class DateValidatorTest extends TestCase public function timestampFormatProvider() { $return = []; - foreach($this->provideTimezones() as $appTz) { + foreach ($this->provideTimezones() as $appTz) { foreach ($this->provideTimezones() as $tz) { $return[] = ['yyyy-MM-dd', '2013-09-13', '2013-09-13', $tz[0], $appTz[0]]; // regardless of timezone, a simple date input should always result in 00:00:00 time diff --git a/tests/framework/validators/EmailValidatorTest.php b/tests/framework/validators/EmailValidatorTest.php index 1b49ed8..6e59dee 100644 --- a/tests/framework/validators/EmailValidatorTest.php +++ b/tests/framework/validators/EmailValidatorTest.php @@ -114,7 +114,7 @@ class EmailValidatorTest extends TestCase 'ipetrov@gmail.com', 'Ivan Petrov ', ]; - foreach($emails as $email) { + foreach ($emails as $email) { $this->assertTrue($validator->validate($email),"Email: '$email' failed to validate(checkDNS=true, allowName=true)"); } } diff --git a/tests/framework/validators/FileValidatorTest.php b/tests/framework/validators/FileValidatorTest.php index aff946e..f6a406b 100644 --- a/tests/framework/validators/FileValidatorTest.php +++ b/tests/framework/validators/FileValidatorTest.php @@ -71,7 +71,7 @@ class FileValidatorTest extends TestCase public function testGetSizeLimit() { - $size = min($this->sizeToBytes(ini_get('upload_max_filesize')),$this->sizeToBytes(ini_get('post_max_size'))); + $size = min($this->sizeToBytes(ini_get('upload_max_filesize')), $this->sizeToBytes(ini_get('post_max_size'))); $val = new FileValidator(); $this->assertEquals($size, $val->getSizeLimit()); $val->maxSize = $size + 1; // set and test if value is overridden diff --git a/tests/framework/validators/UniqueValidatorTest.php b/tests/framework/validators/UniqueValidatorTest.php index bf8c4e9..6d25d60 100644 --- a/tests/framework/validators/UniqueValidatorTest.php +++ b/tests/framework/validators/UniqueValidatorTest.php @@ -338,7 +338,7 @@ abstract class UniqueValidatorTest extends DatabaseTestCase $schema = $this->getConnection()->schema; $model = new ValidatorTestMainModel(); - $query = $this->invokeMethod(new UniqueValidator(), 'prepareQuery', [$model,['val_attr_b' => 'test value a']]); + $query = $this->invokeMethod(new UniqueValidator(), 'prepareQuery', [$model, ['val_attr_b' => 'test value a']]); $expected = "SELECT * FROM {$schema->quoteTableName('validator_main')} WHERE {$schema->quoteColumnName('val_attr_b')}=:qp0"; $this->assertEquals($expected, $query->createCommand()->getSql()); diff --git a/tests/framework/web/DbSessionTest.php b/tests/framework/web/DbSessionTest.php index 2ab01c9..eefc0ad 100644 --- a/tests/framework/web/DbSessionTest.php +++ b/tests/framework/web/DbSessionTest.php @@ -113,7 +113,7 @@ class DbSessionTest extends TestCase $migrate->run($action, $params); ob_get_clean(); - return array_map(function($version){ + return array_map(function($version) { return substr($version, 15); }, (new Query())->select(['version'])->from('migration')->column()); } diff --git a/tests/framework/web/RequestTest.php b/tests/framework/web/RequestTest.php index b9d5c49..d671f50 100644 --- a/tests/framework/web/RequestTest.php +++ b/tests/framework/web/RequestTest.php @@ -101,7 +101,7 @@ class RequestTest extends TestCase $request->enableCsrfValidation = true; // accept any value on GET request - foreach(['GET', 'HEAD', 'OPTIONS'] as $method) { + foreach (['GET', 'HEAD', 'OPTIONS'] as $method) { $_POST[$request->methodParam] = $method; $this->assertTrue($request->validateCsrfToken($token)); $this->assertTrue($request->validateCsrfToken($token . 'a')); @@ -112,7 +112,7 @@ class RequestTest extends TestCase } // only accept valid token on POST - foreach(['POST', 'PUT', 'DELETE'] as $method) { + foreach (['POST', 'PUT', 'DELETE'] as $method) { $_POST[$request->methodParam] = $method; $this->assertTrue($request->validateCsrfToken($token)); $this->assertFalse($request->validateCsrfToken($token . 'a')); @@ -136,13 +136,13 @@ class RequestTest extends TestCase $token = $request->getCsrfToken(); // accept no value on GET request - foreach(['GET', 'HEAD', 'OPTIONS'] as $method) { + foreach (['GET', 'HEAD', 'OPTIONS'] as $method) { $_POST[$request->methodParam] = $method; $this->assertTrue($request->validateCsrfToken()); } // only accept valid token on POST - foreach(['POST', 'PUT', 'DELETE'] as $method) { + foreach (['POST', 'PUT', 'DELETE'] as $method) { $_POST[$request->methodParam] = $method; $request->setBodyParams([]); $this->assertFalse($request->validateCsrfToken()); @@ -165,13 +165,13 @@ class RequestTest extends TestCase $token = $request->getCsrfToken(); // accept no value on GET request - foreach(['GET', 'HEAD', 'OPTIONS'] as $method) { + foreach (['GET', 'HEAD', 'OPTIONS'] as $method) { $_POST[$request->methodParam] = $method; $this->assertTrue($request->validateCsrfToken()); } // only accept valid token on POST - foreach(['POST', 'PUT', 'DELETE'] as $method) { + foreach (['POST', 'PUT', 'DELETE'] as $method) { $_POST[$request->methodParam] = $method; $request->setBodyParams([]); //$request->headers->remove(Request::CSRF_HEADER); diff --git a/tests/framework/web/UserTest.php b/tests/framework/web/UserTest.php index 8b2838c..e82693b 100644 --- a/tests/framework/web/UserTest.php +++ b/tests/framework/web/UserTest.php @@ -151,8 +151,8 @@ class UserTest extends TestCase } $_SERVER = $server; - Yii::$app->set('response',['class' => 'yii\web\Response']); - Yii::$app->set('request',[ + Yii::$app->set('response', ['class' => 'yii\web\Response']); + Yii::$app->set('request', [ 'class' => 'yii\web\Request', 'scriptFile' => __DIR__ .'/index.php', 'scriptUrl' => '/index.php', diff --git a/tests/framework/widgets/ActiveFieldTest.php b/tests/framework/widgets/ActiveFieldTest.php index c55ff7a..35256a1 100644 --- a/tests/framework/widgets/ActiveFieldTest.php +++ b/tests/framework/widgets/ActiveFieldTest.php @@ -395,7 +395,7 @@ EOD; $this->activeField->enableAjaxValidation = true; $this->activeField->model->addRule($this->attributeName, 'yiiunit\framework\widgets\TestValidator'); - foreach($this->activeField->model->validators as $validator) { + foreach ($this->activeField->model->validators as $validator) { $validator->whenClient = "function (attribute, value) { return 'yii2' == 'yii2'; }"; // js }