Commit 08c844f3 by Qiang Xue

Merge pull request #1093 from mongosoft/master

code style
parents 66b27fca 0d04846c
......@@ -25,10 +25,10 @@ $this->params['breadcrumbs'][] = $this->title;
<?= $form->field($model, 'email') ?>
<?= $form->field($model, 'subject') ?>
<?= $form->field($model, 'body')->textArea(['rows' => 6]) ?>
<?=$form->field($model, 'verifyCode')->widget(Captcha::className(), [
<?= $form->field($model, 'verifyCode')->widget(Captcha::className(), [
'options' => ['class' => 'form-control'],
'template' => '<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>',
]); ?>
]) ?>
<div class="form-group">
<?= Html::submitButton('Submit', ['class' => 'btn btn-primary']) ?>
</div>
......
......@@ -21,7 +21,7 @@ if (empty($params['env'])) {
exit(1);
}
if(isset($envNames[$answer])) {
if (isset($envNames[$answer])) {
$envName = $envNames[$answer];
}
}
......
......@@ -33,10 +33,10 @@ $this->params['breadcrumbs'][] = $this->title;
<?= $form->field($model, 'email') ?>
<?= $form->field($model, 'subject') ?>
<?= $form->field($model, 'body')->textArea(['rows' => 6]) ?>
<?=$form->field($model, 'verifyCode')->widget(Captcha::className(), [
<?= $form->field($model, 'verifyCode')->widget(Captcha::className(), [
'options' => ['class' => 'form-control'],
'template' => '<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>',
]); ?>
]) ?>
<div class="form-group">
<?= Html::submitButton('Submit', ['class' => 'btn btn-primary']) ?>
</div>
......
......@@ -28,9 +28,9 @@ $this->params['breadcrumbs'][] = $this->title;
<?= $form->field($model, 'password')->passwordInput() ?>
<?=$form->field($model, 'rememberMe', [
<?= $form->field($model, 'rememberMe', [
'template' => "<div class=\"col-lg-offset-1 col-lg-3\">{input}</div>\n<div class=\"col-lg-8\">{error}</div>",
])->checkbox(); ?>
])->checkbox() ?>
<div class="form-group">
<div class="col-lg-offset-1 col-lg-11">
......
......@@ -115,7 +115,7 @@ class PhpDocController extends Controller
if (trim($lines[1]) == '*' || substr(trim($lines[1]), 0, 3) == '* @') {
$this->stderr("[WARN] Class $className has no short description.\n", Console::FG_YELLOW, Console::BOLD);
}
foreach($lines as $line) {
foreach ($lines as $line) {
if (substr(trim($line), 0, 9) == '* @since ') {
$seenSince = true;
} elseif (substr(trim($line), 0, 10) == '* @author ') {
......@@ -138,7 +138,7 @@ class PhpDocController extends Controller
$newFileContent = [];
$n = count($fileContent);
for($i = 0; $i < $n; $i++) {
for ($i = 0; $i < $n; $i++) {
if ($i > $start || $i < $docStart) {
$newFileContent[] = $fileContent[$i];
} else {
......@@ -164,7 +164,7 @@ class PhpDocController extends Controller
{
$lines = explode("\n", $doc);
$n = count($lines);
for($i = 0; $i < $n; $i++) {
for ($i = 0; $i < $n; $i++) {
$lines[$i] = rtrim($lines[$i]);
if (trim($lines[$i]) == '*' && trim($lines[$i + 1]) == '*') {
unset($lines[$i]);
......@@ -184,7 +184,7 @@ class PhpDocController extends Controller
$lines = explode("\n", $doc);
$propertyPart = false;
$propertyPosition = false;
foreach($lines as $i => $line) {
foreach ($lines as $i => $line) {
if (substr(trim($line), 0, 12) == '* @property ') {
$propertyPart = true;
} elseif ($propertyPart && trim($line) == '*') {
......@@ -200,7 +200,7 @@ class PhpDocController extends Controller
}
}
$finalDoc = '';
foreach($lines as $i => $line) {
foreach ($lines as $i => $line) {
$finalDoc .= $line . "\n";
if ($i == $propertyPosition) {
$finalDoc .= $properties;
......
......@@ -89,7 +89,7 @@ class BlogController extends Controller
$post = Post::find($id);
$text = $post->text;
if($version) {
if ($version) {
$text = $post->getHistory($version);
}
......@@ -121,13 +121,13 @@ class BlogController extends Controller
public function actionUpdate($id)
{
$post = Post::find($id);
if(!$post) {
if (!$post) {
throw new HttpException(404);
}
if(\Yii::$app->request->isPost)) {
if (\Yii::$app->request->isPost)) {
$post->load($_POST);
if($post->save()) {
if ($post->save()) {
$this->redirect(['view', 'id' => $post->id]);
}
}
......
......@@ -179,7 +179,7 @@ $model->save();
$postTags = [];
$tagsCount = count($_POST['PostTag']);
while($tagsCount-- > 0){
while ($tagsCount-- > 0) {
$postTags[] = new PostTag(['post_id' => $model->id]);
}
Model::loadMultiple($postTags, $_POST);
......
......@@ -28,7 +28,7 @@ as the corresponding key.
So the view for the action above should be in `views/site/index.php` and can be something like:
```php
<p>Hello, <?=$username?>!</p>
<p>Hello, <?= $username ?>!</p>
```
Instead of just scalar values you can pass anything else such as arrays or objects.
......@@ -305,7 +305,7 @@ Then we're using it in `index.php` view where we display a list of users:
```php
<div class="user-index">
<?php
foreach($users as $user) {
foreach ($users as $user) {
echo $this->render('_profile', [
'username' => $user->name,
'tagline' => $user->tagline,
......
......@@ -515,7 +515,7 @@ class BaseYii
return self::$app->getI18n()->translate($category, $message, $params, $language ?: self::$app->language);
} else {
$p = [];
foreach((array) $params as $name => $value) {
foreach ((array) $params as $name => $value) {
$p['{' . $name . '}'] = $value;
}
return ($p === []) ? $message : strtr($message, $p);
......
......@@ -519,7 +519,7 @@ class View extends Component
$this->trigger(self::EVENT_END_PAGE);
$content = ob_get_clean();
foreach(array_keys($this->assetBundles) as $bundle) {
foreach (array_keys($this->assetBundles) as $bundle) {
$this->registerAssetFiles($bundle);
}
echo strtr($content, [
......@@ -549,7 +549,7 @@ class View extends Component
return;
}
$bundle = $this->assetBundles[$name];
foreach($bundle->depends as $dep) {
foreach ($bundle->depends as $dep) {
$this->registerAssetFiles($dep);
}
$bundle->registerAssetFiles($this);
......
......@@ -139,7 +139,7 @@ class RedisCache extends Cache
$response = $this->_connection->executeCommand('MGET', $keys);
$result = [];
$i = 0;
foreach($keys as $key) {
foreach ($keys as $key) {
$result[$key] = $response[$i++];
}
return $result;
......
......@@ -170,7 +170,7 @@ class ActiveDataProvider extends BaseDataProvider
if (($sort = $this->getSort()) !== false && empty($sort->attributes) && $this->query instanceof ActiveQuery) {
/** @var Model $model */
$model = new $this->query->modelClass;
foreach($model->attributes() as $attribute) {
foreach ($model->attributes() as $attribute) {
$sort->attributes[$attribute] = [
'asc' => [$attribute => Sort::ASC],
'desc' => [$attribute => Sort::DESC],
......
......@@ -147,7 +147,7 @@ class Schema extends \yii\db\Schema
}
$foreignKeys = $this->db->pdo->cubrid_schema(\PDO::CUBRID_SCH_IMPORTED_KEYS, $table->name);
foreach($foreignKeys as $key) {
foreach ($foreignKeys as $key) {
if (isset($table->foreignKeys[$key['FK_NAME']])) {
$table->foreignKeys[$key['FK_NAME']][$key['FKCOLUMN_NAME']] = $key['PKCOLUMN_NAME'];
} else {
......@@ -230,7 +230,7 @@ class Schema extends \yii\db\Schema
$this->db->open();
$tables = $this->db->pdo->cubrid_schema(\PDO::CUBRID_SCH_TABLE);
$tableNames = [];
foreach($tables as $table) {
foreach ($tables as $table) {
// do not list system tables
if ($table['TYPE'] != 0) {
$tableNames[] = $table['NAME'];
......
......@@ -17,7 +17,7 @@ public function action<?= Inflector::id2camel(trim(basename($generator->viewName
$model = new <?= $generator->modelClass ?><?= empty($generator->scenarioName) ? "" : "(['scenario' => '{$generator->scenarioName}'])" ?>;
if ($model->load($_POST)) {
if($model->validate()) {
if ($model->validate()) {
// form inputs are valid, do something here
return;
}
......
......@@ -34,19 +34,19 @@ foreach ($generator->templates as $name => $path) {
]); ?>
<div class="row">
<div class="col-lg-8">
<?=$this->renderFile($generator->formView(), [
<?= $this->renderFile($generator->formView(), [
'generator' => $generator,
'form' => $form,
]); ?>
<?=$form->field($generator, 'template')->sticky()
]) ?>
<?= $form->field($generator, 'template')->sticky()
->label('Code Template')
->dropDownList($templates)->hint('
Please select which set of the templates should be used to generated the code.
'); ?>
') ?>
<div class="form-group">
<?= Html::submitButton('Preview', ['name' => 'preview', 'class' => 'btn btn-primary']) ?>
<?php if(isset($files)): ?>
<?php if (isset($files)): ?>
<?= Html::submitButton('Generate', ['name' => 'generate', 'class' => 'btn btn-success']) ?>
<?php endif; ?>
</div>
......
......@@ -190,7 +190,7 @@ class MessageFormatter extends Component
$pattern = $parts[0];
$d = 0;
$stack = [];
for($i = 1; $i < $c; $i++) {
for ($i = 1; $i < $c; $i++) {
if (preg_match('~^(\s*)([\d\w]+)(\s*)([},])(\s*)(.*)$~us', $parts[$i], $matches)) {
// if we are not inside a plural or select this is a message
if (!isset($stack[$d]) || $stack[$d] != 'plural' && $stack[$d] != 'select') {
......@@ -257,7 +257,7 @@ class MessageFormatter extends Component
return [$pattern];
}
$tokens = [mb_substr($pattern, 0, $pos)];
while(true) {
while (true) {
$open = mb_strpos($pattern, '{', $pos + 1);
$close = mb_strpos($pattern, '}', $pos + 1);
if ($open === false && $close === false) {
......@@ -326,7 +326,7 @@ class MessageFormatter extends Component
$select = static::tokenizePattern($token[2]);
$c = count($select);
$message = false;
for($i = 0; $i + 1 < $c; $i++) {
for ($i = 0; $i + 1 < $c; $i++) {
if (is_array($select[$i]) || !is_array($select[$i + 1])) {
return false;
}
......@@ -352,7 +352,7 @@ class MessageFormatter extends Component
$c = count($plural);
$message = false;
$offset = 0;
for($i = 0; $i + 1 < $c; $i++) {
for ($i = 0; $i + 1 < $c; $i++) {
if (is_array($plural[$i]) || !is_array($plural[$i + 1])) {
return false;
}
......
......@@ -384,7 +384,7 @@ class Connection extends Component
private function parseResponse($command)
{
if(($line = fgets($this->_socket)) === false) {
if (($line = fgets($this->_socket)) === false) {
throw new Exception("Failed to read from socket.\nRedis command was: " . $command);
}
$type = $line[0];
......@@ -405,7 +405,7 @@ class Connection extends Component
$length = $line + 2;
$data = '';
while ($length > 0) {
if(($block = fread($this->_socket, $line + 2)) === false) {
if (($block = fread($this->_socket, $line + 2)) === false) {
throw new Exception("Failed to read from socket.\nRedis command was: " . $command);
}
$data .= $block;
......@@ -415,7 +415,7 @@ class Connection extends Component
case '*': // Multi-bulk replies
$count = (int) $line;
$data = [];
for($i = 0; $i < $count; $i++) {
for ($i = 0; $i < $count; $i++) {
$data[] = $this->parseResponse($command);
}
return $data;
......
......@@ -367,8 +367,8 @@ pre .diff .change{
<ul>
<?= $handler->renderCallStackItem($exception->getFile(), $exception->getLine(), null, null, 1) ?>
<?php for ($i = 0, $trace = $exception->getTrace(), $length = count($trace); $i < $length; ++$i): ?>
<?=$handler->renderCallStackItem(@$trace[$i]['file'] ?: null, @$trace[$i]['line'] ?: null,
@$trace[$i]['class'] ?: null, @$trace[$i]['function'] ?: null, $i + 2); ?>
<?= $handler->renderCallStackItem(@$trace[$i]['file'] ?: null, @$trace[$i]['line'] ?: null,
@$trace[$i]['class'] ?: null, @$trace[$i]['function'] ?: null, $i + 2) ?>
<?php endfor; ?>
</ul>
</div>
......
......@@ -24,11 +24,11 @@ class RedisCacheTest extends CacheTestCase
'dataTimeout' => 0.1,
];
$dsn = $config['hostname'] . ':' .$config['port'];
if(!@stream_socket_client($dsn, $errorNumber, $errorDescription, 0.5)) {
if (!@stream_socket_client($dsn, $errorNumber, $errorDescription, 0.5)) {
$this->markTestSkipped('No redis server running at ' . $dsn .' : ' . $errorNumber . ' - ' . $errorDescription);
}
if($this->_cacheInstance === null) {
if ($this->_cacheInstance === null) {
$this->_cacheInstance = new RedisCache($config);
}
return $this->_cacheInstance;
......
......@@ -73,7 +73,7 @@ class ConsoleTest extends TestCase
/* public function testScreenSize()
{
for($i = 1; $i < 20; $i++) {
for ($i = 1; $i < 20; $i++) {
echo implode(', ', Console::getScreenSize(true)) . "\n";
ob_flush();
sleep(1);
......
......@@ -59,7 +59,7 @@ class UrlValidatorTest extends TestCase
public function testValidateWithIdn()
{
if(!function_exists('idn_to_ascii')) {
if (!function_exists('idn_to_ascii')) {
$this->markTestSkipped('intl package required');
return;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment