From ea68bd3a5521172750405e510c71d2faeba58036 Mon Sep 17 00:00:00 2001 From: resurtm Date: Sat, 11 May 2013 15:58:27 +0600 Subject: [PATCH] CS fixes. --- tests/unit/framework/base/DictionaryTest.php | 4 ++-- tests/unit/framework/db/QueryTest.php | 2 +- tests/unit/framework/rbac/ManagerTestBase.php | 6 +++--- yii/console/controllers/AppController.php | 25 ++++++++++++------------- yii/console/controllers/MessageController.php | 4 ++-- yii/db/Query.php | 2 +- yii/helpers/base/Markdown.php | 2 +- yii/i18n/GettextMoFile.php | 2 +- yii/i18n/I18N.php | 2 +- yii/logging/ProfileTarget.php | 2 +- yii/test/TestCase.php | 4 ++-- yii/widgets/ListPager.php | 2 +- 12 files changed, 28 insertions(+), 29 deletions(-) diff --git a/tests/unit/framework/base/DictionaryTest.php b/tests/unit/framework/base/DictionaryTest.php index 40cabbb..882ffc2 100644 --- a/tests/unit/framework/base/DictionaryTest.php +++ b/tests/unit/framework/base/DictionaryTest.php @@ -111,8 +111,8 @@ class DictionaryTest extends \yiiunit\TestCase public function testMergeWith() { - $a = array('a' => 'v1', 'v2', array('2'), 'c' => array('3','c' => 'a')); - $b = array('v22', 'a' => 'v11', array('2'), 'c' => array('c' => '3','a')); + $a = array('a' => 'v1', 'v2', array('2'), 'c' => array('3', 'c' => 'a')); + $b = array('v22', 'a' => 'v11', array('2'), 'c' => array('c' => '3', 'a')); $c = array('a' => 'v11', 'v2', array('2'), 'c' => array('3', 'c' => '3', 'a'), 'v22', array('2')); $dictionary = new Dictionary($a); $dictionary2 = new Dictionary($b); diff --git a/tests/unit/framework/db/QueryTest.php b/tests/unit/framework/db/QueryTest.php index 398d0d9..9486acb 100644 --- a/tests/unit/framework/db/QueryTest.php +++ b/tests/unit/framework/db/QueryTest.php @@ -20,7 +20,7 @@ class QueryTest extends \yiiunit\DatabaseTestCase $query = new Query; $query->select('id, name', 'something')->distinct(true); - $this->assertEquals(array('id','name'), $query->select); + $this->assertEquals(array('id', 'name'), $query->select); $this->assertTrue($query->distinct); $this->assertEquals('something', $query->selectOption); } diff --git a/tests/unit/framework/rbac/ManagerTestBase.php b/tests/unit/framework/rbac/ManagerTestBase.php index 03d5354..dc426a1 100644 --- a/tests/unit/framework/rbac/ManagerTestBase.php +++ b/tests/unit/framework/rbac/ManagerTestBase.php @@ -164,8 +164,8 @@ abstract class ManagerTestBase extends TestCase public function testExecuteBizRule() { $this->assertTrue($this->auth->executeBizRule(null, array(), null)); - $this->assertTrue($this->auth->executeBizRule('return 1==true;', array(), null)); - $this->assertTrue($this->auth->executeBizRule('return $params[0]==$params[1];', array(1, '1'), null)); + $this->assertTrue($this->auth->executeBizRule('return 1 == true;', array(), null)); + $this->assertTrue($this->auth->executeBizRule('return $params[0] == $params[1];', array(1, '1'), null)); $this->assertFalse($this->auth->executeBizRule('invalid', array(), null)); } @@ -220,7 +220,7 @@ abstract class ManagerTestBase extends TestCase $this->auth->createOperation('updatePost', 'update a post'); $this->auth->createOperation('deletePost', 'delete a post'); - $task = $this->auth->createTask('updateOwnPost', 'update a post by author himself', 'return $params["authorID"]==$params["userID"];'); + $task = $this->auth->createTask('updateOwnPost', 'update a post by author himself', 'return $params["authorID"] == $params["userID"];'); $task->addChild('updatePost'); $role = $this->auth->createRole('reader'); diff --git a/yii/console/controllers/AppController.php b/yii/console/controllers/AppController.php index 0d31776..95e6e5b 100644 --- a/yii/console/controllers/AppController.php +++ b/yii/console/controllers/AppController.php @@ -8,7 +8,6 @@ namespace yii\console\controllers; use yii\console\Controller; -use yii\helpers\FileHelper; use yii\base\Exception; /** @@ -140,10 +139,10 @@ class AppController extends Controller */ protected function getConfig() { - if ($this->_config===null) { - $this->_config = require $this->getDefaultTemplatesPath().'/config.php'; + if ($this->_config === null) { + $this->_config = require $this->getDefaultTemplatesPath() . '/config.php'; if ($this->templatesPath && file_exists($this->templatesPath)) { - $this->_config = array_merge($this->_config, require $this->templatesPath.'/config.php'); + $this->_config = array_merge($this->_config, require $this->templatesPath . '/config.php'); } } if (isset($this->_config[$this->type])) { @@ -188,18 +187,18 @@ class AppController extends Controller } } - if ($i===0) { - return "'".$path1."'"; + if ($i === 0) { + return "'" . $path1 . "'"; } - $up=''; - for($j=$i;$j<$n2-1;++$j) { - $up.='/..'; + $up = ''; + for ($j = $i; $j < $n2 - 1; ++$j) { + $up .= '/..'; } - for(; $i<$n1-1; ++$i) { - $up.='/'.$segs1[$i]; + for(; $i < $n1 - 1; ++$i) { + $up .= '/' . $segs1[$i]; } - return '__DIR__.\''.$up.'/'.basename($path1).'\''; + return '__DIR__.\'' . $up . '/' . basename($path1) . '\''; } @@ -214,7 +213,7 @@ class AppController extends Controller *
  • callback: optional, the callback to be invoked when copying a file. The callback function * should be declared as follows: *
    -	 *   function foo($source,$params)
    +	 *   function foo($source, $params)
     	 *   
    * where $source parameter is the source file path, and the content returned * by the function will be saved into the target file.
  • diff --git a/yii/console/controllers/MessageController.php b/yii/console/controllers/MessageController.php index defd219..0ad0486 100644 --- a/yii/console/controllers/MessageController.php +++ b/yii/console/controllers/MessageController.php @@ -36,7 +36,7 @@ class MessageController extends Controller * - sourcePath: string, root directory of all source files. * - messagePath: string, root directory containing message translations. * - languages: array, list of language codes that the extracted messages - * should be translated to. For example, array('zh_cn','en_au'). + * should be translated to. For example, array('zh_cn', 'en_au'). * - fileTypes: array, a list of file extensions (e.g. 'php', 'xml'). * Only the files whose extension name can be found in this list * will be processed. If empty, all files will be processed. @@ -135,7 +135,7 @@ class MessageController extends Controller return $messages; } - protected function generateMessageFile($messages,$fileName,$overwrite,$removeOld,$sort) + protected function generateMessageFile($messages, $fileName, $overwrite, $removeOld, $sort) { echo "Saving messages to $fileName..."; if (is_file($fileName)) { diff --git a/yii/db/Query.php b/yii/db/Query.php index 761fae7..1c319a9 100644 --- a/yii/db/Query.php +++ b/yii/db/Query.php @@ -234,7 +234,7 @@ class Query extends \yii\base\Component * * - `in`: operand 1 should be a column or DB expression, and operand 2 be an array representing * the range of the values that the column or DB expression should be in. For example, - * `array('in', 'id', array(1,2,3))` will generate `id IN (1,2,3)`. + * `array('in', 'id', array(1, 2, 3))` will generate `id IN (1, 2, 3)`. * The method will properly quote the column name and escape values in the range. * * - `not in`: similar to the `in` operator except that `IN` is replaced with `NOT IN` in the generated condition. diff --git a/yii/helpers/base/Markdown.php b/yii/helpers/base/Markdown.php index 1efdccb..2e14da5 100644 --- a/yii/helpers/base/Markdown.php +++ b/yii/helpers/base/Markdown.php @@ -39,7 +39,7 @@ class Markdown public static function process($content, $config = array()) { - if (static::$markdown===null) { + if (static::$markdown === null) { static::$markdown = new MarkdownExtra(); } foreach ($config as $name => $value) { diff --git a/yii/i18n/GettextMoFile.php b/yii/i18n/GettextMoFile.php index bacba52..c12aebe 100644 --- a/yii/i18n/GettextMoFile.php +++ b/yii/i18n/GettextMoFile.php @@ -109,7 +109,7 @@ class GettextMoFile extends GettextFile if (($context && $separatorPosition !== false && substr($id, 0, $separatorPosition) === $context) || (!$context && $separatorPosition === false)) { if ($separatorPosition !== false) { - $id = substr($id,$separatorPosition+1); + $id = substr($id, $separatorPosition+1); } $message = $this->readString($fileHandle, $targetLengths[$i], $targetOffsets[$i]); diff --git a/yii/i18n/I18N.php b/yii/i18n/I18N.php index 7fae5b0..1477fd4 100644 --- a/yii/i18n/I18N.php +++ b/yii/i18n/I18N.php @@ -87,7 +87,7 @@ class I18N extends Component $language = Yii::$app->language; } - // allow chars for category: word chars, ".", "-", "/","\" + // allow chars for category: word chars, ".", "-", "/", "\" if (strpos($message, '|') !== false && preg_match('/^([\w\-\\/\.\\\\]+)\|(.*)/', $message, $matches)) { $category = $matches[1]; $message = $matches[2]; diff --git a/yii/logging/ProfileTarget.php b/yii/logging/ProfileTarget.php index 335e172..75447c9 100644 --- a/yii/logging/ProfileTarget.php +++ b/yii/logging/ProfileTarget.php @@ -166,7 +166,7 @@ class CProfileLogRoute extends CWebLogRoute } $entries = array_values($results); - $func = create_function('$a,$b', 'return $a[4]<$b[4]?1:0;'); + $func = create_function('$a,$b', 'return $a[4] < $b[4] ? 1 : 0;'); usort($entries, $func); $this->render('profile-summary', $entries); diff --git a/yii/test/TestCase.php b/yii/test/TestCase.php index f190e5a..2e9b480 100644 --- a/yii/test/TestCase.php +++ b/yii/test/TestCase.php @@ -10,9 +10,9 @@ namespace yii\test; require_once('PHPUnit/Runner/Version.php'); -spl_autoload_unregister(array('Yii','autoload')); +spl_autoload_unregister(array('Yii', 'autoload')); require_once('PHPUnit/Autoload.php'); -spl_autoload_register(array('Yii','autoload')); // put yii's autoloader at the end +spl_autoload_register(array('Yii', 'autoload')); // put yii's autoloader at the end /** * TestCase is the base class for all test case classes. diff --git a/yii/widgets/ListPager.php b/yii/widgets/ListPager.php index 1bc2b21..a68b624 100644 --- a/yii/widgets/ListPager.php +++ b/yii/widgets/ListPager.php @@ -73,7 +73,7 @@ class ListPager extends Widget $selection = $this->pagination->createUrl($currentPage); if (!isset($this->options['onchange'])) { - $this->options['onchange'] = "if(this.value!='') {window.location=this.value;};"; + $this->options['onchange'] = "if (this.value != '') { window.location = this.value; };"; } echo Html::dropDownList(null, $selection, $pages, $this->options);