From 5575f53657f8a3810f914d84c6ad654bf5e85653 Mon Sep 17 00:00:00 2001 From: resurtm Date: Sat, 11 May 2013 15:38:07 +0600 Subject: [PATCH 1/5] CS fixes. --- apps/bootstrap/index.php | 2 +- apps/bootstrap/protected/views/site/contact.php | 2 +- docs/guide/performance.md | 2 +- tests/unit/framework/base/DictionaryTest.php | 123 ++++++++-------- tests/unit/framework/base/ModelTest.php | 2 +- tests/unit/framework/base/VectorTest.php | 133 +++++++++-------- tests/unit/framework/caching/DbCacheTest.php | 4 +- tests/unit/framework/caching/FileCacheTest.php | 2 +- tests/unit/framework/caching/MemCacheTest.php | 4 +- tests/unit/framework/caching/MemCachedTest.php | 4 +- tests/unit/framework/caching/WinCacheTest.php | 6 +- tests/unit/framework/caching/XCacheTest.php | 4 +- tests/unit/framework/caching/ZendDataCacheTest.php | 4 +- tests/unit/framework/db/CommandTest.php | 2 +- tests/unit/framework/helpers/StringHelperTest.php | 2 +- yii/base/ErrorHandler.php | 4 +- yii/base/HttpException.php | 5 +- yii/base/View.php | 2 +- yii/caching/Cache.php | 2 +- yii/console/controllers/AppController.php | 77 +++++----- yii/console/controllers/CacheController.php | 4 +- yii/console/controllers/MessageController.php | 158 +++++++++++---------- yii/db/DataReader.php | 2 +- yii/db/Query.php | 6 +- yii/helpers/base/ArrayHelper.php | 4 +- yii/logging/FileTarget.php | 4 +- yii/renderers/SmartyViewRenderer.php | 2 +- yii/views/exception.php | 17 ++- yii/web/Pagination.php | 2 +- yii/web/Response.php | 8 +- yii/web/Sort.php | 2 +- yii/widgets/ActiveField.php | 2 +- yii/yiic.php | 2 +- 33 files changed, 306 insertions(+), 293 deletions(-) diff --git a/apps/bootstrap/index.php b/apps/bootstrap/index.php index dec6e35..cf87d81 100644 --- a/apps/bootstrap/index.php +++ b/apps/bootstrap/index.php @@ -1,5 +1,5 @@ params['breadcrumbs'][] = $this->title; ?>

title); ?>

-session->hasFlash('contactFormSubmitted')): ?> +session->hasFlash('contactFormSubmitted')): ?>
Thank you for contacting us. We will respond to you as soon as possible.
diff --git a/docs/guide/performance.md b/docs/guide/performance.md index 9a871dc..35efa67 100644 --- a/docs/guide/performance.md +++ b/docs/guide/performance.md @@ -162,7 +162,7 @@ class PostController extends Controller In the view you should access fields of each invidual record from `$posts` as array: ```php -foreach($posts as $post) { +foreach ($posts as $post) { echo $post['title']."
"; } ``` diff --git a/tests/unit/framework/base/DictionaryTest.php b/tests/unit/framework/base/DictionaryTest.php index 9e55547..40cabbb 100644 --- a/tests/unit/framework/base/DictionaryTest.php +++ b/tests/unit/framework/base/DictionaryTest.php @@ -15,52 +15,54 @@ class DictionaryTest extends \yiiunit\TestCase * @var \yii\base\Dictionary */ protected $dictionary; - protected $item1,$item2,$item3; + protected $item1; + protected $item2; + protected $item3; public function setUp() { - $this->dictionary=new Dictionary; - $this->item1=new MapItem; - $this->item2=new MapItem; - $this->item3=new MapItem; - $this->dictionary->add('key1',$this->item1); - $this->dictionary->add('key2',$this->item2); + $this->dictionary = new Dictionary; + $this->item1 = new MapItem; + $this->item2 = new MapItem; + $this->item3 = new MapItem; + $this->dictionary->add('key1', $this->item1); + $this->dictionary->add('key2', $this->item2); } public function tearDown() { - $this->dictionary=null; - $this->item1=null; - $this->item2=null; - $this->item3=null; + $this->dictionary = null; + $this->item1 = null; + $this->item2 = null; + $this->item3 = null; } public function testConstruct() { - $a=array(1,2,'key3'=>3); - $dictionary=new Dictionary($a); - $this->assertEquals(3,$dictionary->getCount()); + $a = array(1, 2, 'key3' => 3); + $dictionary = new Dictionary($a); + $this->assertEquals(3, $dictionary->getCount()); $dictionary2=new Dictionary($this->dictionary); - $this->assertEquals(2,$dictionary2->getCount()); + $this->assertEquals(2, $dictionary2->getCount()); } public function testGetCount() { - $this->assertEquals(2,$this->dictionary->getCount()); + $this->assertEquals(2, $this->dictionary->getCount()); } public function testGetKeys() { - $keys=$this->dictionary->getKeys(); - $this->assertEquals(2,count($keys)); - $this->assertEquals('key1',$keys[0]); - $this->assertEquals('key2',$keys[1]); + $keys = $this->dictionary->getKeys(); + $this->assertEquals(2, count($keys)); + $this->assertEquals('key1', $keys[0]); + $this->assertEquals('key2', $keys[1]); } public function testAdd() { - $this->dictionary->add('key3',$this->item3); - $this->assertEquals(3,$this->dictionary->getCount()); + $this->dictionary->add('key3', $this->item3); + $this->assertEquals(3, $this->dictionary->getCount()); $this->assertTrue($this->dictionary->has('key3')); $this->dictionary[] = 'test'; @@ -69,21 +71,21 @@ class DictionaryTest extends \yiiunit\TestCase public function testRemove() { $this->dictionary->remove('key1'); - $this->assertEquals(1,$this->dictionary->getCount()); + $this->assertEquals(1, $this->dictionary->getCount()); $this->assertTrue(!$this->dictionary->has('key1')); - $this->assertTrue($this->dictionary->remove('unknown key')===null); + $this->assertTrue($this->dictionary->remove('unknown key') === null); } public function testRemoveAll() { - $this->dictionary->add('key3',$this->item3); + $this->dictionary->add('key3', $this->item3); $this->dictionary->removeAll(); - $this->assertEquals(0,$this->dictionary->getCount()); + $this->assertEquals(0, $this->dictionary->getCount()); $this->assertTrue(!$this->dictionary->has('key1') && !$this->dictionary->has('key2')); - $this->dictionary->add('key3',$this->item3); + $this->dictionary->add('key3', $this->item3); $this->dictionary->removeAll(true); - $this->assertEquals(0,$this->dictionary->getCount()); + $this->assertEquals(0, $this->dictionary->getCount()); $this->assertTrue(!$this->dictionary->has('key1') && !$this->dictionary->has('key2')); } @@ -96,7 +98,7 @@ class DictionaryTest extends \yiiunit\TestCase public function testFromArray() { - $array=array('key3'=>$this->item3,'key4'=>$this->item1); + $array = array('key3' => $this->item3, 'key4' => $this->item1); $this->dictionary->copyFrom($array); $this->assertEquals(2, $this->dictionary->getCount()); @@ -109,21 +111,21 @@ 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')); - $c=array('a'=>'v11','v2',array('2'),'c'=>array('3','c'=>'3','a'),'v22',array('2')); - $dictionary=new Dictionary($a); - $dictionary2=new Dictionary($b); + $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); $dictionary->mergeWith($dictionary2); - $this->assertTrue($dictionary->toArray()===$c); + $this->assertTrue($dictionary->toArray() === $c); - $array=array('key2'=>$this->item1,'key3'=>$this->item3); - $this->dictionary->mergeWith($array,false); - $this->assertEquals(3,$this->dictionary->getCount()); - $this->assertEquals($this->item1,$this->dictionary['key2']); - $this->assertEquals($this->item3,$this->dictionary['key3']); + $array = array('key2' => $this->item1, 'key3' => $this->item3); + $this->dictionary->mergeWith($array, false); + $this->assertEquals(3, $this->dictionary->getCount()); + $this->assertEquals($this->item1, $this->dictionary['key2']); + $this->assertEquals($this->item3, $this->dictionary['key3']); $this->setExpectedException('yii\base\InvalidParamException'); - $this->dictionary->mergeWith($this,false); + $this->dictionary->mergeWith($this, false); } public function testRecursiveMergeWithTraversable(){ @@ -135,7 +137,7 @@ class DictionaryTest extends \yiiunit\TestCase 'k4' => $this->item3, )) )); - $dictionary->mergeWith($obj,true); + $dictionary->mergeWith($obj, true); $this->assertEquals(3, $dictionary->getCount()); $this->assertEquals($this->item1, $dictionary['k1']); @@ -145,23 +147,23 @@ class DictionaryTest extends \yiiunit\TestCase public function testArrayRead() { - $this->assertEquals($this->item1,$this->dictionary['key1']); - $this->assertEquals($this->item2,$this->dictionary['key2']); - $this->assertEquals(null,$this->dictionary['key3']); + $this->assertEquals($this->item1, $this->dictionary['key1']); + $this->assertEquals($this->item2, $this->dictionary['key2']); + $this->assertEquals(null, $this->dictionary['key3']); } public function testArrayWrite() { - $this->dictionary['key3']=$this->item3; - $this->assertEquals(3,$this->dictionary->getCount()); - $this->assertEquals($this->item3,$this->dictionary['key3']); + $this->dictionary['key3'] = $this->item3; + $this->assertEquals(3, $this->dictionary->getCount()); + $this->assertEquals($this->item3, $this->dictionary['key3']); - $this->dictionary['key1']=$this->item3; - $this->assertEquals(3,$this->dictionary->getCount()); - $this->assertEquals($this->item3,$this->dictionary['key1']); + $this->dictionary['key1'] = $this->item3; + $this->assertEquals(3, $this->dictionary->getCount()); + $this->assertEquals($this->item3, $this->dictionary['key1']); unset($this->dictionary['key2']); - $this->assertEquals(2,$this->dictionary->getCount()); + $this->assertEquals(2, $this->dictionary->getCount()); $this->assertTrue(!$this->dictionary->has('key2')); unset($this->dictionary['unknown key']); @@ -169,22 +171,23 @@ class DictionaryTest extends \yiiunit\TestCase public function testArrayForeach() { - $n=0; - $found=0; - foreach($this->dictionary as $index=>$item) - { + $n = 0; + $found = 0; + foreach ($this->dictionary as $index => $item) { $n++; - if($index==='key1' && $item===$this->item1) + if ($index === 'key1' && $item === $this->item1) { $found++; - if($index==='key2' && $item===$this->item2) + } + if ($index === 'key2' && $item === $this->item2) { $found++; + } } - $this->assertTrue($n==2 && $found==2); + $this->assertTrue($n == 2 && $found == 2); } public function testArrayMisc() { - $this->assertEquals($this->dictionary->Count,count($this->dictionary)); + $this->assertEquals($this->dictionary->Count, count($this->dictionary)); $this->assertTrue(isset($this->dictionary['key1'])); $this->assertFalse(isset($this->dictionary['unknown key'])); } diff --git a/tests/unit/framework/base/ModelTest.php b/tests/unit/framework/base/ModelTest.php index f04e550..cf6f09f 100644 --- a/tests/unit/framework/base/ModelTest.php +++ b/tests/unit/framework/base/ModelTest.php @@ -155,7 +155,7 @@ class ModelTest extends TestCase // iteration $attributes = array(); - foreach($speaker as $key => $attribute) { + foreach ($speaker as $key => $attribute) { $attributes[$key] = $attribute; } $this->assertEquals(array( diff --git a/tests/unit/framework/base/VectorTest.php b/tests/unit/framework/base/VectorTest.php index 5c44d17..b14d5dc 100644 --- a/tests/unit/framework/base/VectorTest.php +++ b/tests/unit/framework/base/VectorTest.php @@ -15,39 +15,41 @@ class VectorTest extends \yiiunit\TestCase * @var Vector */ protected $vector; - protected $item1, $item2, $item3; + protected $item1; + protected $item2; + protected $item3; public function setUp() { - $this->vector=new Vector; - $this->item1=new ListItem; - $this->item2=new ListItem; - $this->item3=new ListItem; + $this->vector = new Vector; + $this->item1 = new ListItem; + $this->item2 = new ListItem; + $this->item3 = new ListItem; $this->vector->add($this->item1); $this->vector->add($this->item2); } public function tearDown() { - $this->vector=null; - $this->item1=null; - $this->item2=null; - $this->item3=null; + $this->vector = null; + $this->item1 = null; + $this->item2 = null; + $this->item3 = null; } public function testConstruct() { - $a=array(1,2,3); - $vector=new Vector($a); - $this->assertEquals(3,$vector->getCount()); - $vector2=new Vector($this->vector); - $this->assertEquals(2,$vector2->getCount()); + $a = array(1, 2, 3); + $vector = new Vector($a); + $this->assertEquals(3, $vector->getCount()); + $vector2 = new Vector($this->vector); + $this->assertEquals(2, $vector2->getCount()); } public function testItemAt() { - $a=array(1, 2, null, 4); - $vector=new Vector($a); + $a = array(1, 2, null, 4); + $vector = new Vector($a); $this->assertEquals(1, $vector->itemAt(0)); $this->assertEquals(2, $vector->itemAt(1)); $this->assertNull($vector->itemAt(2)); @@ -56,37 +58,37 @@ class VectorTest extends \yiiunit\TestCase public function testGetCount() { - $this->assertEquals(2,$this->vector->getCount()); - $this->assertEquals(2,$this->vector->Count); + $this->assertEquals(2, $this->vector->getCount()); + $this->assertEquals(2, $this->vector->Count); } public function testAdd() { $this->vector->add(null); $this->vector->add($this->item3); - $this->assertEquals(4,$this->vector->getCount()); - $this->assertEquals(3,$this->vector->indexOf($this->item3)); + $this->assertEquals(4, $this->vector->getCount()); + $this->assertEquals(3, $this->vector->indexOf($this->item3)); } public function testInsertAt() { - $this->vector->insertAt(0,$this->item3); - $this->assertEquals(3,$this->vector->getCount()); - $this->assertEquals(2,$this->vector->indexOf($this->item2)); - $this->assertEquals(0,$this->vector->indexOf($this->item3)); - $this->assertEquals(1,$this->vector->indexOf($this->item1)); + $this->vector->insertAt(0, $this->item3); + $this->assertEquals(3, $this->vector->getCount()); + $this->assertEquals(2, $this->vector->indexOf($this->item2)); + $this->assertEquals(0, $this->vector->indexOf($this->item3)); + $this->assertEquals(1, $this->vector->indexOf($this->item1)); $this->setExpectedException('yii\base\InvalidParamException'); - $this->vector->insertAt(4,$this->item3); + $this->vector->insertAt(4, $this->item3); } public function testRemove() { $this->vector->remove($this->item1); - $this->assertEquals(1,$this->vector->getCount()); - $this->assertEquals(-1,$this->vector->indexOf($this->item1)); - $this->assertEquals(0,$this->vector->indexOf($this->item2)); + $this->assertEquals(1, $this->vector->getCount()); + $this->assertEquals(-1, $this->vector->indexOf($this->item1)); + $this->assertEquals(0, $this->vector->indexOf($this->item2)); - $this->assertEquals(false,$this->vector->remove($this->item1)); + $this->assertEquals(false, $this->vector->remove($this->item1)); } @@ -94,9 +96,9 @@ class VectorTest extends \yiiunit\TestCase { $this->vector->add($this->item3); $this->vector->removeAt(1); - $this->assertEquals(-1,$this->vector->indexOf($this->item2)); - $this->assertEquals(1,$this->vector->indexOf($this->item3)); - $this->assertEquals(0,$this->vector->indexOf($this->item1)); + $this->assertEquals(-1, $this->vector->indexOf($this->item2)); + $this->assertEquals(1, $this->vector->indexOf($this->item3)); + $this->assertEquals(0, $this->vector->indexOf($this->item1)); $this->setExpectedException('yii\base\InvalidParamException'); $this->vector->removeAt(2); } @@ -105,15 +107,15 @@ class VectorTest extends \yiiunit\TestCase { $this->vector->add($this->item3); $this->vector->removeAll(); - $this->assertEquals(0,$this->vector->getCount()); - $this->assertEquals(-1,$this->vector->indexOf($this->item1)); - $this->assertEquals(-1,$this->vector->indexOf($this->item2)); + $this->assertEquals(0, $this->vector->getCount()); + $this->assertEquals(-1, $this->vector->indexOf($this->item1)); + $this->assertEquals(-1, $this->vector->indexOf($this->item2)); $this->vector->add($this->item3); $this->vector->removeAll(true); - $this->assertEquals(0,$this->vector->getCount()); - $this->assertEquals(-1,$this->vector->indexOf($this->item1)); - $this->assertEquals(-1,$this->vector->indexOf($this->item2)); + $this->assertEquals(0, $this->vector->getCount()); + $this->assertEquals(-1, $this->vector->indexOf($this->item1)); + $this->assertEquals(-1, $this->vector->indexOf($this->item2)); } public function testHas() @@ -125,30 +127,32 @@ class VectorTest extends \yiiunit\TestCase public function testIndexOf() { - $this->assertEquals(0,$this->vector->indexOf($this->item1)); - $this->assertEquals(1,$this->vector->indexOf($this->item2)); - $this->assertEquals(-1,$this->vector->indexOf($this->item3)); + $this->assertEquals(0, $this->vector->indexOf($this->item1)); + $this->assertEquals(1, $this->vector->indexOf($this->item2)); + $this->assertEquals(-1, $this->vector->indexOf($this->item3)); } public function testFromArray() { - $array=array($this->item3,$this->item1); + $array = array($this->item3, $this->item1); $this->vector->copyFrom($array); - $this->assertTrue(count($array)==2 && $this->vector[0]===$this->item3 && $this->vector[1]===$this->item1); + $this->assertTrue(count($array) == 2 && $this->vector[0] === $this->item3 && $this->vector[1] === $this->item1); $this->setExpectedException('yii\base\InvalidParamException'); $this->vector->copyFrom($this); } public function testMergeWith() { - $array=array($this->item3,$this->item1); + $array = array($this->item3, $this->item1); $this->vector->mergeWith($array); - $this->assertTrue($this->vector->getCount()==4 && $this->vector[0]===$this->item1 && $this->vector[3]===$this->item1); + $this->assertTrue($this->vector->getCount() == 4 && $this->vector[0] === $this->item1 && + $this->vector[3] === $this->item1); - $a=array(1); - $vector=new Vector($a); + $a = array(1); + $vector = new Vector($a); $this->vector->mergeWith($vector); - $this->assertTrue($this->vector->getCount()==5 && $this->vector[0]===$this->item1 && $this->vector[3]===$this->item1 && $this->vector[4]===1); + $this->assertTrue($this->vector->getCount() == 5 && $this->vector[0] === $this->item1 && + $this->vector[3] === $this->item1 && $this->vector[4] === 1); $this->setExpectedException('yii\base\InvalidParamException'); $this->vector->mergeWith($this); @@ -156,37 +160,40 @@ class VectorTest extends \yiiunit\TestCase public function testToArray() { - $array=$this->vector->toArray(); - $this->assertTrue(count($array)==2 && $array[0]===$this->item1 && $array[1]===$this->item2); + $array = $this->vector->toArray(); + $this->assertTrue(count($array) == 2 && $array[0] === $this->item1 && $array[1] === $this->item2); } public function testArrayRead() { - $this->assertTrue($this->vector[0]===$this->item1); - $this->assertTrue($this->vector[1]===$this->item2); + $this->assertTrue($this->vector[0] === $this->item1); + $this->assertTrue($this->vector[1] === $this->item2); $this->setExpectedException('yii\base\InvalidParamException'); - $a=$this->vector[2]; + $a = $this->vector[2]; } public function testGetIterator() { - $n=0; - $found=0; - foreach($this->vector as $index=>$item) - { - foreach($this->vector as $a=>$b); // test of iterator + $n = 0; + $found = 0; + foreach ($this->vector as $index => $item) { + foreach ($this->vector as $a => $b) { + // test of iterator + } $n++; - if($index===0 && $item===$this->item1) + if ($index === 0 && $item === $this->item1) { $found++; - if($index===1 && $item===$this->item2) + } + if ($index === 1 && $item === $this->item2) { $found++; + } } - $this->assertTrue($n==2 && $found==2); + $this->assertTrue($n == 2 && $found == 2); } public function testArrayMisc() { - $this->assertEquals($this->vector->Count,count($this->vector)); + $this->assertEquals($this->vector->Count, count($this->vector)); $this->assertTrue(isset($this->vector[1])); $this->assertFalse(isset($this->vector[2])); } diff --git a/tests/unit/framework/caching/DbCacheTest.php b/tests/unit/framework/caching/DbCacheTest.php index 253240d..523281d 100644 --- a/tests/unit/framework/caching/DbCacheTest.php +++ b/tests/unit/framework/caching/DbCacheTest.php @@ -34,7 +34,7 @@ class DbCacheTest extends CacheTest */ function getConnection($reset = true) { - if($this->_connection === null) { + if ($this->_connection === null) { $databases = $this->getParam('databases'); $params = $databases['mysql']; $db = new \yii\db\Connection; @@ -61,7 +61,7 @@ class DbCacheTest extends CacheTest */ protected function getCacheInstance() { - if($this->_cacheInstance === null) { + if ($this->_cacheInstance === null) { $this->_cacheInstance = new DbCache(array( 'db' => $this->getConnection(), )); diff --git a/tests/unit/framework/caching/FileCacheTest.php b/tests/unit/framework/caching/FileCacheTest.php index 37d3222..99e3cbc 100644 --- a/tests/unit/framework/caching/FileCacheTest.php +++ b/tests/unit/framework/caching/FileCacheTest.php @@ -15,7 +15,7 @@ class FileCacheTest extends CacheTest */ protected function getCacheInstance() { - if($this->_cacheInstance === null) { + if ($this->_cacheInstance === null) { $this->_cacheInstance = new FileCache(array( 'cachePath' => '@yiiunit/runtime/cache', )); diff --git a/tests/unit/framework/caching/MemCacheTest.php b/tests/unit/framework/caching/MemCacheTest.php index 40dba12..2855e2c 100644 --- a/tests/unit/framework/caching/MemCacheTest.php +++ b/tests/unit/framework/caching/MemCacheTest.php @@ -15,11 +15,11 @@ class MemCacheTest extends CacheTest */ protected function getCacheInstance() { - if(!extension_loaded("memcache")) { + if (!extension_loaded("memcache")) { $this->markTestSkipped("memcache not installed. Skipping."); } - if($this->_cacheInstance === null) { + if ($this->_cacheInstance === null) { $this->_cacheInstance = new MemCache(); } return $this->_cacheInstance; diff --git a/tests/unit/framework/caching/MemCachedTest.php b/tests/unit/framework/caching/MemCachedTest.php index c9e437c..66dfb50 100644 --- a/tests/unit/framework/caching/MemCachedTest.php +++ b/tests/unit/framework/caching/MemCachedTest.php @@ -15,11 +15,11 @@ class MemCachedTest extends CacheTest */ protected function getCacheInstance() { - if(!extension_loaded("memcached")) { + if (!extension_loaded("memcached")) { $this->markTestSkipped("memcached not installed. Skipping."); } - if($this->_cacheInstance === null) { + if ($this->_cacheInstance === null) { $this->_cacheInstance = new MemCache(array( 'useMemcached' => true, )); diff --git a/tests/unit/framework/caching/WinCacheTest.php b/tests/unit/framework/caching/WinCacheTest.php index c9470bd..1b3399c 100644 --- a/tests/unit/framework/caching/WinCacheTest.php +++ b/tests/unit/framework/caching/WinCacheTest.php @@ -15,15 +15,15 @@ class WinCacheTest extends CacheTest */ protected function getCacheInstance() { - if(!extension_loaded('wincache')) { + if (!extension_loaded('wincache')) { $this->markTestSkipped("Wincache not installed. Skipping."); } - if(!ini_get('wincache.ucenabled')) { + if (!ini_get('wincache.ucenabled')) { $this->markTestSkipped("Wincache user cache disabled. Skipping."); } - if($this->_cacheInstance === null) { + if ($this->_cacheInstance === null) { $this->_cacheInstance = new WinCache(); } return $this->_cacheInstance; diff --git a/tests/unit/framework/caching/XCacheTest.php b/tests/unit/framework/caching/XCacheTest.php index b5e41a6..5e952af 100644 --- a/tests/unit/framework/caching/XCacheTest.php +++ b/tests/unit/framework/caching/XCacheTest.php @@ -15,11 +15,11 @@ class XCacheTest extends CacheTest */ protected function getCacheInstance() { - if(!function_exists("xcache_isset")) { + if (!function_exists("xcache_isset")) { $this->markTestSkipped("XCache not installed. Skipping."); } - if($this->_cacheInstance === null) { + if ($this->_cacheInstance === null) { $this->_cacheInstance = new XCache(); } return $this->_cacheInstance; diff --git a/tests/unit/framework/caching/ZendDataCacheTest.php b/tests/unit/framework/caching/ZendDataCacheTest.php index 86c06c8..20aa3fc 100644 --- a/tests/unit/framework/caching/ZendDataCacheTest.php +++ b/tests/unit/framework/caching/ZendDataCacheTest.php @@ -15,11 +15,11 @@ class ZendDataCacheTest extends CacheTest */ protected function getCacheInstance() { - if(!function_exists("zend_shm_cache_store")) { + if (!function_exists("zend_shm_cache_store")) { $this->markTestSkipped("Zend Data cache not installed. Skipping."); } - if($this->_cacheInstance === null) { + if ($this->_cacheInstance === null) { $this->_cacheInstance = new ZendDataCache(); } return $this->_cacheInstance; diff --git a/tests/unit/framework/db/CommandTest.php b/tests/unit/framework/db/CommandTest.php index 0d9652b..498df2a 100644 --- a/tests/unit/framework/db/CommandTest.php +++ b/tests/unit/framework/db/CommandTest.php @@ -140,7 +140,7 @@ class CommandTest extends \yiiunit\DatabaseTestCase $db = $this->getConnection(); // bindParam - $sql = 'INSERT INTO tbl_customer(email,name,address) VALUES (:email, :name, :address)'; + $sql = 'INSERT INTO tbl_customer(email, name, address) VALUES (:email, :name, :address)'; $command = $db->createCommand($sql); $email = 'user4@example.com'; $name = 'user4'; diff --git a/tests/unit/framework/helpers/StringHelperTest.php b/tests/unit/framework/helpers/StringHelperTest.php index 64811d1..fc76a26 100644 --- a/tests/unit/framework/helpers/StringHelperTest.php +++ b/tests/unit/framework/helpers/StringHelperTest.php @@ -40,7 +40,7 @@ class StringHelperTest extends \yii\test\TestCase 'car' => 'cars', ); - foreach($testData as $testIn => $testOut) { + foreach ($testData as $testIn => $testOut) { $this->assertEquals($testOut, StringHelper::pluralize($testIn)); $this->assertEquals(ucfirst($testOut), ucfirst(StringHelper::pluralize($testIn))); } diff --git a/yii/base/ErrorHandler.php b/yii/base/ErrorHandler.php index 98a061d..44c2ca0 100644 --- a/yii/base/ErrorHandler.php +++ b/yii/base/ErrorHandler.php @@ -83,7 +83,7 @@ class ErrorHandler extends Component } else { // if there is an error during error rendering it's useful to // display PHP error in debug mode instead of a blank screen - if(YII_DEBUG) { + if (YII_DEBUG) { ini_set('display_errors', 1); } @@ -231,7 +231,7 @@ class ErrorHandler extends Component echo '
+
-
'; } echo ' '; - if(isset($t['file'])) { + if (isset($t['file'])) { echo $this->htmlEncode($t['file']) . '(' . $t['line'] . '): '; } if (!empty($t['class'])) { diff --git a/yii/base/HttpException.php b/yii/base/HttpException.php index 948d96b..55e0531 100644 --- a/yii/base/HttpException.php +++ b/yii/base/HttpException.php @@ -100,9 +100,10 @@ class HttpException extends UserException 509 => 'Bandwidth Limit Exceeded', ); - if(isset($httpCodes[$this->statusCode])) + if (isset($httpCodes[$this->statusCode])) { return $httpCodes[$this->statusCode]; - else + } else { return \Yii::t('yii|Error'); + } } } diff --git a/yii/base/View.php b/yii/base/View.php index af65c49..b71e605 100644 --- a/yii/base/View.php +++ b/yii/base/View.php @@ -503,7 +503,7 @@ class View extends Component * A typical usage of fragment caching is as follows, * * ~~~ - * if($this->beginCache($id)) { + * if ($this->beginCache($id)) { * // ...generate content here * $this->endCache(); * } diff --git a/yii/caching/Cache.php b/yii/caching/Cache.php index 78f2854..ffc7081 100644 --- a/yii/caching/Cache.php +++ b/yii/caching/Cache.php @@ -140,7 +140,7 @@ abstract class Cache extends Component implements \ArrayAccess * this method will try to simulate it. * @param array $keys list of keys identifying the cached values * @return array list of cached values corresponding to the specified keys. The array - * is returned in terms of (key,value) pairs. + * is returned in terms of (key, value) pairs. * If a value is not cached or expired, the corresponding array value will be false. */ public function mget($keys) diff --git a/yii/console/controllers/AppController.php b/yii/console/controllers/AppController.php index 17f7420..0d31776 100644 --- a/yii/console/controllers/AppController.php +++ b/yii/console/controllers/AppController.php @@ -39,7 +39,7 @@ class AppController extends Controller { parent::init(); - if($this->templatesPath && !is_dir($this->templatesPath)) { + if ($this->templatesPath && !is_dir($this->templatesPath)) { throw new Exception('--templatesPath "'.$this->templatesPath.'" does not exist or can not be read.'); } } @@ -67,30 +67,29 @@ class AppController extends Controller public function actionCreate($path) { $path = strtr($path, '/\\', DIRECTORY_SEPARATOR); - if(strpos($path, DIRECTORY_SEPARATOR) === false) { + if (strpos($path, DIRECTORY_SEPARATOR) === false) { $path = '.'.DIRECTORY_SEPARATOR.$path; } $dir = rtrim(realpath(dirname($path)), '\\/'); - if($dir === false || !is_dir($dir)) { + if ($dir === false || !is_dir($dir)) { throw new Exception("The directory '$path' is not valid. Please make sure the parent directory exists."); } - if(basename($path) === '.') { + if (basename($path) === '.') { $this->_rootPath = $path = $dir; - } - else { + } else { $this->_rootPath = $path = $dir.DIRECTORY_SEPARATOR.basename($path); } - if($this->confirm("Create \"$this->type\" application under '$path'?")) { + if ($this->confirm("Create \"$this->type\" application under '$path'?")) { $sourceDir = $this->getSourceDir(); $config = $this->getConfig(); $list = $this->buildFileList($sourceDir, $path); - if(is_array($config)) { - foreach($config as $file => $settings) { - if(isset($settings['handler'])) { + if (is_array($config)) { + foreach ($config as $file => $settings) { + if (isset($settings['handler'])) { $list[$file]['callback'] = $settings['handler']; } } @@ -98,9 +97,9 @@ class AppController extends Controller $this->copyFiles($list); - if(is_array($config)) { - foreach($config as $file => $settings) { - if(isset($settings['permissions'])) { + if (is_array($config)) { + foreach ($config as $file => $settings) { + if (isset($settings['permissions'])) { @chmod($path.'/'.$file, $settings['permissions']); } } @@ -119,13 +118,11 @@ class AppController extends Controller $customSource = realpath($this->templatesPath.'/'.$this->type); $defaultSource = realpath($this->getDefaultTemplatesPath().'/'.$this->type); - if($customSource) { + if ($customSource) { return $customSource; - } - elseif($defaultSource) { + } elseif ($defaultSource) { return $defaultSource; - } - else { + } else { throw new Exception('Unable to locate the source directory for "'.$this->type.'".'); } } @@ -143,13 +140,13 @@ class AppController extends Controller */ protected function getConfig() { - if($this->_config===null) { + if ($this->_config===null) { $this->_config = require $this->getDefaultTemplatesPath().'/config.php'; - if($this->templatesPath && file_exists($this->templatesPath)) { + if ($this->templatesPath && file_exists($this->templatesPath)) { $this->_config = array_merge($this->_config, require $this->templatesPath.'/config.php'); } } - if(isset($this->_config[$this->type])) { + if (isset($this->_config[$this->type])) { return $this->_config[$this->type]; } } @@ -185,13 +182,13 @@ class AppController extends Controller $n1 = count($segs1); $n2 = count($segs2); - for($i=0; $i<$n1 && $i<$n2; ++$i) { - if($segs1[$i] !== $segs2[$i]) { + for ($i = 0; $i < $n1 && $i < $n2; ++$i) { + if ($segs1[$i] !== $segs2[$i]) { break; } } - if($i===0) { + if ($i===0) { return "'".$path1."'"; } $up=''; @@ -228,48 +225,44 @@ class AppController extends Controller protected function copyFiles($fileList) { $overwriteAll = false; - foreach($fileList as $name=>$file) { + foreach ($fileList as $name => $file) { $source = strtr($file['source'], '/\\', DIRECTORY_SEPARATOR); $target = strtr($file['target'], '/\\', DIRECTORY_SEPARATOR); $callback = isset($file['callback']) ? $file['callback'] : null; $params = isset($file['params']) ? $file['params'] : null; - if(is_dir($source)) { + if (is_dir($source)) { if (!is_dir($target)) { mkdir($target, 0777, true); } continue; } - if($callback !== null) { + if ($callback !== null) { $content = call_user_func($callback, $source, $params); - } - else { + } else { $content = file_get_contents($source); } - if(is_file($target)) { - if($content === file_get_contents($target)) { + if (is_file($target)) { + if ($content === file_get_contents($target)) { echo " unchanged $name\n"; continue; } - if($overwriteAll) { + if ($overwriteAll) { echo " overwrite $name\n"; } else { echo " exist $name\n"; echo " ...overwrite? [Yes|No|All|Quit] "; $answer = trim(fgets(STDIN)); - if(!strncasecmp($answer, 'q', 1)) { + if (!strncasecmp($answer, 'q', 1)) { return; - } - elseif(!strncasecmp($answer, 'y', 1)) { + } elseif (!strncasecmp($answer, 'y', 1)) { echo " overwrite $name\n"; - } - elseif(!strncasecmp($answer, 'a', 1)) { + } elseif (!strncasecmp($answer, 'a', 1)) { echo " overwrite $name\n"; $overwriteAll = true; - } - else { + } else { echo " skip $name\n"; continue; } @@ -303,8 +296,8 @@ class AppController extends Controller { $list = array(); $handle = opendir($sourceDir); - while(($file = readdir($handle)) !== false) { - if(in_array($file, array('.', '..', '.svn', '.gitignore', '.hgignore')) || in_array($file, $ignoreFiles)) { + while (($file = readdir($handle)) !== false) { + if (in_array($file, array('.', '..', '.svn', '.gitignore', '.hgignore')) || in_array($file, $ignoreFiles)) { continue; } $sourcePath = $sourceDir.DIRECTORY_SEPARATOR.$file; @@ -314,7 +307,7 @@ class AppController extends Controller 'source' => $sourcePath, 'target' => $targetPath, ); - if(is_dir($sourcePath)) { + if (is_dir($sourcePath)) { $list = array_merge($list, self::buildFileList($sourcePath, $targetPath, $name, $ignoreFiles, $renameMap)); } } diff --git a/yii/console/controllers/CacheController.php b/yii/console/controllers/CacheController.php index 6765f9b..b171780 100644 --- a/yii/console/controllers/CacheController.php +++ b/yii/console/controllers/CacheController.php @@ -34,11 +34,11 @@ class CacheController extends Controller { /** @var $cache Cache */ $cache = \Yii::$app->getComponent($component); - if(!$cache || !$cache instanceof Cache) { + if (!$cache || !$cache instanceof Cache) { throw new Exception('Application component "'.$component.'" is not defined or not a cache.'); } - if(!$cache->flush()) { + if (!$cache->flush()) { throw new Exception('Unable to flush cache.'); } diff --git a/yii/console/controllers/MessageController.php b/yii/console/controllers/MessageController.php index e010b55..defd219 100644 --- a/yii/console/controllers/MessageController.php +++ b/yii/console/controllers/MessageController.php @@ -57,70 +57,80 @@ class MessageController extends Controller */ public function actionIndex($config) { - if(!is_file($config)) + if (!is_file($config)) { $this->usageError("the configuration file {$config} does not exist."); + } - $config=require_once($config); + $config = require_once($config); $translator='Yii::t'; extract($config); - if(!isset($sourcePath,$messagePath,$languages)) + if (!isset($sourcePath, $messagePath, $languages)) { $this->usageError('The configuration file must specify "sourcePath", "messagePath" and "languages".'); - if(!is_dir($sourcePath)) + } + if (!is_dir($sourcePath)) { $this->usageError("The source path $sourcePath is not a valid directory."); - if(!is_dir($messagePath)) + } + if (!is_dir($messagePath)) { $this->usageError("The message path $messagePath is not a valid directory."); - if(empty($languages)) + } + if (empty($languages)) { $this->usageError("Languages cannot be empty."); + } - if(!isset($overwrite)) + if (!isset($overwrite)) { $overwrite = false; - - if(!isset($removeOld)) + } + if (!isset($removeOld)) { $removeOld = false; - - if(!isset($sort)) + } + if (!isset($sort)) { $sort = false; + } - $options=array(); - if(isset($fileTypes)) - $options['fileTypes']=$fileTypes; - if(isset($exclude)) - $options['exclude']=$exclude; - $files=CFileHelper::findFiles(realpath($sourcePath),$options); + $options = array(); + if (isset($fileTypes)) { + $options['fileTypes'] = $fileTypes; + } + if (isset($exclude)) { + $options['exclude'] = $exclude; + } + $files = CFileHelper::findFiles(realpath($sourcePath), $options); - $messages=array(); - foreach($files as $file) - $messages=array_merge_recursive($messages,$this->extractMessages($file,$translator)); + $messages = array(); + foreach ($files as $file) { + $messages = array_merge_recursive($messages, $this->extractMessages($file, $translator)); + } - foreach($languages as $language) - { - $dir=$messagePath.DIRECTORY_SEPARATOR.$language; - if(!is_dir($dir)) + foreach ($languages as $language) { + $dir = $messagePath . DIRECTORY_SEPARATOR . $language; + if (!is_dir($dir)) { @mkdir($dir); - foreach($messages as $category=>$msgs) - { - $msgs=array_values(array_unique($msgs)); - $this->generateMessageFile($msgs,$dir.DIRECTORY_SEPARATOR.$category.'.php',$overwrite,$removeOld,$sort); + } + foreach ($messages as $category => $msgs) { + $msgs = array_values(array_unique($msgs)); + $this->generateMessageFile($msgs, $dir . DIRECTORY_SEPARATOR . $category . '.php', $overwrite, $removeOld, $sort); } } } - protected function extractMessages($fileName,$translator) + protected function extractMessages($fileName, $translator) { echo "Extracting messages from $fileName...\n"; - $subject=file_get_contents($fileName); - $n=preg_match_all('/\b'.$translator.'\s*\(\s*(\'.*?(?$translation) - { - if(!isset($merged[$message]) && !isset($todo[$message]) && !$removeOld) + foreach ($translated as $message => $translation) { + if (!isset($merged[$message]) && !isset($todo[$message]) && !$removeOld) { - if(substr($translation,0,2)==='@@' && substr($translation,-2)==='@@') + if (substr($translation, 0, 2) === '@@' && substr($translation, -2) === '@@') { $todo[$message]=$translation; - else - $todo[$message]='@@'.$translation.'@@'; + } else { + $todo[$message] = '@@' . $translation . '@@'; + } } } - $merged=array_merge($todo,$merged); - if($sort) + $merged = array_merge($todo, $merged); + if ($sort) { ksort($merged); - if($overwrite === false) - $fileName.='.merged'; + } + if (false === $overwrite) { + $fileName .= '.merged'; + } echo "translation merged.\n"; - } - else - { - $merged=array(); - foreach($messages as $message) - $merged[$message]=''; + } else { + $merged = array(); + foreach ($messages as $message) { + $merged[$message] = ''; + } ksort($merged); echo "saved.\n"; } - $array=str_replace("\r",'',var_export($merged,true)); - $content=<<1, 'status'=>2)` generates `(type=1) AND (status=2)`. - * - `array('id'=>array(1,2,3), 'status'=>2)` generates `(id IN (1,2,3)) AND (status=2)`. - * - `array('status'=>null) generates `status IS NULL`. + * - `array('type' => 1, 'status' => 2)` generates `(type = 1) AND (status = 2)`. + * - `array('id' => array(1, 2, 3), 'status' => 2)` generates `(id IN (1, 2, 3)) AND (status = 2)`. + * - `array('status' => null) generates `status IS NULL`. * * A condition in operator format generates the SQL expression according to the specified operator, which * can be one of the followings: diff --git a/yii/helpers/base/ArrayHelper.php b/yii/helpers/base/ArrayHelper.php index e482883..c70e63d 100644 --- a/yii/helpers/base/ArrayHelper.php +++ b/yii/helpers/base/ArrayHelper.php @@ -93,11 +93,11 @@ class ArrayHelper * Usage examples, * * ~~~ - * // $array = array('type'=>'A', 'options'=>array(1,2)); + * // $array = array('type' => 'A', 'options' => array(1, 2)); * // working with array * $type = \yii\helpers\ArrayHelper::remove($array, 'type'); * // $array content - * // $array = array('options'=>array(1,2)); + * // $array = array('options' => array(1, 2)); * ~~~ * * @param array $array the array to extract value from diff --git a/yii/logging/FileTarget.php b/yii/logging/FileTarget.php index 69799cd..2db43b5 100644 --- a/yii/logging/FileTarget.php +++ b/yii/logging/FileTarget.php @@ -81,12 +81,12 @@ class FileTarget extends Target @flock($fp, LOCK_EX); if (@filesize($this->logFile) > $this->maxFileSize * 1024) { $this->rotateFiles(); - @flock($fp,LOCK_UN); + @flock($fp, LOCK_UN); @fclose($fp); @file_put_contents($this->logFile, $text, FILE_APPEND | LOCK_EX); } else { @fwrite($fp, $text); - @flock($fp,LOCK_UN); + @flock($fp, LOCK_UN); @fclose($fp); } } diff --git a/yii/renderers/SmartyViewRenderer.php b/yii/renderers/SmartyViewRenderer.php index c6147c0..ac66e0d 100644 --- a/yii/renderers/SmartyViewRenderer.php +++ b/yii/renderers/SmartyViewRenderer.php @@ -63,7 +63,7 @@ class SmartyViewRenderer extends ViewRenderer */ public function smarty_function_path($params, \Smarty_Internal_Template $template) { - if(!isset($params['route'])) { + if (!isset($params['route'])) { trigger_error("path: missing 'route' parameter"); } diff --git a/yii/views/exception.php b/yii/views/exception.php index f2aced0..0f26ed7 100644 --- a/yii/views/exception.php +++ b/yii/views/exception.php @@ -191,16 +191,15 @@ $title = $context->htmlEncode($exception instanceof \yii\base\Exception ? $excep var traceReg = new RegExp("(^|\\s)trace-file(\\s|$)"); var collapsedReg = new RegExp("(^|\\s)collapsed(\\s|$)"); -var e = document.getElementsByTagName("div"); -for(var j=0,len=e.length;jExample: *
 	 * request->xSendFile('/home/user/Pictures/picture1.jpg',array(
-	 *        'saveName'=>'image1.jpg',
-	 *        'mimeType'=>'image/jpeg',
-	 *        'terminate'=>false,
+	 *    Yii::app()->request->xSendFile('/home/user/Pictures/picture1.jpg', array(
+	 *        'saveName' => 'image1.jpg',
+	 *        'mimeType' => 'image/jpeg',
+	 *        'terminate' => false,
 	 *    ));
 	 * ?>
 	 * 
diff --git a/yii/web/Sort.php b/yii/web/Sort.php index 324e733..6014a3e 100644 --- a/yii/web/Sort.php +++ b/yii/web/Sort.php @@ -50,7 +50,7 @@ use yii\helpers\Html; * // display links leading to sort actions * echo $sort->link('name', 'Name') . ' | ' . $sort->link('age', 'Age'); * - * foreach($models as $model) { + * foreach ($models as $model) { * // display $model here * } * ~~~ diff --git a/yii/widgets/ActiveField.php b/yii/widgets/ActiveField.php index 9f3f201..55357a3 100644 --- a/yii/widgets/ActiveField.php +++ b/yii/widgets/ActiveField.php @@ -144,7 +144,7 @@ class ActiveField extends Component } } if (!empty($validators)) { - $options['validate'] = new JsExpression("function(attribute,value,messages){" . implode('', $validators) . '}'); + $options['validate'] = new JsExpression("function(attribute, value, messages) {" . implode('', $validators) . '}'); } } diff --git a/yii/yiic.php b/yii/yiic.php index 3be0436..3803455 100644 --- a/yii/yiic.php +++ b/yii/yiic.php @@ -7,7 +7,7 @@ * @license http://www.yiiframework.com/license/ */ -if(!ini_get('date.timezone')) { +if (!ini_get('date.timezone')) { date_default_timezone_set('UTC'); } From b314d9635538dc5084ebd77f4522234c927995ba Mon Sep 17 00:00:00 2001 From: resurtm Date: Sat, 11 May 2013 15:43:19 +0600 Subject: [PATCH 2/5] Change magic property to normal method. (Thanks to @maxlapko.) --- yii/base/Controller.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yii/base/Controller.php b/yii/base/Controller.php index 3b16a93..1a92a46 100644 --- a/yii/base/Controller.php +++ b/yii/base/Controller.php @@ -318,10 +318,10 @@ class Controller extends Component /** @var Model $model */ $scope = $model->formName(); if ($scope == '') { - $model->attributes = $data; + $model->setAttributes($data); $success = true; } elseif (isset($data[$scope])) { - $model->attributes = $data[$scope]; + $model->setAttributes($data[$scope]); $success = true; } } From ea68bd3a5521172750405e510c71d2faeba58036 Mon Sep 17 00:00:00 2001 From: resurtm Date: Sat, 11 May 2013 15:58:27 +0600 Subject: [PATCH 3/5] 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); From c98628d42eb1a4edc507847068d235ee5496e5a6 Mon Sep 17 00:00:00 2001 From: resurtm Date: Sat, 11 May 2013 16:09:40 +0600 Subject: [PATCH 4/5] CS fixes. --- yii/base/Controller.php | 2 +- yii/base/Dictionary.php | 2 +- yii/base/Model.php | 16 ++++++++-------- yii/base/Vector.php | 2 +- yii/base/View.php | 2 +- yii/caching/DbDependency.php | 4 ++-- yii/caching/MemCache.php | 20 ++++++++++---------- yii/console/controllers/AppController.php | 4 ++-- yii/db/ActiveRecord.php | 10 +++++----- yii/db/Command.php | 14 +++++++------- yii/db/Connection.php | 2 +- yii/db/Migration.php | 11 ++++++----- yii/db/Query.php | 26 +++++++++++++------------- yii/db/QueryBuilder.php | 10 +++++----- yii/rbac/Manager.php | 12 ++++++------ yii/web/Pagination.php | 2 +- yii/web/UrlRule.php | 2 +- yii/widgets/ContentDecorator.php | 2 +- 18 files changed, 72 insertions(+), 71 deletions(-) diff --git a/yii/base/Controller.php b/yii/base/Controller.php index 1a92a46..6b6c926 100644 --- a/yii/base/Controller.php +++ b/yii/base/Controller.php @@ -278,7 +278,7 @@ class Controller extends Component * Child classes may override this method to throw exceptions when there are missing and/or unknown parameters. * @param Action $action the currently requested action * @param array $missingParams the names of the missing parameters - * @param array $unknownParams the unknown parameters (name=>value) + * @param array $unknownParams the unknown parameters (name => value) */ public function validateActionParams($action, $missingParams, $unknownParams) { diff --git a/yii/base/Dictionary.php b/yii/base/Dictionary.php index 5807d93..0a4741e 100644 --- a/yii/base/Dictionary.php +++ b/yii/base/Dictionary.php @@ -24,7 +24,7 @@ use yii\helpers\ArrayHelper; * $dictionary[$key] = $value; // add a key-value pair * unset($dictionary[$key]); // remove the value with the specified key * if (isset($dictionary[$key])) // if the dictionary contains the key - * foreach ($dictionary as $key=>$value) // traverse the items in the dictionary + * foreach ($dictionary as $key => $value) // traverse the items in the dictionary * $n = count($dictionary); // returns the number of items in the dictionary * ~~~ * diff --git a/yii/base/Model.php b/yii/base/Model.php index 7f55239..8348d97 100644 --- a/yii/base/Model.php +++ b/yii/base/Model.php @@ -33,7 +33,7 @@ use yii\validators\Validator; * @property Vector $validators All the validators declared in the model. * @property array $activeValidators The validators applicable to the current [[scenario]]. * @property array $errors Errors for all attributes or the specified attribute. Empty array is returned if no error. - * @property array $attributes Attribute values (name=>value). + * @property array $attributes Attribute values (name => value). * @property string $scenario The scenario that this model is in. * * @author Qiang Xue @@ -76,7 +76,7 @@ class Model extends Component implements \IteratorAggregate, \ArrayAccess * array( * 'attribute list', * 'validator type', - * 'on'=>'scenario name', + * 'on' => 'scenario name', * ...other parameters... * ) * ~~~ @@ -109,11 +109,11 @@ class Model extends Component implements \IteratorAggregate, \ArrayAccess * // built-in "required" validator * array('username', 'required'), * // built-in "length" validator customized with "min" and "max" properties - * array('username', 'length', 'min'=>3, 'max'=>12), + * array('username', 'length', 'min' => 3, 'max' => 12), * // built-in "compare" validator that is used in "register" scenario only - * array('password', 'compare', 'compareAttribute'=>'password2', 'on'=>'register'), + * array('password', 'compare', 'compareAttribute' => 'password2', 'on' => 'register'), * // an inline validator defined via the "authenticate()" method in the model class - * array('password', 'authenticate', 'on'=>'login'), + * array('password', 'authenticate', 'on' => 'login'), * // a validator of class "CaptchaValidator" * array('captcha', 'CaptchaValidator'), * ); @@ -220,7 +220,7 @@ class Model extends Component implements \IteratorAggregate, \ArrayAccess * Note, in order to inherit labels defined in the parent class, a child class needs to * merge the parent labels with child labels using functions such as `array_merge()`. * - * @return array attribute labels (name=>label) + * @return array attribute labels (name => label) * @see generateAttributeLabel */ public function attributeLabels() @@ -511,7 +511,7 @@ class Model extends Component implements \IteratorAggregate, \ArrayAccess * Defaults to null, meaning all attributes listed in [[attributes()]] will be returned. * If it is an array, only the attributes in the array will be returned. * @param array $except list of attributes whose value should NOT be returned. - * @return array attribute values (name=>value). + * @return array attribute values (name => value). */ public function getAttributes($names = null, $except = array()) { @@ -531,7 +531,7 @@ class Model extends Component implements \IteratorAggregate, \ArrayAccess /** * Sets the attribute values in a massive way. - * @param array $values attribute values (name=>value) to be assigned to the model. + * @param array $values attribute values (name => value) to be assigned to the model. * @param boolean $safeOnly whether the assignments should only be done to the safe attributes. * A safe attribute is one that is associated with a validation rule in the current [[scenario]]. * @see safeAttributes() diff --git a/yii/base/Vector.php b/yii/base/Vector.php index 6418077..ae35cca 100644 --- a/yii/base/Vector.php +++ b/yii/base/Vector.php @@ -24,7 +24,7 @@ namespace yii\base; * $vector[$index] = $item; // set new item at $index * unset($vector[$index]); // remove the item at $index * if (isset($vector[$index])) // if the vector has an item at $index - * foreach ($vector as $index=>$item) // traverse each item in the vector + * foreach ($vector as $index => $item) // traverse each item in the vector * $n = count($vector); // count the number of items * ~~~ * diff --git a/yii/base/View.php b/yii/base/View.php index b71e605..f1a9a0f 100644 --- a/yii/base/View.php +++ b/yii/base/View.php @@ -475,7 +475,7 @@ class View extends Component * * @param string $viewFile the view file that will be used to decorate the content enclosed by this widget. * This can be specified as either the view file path or path alias. - * @param array $params the variables (name=>value) to be extracted and made available in the decorative view. + * @param array $params the variables (name => value) to be extracted and made available in the decorative view. * @return \yii\widgets\ContentDecorator the ContentDecorator widget instance * @see \yii\widgets\ContentDecorator */ diff --git a/yii/caching/DbDependency.php b/yii/caching/DbDependency.php index 7d45223..fd92aea 100644 --- a/yii/caching/DbDependency.php +++ b/yii/caching/DbDependency.php @@ -32,14 +32,14 @@ class DbDependency extends Dependency */ public $sql; /** - * @var array the parameters (name=>value) to be bound to the SQL statement specified by [[sql]]. + * @var array the parameters (name => value) to be bound to the SQL statement specified by [[sql]]. */ public $params; /** * Constructor. * @param string $sql the SQL query whose result is used to determine if the dependency has been changed. - * @param array $params the parameters (name=>value) to be bound to the SQL statement specified by [[sql]]. + * @param array $params the parameters (name => value) to be bound to the SQL statement specified by [[sql]]. * @param array $config name-value pairs that will be used to initialize the object properties */ public function __construct($sql, $params = array(), $config = array()) diff --git a/yii/caching/MemCache.php b/yii/caching/MemCache.php index 20aff21..e6b9b53 100644 --- a/yii/caching/MemCache.php +++ b/yii/caching/MemCache.php @@ -30,19 +30,19 @@ use yii\base\InvalidConfigException; * * ~~~ * array( - * 'components'=>array( - * 'cache'=>array( - * 'class'=>'MemCache', - * 'servers'=>array( + * 'components' => array( + * 'cache' => array( + * 'class' => 'MemCache', + * 'servers' => array( * array( - * 'host'=>'server1', - * 'port'=>11211, - * 'weight'=>60, + * 'host' => 'server1', + * 'port' => 11211, + * 'weight' => 60, * ), * array( - * 'host'=>'server2', - * 'port'=>11211, - * 'weight'=>40, + * 'host' => 'server2', + * 'port' => 11211, + * 'weight' => 40, * ), * ), * ), diff --git a/yii/console/controllers/AppController.php b/yii/console/controllers/AppController.php index 95e6e5b..6baf019 100644 --- a/yii/console/controllers/AppController.php +++ b/yii/console/controllers/AppController.php @@ -204,7 +204,7 @@ class AppController extends Controller /** * Copies a list of files from one place to another. - * @param array $fileList the list of files to be copied (name=>spec). + * @param array $fileList the list of files to be copied (name => spec). * The array keys are names displayed during the copy process, and array values are specifications * for files to be copied. Each array value must be an array of the following structure: *
      @@ -288,7 +288,7 @@ class AppController extends Controller * @param array $ignoreFiles list of the names of files that should * be ignored in list building process. * @param array $renameMap hash array of file names that should be - * renamed. Example value: array('1.old.txt'=>'2.new.txt'). + * renamed. Example value: array('1.old.txt' => '2.new.txt'). * @return array the file list (see {@link copyFiles}) */ protected function buildFileList($sourceDir, $targetDir, $baseDir='', $ignoreFiles=array(), $renameMap=array()) diff --git a/yii/db/ActiveRecord.php b/yii/db/ActiveRecord.php index 356819d..41ce84c 100644 --- a/yii/db/ActiveRecord.php +++ b/yii/db/ActiveRecord.php @@ -169,7 +169,7 @@ class ActiveRecord extends Model * @param array $attributes attribute values (name-value pairs) to be saved into the table * @param string|array $condition the conditions that will be put in the WHERE part of the UPDATE SQL. * Please refer to [[Query::where()]] on how to specify this parameter. - * @param array $params the parameters (name=>value) to be bound to the query. + * @param array $params the parameters (name => value) to be bound to the query. * @return integer the number of rows updated */ public static function updateAll($attributes, $condition = '', $params = array()) @@ -191,7 +191,7 @@ class ActiveRecord extends Model * Use negative values if you want to decrement the counters. * @param string|array $condition the conditions that will be put in the WHERE part of the UPDATE SQL. * Please refer to [[Query::where()]] on how to specify this parameter. - * @param array $params the parameters (name=>value) to be bound to the query. + * @param array $params the parameters (name => value) to be bound to the query. * Do not name the parameters as `:bp0`, `:bp1`, etc., because they are used internally by this method. * @return integer the number of rows updated */ @@ -219,7 +219,7 @@ class ActiveRecord extends Model * * @param string|array $condition the conditions that will be put in the WHERE part of the DELETE SQL. * Please refer to [[Query::where()]] on how to specify this parameter. - * @param array $params the parameters (name=>value) to be bound to the query. + * @param array $params the parameters (name => value) to be bound to the query. * @return integer the number of rows deleted */ public static function deleteAll($condition = '', $params = array()) @@ -1014,7 +1014,7 @@ class ActiveRecord extends Model * @param boolean $asArray whether to return the primary key value as an array. If true, * the return value will be an array with column names as keys and column values as values. * Note that for composite primary keys, an array will always be returned regardless of this parameter value. - * @return mixed the primary key value. An array (column name=>column value) is returned if the primary key + * @return mixed the primary key value. An array (column name => column value) is returned if the primary key * is composite or `$asArray` is true. A string is returned otherwise (null will be returned if * the key value is null). */ @@ -1040,7 +1040,7 @@ class ActiveRecord extends Model * @param boolean $asArray whether to return the primary key value as an array. If true, * the return value will be an array with column name as key and column value as value. * If this is false (default), a scalar value will be returned for non-composite primary key. - * @return mixed the old primary key value. An array (column name=>column value) is returned if the primary key + * @return mixed the old primary key value. An array (column name => column value) is returned if the primary key * is composite or `$asArray` is true. A string is returned otherwise (null will be returned if * the key value is null). */ diff --git a/yii/db/Command.php b/yii/db/Command.php index a117685..a3e2994 100644 --- a/yii/db/Command.php +++ b/yii/db/Command.php @@ -69,7 +69,7 @@ class Command extends \yii\base\Component */ private $_sql; /** - * @var array the parameter log information (name=>value) + * @var array the parameter log information (name => value) */ private $_params = array(); @@ -220,9 +220,9 @@ class Command extends \yii\base\Component * Note that the SQL data type of each value is determined by its PHP type. * @param array $values the values to be bound. This must be given in terms of an associative * array with array keys being the parameter names, and array values the corresponding parameter values, - * e.g. `array(':name'=>'John', ':age'=>25)`. By default, the PDO type of each value is determined + * e.g. `array(':name' => 'John', ':age' => 25)`. By default, the PDO type of each value is determined * by its PHP type. You may explicitly specify the PDO type by using an array: `array(value, type)`, - * e.g. `array(':name'=>'John', ':profile'=>array($profile, \PDO::PARAM_LOB))`. + * e.g. `array(':name' => 'John', ':profile' => array($profile, \PDO::PARAM_LOB))`. * @return Command the current command being executed */ public function bindValues($values) @@ -465,7 +465,7 @@ class Command extends \yii\base\Component * Note that the created command is not executed until [[execute()]] is called. * * @param string $table the table that new rows will be inserted into. - * @param array $columns the column data (name=>value) to be inserted into the table. + * @param array $columns the column data (name => value) to be inserted into the table. * @return Command the command object itself */ public function insert($table, $columns) @@ -515,7 +515,7 @@ class Command extends \yii\base\Component * Note that the created command is not executed until [[execute()]] is called. * * @param string $table the table to be updated. - * @param array $columns the column data (name=>value) to be updated. + * @param array $columns the column data (name => value) to be updated. * @param mixed $condition the condition that will be put in the WHERE part. Please * refer to [[Query::where()]] on how to specify condition. * @param array $params the parameters to be bound to the command @@ -555,7 +555,7 @@ class Command extends \yii\base\Component /** * Creates a SQL command for creating a new DB table. * - * The columns in the new table should be specified as name-definition pairs (e.g. 'name'=>'string'), + * The columns in the new table should be specified as name-definition pairs (e.g. 'name' => 'string'), * where name stands for a column name which will be properly quoted by the method, and definition * stands for the column type which can contain an abstract DB type. * The method [[QueryBuilder::getColumnType()]] will be called @@ -566,7 +566,7 @@ class Command extends \yii\base\Component * inserted into the generated SQL. * * @param string $table the name of the table to be created. The name will be properly quoted by the method. - * @param array $columns the columns (name=>definition) in the new table. + * @param array $columns the columns (name => definition) in the new table. * @param string $options additional SQL fragment that will be appended to the generated SQL. * @return Command the command object itself */ diff --git a/yii/db/Connection.php b/yii/db/Connection.php index 37a5307..c1e65f9 100644 --- a/yii/db/Connection.php +++ b/yii/db/Connection.php @@ -121,7 +121,7 @@ class Connection extends Component */ public $password = ''; /** - * @var array PDO attributes (name=>value) that should be set when calling [[open()]] + * @var array PDO attributes (name => value) that should be set when calling [[open()]] * to establish a DB connection. Please refer to the * [PHP manual](http://www.php.net/manual/en/function.PDO-setAttribute.php) for * details about available attributes. diff --git a/yii/db/Migration.php b/yii/db/Migration.php index f51e597..51e230b 100644 --- a/yii/db/Migration.php +++ b/yii/db/Migration.php @@ -132,7 +132,8 @@ class Migration extends \yii\base\Component * Executes a SQL statement. * This method executes the specified SQL statement using [[db]]. * @param string $sql the SQL statement to be executed - * @param array $params input parameters (name=>value) for the SQL execution. See [[Command::execute()]] for more details. + * @param array $params input parameters (name => value) for the SQL execution. + * See [[Command::execute()]] for more details. */ public function execute($sql, $params = array()) { @@ -146,7 +147,7 @@ class Migration extends \yii\base\Component * Creates and executes an INSERT SQL statement. * The method will properly escape the column names, and bind the values to be inserted. * @param string $table the table that new rows will be inserted into. - * @param array $columns the column data (name=>value) to be inserted into the table. + * @param array $columns the column data (name => value) to be inserted into the table. */ public function insert($table, $columns) { @@ -160,7 +161,7 @@ class Migration extends \yii\base\Component * Creates and executes an UPDATE SQL statement. * The method will properly escape the column names and bind the values to be updated. * @param string $table the table to be updated. - * @param array $columns the column data (name=>value) to be updated. + * @param array $columns the column data (name => value) to be updated. * @param mixed $condition the conditions that will be put in the WHERE part. Please * refer to [[Query::where()]] on how to specify conditions. * @param array $params the parameters to be bound to the query. @@ -191,7 +192,7 @@ class Migration extends \yii\base\Component /** * Builds and executes a SQL statement for creating a new DB table. * - * The columns in the new table should be specified as name-definition pairs (e.g. 'name'=>'string'), + * The columns in the new table should be specified as name-definition pairs (e.g. 'name' => 'string'), * where name stands for a column name which will be properly quoted by the method, and definition * stands for the column type which can contain an abstract DB type. * @@ -201,7 +202,7 @@ class Migration extends \yii\base\Component * put into the generated SQL. * * @param string $table the name of the table to be created. The name will be properly quoted by the method. - * @param array $columns the columns (name=>definition) in the new table. + * @param array $columns the columns (name => definition) in the new table. * @param string $options additional SQL fragment that will be appended to the generated SQL. */ public function createTable($table, $columns, $options = null) diff --git a/yii/db/Query.php b/yii/db/Query.php index 1c319a9..2e03949 100644 --- a/yii/db/Query.php +++ b/yii/db/Query.php @@ -124,7 +124,7 @@ class Query extends \yii\base\Component public $union; /** * @var array list of query parameter values indexed by parameter placeholders. - * For example, `array(':name'=>'Dan', ':age'=>31)`. + * For example, `array(':name' => 'Dan', ':age' => 31)`. */ public $params; @@ -257,7 +257,7 @@ class Query extends \yii\base\Component * the `NOT LIKE` predicates. * * @param string|array $condition the conditions that should be put in the WHERE part. - * @param array $params the parameters (name=>value) to be bound to the query. + * @param array $params the parameters (name => value) to be bound to the query. * @return Query the query object itself * @see andWhere() * @see orWhere() @@ -274,7 +274,7 @@ class Query extends \yii\base\Component * The new condition and the existing one will be joined using the 'AND' operator. * @param string|array $condition the new WHERE condition. Please refer to [[where()]] * on how to specify this parameter. - * @param array $params the parameters (name=>value) to be bound to the query. + * @param array $params the parameters (name => value) to be bound to the query. * @return Query the query object itself * @see where() * @see orWhere() @@ -295,7 +295,7 @@ class Query extends \yii\base\Component * The new condition and the existing one will be joined using the 'OR' operator. * @param string|array $condition the new WHERE condition. Please refer to [[where()]] * on how to specify this parameter. - * @param array $params the parameters (name=>value) to be bound to the query. + * @param array $params the parameters (name => value) to be bound to the query. * @return Query the query object itself * @see where() * @see andWhere() @@ -321,7 +321,7 @@ class Query extends \yii\base\Component * (which means the table is given as a sub-query or DB expression). * @param string|array $on the join condition that should appear in the ON part. * Please refer to [[where()]] on how to specify this parameter. - * @param array $params the parameters (name=>value) to be bound to the query. + * @param array $params the parameters (name => value) to be bound to the query. * @return Query the query object itself */ public function join($type, $table, $on = '', $params = array()) @@ -338,7 +338,7 @@ class Query extends \yii\base\Component * (which means the table is given as a sub-query or DB expression). * @param string|array $on the join condition that should appear in the ON part. * Please refer to [[where()]] on how to specify this parameter. - * @param array $params the parameters (name=>value) to be bound to the query. + * @param array $params the parameters (name => value) to be bound to the query. * @return Query the query object itself */ public function innerJoin($table, $on = '', $params = array()) @@ -355,7 +355,7 @@ class Query extends \yii\base\Component * (which means the table is given as a sub-query or DB expression). * @param string|array $on the join condition that should appear in the ON part. * Please refer to [[where()]] on how to specify this parameter. - * @param array $params the parameters (name=>value) to be bound to the query + * @param array $params the parameters (name => value) to be bound to the query * @return Query the query object itself */ public function leftJoin($table, $on = '', $params = array()) @@ -372,7 +372,7 @@ class Query extends \yii\base\Component * (which means the table is given as a sub-query or DB expression). * @param string|array $on the join condition that should appear in the ON part. * Please refer to [[where()]] on how to specify this parameter. - * @param array $params the parameters (name=>value) to be bound to the query + * @param array $params the parameters (name => value) to be bound to the query * @return Query the query object itself */ public function rightJoin($table, $on = '', $params = array()) @@ -425,7 +425,7 @@ class Query extends \yii\base\Component * Sets the HAVING part of the query. * @param string|array $condition the conditions to be put after HAVING. * Please refer to [[where()]] on how to specify this parameter. - * @param array $params the parameters (name=>value) to be bound to the query. + * @param array $params the parameters (name => value) to be bound to the query. * @return Query the query object itself * @see andHaving() * @see orHaving() @@ -442,7 +442,7 @@ class Query extends \yii\base\Component * The new condition and the existing one will be joined using the 'AND' operator. * @param string|array $condition the new HAVING condition. Please refer to [[where()]] * on how to specify this parameter. - * @param array $params the parameters (name=>value) to be bound to the query. + * @param array $params the parameters (name => value) to be bound to the query. * @return Query the query object itself * @see having() * @see orHaving() @@ -463,7 +463,7 @@ class Query extends \yii\base\Component * The new condition and the existing one will be joined using the 'OR' operator. * @param string|array $condition the new HAVING condition. Please refer to [[where()]] * on how to specify this parameter. - * @param array $params the parameters (name=>value) to be bound to the query. + * @param array $params the parameters (name => value) to be bound to the query. * @return Query the query object itself * @see having() * @see andHaving() @@ -570,7 +570,7 @@ class Query extends \yii\base\Component /** * Sets the parameters to be bound to the query. * @param array $params list of query parameter values indexed by parameter placeholders. - * For example, `array(':name'=>'Dan', ':age'=>31)`. + * For example, `array(':name' => 'Dan', ':age' => 31)`. * @return Query the query object itself * @see addParams() */ @@ -583,7 +583,7 @@ class Query extends \yii\base\Component /** * Adds additional parameters to be bound to the query. * @param array $params list of query parameter values indexed by parameter placeholders. - * For example, `array(':name'=>'Dan', ':age'=>31)`. + * For example, `array(':name' => 'Dan', ':age' => 31)`. * @return Query the query object itself * @see params() */ diff --git a/yii/db/QueryBuilder.php b/yii/db/QueryBuilder.php index a4e30ea..9e7749a 100644 --- a/yii/db/QueryBuilder.php +++ b/yii/db/QueryBuilder.php @@ -88,7 +88,7 @@ class QueryBuilder extends \yii\base\Object * The method will properly escape the table and column names. * * @param string $table the table that new rows will be inserted into. - * @param array $columns the column data (name=>value) to be inserted into the table. + * @param array $columns the column data (name => value) to be inserted into the table. * @param array $params the binding parameters that will be generated by this method. * They should be bound to the DB command later. * @return string the INSERT SQL @@ -156,7 +156,7 @@ class QueryBuilder extends \yii\base\Object * The method will properly escape the table and column names. * * @param string $table the table to be updated. - * @param array $columns the column data (name=>value) to be updated. + * @param array $columns the column data (name => value) to be updated. * @param mixed $condition the condition that will be put in the WHERE part. Please * refer to [[Query::where()]] on how to specify condition. * @param array $params the binding parameters that will be modified by this method @@ -211,7 +211,7 @@ class QueryBuilder extends \yii\base\Object /** * Builds a SQL statement for creating a new DB table. * - * The columns in the new table should be specified as name-definition pairs (e.g. 'name'=>'string'), + * The columns in the new table should be specified as name-definition pairs (e.g. 'name' => 'string'), * where name stands for a column name which will be properly quoted by the method, and definition * stands for the column type which can contain an abstract DB type. * The [[getColumnType()]] method will be invoked to convert any abstract type into a physical one. @@ -230,7 +230,7 @@ class QueryBuilder extends \yii\base\Object * ~~~ * * @param string $table the name of the table to be created. The name will be properly quoted by the method. - * @param array $columns the columns (name=>definition) in the new table. + * @param array $columns the columns (name => definition) in the new table. * @param string $options additional SQL fragment that will be appended to the generated SQL. * @return string the SQL statement for creating a new DB table. */ @@ -734,7 +734,7 @@ class QueryBuilder extends \yii\base\Object } else { throw new Exception('Found unknown operator in query: ' . $operator); } - } else { // hash format: 'column1'=>'value1', 'column2'=>'value2', ... + } else { // hash format: 'column1' => 'value1', 'column2' => 'value2', ... return $this->buildHashCondition($condition, $params); } } diff --git a/yii/rbac/Manager.php b/yii/rbac/Manager.php index 5c3c4f6..adc9013 100644 --- a/yii/rbac/Manager.php +++ b/yii/rbac/Manager.php @@ -33,9 +33,9 @@ use yii\base\InvalidParamException; * at appropriate places in the application code to check if the current user * has the needed permission for an operation. * - * @property array $roles Roles (name=>Item). - * @property array $tasks Tasks (name=>Item). - * @property array $operations Operations (name=>Item). + * @property array $roles Roles (name => Item). + * @property array $tasks Tasks (name => Item). + * @property array $operations Operations (name => Item). * * @author Qiang Xue * @author Alexander Kochetov @@ -107,7 +107,7 @@ abstract class Manager extends Component * This is a shortcut method to [[Manager::getItems()]]. * @param mixed $userId the user ID. If not null, only the roles directly assigned to the user * will be returned. Otherwise, all roles will be returned. - * @return Item[] roles (name=>AuthItem) + * @return Item[] roles (name => AuthItem) */ public function getRoles($userId = null) { @@ -119,7 +119,7 @@ abstract class Manager extends Component * This is a shortcut method to [[Manager::getItems()]]. * @param mixed $userId the user ID. If not null, only the tasks directly assigned to the user * will be returned. Otherwise, all tasks will be returned. - * @return Item[] tasks (name=>AuthItem) + * @return Item[] tasks (name => AuthItem) */ public function getTasks($userId = null) { @@ -131,7 +131,7 @@ abstract class Manager extends Component * This is a shortcut method to [[Manager::getItems()]]. * @param mixed $userId the user ID. If not null, only the operations directly assigned to the user * will be returned. Otherwise, all operations will be returned. - * @return Item[] operations (name=>AuthItem) + * @return Item[] operations (name => AuthItem) */ public function getOperations($userId = null) { diff --git a/yii/web/Pagination.php b/yii/web/Pagination.php index 8d08c93..20241ef 100644 --- a/yii/web/Pagination.php +++ b/yii/web/Pagination.php @@ -80,7 +80,7 @@ class Pagination extends \yii\base\Object */ public $route; /** - * @var array parameters (name=>value) that should be used to obtain the current page number + * @var array parameters (name => value) that should be used to obtain the current page number * and to create new pagination URLs. If not set, $_GET will be used instead. * * The array element indexed by [[pageVar]] is considered to be the current page number. diff --git a/yii/web/UrlRule.php b/yii/web/UrlRule.php index 96cb994..ed2bc14 100644 --- a/yii/web/UrlRule.php +++ b/yii/web/UrlRule.php @@ -36,7 +36,7 @@ class UrlRule extends Object */ public $route; /** - * @var array the default GET parameters (name=>value) that this rule provides. + * @var array the default GET parameters (name => value) that this rule provides. * When this rule is used to parse the incoming request, the values declared in this property * will be injected into $_GET. */ diff --git a/yii/widgets/ContentDecorator.php b/yii/widgets/ContentDecorator.php index 3f63621..f91117a 100644 --- a/yii/widgets/ContentDecorator.php +++ b/yii/widgets/ContentDecorator.php @@ -22,7 +22,7 @@ class ContentDecorator extends Widget */ public $viewFile; /** - * @var array the parameters (name=>value) to be extracted and made available in the decorative view. + * @var array the parameters (name => value) to be extracted and made available in the decorative view. */ public $params = array(); From abeb02e902acf5c39f0abf95235a14bdc1670a00 Mon Sep 17 00:00:00 2001 From: resurtm Date: Sat, 11 May 2013 16:12:47 +0600 Subject: [PATCH 5/5] Travis-CI build status. --- readme.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/readme.md b/readme.md index 178acd4..71c990e 100644 --- a/readme.md +++ b/readme.md @@ -9,6 +9,8 @@ If you are looking for a production-ready PHP framework, please use Yii 2.0 is still under heavy development. We may make significant changes without prior notices. **Yii 2.0 is not ready for production use yet.** +[![Build Status](https://secure.travis-ci.org/yiisoft/yii2.png)](http://travis-ci.org/yiisoft/yii2) + DIRECTORY STRUCTURE -------------------