Commit 51211898 by Alexander Mohorev

Control statements based on the if and elseif constructs must have a single…

Control statements based on the if and elseif constructs must have a single space before the opening parenthesis of the conditional and a single space after the closing parenthesis.
parent 66b27fca
......@@ -21,7 +21,7 @@ if (empty($params['env'])) {
exit(1);
}
if(isset($envNames[$answer])) {
if (isset($envNames[$answer])) {
$envName = $envNames[$answer];
}
}
......
......@@ -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);
......
......@@ -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;
......
......@@ -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