diff --git a/apps/bootstrap/protected/views/site/contact.php b/apps/bootstrap/protected/views/site/contact.php index bee1ede..a632345 100644 --- a/apps/bootstrap/protected/views/site/contact.php +++ b/apps/bootstrap/protected/views/site/contact.php @@ -13,7 +13,7 @@ $this->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/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 ------------------- diff --git a/tests/unit/framework/base/DictionaryTest.php b/tests/unit/framework/base/DictionaryTest.php index 9e55547..882ffc2 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/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/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/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/base/Controller.php b/yii/base/Controller.php index 3b16a93..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) { @@ -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; } } 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/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/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 af65c49..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 */ @@ -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/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 17f7420..6baf019 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; /** @@ -39,7 +38,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 +66,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 +96,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 +117,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 +139,13 @@ class AppController extends Controller */ protected function getConfig() { - 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'); + 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'); } } - if(isset($this->_config[$this->type])) { + if (isset($this->_config[$this->type])) { return $this->_config[$this->type]; } } @@ -185,30 +181,30 @@ 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) { - 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) . '\''; } /** * 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: *