Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
4686c7c3
Commit
4686c7c3
authored
12 years ago
by
resurtm
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:yiisoft/yii2 into mssql
parents
5c101ae3
abeb02e9
Hide whitespace changes
Inline
Side-by-side
Showing
54 changed files
with
404 additions
and
389 deletions
+404
-389
contact.php
apps/bootstrap/protected/views/site/contact.php
+1
-1
performance.md
docs/guide/performance.md
+1
-1
readme.md
readme.md
+2
-0
DictionaryTest.php
tests/unit/framework/base/DictionaryTest.php
+63
-60
ModelTest.php
tests/unit/framework/base/ModelTest.php
+1
-1
VectorTest.php
tests/unit/framework/base/VectorTest.php
+70
-63
DbCacheTest.php
tests/unit/framework/caching/DbCacheTest.php
+2
-2
FileCacheTest.php
tests/unit/framework/caching/FileCacheTest.php
+1
-1
MemCacheTest.php
tests/unit/framework/caching/MemCacheTest.php
+2
-2
MemCachedTest.php
tests/unit/framework/caching/MemCachedTest.php
+2
-2
WinCacheTest.php
tests/unit/framework/caching/WinCacheTest.php
+3
-3
XCacheTest.php
tests/unit/framework/caching/XCacheTest.php
+2
-2
ZendDataCacheTest.php
tests/unit/framework/caching/ZendDataCacheTest.php
+2
-2
CommandTest.php
tests/unit/framework/db/CommandTest.php
+1
-1
QueryTest.php
tests/unit/framework/db/QueryTest.php
+1
-1
StringHelperTest.php
tests/unit/framework/helpers/StringHelperTest.php
+1
-1
ManagerTestBase.php
tests/unit/framework/rbac/ManagerTestBase.php
+3
-3
Controller.php
yii/base/Controller.php
+3
-3
Dictionary.php
yii/base/Dictionary.php
+1
-1
ErrorHandler.php
yii/base/ErrorHandler.php
+2
-2
HttpException.php
yii/base/HttpException.php
+3
-2
Model.php
yii/base/Model.php
+8
-8
Vector.php
yii/base/Vector.php
+1
-1
View.php
yii/base/View.php
+2
-2
Cache.php
yii/caching/Cache.php
+1
-1
DbDependency.php
yii/caching/DbDependency.php
+2
-2
MemCache.php
yii/caching/MemCache.php
+10
-10
AppController.php
yii/console/controllers/AppController.php
+47
-55
CacheController.php
yii/console/controllers/CacheController.php
+2
-2
MessageController.php
yii/console/controllers/MessageController.php
+86
-76
ActiveRecord.php
yii/db/ActiveRecord.php
+5
-5
Command.php
yii/db/Command.php
+7
-7
Connection.php
yii/db/Connection.php
+1
-1
DataReader.php
yii/db/DataReader.php
+1
-1
Migration.php
yii/db/Migration.php
+6
-5
Query.php
yii/db/Query.php
+17
-17
QueryBuilder.php
yii/db/QueryBuilder.php
+5
-5
ArrayHelper.php
yii/helpers/base/ArrayHelper.php
+2
-2
Markdown.php
yii/helpers/base/Markdown.php
+1
-1
GettextMoFile.php
yii/i18n/GettextMoFile.php
+1
-1
I18N.php
yii/i18n/I18N.php
+1
-1
FileTarget.php
yii/logging/FileTarget.php
+2
-2
ProfileTarget.php
yii/logging/ProfileTarget.php
+1
-1
Manager.php
yii/rbac/Manager.php
+6
-6
SmartyViewRenderer.php
yii/renderers/SmartyViewRenderer.php
+1
-1
TestCase.php
yii/test/TestCase.php
+2
-2
exception.php
yii/views/exception.php
+8
-9
Pagination.php
yii/web/Pagination.php
+2
-2
Response.php
yii/web/Response.php
+4
-4
Sort.php
yii/web/Sort.php
+1
-1
UrlRule.php
yii/web/UrlRule.php
+1
-1
ActiveField.php
yii/widgets/ActiveField.php
+1
-1
ContentDecorator.php
yii/widgets/ContentDecorator.php
+1
-1
ListPager.php
yii/widgets/ListPager.php
+1
-1
No files found.
apps/bootstrap/protected/views/site/contact.php
View file @
4686c7c3
...
@@ -13,7 +13,7 @@ $this->params['breadcrumbs'][] = $this->title;
...
@@ -13,7 +13,7 @@ $this->params['breadcrumbs'][] = $this->title;
?>
?>
<h1>
<?php
echo
Html
::
encode
(
$this
->
title
);
?>
</h1>
<h1>
<?php
echo
Html
::
encode
(
$this
->
title
);
?>
</h1>
<?php
if
(
Yii
::
$app
->
session
->
hasFlash
(
'contactFormSubmitted'
))
:
?>
<?php
if
(
Yii
::
$app
->
session
->
hasFlash
(
'contactFormSubmitted'
))
:
?>
<div
class=
"alert alert-success"
>
<div
class=
"alert alert-success"
>
Thank you for contacting us. We will respond to you as soon as possible.
Thank you for contacting us. We will respond to you as soon as possible.
</div>
</div>
...
...
This diff is collapsed.
Click to expand it.
docs/guide/performance.md
View file @
4686c7c3
...
@@ -162,7 +162,7 @@ class PostController extends Controller
...
@@ -162,7 +162,7 @@ class PostController extends Controller
In the view you should access fields of each invidual record from
`$posts`
as array:
In the view you should access fields of each invidual record from
`$posts`
as array:
```
php
```
php
foreach
(
$posts
as
$post
)
{
foreach
(
$posts
as
$post
)
{
echo
$post
[
'title'
]
.
"<br>"
;
echo
$post
[
'title'
]
.
"<br>"
;
}
}
```
```
...
...
This diff is collapsed.
Click to expand it.
readme.md
View file @
4686c7c3
...
@@ -9,6 +9,8 @@ If you are looking for a production-ready PHP framework, please use
...
@@ -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
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.**
without prior notices.
**Yii 2.0 is not ready for production use yet.**
[

](http://travis-ci.org/yiisoft/yii2)
DIRECTORY STRUCTURE
DIRECTORY STRUCTURE
-------------------
-------------------
...
...
This diff is collapsed.
Click to expand it.
tests/unit/framework/base/DictionaryTest.php
View file @
4686c7c3
...
@@ -15,52 +15,54 @@ class DictionaryTest extends \yiiunit\TestCase
...
@@ -15,52 +15,54 @@ class DictionaryTest extends \yiiunit\TestCase
* @var \yii\base\Dictionary
* @var \yii\base\Dictionary
*/
*/
protected
$dictionary
;
protected
$dictionary
;
protected
$item1
,
$item2
,
$item3
;
protected
$item1
;
protected
$item2
;
protected
$item3
;
public
function
setUp
()
public
function
setUp
()
{
{
$this
->
dictionary
=
new
Dictionary
;
$this
->
dictionary
=
new
Dictionary
;
$this
->
item1
=
new
MapItem
;
$this
->
item1
=
new
MapItem
;
$this
->
item2
=
new
MapItem
;
$this
->
item2
=
new
MapItem
;
$this
->
item3
=
new
MapItem
;
$this
->
item3
=
new
MapItem
;
$this
->
dictionary
->
add
(
'key1'
,
$this
->
item1
);
$this
->
dictionary
->
add
(
'key1'
,
$this
->
item1
);
$this
->
dictionary
->
add
(
'key2'
,
$this
->
item2
);
$this
->
dictionary
->
add
(
'key2'
,
$this
->
item2
);
}
}
public
function
tearDown
()
public
function
tearDown
()
{
{
$this
->
dictionary
=
null
;
$this
->
dictionary
=
null
;
$this
->
item1
=
null
;
$this
->
item1
=
null
;
$this
->
item2
=
null
;
$this
->
item2
=
null
;
$this
->
item3
=
null
;
$this
->
item3
=
null
;
}
}
public
function
testConstruct
()
public
function
testConstruct
()
{
{
$a
=
array
(
1
,
2
,
'key3'
=>
3
);
$a
=
array
(
1
,
2
,
'key3'
=>
3
);
$dictionary
=
new
Dictionary
(
$a
);
$dictionary
=
new
Dictionary
(
$a
);
$this
->
assertEquals
(
3
,
$dictionary
->
getCount
());
$this
->
assertEquals
(
3
,
$dictionary
->
getCount
());
$dictionary2
=
new
Dictionary
(
$this
->
dictionary
);
$dictionary2
=
new
Dictionary
(
$this
->
dictionary
);
$this
->
assertEquals
(
2
,
$dictionary2
->
getCount
());
$this
->
assertEquals
(
2
,
$dictionary2
->
getCount
());
}
}
public
function
testGetCount
()
public
function
testGetCount
()
{
{
$this
->
assertEquals
(
2
,
$this
->
dictionary
->
getCount
());
$this
->
assertEquals
(
2
,
$this
->
dictionary
->
getCount
());
}
}
public
function
testGetKeys
()
public
function
testGetKeys
()
{
{
$keys
=
$this
->
dictionary
->
getKeys
();
$keys
=
$this
->
dictionary
->
getKeys
();
$this
->
assertEquals
(
2
,
count
(
$keys
));
$this
->
assertEquals
(
2
,
count
(
$keys
));
$this
->
assertEquals
(
'key1'
,
$keys
[
0
]);
$this
->
assertEquals
(
'key1'
,
$keys
[
0
]);
$this
->
assertEquals
(
'key2'
,
$keys
[
1
]);
$this
->
assertEquals
(
'key2'
,
$keys
[
1
]);
}
}
public
function
testAdd
()
public
function
testAdd
()
{
{
$this
->
dictionary
->
add
(
'key3'
,
$this
->
item3
);
$this
->
dictionary
->
add
(
'key3'
,
$this
->
item3
);
$this
->
assertEquals
(
3
,
$this
->
dictionary
->
getCount
());
$this
->
assertEquals
(
3
,
$this
->
dictionary
->
getCount
());
$this
->
assertTrue
(
$this
->
dictionary
->
has
(
'key3'
));
$this
->
assertTrue
(
$this
->
dictionary
->
has
(
'key3'
));
$this
->
dictionary
[]
=
'test'
;
$this
->
dictionary
[]
=
'test'
;
...
@@ -69,21 +71,21 @@ class DictionaryTest extends \yiiunit\TestCase
...
@@ -69,21 +71,21 @@ class DictionaryTest extends \yiiunit\TestCase
public
function
testRemove
()
public
function
testRemove
()
{
{
$this
->
dictionary
->
remove
(
'key1'
);
$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
->
has
(
'key1'
));
$this
->
assertTrue
(
$this
->
dictionary
->
remove
(
'unknown key'
)
===
null
);
$this
->
assertTrue
(
$this
->
dictionary
->
remove
(
'unknown key'
)
===
null
);
}
}
public
function
testRemoveAll
()
public
function
testRemoveAll
()
{
{
$this
->
dictionary
->
add
(
'key3'
,
$this
->
item3
);
$this
->
dictionary
->
add
(
'key3'
,
$this
->
item3
);
$this
->
dictionary
->
removeAll
();
$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
->
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
->
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'
));
$this
->
assertTrue
(
!
$this
->
dictionary
->
has
(
'key1'
)
&&
!
$this
->
dictionary
->
has
(
'key2'
));
}
}
...
@@ -96,7 +98,7 @@ class DictionaryTest extends \yiiunit\TestCase
...
@@ -96,7 +98,7 @@ class DictionaryTest extends \yiiunit\TestCase
public
function
testFromArray
()
public
function
testFromArray
()
{
{
$array
=
array
(
'key3'
=>
$this
->
item3
,
'key4'
=>
$this
->
item1
);
$array
=
array
(
'key3'
=>
$this
->
item3
,
'key4'
=>
$this
->
item1
);
$this
->
dictionary
->
copyFrom
(
$array
);
$this
->
dictionary
->
copyFrom
(
$array
);
$this
->
assertEquals
(
2
,
$this
->
dictionary
->
getCount
());
$this
->
assertEquals
(
2
,
$this
->
dictionary
->
getCount
());
...
@@ -109,21 +111,21 @@ class DictionaryTest extends \yiiunit\TestCase
...
@@ -109,21 +111,21 @@ class DictionaryTest extends \yiiunit\TestCase
public
function
testMergeWith
()
public
function
testMergeWith
()
{
{
$a
=
array
(
'a'
=>
'v1'
,
'v2'
,
array
(
'2'
),
'c'
=>
array
(
'3'
,
'c'
=>
'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'
));
$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'
));
$c
=
array
(
'a'
=>
'v11'
,
'v2'
,
array
(
'2'
),
'c'
=>
array
(
'3'
,
'c'
=>
'3'
,
'a'
),
'v22'
,
array
(
'2'
));
$dictionary
=
new
Dictionary
(
$a
);
$dictionary
=
new
Dictionary
(
$a
);
$dictionary2
=
new
Dictionary
(
$b
);
$dictionary2
=
new
Dictionary
(
$b
);
$dictionary
->
mergeWith
(
$dictionary2
);
$dictionary
->
mergeWith
(
$dictionary2
);
$this
->
assertTrue
(
$dictionary
->
toArray
()
===
$c
);
$this
->
assertTrue
(
$dictionary
->
toArray
()
===
$c
);
$array
=
array
(
'key2'
=>
$this
->
item1
,
'key3'
=>
$this
->
item3
);
$array
=
array
(
'key2'
=>
$this
->
item1
,
'key3'
=>
$this
->
item3
);
$this
->
dictionary
->
mergeWith
(
$array
,
false
);
$this
->
dictionary
->
mergeWith
(
$array
,
false
);
$this
->
assertEquals
(
3
,
$this
->
dictionary
->
getCount
());
$this
->
assertEquals
(
3
,
$this
->
dictionary
->
getCount
());
$this
->
assertEquals
(
$this
->
item1
,
$this
->
dictionary
[
'key2'
]);
$this
->
assertEquals
(
$this
->
item1
,
$this
->
dictionary
[
'key2'
]);
$this
->
assertEquals
(
$this
->
item3
,
$this
->
dictionary
[
'key3'
]);
$this
->
assertEquals
(
$this
->
item3
,
$this
->
dictionary
[
'key3'
]);
$this
->
setExpectedException
(
'yii\base\InvalidParamException'
);
$this
->
setExpectedException
(
'yii\base\InvalidParamException'
);
$this
->
dictionary
->
mergeWith
(
$this
,
false
);
$this
->
dictionary
->
mergeWith
(
$this
,
false
);
}
}
public
function
testRecursiveMergeWithTraversable
(){
public
function
testRecursiveMergeWithTraversable
(){
...
@@ -135,7 +137,7 @@ class DictionaryTest extends \yiiunit\TestCase
...
@@ -135,7 +137,7 @@ class DictionaryTest extends \yiiunit\TestCase
'k4'
=>
$this
->
item3
,
'k4'
=>
$this
->
item3
,
))
))
));
));
$dictionary
->
mergeWith
(
$obj
,
true
);
$dictionary
->
mergeWith
(
$obj
,
true
);
$this
->
assertEquals
(
3
,
$dictionary
->
getCount
());
$this
->
assertEquals
(
3
,
$dictionary
->
getCount
());
$this
->
assertEquals
(
$this
->
item1
,
$dictionary
[
'k1'
]);
$this
->
assertEquals
(
$this
->
item1
,
$dictionary
[
'k1'
]);
...
@@ -145,23 +147,23 @@ class DictionaryTest extends \yiiunit\TestCase
...
@@ -145,23 +147,23 @@ class DictionaryTest extends \yiiunit\TestCase
public
function
testArrayRead
()
public
function
testArrayRead
()
{
{
$this
->
assertEquals
(
$this
->
item1
,
$this
->
dictionary
[
'key1'
]);
$this
->
assertEquals
(
$this
->
item1
,
$this
->
dictionary
[
'key1'
]);
$this
->
assertEquals
(
$this
->
item2
,
$this
->
dictionary
[
'key2'
]);
$this
->
assertEquals
(
$this
->
item2
,
$this
->
dictionary
[
'key2'
]);
$this
->
assertEquals
(
null
,
$this
->
dictionary
[
'key3'
]);
$this
->
assertEquals
(
null
,
$this
->
dictionary
[
'key3'
]);
}
}
public
function
testArrayWrite
()
public
function
testArrayWrite
()
{
{
$this
->
dictionary
[
'key3'
]
=
$this
->
item3
;
$this
->
dictionary
[
'key3'
]
=
$this
->
item3
;
$this
->
assertEquals
(
3
,
$this
->
dictionary
->
getCount
());
$this
->
assertEquals
(
3
,
$this
->
dictionary
->
getCount
());
$this
->
assertEquals
(
$this
->
item3
,
$this
->
dictionary
[
'key3'
]);
$this
->
assertEquals
(
$this
->
item3
,
$this
->
dictionary
[
'key3'
]);
$this
->
dictionary
[
'key1'
]
=
$this
->
item3
;
$this
->
dictionary
[
'key1'
]
=
$this
->
item3
;
$this
->
assertEquals
(
3
,
$this
->
dictionary
->
getCount
());
$this
->
assertEquals
(
3
,
$this
->
dictionary
->
getCount
());
$this
->
assertEquals
(
$this
->
item3
,
$this
->
dictionary
[
'key1'
]);
$this
->
assertEquals
(
$this
->
item3
,
$this
->
dictionary
[
'key1'
]);
unset
(
$this
->
dictionary
[
'key2'
]);
unset
(
$this
->
dictionary
[
'key2'
]);
$this
->
assertEquals
(
2
,
$this
->
dictionary
->
getCount
());
$this
->
assertEquals
(
2
,
$this
->
dictionary
->
getCount
());
$this
->
assertTrue
(
!
$this
->
dictionary
->
has
(
'key2'
));
$this
->
assertTrue
(
!
$this
->
dictionary
->
has
(
'key2'
));
unset
(
$this
->
dictionary
[
'unknown key'
]);
unset
(
$this
->
dictionary
[
'unknown key'
]);
...
@@ -169,22 +171,23 @@ class DictionaryTest extends \yiiunit\TestCase
...
@@ -169,22 +171,23 @@ class DictionaryTest extends \yiiunit\TestCase
public
function
testArrayForeach
()
public
function
testArrayForeach
()
{
{
$n
=
0
;
$n
=
0
;
$found
=
0
;
$found
=
0
;
foreach
(
$this
->
dictionary
as
$index
=>
$item
)
foreach
(
$this
->
dictionary
as
$index
=>
$item
)
{
{
$n
++
;
$n
++
;
if
(
$index
===
'key1'
&&
$item
===
$this
->
item1
)
if
(
$index
===
'key1'
&&
$item
===
$this
->
item1
)
{
$found
++
;
$found
++
;
if
(
$index
===
'key2'
&&
$item
===
$this
->
item2
)
}
if
(
$index
===
'key2'
&&
$item
===
$this
->
item2
)
{
$found
++
;
$found
++
;
}
}
}
$this
->
assertTrue
(
$n
==
2
&&
$found
==
2
);
$this
->
assertTrue
(
$n
==
2
&&
$found
==
2
);
}
}
public
function
testArrayMisc
()
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
->
assertTrue
(
isset
(
$this
->
dictionary
[
'key1'
]));
$this
->
assertFalse
(
isset
(
$this
->
dictionary
[
'unknown key'
]));
$this
->
assertFalse
(
isset
(
$this
->
dictionary
[
'unknown key'
]));
}
}
...
...
This diff is collapsed.
Click to expand it.
tests/unit/framework/base/ModelTest.php
View file @
4686c7c3
...
@@ -155,7 +155,7 @@ class ModelTest extends TestCase
...
@@ -155,7 +155,7 @@ class ModelTest extends TestCase
// iteration
// iteration
$attributes
=
array
();
$attributes
=
array
();
foreach
(
$speaker
as
$key
=>
$attribute
)
{
foreach
(
$speaker
as
$key
=>
$attribute
)
{
$attributes
[
$key
]
=
$attribute
;
$attributes
[
$key
]
=
$attribute
;
}
}
$this
->
assertEquals
(
array
(
$this
->
assertEquals
(
array
(
...
...
This diff is collapsed.
Click to expand it.
tests/unit/framework/base/VectorTest.php
View file @
4686c7c3
...
@@ -15,39 +15,41 @@ class VectorTest extends \yiiunit\TestCase
...
@@ -15,39 +15,41 @@ class VectorTest extends \yiiunit\TestCase
* @var Vector
* @var Vector
*/
*/
protected
$vector
;
protected
$vector
;
protected
$item1
,
$item2
,
$item3
;
protected
$item1
;
protected
$item2
;
protected
$item3
;
public
function
setUp
()
public
function
setUp
()
{
{
$this
->
vector
=
new
Vector
;
$this
->
vector
=
new
Vector
;
$this
->
item1
=
new
ListItem
;
$this
->
item1
=
new
ListItem
;
$this
->
item2
=
new
ListItem
;
$this
->
item2
=
new
ListItem
;
$this
->
item3
=
new
ListItem
;
$this
->
item3
=
new
ListItem
;
$this
->
vector
->
add
(
$this
->
item1
);
$this
->
vector
->
add
(
$this
->
item1
);
$this
->
vector
->
add
(
$this
->
item2
);
$this
->
vector
->
add
(
$this
->
item2
);
}
}
public
function
tearDown
()
public
function
tearDown
()
{
{
$this
->
vector
=
null
;
$this
->
vector
=
null
;
$this
->
item1
=
null
;
$this
->
item1
=
null
;
$this
->
item2
=
null
;
$this
->
item2
=
null
;
$this
->
item3
=
null
;
$this
->
item3
=
null
;
}
}
public
function
testConstruct
()
public
function
testConstruct
()
{
{
$a
=
array
(
1
,
2
,
3
);
$a
=
array
(
1
,
2
,
3
);
$vector
=
new
Vector
(
$a
);
$vector
=
new
Vector
(
$a
);
$this
->
assertEquals
(
3
,
$vector
->
getCount
());
$this
->
assertEquals
(
3
,
$vector
->
getCount
());
$vector2
=
new
Vector
(
$this
->
vector
);
$vector2
=
new
Vector
(
$this
->
vector
);
$this
->
assertEquals
(
2
,
$vector2
->
getCount
());
$this
->
assertEquals
(
2
,
$vector2
->
getCount
());
}
}
public
function
testItemAt
()
public
function
testItemAt
()
{
{
$a
=
array
(
1
,
2
,
null
,
4
);
$a
=
array
(
1
,
2
,
null
,
4
);
$vector
=
new
Vector
(
$a
);
$vector
=
new
Vector
(
$a
);
$this
->
assertEquals
(
1
,
$vector
->
itemAt
(
0
));
$this
->
assertEquals
(
1
,
$vector
->
itemAt
(
0
));
$this
->
assertEquals
(
2
,
$vector
->
itemAt
(
1
));
$this
->
assertEquals
(
2
,
$vector
->
itemAt
(
1
));
$this
->
assertNull
(
$vector
->
itemAt
(
2
));
$this
->
assertNull
(
$vector
->
itemAt
(
2
));
...
@@ -56,37 +58,37 @@ class VectorTest extends \yiiunit\TestCase
...
@@ -56,37 +58,37 @@ class VectorTest extends \yiiunit\TestCase
public
function
testGetCount
()
public
function
testGetCount
()
{
{
$this
->
assertEquals
(
2
,
$this
->
vector
->
getCount
());
$this
->
assertEquals
(
2
,
$this
->
vector
->
getCount
());
$this
->
assertEquals
(
2
,
$this
->
vector
->
Count
);
$this
->
assertEquals
(
2
,
$this
->
vector
->
Count
);
}
}
public
function
testAdd
()
public
function
testAdd
()
{
{
$this
->
vector
->
add
(
null
);
$this
->
vector
->
add
(
null
);
$this
->
vector
->
add
(
$this
->
item3
);
$this
->
vector
->
add
(
$this
->
item3
);
$this
->
assertEquals
(
4
,
$this
->
vector
->
getCount
());
$this
->
assertEquals
(
4
,
$this
->
vector
->
getCount
());
$this
->
assertEquals
(
3
,
$this
->
vector
->
indexOf
(
$this
->
item3
));
$this
->
assertEquals
(
3
,
$this
->
vector
->
indexOf
(
$this
->
item3
));
}
}
public
function
testInsertAt
()
public
function
testInsertAt
()
{
{
$this
->
vector
->
insertAt
(
0
,
$this
->
item3
);
$this
->
vector
->
insertAt
(
0
,
$this
->
item3
);
$this
->
assertEquals
(
3
,
$this
->
vector
->
getCount
());
$this
->
assertEquals
(
3
,
$this
->
vector
->
getCount
());
$this
->
assertEquals
(
2
,
$this
->
vector
->
indexOf
(
$this
->
item2
));
$this
->
assertEquals
(
2
,
$this
->
vector
->
indexOf
(
$this
->
item2
));
$this
->
assertEquals
(
0
,
$this
->
vector
->
indexOf
(
$this
->
item3
));
$this
->
assertEquals
(
0
,
$this
->
vector
->
indexOf
(
$this
->
item3
));
$this
->
assertEquals
(
1
,
$this
->
vector
->
indexOf
(
$this
->
item1
));
$this
->
assertEquals
(
1
,
$this
->
vector
->
indexOf
(
$this
->
item1
));
$this
->
setExpectedException
(
'yii\base\InvalidParamException'
);
$this
->
setExpectedException
(
'yii\base\InvalidParamException'
);
$this
->
vector
->
insertAt
(
4
,
$this
->
item3
);
$this
->
vector
->
insertAt
(
4
,
$this
->
item3
);
}
}
public
function
testRemove
()
public
function
testRemove
()
{
{
$this
->
vector
->
remove
(
$this
->
item1
);
$this
->
vector
->
remove
(
$this
->
item1
);
$this
->
assertEquals
(
1
,
$this
->
vector
->
getCount
());
$this
->
assertEquals
(
1
,
$this
->
vector
->
getCount
());
$this
->
assertEquals
(
-
1
,
$this
->
vector
->
indexOf
(
$this
->
item1
));
$this
->
assertEquals
(
-
1
,
$this
->
vector
->
indexOf
(
$this
->
item1
));
$this
->
assertEquals
(
0
,
$this
->
vector
->
indexOf
(
$this
->
item2
));
$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
...
@@ -94,9 +96,9 @@ class VectorTest extends \yiiunit\TestCase
{
{
$this
->
vector
->
add
(
$this
->
item3
);
$this
->
vector
->
add
(
$this
->
item3
);
$this
->
vector
->
removeAt
(
1
);
$this
->
vector
->
removeAt
(
1
);
$this
->
assertEquals
(
-
1
,
$this
->
vector
->
indexOf
(
$this
->
item2
));
$this
->
assertEquals
(
-
1
,
$this
->
vector
->
indexOf
(
$this
->
item2
));
$this
->
assertEquals
(
1
,
$this
->
vector
->
indexOf
(
$this
->
item3
));
$this
->
assertEquals
(
1
,
$this
->
vector
->
indexOf
(
$this
->
item3
));
$this
->
assertEquals
(
0
,
$this
->
vector
->
indexOf
(
$this
->
item1
));
$this
->
assertEquals
(
0
,
$this
->
vector
->
indexOf
(
$this
->
item1
));
$this
->
setExpectedException
(
'yii\base\InvalidParamException'
);
$this
->
setExpectedException
(
'yii\base\InvalidParamException'
);
$this
->
vector
->
removeAt
(
2
);
$this
->
vector
->
removeAt
(
2
);
}
}
...
@@ -105,15 +107,15 @@ class VectorTest extends \yiiunit\TestCase
...
@@ -105,15 +107,15 @@ class VectorTest extends \yiiunit\TestCase
{
{
$this
->
vector
->
add
(
$this
->
item3
);
$this
->
vector
->
add
(
$this
->
item3
);
$this
->
vector
->
removeAll
();
$this
->
vector
->
removeAll
();
$this
->
assertEquals
(
0
,
$this
->
vector
->
getCount
());
$this
->
assertEquals
(
0
,
$this
->
vector
->
getCount
());
$this
->
assertEquals
(
-
1
,
$this
->
vector
->
indexOf
(
$this
->
item1
));
$this
->
assertEquals
(
-
1
,
$this
->
vector
->
indexOf
(
$this
->
item1
));
$this
->
assertEquals
(
-
1
,
$this
->
vector
->
indexOf
(
$this
->
item2
));
$this
->
assertEquals
(
-
1
,
$this
->
vector
->
indexOf
(
$this
->
item2
));
$this
->
vector
->
add
(
$this
->
item3
);
$this
->
vector
->
add
(
$this
->
item3
);
$this
->
vector
->
removeAll
(
true
);
$this
->
vector
->
removeAll
(
true
);
$this
->
assertEquals
(
0
,
$this
->
vector
->
getCount
());
$this
->
assertEquals
(
0
,
$this
->
vector
->
getCount
());
$this
->
assertEquals
(
-
1
,
$this
->
vector
->
indexOf
(
$this
->
item1
));
$this
->
assertEquals
(
-
1
,
$this
->
vector
->
indexOf
(
$this
->
item1
));
$this
->
assertEquals
(
-
1
,
$this
->
vector
->
indexOf
(
$this
->
item2
));
$this
->
assertEquals
(
-
1
,
$this
->
vector
->
indexOf
(
$this
->
item2
));
}
}
public
function
testHas
()
public
function
testHas
()
...
@@ -125,30 +127,32 @@ class VectorTest extends \yiiunit\TestCase
...
@@ -125,30 +127,32 @@ class VectorTest extends \yiiunit\TestCase
public
function
testIndexOf
()
public
function
testIndexOf
()
{
{
$this
->
assertEquals
(
0
,
$this
->
vector
->
indexOf
(
$this
->
item1
));
$this
->
assertEquals
(
0
,
$this
->
vector
->
indexOf
(
$this
->
item1
));
$this
->
assertEquals
(
1
,
$this
->
vector
->
indexOf
(
$this
->
item2
));
$this
->
assertEquals
(
1
,
$this
->
vector
->
indexOf
(
$this
->
item2
));
$this
->
assertEquals
(
-
1
,
$this
->
vector
->
indexOf
(
$this
->
item3
));
$this
->
assertEquals
(
-
1
,
$this
->
vector
->
indexOf
(
$this
->
item3
));
}
}
public
function
testFromArray
()
public
function
testFromArray
()
{
{
$array
=
array
(
$this
->
item3
,
$this
->
item1
);
$array
=
array
(
$this
->
item3
,
$this
->
item1
);
$this
->
vector
->
copyFrom
(
$array
);
$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
->
setExpectedException
(
'yii\base\InvalidParamException'
);
$this
->
vector
->
copyFrom
(
$this
);
$this
->
vector
->
copyFrom
(
$this
);
}
}
public
function
testMergeWith
()
public
function
testMergeWith
()
{
{
$array
=
array
(
$this
->
item3
,
$this
->
item1
);
$array
=
array
(
$this
->
item3
,
$this
->
item1
);
$this
->
vector
->
mergeWith
(
$array
);
$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
);
$a
=
array
(
1
);
$vector
=
new
Vector
(
$a
);
$vector
=
new
Vector
(
$a
);
$this
->
vector
->
mergeWith
(
$vector
);
$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
->
setExpectedException
(
'yii\base\InvalidParamException'
);
$this
->
vector
->
mergeWith
(
$this
);
$this
->
vector
->
mergeWith
(
$this
);
...
@@ -156,37 +160,40 @@ class VectorTest extends \yiiunit\TestCase
...
@@ -156,37 +160,40 @@ class VectorTest extends \yiiunit\TestCase
public
function
testToArray
()
public
function
testToArray
()
{
{
$array
=
$this
->
vector
->
toArray
();
$array
=
$this
->
vector
->
toArray
();
$this
->
assertTrue
(
count
(
$array
)
==
2
&&
$array
[
0
]
===
$this
->
item1
&&
$array
[
1
]
===
$this
->
item2
);
$this
->
assertTrue
(
count
(
$array
)
==
2
&&
$array
[
0
]
===
$this
->
item1
&&
$array
[
1
]
===
$this
->
item2
);
}
}
public
function
testArrayRead
()
public
function
testArrayRead
()
{
{
$this
->
assertTrue
(
$this
->
vector
[
0
]
===
$this
->
item1
);
$this
->
assertTrue
(
$this
->
vector
[
0
]
===
$this
->
item1
);
$this
->
assertTrue
(
$this
->
vector
[
1
]
===
$this
->
item2
);
$this
->
assertTrue
(
$this
->
vector
[
1
]
===
$this
->
item2
);
$this
->
setExpectedException
(
'yii\base\InvalidParamException'
);
$this
->
setExpectedException
(
'yii\base\InvalidParamException'
);
$a
=
$this
->
vector
[
2
];
$a
=
$this
->
vector
[
2
];
}
}
public
function
testGetIterator
()
public
function
testGetIterator
()
{
{
$n
=
0
;
$n
=
0
;
$found
=
0
;
$found
=
0
;
foreach
(
$this
->
vector
as
$index
=>
$item
)
foreach
(
$this
->
vector
as
$index
=>
$item
)
{
{
foreach
(
$this
->
vector
as
$a
=>
$b
)
{
foreach
(
$this
->
vector
as
$a
=>
$b
);
// test of iterator
// test of iterator
}
$n
++
;
$n
++
;
if
(
$index
===
0
&&
$item
===
$this
->
item1
)
if
(
$index
===
0
&&
$item
===
$this
->
item1
)
{
$found
++
;
$found
++
;
if
(
$index
===
1
&&
$item
===
$this
->
item2
)
}
if
(
$index
===
1
&&
$item
===
$this
->
item2
)
{
$found
++
;
$found
++
;
}
}
}
$this
->
assertTrue
(
$n
==
2
&&
$found
==
2
);
$this
->
assertTrue
(
$n
==
2
&&
$found
==
2
);
}
}
public
function
testArrayMisc
()
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
->
assertTrue
(
isset
(
$this
->
vector
[
1
]));
$this
->
assertFalse
(
isset
(
$this
->
vector
[
2
]));
$this
->
assertFalse
(
isset
(
$this
->
vector
[
2
]));
}
}
...
...
This diff is collapsed.
Click to expand it.
tests/unit/framework/caching/DbCacheTest.php
View file @
4686c7c3
...
@@ -34,7 +34,7 @@ class DbCacheTest extends CacheTest
...
@@ -34,7 +34,7 @@ class DbCacheTest extends CacheTest
*/
*/
function
getConnection
(
$reset
=
true
)
function
getConnection
(
$reset
=
true
)
{
{
if
(
$this
->
_connection
===
null
)
{
if
(
$this
->
_connection
===
null
)
{
$databases
=
$this
->
getParam
(
'databases'
);
$databases
=
$this
->
getParam
(
'databases'
);
$params
=
$databases
[
'mysql'
];
$params
=
$databases
[
'mysql'
];
$db
=
new
\yii\db\Connection
;
$db
=
new
\yii\db\Connection
;
...
@@ -61,7 +61,7 @@ class DbCacheTest extends CacheTest
...
@@ -61,7 +61,7 @@ class DbCacheTest extends CacheTest
*/
*/
protected
function
getCacheInstance
()
protected
function
getCacheInstance
()
{
{
if
(
$this
->
_cacheInstance
===
null
)
{
if
(
$this
->
_cacheInstance
===
null
)
{
$this
->
_cacheInstance
=
new
DbCache
(
array
(
$this
->
_cacheInstance
=
new
DbCache
(
array
(
'db'
=>
$this
->
getConnection
(),
'db'
=>
$this
->
getConnection
(),
));
));
...
...
This diff is collapsed.
Click to expand it.
tests/unit/framework/caching/FileCacheTest.php
View file @
4686c7c3
...
@@ -15,7 +15,7 @@ class FileCacheTest extends CacheTest
...
@@ -15,7 +15,7 @@ class FileCacheTest extends CacheTest
*/
*/
protected
function
getCacheInstance
()
protected
function
getCacheInstance
()
{
{
if
(
$this
->
_cacheInstance
===
null
)
{
if
(
$this
->
_cacheInstance
===
null
)
{
$this
->
_cacheInstance
=
new
FileCache
(
array
(
$this
->
_cacheInstance
=
new
FileCache
(
array
(
'cachePath'
=>
'@yiiunit/runtime/cache'
,
'cachePath'
=>
'@yiiunit/runtime/cache'
,
));
));
...
...
This diff is collapsed.
Click to expand it.
tests/unit/framework/caching/MemCacheTest.php
View file @
4686c7c3
...
@@ -15,11 +15,11 @@ class MemCacheTest extends CacheTest
...
@@ -15,11 +15,11 @@ class MemCacheTest extends CacheTest
*/
*/
protected
function
getCacheInstance
()
protected
function
getCacheInstance
()
{
{
if
(
!
extension_loaded
(
"memcache"
))
{
if
(
!
extension_loaded
(
"memcache"
))
{
$this
->
markTestSkipped
(
"memcache not installed. Skipping."
);
$this
->
markTestSkipped
(
"memcache not installed. Skipping."
);
}
}
if
(
$this
->
_cacheInstance
===
null
)
{
if
(
$this
->
_cacheInstance
===
null
)
{
$this
->
_cacheInstance
=
new
MemCache
();
$this
->
_cacheInstance
=
new
MemCache
();
}
}
return
$this
->
_cacheInstance
;
return
$this
->
_cacheInstance
;
...
...
This diff is collapsed.
Click to expand it.
tests/unit/framework/caching/MemCachedTest.php
View file @
4686c7c3
...
@@ -15,11 +15,11 @@ class MemCachedTest extends CacheTest
...
@@ -15,11 +15,11 @@ class MemCachedTest extends CacheTest
*/
*/
protected
function
getCacheInstance
()
protected
function
getCacheInstance
()
{
{
if
(
!
extension_loaded
(
"memcached"
))
{
if
(
!
extension_loaded
(
"memcached"
))
{
$this
->
markTestSkipped
(
"memcached not installed. Skipping."
);
$this
->
markTestSkipped
(
"memcached not installed. Skipping."
);
}
}
if
(
$this
->
_cacheInstance
===
null
)
{
if
(
$this
->
_cacheInstance
===
null
)
{
$this
->
_cacheInstance
=
new
MemCache
(
array
(
$this
->
_cacheInstance
=
new
MemCache
(
array
(
'useMemcached'
=>
true
,
'useMemcached'
=>
true
,
));
));
...
...
This diff is collapsed.
Click to expand it.
tests/unit/framework/caching/WinCacheTest.php
View file @
4686c7c3
...
@@ -15,15 +15,15 @@ class WinCacheTest extends CacheTest
...
@@ -15,15 +15,15 @@ class WinCacheTest extends CacheTest
*/
*/
protected
function
getCacheInstance
()
protected
function
getCacheInstance
()
{
{
if
(
!
extension_loaded
(
'wincache'
))
{
if
(
!
extension_loaded
(
'wincache'
))
{
$this
->
markTestSkipped
(
"Wincache not installed. Skipping."
);
$this
->
markTestSkipped
(
"Wincache not installed. Skipping."
);
}
}
if
(
!
ini_get
(
'wincache.ucenabled'
))
{
if
(
!
ini_get
(
'wincache.ucenabled'
))
{
$this
->
markTestSkipped
(
"Wincache user cache disabled. Skipping."
);
$this
->
markTestSkipped
(
"Wincache user cache disabled. Skipping."
);
}
}
if
(
$this
->
_cacheInstance
===
null
)
{
if
(
$this
->
_cacheInstance
===
null
)
{
$this
->
_cacheInstance
=
new
WinCache
();
$this
->
_cacheInstance
=
new
WinCache
();
}
}
return
$this
->
_cacheInstance
;
return
$this
->
_cacheInstance
;
...
...
This diff is collapsed.
Click to expand it.
tests/unit/framework/caching/XCacheTest.php
View file @
4686c7c3
...
@@ -15,11 +15,11 @@ class XCacheTest extends CacheTest
...
@@ -15,11 +15,11 @@ class XCacheTest extends CacheTest
*/
*/
protected
function
getCacheInstance
()
protected
function
getCacheInstance
()
{
{
if
(
!
function_exists
(
"xcache_isset"
))
{
if
(
!
function_exists
(
"xcache_isset"
))
{
$this
->
markTestSkipped
(
"XCache not installed. Skipping."
);
$this
->
markTestSkipped
(
"XCache not installed. Skipping."
);
}
}
if
(
$this
->
_cacheInstance
===
null
)
{
if
(
$this
->
_cacheInstance
===
null
)
{
$this
->
_cacheInstance
=
new
XCache
();
$this
->
_cacheInstance
=
new
XCache
();
}
}
return
$this
->
_cacheInstance
;
return
$this
->
_cacheInstance
;
...
...
This diff is collapsed.
Click to expand it.
tests/unit/framework/caching/ZendDataCacheTest.php
View file @
4686c7c3
...
@@ -15,11 +15,11 @@ class ZendDataCacheTest extends CacheTest
...
@@ -15,11 +15,11 @@ class ZendDataCacheTest extends CacheTest
*/
*/
protected
function
getCacheInstance
()
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."
);
$this
->
markTestSkipped
(
"Zend Data cache not installed. Skipping."
);
}
}
if
(
$this
->
_cacheInstance
===
null
)
{
if
(
$this
->
_cacheInstance
===
null
)
{
$this
->
_cacheInstance
=
new
ZendDataCache
();
$this
->
_cacheInstance
=
new
ZendDataCache
();
}
}
return
$this
->
_cacheInstance
;
return
$this
->
_cacheInstance
;
...
...
This diff is collapsed.
Click to expand it.
tests/unit/framework/db/CommandTest.php
View file @
4686c7c3
...
@@ -140,7 +140,7 @@ class CommandTest extends \yiiunit\DatabaseTestCase
...
@@ -140,7 +140,7 @@ class CommandTest extends \yiiunit\DatabaseTestCase
$db
=
$this
->
getConnection
();
$db
=
$this
->
getConnection
();
// bindParam
// 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
);
$command
=
$db
->
createCommand
(
$sql
);
$email
=
'user4@example.com'
;
$email
=
'user4@example.com'
;
$name
=
'user4'
;
$name
=
'user4'
;
...
...
This diff is collapsed.
Click to expand it.
tests/unit/framework/db/QueryTest.php
View file @
4686c7c3
...
@@ -20,7 +20,7 @@ class QueryTest extends \yiiunit\DatabaseTestCase
...
@@ -20,7 +20,7 @@ class QueryTest extends \yiiunit\DatabaseTestCase
$query
=
new
Query
;
$query
=
new
Query
;
$query
->
select
(
'id, name'
,
'something'
)
->
distinct
(
true
);
$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
->
assertTrue
(
$query
->
distinct
);
$this
->
assertEquals
(
'something'
,
$query
->
selectOption
);
$this
->
assertEquals
(
'something'
,
$query
->
selectOption
);
}
}
...
...
This diff is collapsed.
Click to expand it.
tests/unit/framework/helpers/StringHelperTest.php
View file @
4686c7c3
...
@@ -40,7 +40,7 @@ class StringHelperTest extends \yii\test\TestCase
...
@@ -40,7 +40,7 @@ class StringHelperTest extends \yii\test\TestCase
'car'
=>
'cars'
,
'car'
=>
'cars'
,
);
);
foreach
(
$testData
as
$testIn
=>
$testOut
)
{
foreach
(
$testData
as
$testIn
=>
$testOut
)
{
$this
->
assertEquals
(
$testOut
,
StringHelper
::
pluralize
(
$testIn
));
$this
->
assertEquals
(
$testOut
,
StringHelper
::
pluralize
(
$testIn
));
$this
->
assertEquals
(
ucfirst
(
$testOut
),
ucfirst
(
StringHelper
::
pluralize
(
$testIn
)));
$this
->
assertEquals
(
ucfirst
(
$testOut
),
ucfirst
(
StringHelper
::
pluralize
(
$testIn
)));
}
}
...
...
This diff is collapsed.
Click to expand it.
tests/unit/framework/rbac/ManagerTestBase.php
View file @
4686c7c3
...
@@ -164,8 +164,8 @@ abstract class ManagerTestBase extends TestCase
...
@@ -164,8 +164,8 @@ abstract class ManagerTestBase extends TestCase
public
function
testExecuteBizRule
()
public
function
testExecuteBizRule
()
{
{
$this
->
assertTrue
(
$this
->
auth
->
executeBizRule
(
null
,
array
(),
null
));
$this
->
assertTrue
(
$this
->
auth
->
executeBizRule
(
null
,
array
(),
null
));
$this
->
assertTrue
(
$this
->
auth
->
executeBizRule
(
'return 1
==
true;'
,
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 $params[0]
==
$params[1];'
,
array
(
1
,
'1'
),
null
));
$this
->
assertFalse
(
$this
->
auth
->
executeBizRule
(
'invalid'
,
array
(),
null
));
$this
->
assertFalse
(
$this
->
auth
->
executeBizRule
(
'invalid'
,
array
(),
null
));
}
}
...
@@ -220,7 +220,7 @@ abstract class ManagerTestBase extends TestCase
...
@@ -220,7 +220,7 @@ abstract class ManagerTestBase extends TestCase
$this
->
auth
->
createOperation
(
'updatePost'
,
'update a post'
);
$this
->
auth
->
createOperation
(
'updatePost'
,
'update a post'
);
$this
->
auth
->
createOperation
(
'deletePost'
,
'delete 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'
);
$task
->
addChild
(
'updatePost'
);
$role
=
$this
->
auth
->
createRole
(
'reader'
);
$role
=
$this
->
auth
->
createRole
(
'reader'
);
...
...
This diff is collapsed.
Click to expand it.
yii/base/Controller.php
View file @
4686c7c3
...
@@ -278,7 +278,7 @@ class Controller extends Component
...
@@ -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.
* 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 Action $action the currently requested action
* @param array $missingParams the names of the missing parameters
* @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
)
public
function
validateActionParams
(
$action
,
$missingParams
,
$unknownParams
)
{
{
...
@@ -318,10 +318,10 @@ class Controller extends Component
...
@@ -318,10 +318,10 @@ class Controller extends Component
/** @var Model $model */
/** @var Model $model */
$scope
=
$model
->
formName
();
$scope
=
$model
->
formName
();
if
(
$scope
==
''
)
{
if
(
$scope
==
''
)
{
$model
->
attributes
=
$data
;
$model
->
setAttributes
(
$data
)
;
$success
=
true
;
$success
=
true
;
}
elseif
(
isset
(
$data
[
$scope
]))
{
}
elseif
(
isset
(
$data
[
$scope
]))
{
$model
->
attributes
=
$data
[
$scope
]
;
$model
->
setAttributes
(
$data
[
$scope
])
;
$success
=
true
;
$success
=
true
;
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
yii/base/Dictionary.php
View file @
4686c7c3
...
@@ -24,7 +24,7 @@ use yii\helpers\ArrayHelper;
...
@@ -24,7 +24,7 @@ use yii\helpers\ArrayHelper;
* $dictionary[$key] = $value; // add a key-value pair
* $dictionary[$key] = $value; // add a key-value pair
* unset($dictionary[$key]); // remove the value with the specified key
* unset($dictionary[$key]); // remove the value with the specified key
* if (isset($dictionary[$key])) // if the dictionary contains the 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
* $n = count($dictionary); // returns the number of items in the dictionary
* ~~~
* ~~~
*
*
...
...
This diff is collapsed.
Click to expand it.
yii/base/ErrorHandler.php
View file @
4686c7c3
...
@@ -83,7 +83,7 @@ class ErrorHandler extends Component
...
@@ -83,7 +83,7 @@ class ErrorHandler extends Component
}
else
{
}
else
{
// if there is an error during error rendering it's useful to
// if there is an error during error rendering it's useful to
// display PHP error in debug mode instead of a blank screen
// display PHP error in debug mode instead of a blank screen
if
(
YII_DEBUG
)
{
if
(
YII_DEBUG
)
{
ini_set
(
'display_errors'
,
1
);
ini_set
(
'display_errors'
,
1
);
}
}
...
@@ -231,7 +231,7 @@ class ErrorHandler extends Component
...
@@ -231,7 +231,7 @@ class ErrorHandler extends Component
echo
'<div class="plus">+</div><div class="minus">-</div>'
;
echo
'<div class="plus">+</div><div class="minus">-</div>'
;
}
}
echo
' '
;
echo
' '
;
if
(
isset
(
$t
[
'file'
]))
{
if
(
isset
(
$t
[
'file'
]))
{
echo
$this
->
htmlEncode
(
$t
[
'file'
])
.
'('
.
$t
[
'line'
]
.
'): '
;
echo
$this
->
htmlEncode
(
$t
[
'file'
])
.
'('
.
$t
[
'line'
]
.
'): '
;
}
}
if
(
!
empty
(
$t
[
'class'
]))
{
if
(
!
empty
(
$t
[
'class'
]))
{
...
...
This diff is collapsed.
Click to expand it.
yii/base/HttpException.php
View file @
4686c7c3
...
@@ -100,9 +100,10 @@ class HttpException extends UserException
...
@@ -100,9 +100,10 @@ class HttpException extends UserException
509
=>
'Bandwidth Limit Exceeded'
,
509
=>
'Bandwidth Limit Exceeded'
,
);
);
if
(
isset
(
$httpCodes
[
$this
->
statusCode
]))
if
(
isset
(
$httpCodes
[
$this
->
statusCode
]))
{
return
$httpCodes
[
$this
->
statusCode
];
return
$httpCodes
[
$this
->
statusCode
];
else
}
else
{
return
\Yii
::
t
(
'yii|Error'
);
return
\Yii
::
t
(
'yii|Error'
);
}
}
}
}
}
This diff is collapsed.
Click to expand it.
yii/base/Model.php
View file @
4686c7c3
...
@@ -33,7 +33,7 @@ use yii\validators\Validator;
...
@@ -33,7 +33,7 @@ use yii\validators\Validator;
* @property Vector $validators All the validators declared in the model.
* @property Vector $validators All the validators declared in the model.
* @property array $activeValidators The validators applicable to the current [[scenario]].
* @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 $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.
* @property string $scenario The scenario that this model is in.
*
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Qiang Xue <qiang.xue@gmail.com>
...
@@ -76,7 +76,7 @@ class Model extends Component implements \IteratorAggregate, \ArrayAccess
...
@@ -76,7 +76,7 @@ class Model extends Component implements \IteratorAggregate, \ArrayAccess
* array(
* array(
* 'attribute list',
* 'attribute list',
* 'validator type',
* 'validator type',
* 'on'
=>
'scenario name',
* 'on'
=>
'scenario name',
* ...other parameters...
* ...other parameters...
* )
* )
* ~~~
* ~~~
...
@@ -109,11 +109,11 @@ class Model extends Component implements \IteratorAggregate, \ArrayAccess
...
@@ -109,11 +109,11 @@ class Model extends Component implements \IteratorAggregate, \ArrayAccess
* // built-in "required" validator
* // built-in "required" validator
* array('username', 'required'),
* array('username', 'required'),
* // built-in "length" validator customized with "min" and "max" properties
* // 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
* // 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
* // 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"
* // a validator of class "CaptchaValidator"
* array('captcha', 'CaptchaValidator'),
* array('captcha', 'CaptchaValidator'),
* );
* );
...
@@ -220,7 +220,7 @@ class Model extends Component implements \IteratorAggregate, \ArrayAccess
...
@@ -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
* 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()`.
* 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
* @see generateAttributeLabel
*/
*/
public
function
attributeLabels
()
public
function
attributeLabels
()
...
@@ -511,7 +511,7 @@ class Model extends Component implements \IteratorAggregate, \ArrayAccess
...
@@ -511,7 +511,7 @@ class Model extends Component implements \IteratorAggregate, \ArrayAccess
* Defaults to null, meaning all attributes listed in [[attributes()]] will be returned.
* 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.
* 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.
* @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
())
public
function
getAttributes
(
$names
=
null
,
$except
=
array
())
{
{
...
@@ -531,7 +531,7 @@ class Model extends Component implements \IteratorAggregate, \ArrayAccess
...
@@ -531,7 +531,7 @@ class Model extends Component implements \IteratorAggregate, \ArrayAccess
/**
/**
* Sets the attribute values in a massive way.
* 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.
* @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]].
* A safe attribute is one that is associated with a validation rule in the current [[scenario]].
* @see safeAttributes()
* @see safeAttributes()
...
...
This diff is collapsed.
Click to expand it.
yii/base/Vector.php
View file @
4686c7c3
...
@@ -24,7 +24,7 @@ namespace yii\base;
...
@@ -24,7 +24,7 @@ namespace yii\base;
* $vector[$index] = $item; // set new item at $index
* $vector[$index] = $item; // set new item at $index
* unset($vector[$index]); // remove the item at $index
* unset($vector[$index]); // remove the item at $index
* if (isset($vector[$index])) // if the vector has an 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
* $n = count($vector); // count the number of items
* ~~~
* ~~~
*
*
...
...
This diff is collapsed.
Click to expand it.
yii/base/View.php
View file @
4686c7c3
...
@@ -475,7 +475,7 @@ class View extends Component
...
@@ -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.
* @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.
* 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
* @return \yii\widgets\ContentDecorator the ContentDecorator widget instance
* @see \yii\widgets\ContentDecorator
* @see \yii\widgets\ContentDecorator
*/
*/
...
@@ -503,7 +503,7 @@ class View extends Component
...
@@ -503,7 +503,7 @@ class View extends Component
* A typical usage of fragment caching is as follows,
* A typical usage of fragment caching is as follows,
*
*
* ~~~
* ~~~
* if($this->beginCache($id)) {
* if
($this->beginCache($id)) {
* // ...generate content here
* // ...generate content here
* $this->endCache();
* $this->endCache();
* }
* }
...
...
This diff is collapsed.
Click to expand it.
yii/caching/Cache.php
View file @
4686c7c3
...
@@ -140,7 +140,7 @@ abstract class Cache extends Component implements \ArrayAccess
...
@@ -140,7 +140,7 @@ abstract class Cache extends Component implements \ArrayAccess
* this method will try to simulate it.
* this method will try to simulate it.
* @param array $keys list of keys identifying the cached values
* @param array $keys list of keys identifying the cached values
* @return array list of cached values corresponding to the specified keys. The array
* @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.
* If a value is not cached or expired, the corresponding array value will be false.
*/
*/
public
function
mget
(
$keys
)
public
function
mget
(
$keys
)
...
...
This diff is collapsed.
Click to expand it.
yii/caching/DbDependency.php
View file @
4686c7c3
...
@@ -32,14 +32,14 @@ class DbDependency extends Dependency
...
@@ -32,14 +32,14 @@ class DbDependency extends Dependency
*/
*/
public
$sql
;
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
;
public
$params
;
/**
/**
* Constructor.
* Constructor.
* @param string $sql the SQL query whose result is used to determine if the dependency has been changed.
* @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
* @param array $config name-value pairs that will be used to initialize the object properties
*/
*/
public
function
__construct
(
$sql
,
$params
=
array
(),
$config
=
array
())
public
function
__construct
(
$sql
,
$params
=
array
(),
$config
=
array
())
...
...
This diff is collapsed.
Click to expand it.
yii/caching/MemCache.php
View file @
4686c7c3
...
@@ -30,19 +30,19 @@ use yii\base\InvalidConfigException;
...
@@ -30,19 +30,19 @@ use yii\base\InvalidConfigException;
*
*
* ~~~
* ~~~
* array(
* array(
* 'components'
=>
array(
* 'components'
=>
array(
* 'cache'
=>
array(
* 'cache'
=>
array(
* 'class'
=>
'MemCache',
* 'class'
=>
'MemCache',
* 'servers'
=>
array(
* 'servers'
=>
array(
* array(
* array(
* 'host'
=>
'server1',
* 'host'
=>
'server1',
* 'port'
=>
11211,
* 'port'
=>
11211,
* 'weight'
=>
60,
* 'weight'
=>
60,
* ),
* ),
* array(
* array(
* 'host'
=>
'server2',
* 'host'
=>
'server2',
* 'port'
=>
11211,
* 'port'
=>
11211,
* 'weight'
=>
40,
* 'weight'
=>
40,
* ),
* ),
* ),
* ),
* ),
* ),
...
...
This diff is collapsed.
Click to expand it.
yii/console/controllers/AppController.php
View file @
4686c7c3
...
@@ -8,7 +8,6 @@
...
@@ -8,7 +8,6 @@
namespace
yii\console\controllers
;
namespace
yii\console\controllers
;
use
yii\console\Controller
;
use
yii\console\Controller
;
use
yii\helpers\FileHelper
;
use
yii\base\Exception
;
use
yii\base\Exception
;
/**
/**
...
@@ -39,7 +38,7 @@ class AppController extends Controller
...
@@ -39,7 +38,7 @@ class AppController extends Controller
{
{
parent
::
init
();
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.'
);
throw
new
Exception
(
'--templatesPath "'
.
$this
->
templatesPath
.
'" does not exist or can not be read.'
);
}
}
}
}
...
@@ -67,30 +66,29 @@ class AppController extends Controller
...
@@ -67,30 +66,29 @@ class AppController extends Controller
public
function
actionCreate
(
$path
)
public
function
actionCreate
(
$path
)
{
{
$path
=
strtr
(
$path
,
'/\\'
,
DIRECTORY_SEPARATOR
);
$path
=
strtr
(
$path
,
'/\\'
,
DIRECTORY_SEPARATOR
);
if
(
strpos
(
$path
,
DIRECTORY_SEPARATOR
)
===
false
)
{
if
(
strpos
(
$path
,
DIRECTORY_SEPARATOR
)
===
false
)
{
$path
=
'.'
.
DIRECTORY_SEPARATOR
.
$path
;
$path
=
'.'
.
DIRECTORY_SEPARATOR
.
$path
;
}
}
$dir
=
rtrim
(
realpath
(
dirname
(
$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."
);
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
;
$this
->
_rootPath
=
$path
=
$dir
;
}
}
else
{
else
{
$this
->
_rootPath
=
$path
=
$dir
.
DIRECTORY_SEPARATOR
.
basename
(
$path
);
$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
();
$sourceDir
=
$this
->
getSourceDir
();
$config
=
$this
->
getConfig
();
$config
=
$this
->
getConfig
();
$list
=
$this
->
buildFileList
(
$sourceDir
,
$path
);
$list
=
$this
->
buildFileList
(
$sourceDir
,
$path
);
if
(
is_array
(
$config
))
{
if
(
is_array
(
$config
))
{
foreach
(
$config
as
$file
=>
$settings
)
{
foreach
(
$config
as
$file
=>
$settings
)
{
if
(
isset
(
$settings
[
'handler'
]))
{
if
(
isset
(
$settings
[
'handler'
]))
{
$list
[
$file
][
'callback'
]
=
$settings
[
'handler'
];
$list
[
$file
][
'callback'
]
=
$settings
[
'handler'
];
}
}
}
}
...
@@ -98,9 +96,9 @@ class AppController extends Controller
...
@@ -98,9 +96,9 @@ class AppController extends Controller
$this
->
copyFiles
(
$list
);
$this
->
copyFiles
(
$list
);
if
(
is_array
(
$config
))
{
if
(
is_array
(
$config
))
{
foreach
(
$config
as
$file
=>
$settings
)
{
foreach
(
$config
as
$file
=>
$settings
)
{
if
(
isset
(
$settings
[
'permissions'
]))
{
if
(
isset
(
$settings
[
'permissions'
]))
{
@
chmod
(
$path
.
'/'
.
$file
,
$settings
[
'permissions'
]);
@
chmod
(
$path
.
'/'
.
$file
,
$settings
[
'permissions'
]);
}
}
}
}
...
@@ -119,13 +117,11 @@ class AppController extends Controller
...
@@ -119,13 +117,11 @@ class AppController extends Controller
$customSource
=
realpath
(
$this
->
templatesPath
.
'/'
.
$this
->
type
);
$customSource
=
realpath
(
$this
->
templatesPath
.
'/'
.
$this
->
type
);
$defaultSource
=
realpath
(
$this
->
getDefaultTemplatesPath
()
.
'/'
.
$this
->
type
);
$defaultSource
=
realpath
(
$this
->
getDefaultTemplatesPath
()
.
'/'
.
$this
->
type
);
if
(
$customSource
)
{
if
(
$customSource
)
{
return
$customSource
;
return
$customSource
;
}
}
elseif
(
$defaultSource
)
{
elseif
(
$defaultSource
)
{
return
$defaultSource
;
return
$defaultSource
;
}
}
else
{
else
{
throw
new
Exception
(
'Unable to locate the source directory for "'
.
$this
->
type
.
'".'
);
throw
new
Exception
(
'Unable to locate the source directory for "'
.
$this
->
type
.
'".'
);
}
}
}
}
...
@@ -143,13 +139,13 @@ class AppController extends Controller
...
@@ -143,13 +139,13 @@ class AppController extends Controller
*/
*/
protected
function
getConfig
()
protected
function
getConfig
()
{
{
if
(
$this
->
_config
===
null
)
{
if
(
$this
->
_config
===
null
)
{
$this
->
_config
=
require
$this
->
getDefaultTemplatesPath
()
.
'/config.php'
;
$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'
);
$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
];
return
$this
->
_config
[
$this
->
type
];
}
}
}
}
...
@@ -185,30 +181,30 @@ class AppController extends Controller
...
@@ -185,30 +181,30 @@ class AppController extends Controller
$n1
=
count
(
$segs1
);
$n1
=
count
(
$segs1
);
$n2
=
count
(
$segs2
);
$n2
=
count
(
$segs2
);
for
(
$i
=
0
;
$i
<
$n1
&&
$i
<
$n2
;
++
$i
)
{
for
(
$i
=
0
;
$i
<
$n1
&&
$i
<
$n2
;
++
$i
)
{
if
(
$segs1
[
$i
]
!==
$segs2
[
$i
])
{
if
(
$segs1
[
$i
]
!==
$segs2
[
$i
])
{
break
;
break
;
}
}
}
}
if
(
$i
===
0
)
{
if
(
$i
===
0
)
{
return
"'"
.
$path1
.
"'"
;
return
"'"
.
$path1
.
"'"
;
}
}
$up
=
''
;
$up
=
''
;
for
(
$j
=
$i
;
$j
<
$n2
-
1
;
++
$j
)
{
for
(
$j
=
$i
;
$j
<
$n2
-
1
;
++
$j
)
{
$up
.=
'/..'
;
$up
.=
'/..'
;
}
}
for
(;
$i
<
$n1
-
1
;
++
$i
)
{
for
(;
$i
<
$n1
-
1
;
++
$i
)
{
$up
.=
'/'
.
$segs1
[
$i
];
$up
.=
'/'
.
$segs1
[
$i
];
}
}
return
'__DIR__.\''
.
$up
.
'/'
.
basename
(
$path1
)
.
'\''
;
return
'__DIR__.\''
.
$up
.
'/'
.
basename
(
$path1
)
.
'\''
;
}
}
/**
/**
* Copies a list of files from one place to another.
* 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
* 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:
* for files to be copied. Each array value must be an array of the following structure:
* <ul>
* <ul>
...
@@ -217,7 +213,7 @@ class AppController extends Controller
...
@@ -217,7 +213,7 @@ class AppController extends Controller
* <li>callback: optional, the callback to be invoked when copying a file. The callback function
* <li>callback: optional, the callback to be invoked when copying a file. The callback function
* should be declared as follows:
* should be declared as follows:
* <pre>
* <pre>
* function foo($source,$params)
* function foo($source,
$params)
* </pre>
* </pre>
* where $source parameter is the source file path, and the content returned
* where $source parameter is the source file path, and the content returned
* by the function will be saved into the target file.</li>
* by the function will be saved into the target file.</li>
...
@@ -228,48 +224,44 @@ class AppController extends Controller
...
@@ -228,48 +224,44 @@ class AppController extends Controller
protected
function
copyFiles
(
$fileList
)
protected
function
copyFiles
(
$fileList
)
{
{
$overwriteAll
=
false
;
$overwriteAll
=
false
;
foreach
(
$fileList
as
$name
=>
$file
)
{
foreach
(
$fileList
as
$name
=>
$file
)
{
$source
=
strtr
(
$file
[
'source'
],
'/\\'
,
DIRECTORY_SEPARATOR
);
$source
=
strtr
(
$file
[
'source'
],
'/\\'
,
DIRECTORY_SEPARATOR
);
$target
=
strtr
(
$file
[
'target'
],
'/\\'
,
DIRECTORY_SEPARATOR
);
$target
=
strtr
(
$file
[
'target'
],
'/\\'
,
DIRECTORY_SEPARATOR
);
$callback
=
isset
(
$file
[
'callback'
])
?
$file
[
'callback'
]
:
null
;
$callback
=
isset
(
$file
[
'callback'
])
?
$file
[
'callback'
]
:
null
;
$params
=
isset
(
$file
[
'params'
])
?
$file
[
'params'
]
:
null
;
$params
=
isset
(
$file
[
'params'
])
?
$file
[
'params'
]
:
null
;
if
(
is_dir
(
$source
))
{
if
(
is_dir
(
$source
))
{
if
(
!
is_dir
(
$target
))
{
if
(
!
is_dir
(
$target
))
{
mkdir
(
$target
,
0777
,
true
);
mkdir
(
$target
,
0777
,
true
);
}
}
continue
;
continue
;
}
}
if
(
$callback
!==
null
)
{
if
(
$callback
!==
null
)
{
$content
=
call_user_func
(
$callback
,
$source
,
$params
);
$content
=
call_user_func
(
$callback
,
$source
,
$params
);
}
}
else
{
else
{
$content
=
file_get_contents
(
$source
);
$content
=
file_get_contents
(
$source
);
}
}
if
(
is_file
(
$target
))
{
if
(
is_file
(
$target
))
{
if
(
$content
===
file_get_contents
(
$target
))
{
if
(
$content
===
file_get_contents
(
$target
))
{
echo
" unchanged
$name
\n
"
;
echo
" unchanged
$name
\n
"
;
continue
;
continue
;
}
}
if
(
$overwriteAll
)
{
if
(
$overwriteAll
)
{
echo
" overwrite
$name
\n
"
;
echo
" overwrite
$name
\n
"
;
}
}
else
{
else
{
echo
" exist
$name
\n
"
;
echo
" exist
$name
\n
"
;
echo
" ...overwrite? [Yes|No|All|Quit] "
;
echo
" ...overwrite? [Yes|No|All|Quit] "
;
$answer
=
trim
(
fgets
(
STDIN
));
$answer
=
trim
(
fgets
(
STDIN
));
if
(
!
strncasecmp
(
$answer
,
'q'
,
1
))
{
if
(
!
strncasecmp
(
$answer
,
'q'
,
1
))
{
return
;
return
;
}
}
elseif
(
!
strncasecmp
(
$answer
,
'y'
,
1
))
{
elseif
(
!
strncasecmp
(
$answer
,
'y'
,
1
))
{
echo
" overwrite
$name
\n
"
;
echo
" overwrite
$name
\n
"
;
}
}
elseif
(
!
strncasecmp
(
$answer
,
'a'
,
1
))
{
elseif
(
!
strncasecmp
(
$answer
,
'a'
,
1
))
{
echo
" overwrite
$name
\n
"
;
echo
" overwrite
$name
\n
"
;
$overwriteAll
=
true
;
$overwriteAll
=
true
;
}
}
else
{
else
{
echo
" skip
$name
\n
"
;
echo
" skip
$name
\n
"
;
continue
;
continue
;
}
}
...
@@ -296,15 +288,15 @@ class AppController extends Controller
...
@@ -296,15 +288,15 @@ class AppController extends Controller
* @param array $ignoreFiles list of the names of files that should
* @param array $ignoreFiles list of the names of files that should
* be ignored in list building process.
* be ignored in list building process.
* @param array $renameMap hash array of file names that should be
* @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})
* @return array the file list (see {@link copyFiles})
*/
*/
protected
function
buildFileList
(
$sourceDir
,
$targetDir
,
$baseDir
=
''
,
$ignoreFiles
=
array
(),
$renameMap
=
array
())
protected
function
buildFileList
(
$sourceDir
,
$targetDir
,
$baseDir
=
''
,
$ignoreFiles
=
array
(),
$renameMap
=
array
())
{
{
$list
=
array
();
$list
=
array
();
$handle
=
opendir
(
$sourceDir
);
$handle
=
opendir
(
$sourceDir
);
while
((
$file
=
readdir
(
$handle
))
!==
false
)
{
while
((
$file
=
readdir
(
$handle
))
!==
false
)
{
if
(
in_array
(
$file
,
array
(
'.'
,
'..'
,
'.svn'
,
'.gitignore'
,
'.hgignore'
))
||
in_array
(
$file
,
$ignoreFiles
))
{
if
(
in_array
(
$file
,
array
(
'.'
,
'..'
,
'.svn'
,
'.gitignore'
,
'.hgignore'
))
||
in_array
(
$file
,
$ignoreFiles
))
{
continue
;
continue
;
}
}
$sourcePath
=
$sourceDir
.
DIRECTORY_SEPARATOR
.
$file
;
$sourcePath
=
$sourceDir
.
DIRECTORY_SEPARATOR
.
$file
;
...
@@ -314,7 +306,7 @@ class AppController extends Controller
...
@@ -314,7 +306,7 @@ class AppController extends Controller
'source'
=>
$sourcePath
,
'source'
=>
$sourcePath
,
'target'
=>
$targetPath
,
'target'
=>
$targetPath
,
);
);
if
(
is_dir
(
$sourcePath
))
{
if
(
is_dir
(
$sourcePath
))
{
$list
=
array_merge
(
$list
,
self
::
buildFileList
(
$sourcePath
,
$targetPath
,
$name
,
$ignoreFiles
,
$renameMap
));
$list
=
array_merge
(
$list
,
self
::
buildFileList
(
$sourcePath
,
$targetPath
,
$name
,
$ignoreFiles
,
$renameMap
));
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
yii/console/controllers/CacheController.php
View file @
4686c7c3
...
@@ -34,11 +34,11 @@ class CacheController extends Controller
...
@@ -34,11 +34,11 @@ class CacheController extends Controller
{
{
/** @var $cache Cache */
/** @var $cache Cache */
$cache
=
\Yii
::
$app
->
getComponent
(
$component
);
$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.'
);
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.'
);
throw
new
Exception
(
'Unable to flush cache.'
);
}
}
...
...
This diff is collapsed.
Click to expand it.
yii/console/controllers/MessageController.php
View file @
4686c7c3
...
@@ -36,7 +36,7 @@ class MessageController extends Controller
...
@@ -36,7 +36,7 @@ class MessageController extends Controller
* - sourcePath: string, root directory of all source files.
* - sourcePath: string, root directory of all source files.
* - messagePath: string, root directory containing message translations.
* - messagePath: string, root directory containing message translations.
* - languages: array, list of language codes that the extracted messages
* - 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').
* - fileTypes: array, a list of file extensions (e.g. 'php', 'xml').
* Only the files whose extension name can be found in this list
* Only the files whose extension name can be found in this list
* will be processed. If empty, all files will be processed.
* will be processed. If empty, all files will be processed.
...
@@ -57,129 +57,139 @@ class MessageController extends Controller
...
@@ -57,129 +57,139 @@ class MessageController extends Controller
*/
*/
public
function
actionIndex
(
$config
)
public
function
actionIndex
(
$config
)
{
{
if
(
!
is_file
(
$config
))
if
(
!
is_file
(
$config
))
{
$this
->
usageError
(
"the configuration file
{
$config
}
does not exist."
);
$this
->
usageError
(
"the configuration file
{
$config
}
does not exist."
);
}
$config
=
require_once
(
$config
);
$config
=
require_once
(
$config
);
$translator
=
'Yii::t'
;
$translator
=
'Yii::t'
;
extract
(
$config
);
extract
(
$config
);
if
(
!
isset
(
$sourcePath
,
$messagePath
,
$languages
))
if
(
!
isset
(
$sourcePath
,
$messagePath
,
$languages
))
{
$this
->
usageError
(
'The configuration file must specify "sourcePath", "messagePath" and "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."
);
$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."
);
$this
->
usageError
(
"The message path
$messagePath
is not a valid directory."
);
if
(
empty
(
$languages
))
}
if
(
empty
(
$languages
))
{
$this
->
usageError
(
"Languages cannot be empty."
);
$this
->
usageError
(
"Languages cannot be empty."
);
}
if
(
!
isset
(
$overwrite
))
if
(
!
isset
(
$overwrite
))
{
$overwrite
=
false
;
$overwrite
=
false
;
}
if
(
!
isset
(
$removeOld
))
if
(
!
isset
(
$removeOld
))
{
$removeOld
=
false
;
$removeOld
=
false
;
}
if
(
!
isset
(
$sort
))
if
(
!
isset
(
$sort
))
{
$sort
=
false
;
$sort
=
false
;
}
$options
=
array
();
$options
=
array
();
if
(
isset
(
$fileTypes
))
if
(
isset
(
$fileTypes
))
{
$options
[
'fileTypes'
]
=
$fileTypes
;
$options
[
'fileTypes'
]
=
$fileTypes
;
if
(
isset
(
$exclude
))
}
$options
[
'exclude'
]
=
$exclude
;
if
(
isset
(
$exclude
))
{
$files
=
CFileHelper
::
findFiles
(
realpath
(
$sourcePath
),
$options
);
$options
[
'exclude'
]
=
$exclude
;
}
$files
=
CFileHelper
::
findFiles
(
realpath
(
$sourcePath
),
$options
);
$messages
=
array
();
$messages
=
array
();
foreach
(
$files
as
$file
)
foreach
(
$files
as
$file
)
{
$messages
=
array_merge_recursive
(
$messages
,
$this
->
extractMessages
(
$file
,
$translator
));
$messages
=
array_merge_recursive
(
$messages
,
$this
->
extractMessages
(
$file
,
$translator
));
}
foreach
(
$languages
as
$language
)
foreach
(
$languages
as
$language
)
{
{
$dir
=
$messagePath
.
DIRECTORY_SEPARATOR
.
$language
;
$dir
=
$messagePath
.
DIRECTORY_SEPARATOR
.
$language
;
if
(
!
is_dir
(
$dir
))
{
if
(
!
is_dir
(
$dir
))
@
mkdir
(
$dir
);
@
mkdir
(
$dir
);
foreach
(
$messages
as
$category
=>
$msgs
)
}
{
foreach
(
$messages
as
$category
=>
$msgs
)
{
$msgs
=
array_values
(
array_unique
(
$msgs
));
$msgs
=
array_values
(
array_unique
(
$msgs
));
$this
->
generateMessageFile
(
$msgs
,
$dir
.
DIRECTORY_SEPARATOR
.
$category
.
'.php'
,
$overwrite
,
$removeOld
,
$sort
);
$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
"
;
echo
"Extracting messages from
$fileName
...
\n
"
;
$subject
=
file_get_contents
(
$fileName
);
$subject
=
file_get_contents
(
$fileName
);
$n
=
preg_match_all
(
'/\b'
.
$translator
.
'\s*\(\s*(\'.*?(?<!\\\\)\'|".*?(?<!\\\\)")\s*,\s*(\'.*?(?<!\\\\)\'|".*?(?<!\\\\)")\s*[,\)]/s'
,
$subject
,
$matches
,
PREG_SET_ORDER
);
$n
=
preg_match_all
(
$messages
=
array
();
'/\b'
.
$translator
.
'\s*\(\s*(\'.*?(?<!\\\\)\'|".*?(?<!\\\\)")\s*,\s*(\'.*?(?<!\\\\)\'|".*?(?<!\\\\)")\s*[,\)]/s'
,
for
(
$i
=
0
;
$i
<
$n
;
++
$i
)
$subject
,
$matches
,
PREG_SET_ORDER
);
{
$messages
=
array
();
if
((
$pos
=
strpos
(
$matches
[
$i
][
1
],
'.'
))
!==
false
)
for
(
$i
=
0
;
$i
<
$n
;
++
$i
)
{
$category
=
substr
(
$matches
[
$i
][
1
],
$pos
+
1
,
-
1
);
if
((
$pos
=
strpos
(
$matches
[
$i
][
1
],
'.'
))
!==
false
)
{
else
$category
=
substr
(
$matches
[
$i
][
1
],
$pos
+
1
,
-
1
);
$category
=
substr
(
$matches
[
$i
][
1
],
1
,
-
1
);
}
else
{
$message
=
$matches
[
$i
][
2
];
$category
=
substr
(
$matches
[
$i
][
1
],
1
,
-
1
);
$messages
[
$category
][]
=
eval
(
"return
$message
;"
);
// use eval to eliminate quote escape
}
$message
=
$matches
[
$i
][
2
];
$messages
[
$category
][]
=
eval
(
"return
$message
;"
);
// use eval to eliminate quote escape
}
}
return
$messages
;
return
$messages
;
}
}
protected
function
generateMessageFile
(
$messages
,
$fileName
,
$overwrite
,
$removeOld
,
$sort
)
protected
function
generateMessageFile
(
$messages
,
$fileName
,
$overwrite
,
$removeOld
,
$sort
)
{
{
echo
"Saving messages to
$fileName
..."
;
echo
"Saving messages to
$fileName
..."
;
if
(
is_file
(
$fileName
))
if
(
is_file
(
$fileName
))
{
{
$translated
=
require
(
$fileName
);
$translated
=
require
(
$fileName
);
sort
(
$messages
);
sort
(
$messages
);
ksort
(
$translated
);
ksort
(
$translated
);
if
(
array_keys
(
$translated
)
==
$messages
)
if
(
array_keys
(
$translated
)
==
$messages
)
{
{
echo
"nothing new...skipped.
\n
"
;
echo
"nothing new...skipped.
\n
"
;
return
;
return
;
}
}
$merged
=
array
();
$merged
=
array
();
$untranslated
=
array
();
$untranslated
=
array
();
foreach
(
$messages
as
$message
)
foreach
(
$messages
as
$message
)
{
{
if
(
!
empty
(
$translated
[
$message
]))
{
if
(
!
empty
(
$translated
[
$message
]))
$merged
[
$message
]
=
$translated
[
$message
];
$merged
[
$message
]
=
$translated
[
$message
];
}
else
{
else
$untranslated
[]
=
$message
;
$untranslated
[]
=
$message
;
}
}
}
ksort
(
$merged
);
ksort
(
$merged
);
sort
(
$untranslated
);
sort
(
$untranslated
);
$todo
=
array
();
$todo
=
array
();
foreach
(
$untranslated
as
$message
)
foreach
(
$untranslated
as
$message
)
{
$todo
[
$message
]
=
''
;
$todo
[
$message
]
=
''
;
}
ksort
(
$translated
);
ksort
(
$translated
);
foreach
(
$translated
as
$message
=>
$translation
)
foreach
(
$translated
as
$message
=>
$translation
)
{
{
if
(
!
isset
(
$merged
[
$message
])
&&
!
isset
(
$todo
[
$message
])
&&
!
$removeOld
)
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
;
$todo
[
$message
]
=
$translation
;
else
}
else
{
$todo
[
$message
]
=
'@@'
.
$translation
.
'@@'
;
$todo
[
$message
]
=
'@@'
.
$translation
.
'@@'
;
}
}
}
}
}
$merged
=
array_merge
(
$todo
,
$merged
);
$merged
=
array_merge
(
$todo
,
$merged
);
if
(
$sort
)
if
(
$sort
)
{
ksort
(
$merged
);
ksort
(
$merged
);
if
(
$overwrite
===
false
)
}
$fileName
.=
'.merged'
;
if
(
false
===
$overwrite
)
{
$fileName
.=
'.merged'
;
}
echo
"translation merged.
\n
"
;
echo
"translation merged.
\n
"
;
}
}
else
{
else
$merged
=
array
();
{
foreach
(
$messages
as
$message
)
{
$merged
=
array
();
$merged
[
$message
]
=
''
;
foreach
(
$messages
as
$message
)
}
$merged
[
$message
]
=
''
;
ksort
(
$merged
);
ksort
(
$merged
);
echo
"saved.
\n
"
;
echo
"saved.
\n
"
;
}
}
$array
=
str_replace
(
"
\r
"
,
''
,
var_export
(
$merged
,
true
));
$array
=
str_replace
(
"
\r
"
,
''
,
var_export
(
$merged
,
true
));
$content
=
<<<
EOD
$content
=
<<<EOD
<?php
<?php
/**
/**
* Message translations.
* Message translations.
...
...
This diff is collapsed.
Click to expand it.
yii/db/ActiveRecord.php
View file @
4686c7c3
...
@@ -169,7 +169,7 @@ class ActiveRecord extends Model
...
@@ -169,7 +169,7 @@ class ActiveRecord extends Model
* @param array $attributes attribute values (name-value pairs) to be saved into the table
* @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.
* @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.
* 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
* @return integer the number of rows updated
*/
*/
public
static
function
updateAll
(
$attributes
,
$condition
=
''
,
$params
=
array
())
public
static
function
updateAll
(
$attributes
,
$condition
=
''
,
$params
=
array
())
...
@@ -191,7 +191,7 @@ class ActiveRecord extends Model
...
@@ -191,7 +191,7 @@ class ActiveRecord extends Model
* Use negative values if you want to decrement the counters.
* 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.
* @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.
* 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.
* Do not name the parameters as `:bp0`, `:bp1`, etc., because they are used internally by this method.
* @return integer the number of rows updated
* @return integer the number of rows updated
*/
*/
...
@@ -219,7 +219,7 @@ class ActiveRecord extends Model
...
@@ -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.
* @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.
* 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
* @return integer the number of rows deleted
*/
*/
public
static
function
deleteAll
(
$condition
=
''
,
$params
=
array
())
public
static
function
deleteAll
(
$condition
=
''
,
$params
=
array
())
...
@@ -1014,7 +1014,7 @@ class ActiveRecord extends Model
...
@@ -1014,7 +1014,7 @@ class ActiveRecord extends Model
* @param boolean $asArray whether to return the primary key value as an array. If true,
* @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.
* 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.
* 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
* is composite or `$asArray` is true. A string is returned otherwise (null will be returned if
* the key value is null).
* the key value is null).
*/
*/
...
@@ -1040,7 +1040,7 @@ class ActiveRecord extends Model
...
@@ -1040,7 +1040,7 @@ class ActiveRecord extends Model
* @param boolean $asArray whether to return the primary key value as an array. If true,
* @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.
* 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.
* 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
* is composite or `$asArray` is true. A string is returned otherwise (null will be returned if
* the key value is null).
* the key value is null).
*/
*/
...
...
This diff is collapsed.
Click to expand it.
yii/db/Command.php
View file @
4686c7c3
...
@@ -69,7 +69,7 @@ class Command extends \yii\base\Component
...
@@ -69,7 +69,7 @@ class Command extends \yii\base\Component
*/
*/
private
$_sql
;
private
$_sql
;
/**
/**
* @var array the parameter log information (name
=>
value)
* @var array the parameter log information (name
=>
value)
*/
*/
private
$_params
=
array
();
private
$_params
=
array
();
...
@@ -220,9 +220,9 @@ class Command extends \yii\base\Component
...
@@ -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.
* 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
* @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,
* 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)`,
* 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
* @return Command the current command being executed
*/
*/
public
function
bindValues
(
$values
)
public
function
bindValues
(
$values
)
...
@@ -465,7 +465,7 @@ class Command extends \yii\base\Component
...
@@ -465,7 +465,7 @@ class Command extends \yii\base\Component
* Note that the created command is not executed until [[execute()]] is called.
* 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 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
* @return Command the command object itself
*/
*/
public
function
insert
(
$table
,
$columns
)
public
function
insert
(
$table
,
$columns
)
...
@@ -515,7 +515,7 @@ class Command extends \yii\base\Component
...
@@ -515,7 +515,7 @@ class Command extends \yii\base\Component
* Note that the created command is not executed until [[execute()]] is called.
* Note that the created command is not executed until [[execute()]] is called.
*
*
* @param string $table the table 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 condition that will be put in the WHERE part. Please
* @param mixed $condition the condition that will be put in the WHERE part. Please
* refer to [[Query::where()]] on how to specify condition.
* refer to [[Query::where()]] on how to specify condition.
* @param array $params the parameters to be bound to the command
* @param array $params the parameters to be bound to the command
...
@@ -555,7 +555,7 @@ class Command extends \yii\base\Component
...
@@ -555,7 +555,7 @@ class Command extends \yii\base\Component
/**
/**
* Creates a SQL command for creating a new DB table.
* 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
* 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.
* stands for the column type which can contain an abstract DB type.
* The method [[QueryBuilder::getColumnType()]] will be called
* The method [[QueryBuilder::getColumnType()]] will be called
...
@@ -566,7 +566,7 @@ class Command extends \yii\base\Component
...
@@ -566,7 +566,7 @@ class Command extends \yii\base\Component
* inserted into the generated SQL.
* 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 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.
* @param string $options additional SQL fragment that will be appended to the generated SQL.
* @return Command the command object itself
* @return Command the command object itself
*/
*/
...
...
This diff is collapsed.
Click to expand it.
yii/db/Connection.php
View file @
4686c7c3
...
@@ -121,7 +121,7 @@ class Connection extends Component
...
@@ -121,7 +121,7 @@ class Connection extends Component
*/
*/
public
$password
=
''
;
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
* to establish a DB connection. Please refer to the
* [PHP manual](http://www.php.net/manual/en/function.PDO-setAttribute.php) for
* [PHP manual](http://www.php.net/manual/en/function.PDO-setAttribute.php) for
* details about available attributes.
* details about available attributes.
...
...
This diff is collapsed.
Click to expand it.
yii/db/DataReader.php
View file @
4686c7c3
...
@@ -24,7 +24,7 @@ use yii\base\InvalidCallException;
...
@@ -24,7 +24,7 @@ use yii\base\InvalidCallException;
* }
* }
*
*
* // equivalent to:
* // equivalent to:
* foreach($reader as $row) {
* foreach
($reader as $row) {
* $rows[] = $row;
* $rows[] = $row;
* }
* }
*
*
...
...
This diff is collapsed.
Click to expand it.
yii/db/Migration.php
View file @
4686c7c3
...
@@ -132,7 +132,8 @@ class Migration extends \yii\base\Component
...
@@ -132,7 +132,8 @@ class Migration extends \yii\base\Component
* Executes a SQL statement.
* Executes a SQL statement.
* This method executes the specified SQL statement using [[db]].
* This method executes the specified SQL statement using [[db]].
* @param string $sql the SQL statement to be executed
* @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
())
public
function
execute
(
$sql
,
$params
=
array
())
{
{
...
@@ -146,7 +147,7 @@ class Migration extends \yii\base\Component
...
@@ -146,7 +147,7 @@ class Migration extends \yii\base\Component
* Creates and executes an INSERT SQL statement.
* Creates and executes an INSERT SQL statement.
* The method will properly escape the column names, and bind the values to be inserted.
* 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 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
)
public
function
insert
(
$table
,
$columns
)
{
{
...
@@ -160,7 +161,7 @@ class Migration extends \yii\base\Component
...
@@ -160,7 +161,7 @@ class Migration extends \yii\base\Component
* Creates and executes an UPDATE SQL statement.
* Creates and executes an UPDATE SQL statement.
* The method will properly escape the column names and bind the values to be updated.
* The method will properly escape the column names and bind the values to be updated.
* @param string $table the table 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
* @param mixed $condition the conditions that will be put in the WHERE part. Please
* refer to [[Query::where()]] on how to specify conditions.
* refer to [[Query::where()]] on how to specify conditions.
* @param array $params the parameters to be bound to the query.
* @param array $params the parameters to be bound to the query.
...
@@ -191,7 +192,7 @@ class Migration extends \yii\base\Component
...
@@ -191,7 +192,7 @@ class Migration extends \yii\base\Component
/**
/**
* Builds and executes a SQL statement for creating a new DB table.
* 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
* 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.
* stands for the column type which can contain an abstract DB type.
*
*
...
@@ -201,7 +202,7 @@ class Migration extends \yii\base\Component
...
@@ -201,7 +202,7 @@ class Migration extends \yii\base\Component
* put into the generated SQL.
* 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 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.
* @param string $options additional SQL fragment that will be appended to the generated SQL.
*/
*/
public
function
createTable
(
$table
,
$columns
,
$options
=
null
)
public
function
createTable
(
$table
,
$columns
,
$options
=
null
)
...
...
This diff is collapsed.
Click to expand it.
yii/db/Query.php
View file @
4686c7c3
...
@@ -124,7 +124,7 @@ class Query extends \yii\base\Component
...
@@ -124,7 +124,7 @@ class Query extends \yii\base\Component
public
$union
;
public
$union
;
/**
/**
* @var array list of query parameter values indexed by parameter placeholders.
* @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
;
public
$params
;
...
@@ -210,9 +210,9 @@ class Query extends \yii\base\Component
...
@@ -210,9 +210,9 @@ class Query extends \yii\base\Component
* an `IN` expression will be generated. And if a value is null, `IS NULL` will be used
* an `IN` expression will be generated. And if a value is null, `IS NULL` will be used
* in the generated expression. Below are some examples:
* in the generated expression. Below are some examples:
*
*
* - `array('type'
=>1, 'status'=>2)` generates `(type=1) AND (status=
2)`.
* - `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('id'
=> array(1, 2, 3), 'status' => 2)` generates `(id IN (1, 2, 3)) AND (status =
2)`.
* - `array('status'
=>
null) generates `status IS NULL`.
* - `array('status'
=>
null) generates `status IS NULL`.
*
*
* A condition in operator format generates the SQL expression according to the specified operator, which
* A condition in operator format generates the SQL expression according to the specified operator, which
* can be one of the followings:
* can be one of the followings:
...
@@ -234,7 +234,7 @@ class Query extends \yii\base\Component
...
@@ -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
* - `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,
* 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.
* 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.
* - `not in`: similar to the `in` operator except that `IN` is replaced with `NOT IN` in the generated condition.
...
@@ -257,7 +257,7 @@ class Query extends \yii\base\Component
...
@@ -257,7 +257,7 @@ class Query extends \yii\base\Component
* the `NOT LIKE` predicates.
* the `NOT LIKE` predicates.
*
*
* @param string|array $condition the conditions that should be put in the WHERE part.
* @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
* @return Query the query object itself
* @see andWhere()
* @see andWhere()
* @see orWhere()
* @see orWhere()
...
@@ -274,7 +274,7 @@ class Query extends \yii\base\Component
...
@@ -274,7 +274,7 @@ class Query extends \yii\base\Component
* The new condition and the existing one will be joined using the 'AND' operator.
* 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()]]
* @param string|array $condition the new WHERE condition. Please refer to [[where()]]
* on how to specify this parameter.
* 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
* @return Query the query object itself
* @see where()
* @see where()
* @see orWhere()
* @see orWhere()
...
@@ -295,7 +295,7 @@ class Query extends \yii\base\Component
...
@@ -295,7 +295,7 @@ class Query extends \yii\base\Component
* The new condition and the existing one will be joined using the 'OR' operator.
* 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()]]
* @param string|array $condition the new WHERE condition. Please refer to [[where()]]
* on how to specify this parameter.
* 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
* @return Query the query object itself
* @see where()
* @see where()
* @see andWhere()
* @see andWhere()
...
@@ -321,7 +321,7 @@ class Query extends \yii\base\Component
...
@@ -321,7 +321,7 @@ class Query extends \yii\base\Component
* (which means the table is given as a sub-query or DB expression).
* (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.
* @param string|array $on the join condition that should appear in the ON part.
* Please refer to [[where()]] on how to specify this parameter.
* 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
* @return Query the query object itself
*/
*/
public
function
join
(
$type
,
$table
,
$on
=
''
,
$params
=
array
())
public
function
join
(
$type
,
$table
,
$on
=
''
,
$params
=
array
())
...
@@ -338,7 +338,7 @@ class Query extends \yii\base\Component
...
@@ -338,7 +338,7 @@ class Query extends \yii\base\Component
* (which means the table is given as a sub-query or DB expression).
* (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.
* @param string|array $on the join condition that should appear in the ON part.
* Please refer to [[where()]] on how to specify this parameter.
* 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
* @return Query the query object itself
*/
*/
public
function
innerJoin
(
$table
,
$on
=
''
,
$params
=
array
())
public
function
innerJoin
(
$table
,
$on
=
''
,
$params
=
array
())
...
@@ -355,7 +355,7 @@ class Query extends \yii\base\Component
...
@@ -355,7 +355,7 @@ class Query extends \yii\base\Component
* (which means the table is given as a sub-query or DB expression).
* (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.
* @param string|array $on the join condition that should appear in the ON part.
* Please refer to [[where()]] on how to specify this parameter.
* 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
* @return Query the query object itself
*/
*/
public
function
leftJoin
(
$table
,
$on
=
''
,
$params
=
array
())
public
function
leftJoin
(
$table
,
$on
=
''
,
$params
=
array
())
...
@@ -372,7 +372,7 @@ class Query extends \yii\base\Component
...
@@ -372,7 +372,7 @@ class Query extends \yii\base\Component
* (which means the table is given as a sub-query or DB expression).
* (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.
* @param string|array $on the join condition that should appear in the ON part.
* Please refer to [[where()]] on how to specify this parameter.
* 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
* @return Query the query object itself
*/
*/
public
function
rightJoin
(
$table
,
$on
=
''
,
$params
=
array
())
public
function
rightJoin
(
$table
,
$on
=
''
,
$params
=
array
())
...
@@ -425,7 +425,7 @@ class Query extends \yii\base\Component
...
@@ -425,7 +425,7 @@ class Query extends \yii\base\Component
* Sets the HAVING part of the query.
* Sets the HAVING part of the query.
* @param string|array $condition the conditions to be put after HAVING.
* @param string|array $condition the conditions to be put after HAVING.
* Please refer to [[where()]] on how to specify this parameter.
* 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
* @return Query the query object itself
* @see andHaving()
* @see andHaving()
* @see orHaving()
* @see orHaving()
...
@@ -442,7 +442,7 @@ class Query extends \yii\base\Component
...
@@ -442,7 +442,7 @@ class Query extends \yii\base\Component
* The new condition and the existing one will be joined using the 'AND' operator.
* 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()]]
* @param string|array $condition the new HAVING condition. Please refer to [[where()]]
* on how to specify this parameter.
* 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
* @return Query the query object itself
* @see having()
* @see having()
* @see orHaving()
* @see orHaving()
...
@@ -463,7 +463,7 @@ class Query extends \yii\base\Component
...
@@ -463,7 +463,7 @@ class Query extends \yii\base\Component
* The new condition and the existing one will be joined using the 'OR' operator.
* 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()]]
* @param string|array $condition the new HAVING condition. Please refer to [[where()]]
* on how to specify this parameter.
* 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
* @return Query the query object itself
* @see having()
* @see having()
* @see andHaving()
* @see andHaving()
...
@@ -570,7 +570,7 @@ class Query extends \yii\base\Component
...
@@ -570,7 +570,7 @@ class Query extends \yii\base\Component
/**
/**
* Sets the parameters to be bound to the query.
* Sets the parameters to be bound to the query.
* @param array $params list of query parameter values indexed by parameter placeholders.
* @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
* @return Query the query object itself
* @see addParams()
* @see addParams()
*/
*/
...
@@ -583,7 +583,7 @@ class Query extends \yii\base\Component
...
@@ -583,7 +583,7 @@ class Query extends \yii\base\Component
/**
/**
* Adds additional parameters to be bound to the query.
* Adds additional parameters to be bound to the query.
* @param array $params list of query parameter values indexed by parameter placeholders.
* @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
* @return Query the query object itself
* @see params()
* @see params()
*/
*/
...
...
This diff is collapsed.
Click to expand it.
yii/db/QueryBuilder.php
View file @
4686c7c3
...
@@ -88,7 +88,7 @@ class QueryBuilder extends \yii\base\Object
...
@@ -88,7 +88,7 @@ class QueryBuilder extends \yii\base\Object
* The method will properly escape the table and column names.
* The method will properly escape the table and column names.
*
*
* @param string $table the table that new rows will be inserted into.
* @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.
* @param array $params the binding parameters that will be generated by this method.
* They should be bound to the DB command later.
* They should be bound to the DB command later.
* @return string the INSERT SQL
* @return string the INSERT SQL
...
@@ -156,7 +156,7 @@ class QueryBuilder extends \yii\base\Object
...
@@ -156,7 +156,7 @@ class QueryBuilder extends \yii\base\Object
* The method will properly escape the table and column names.
* The method will properly escape the table and column names.
*
*
* @param string $table the table 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 condition that will be put in the WHERE part. Please
* @param mixed $condition the condition that will be put in the WHERE part. Please
* refer to [[Query::where()]] on how to specify condition.
* refer to [[Query::where()]] on how to specify condition.
* @param array $params the binding parameters that will be modified by this method
* @param array $params the binding parameters that will be modified by this method
...
@@ -211,7 +211,7 @@ class QueryBuilder extends \yii\base\Object
...
@@ -211,7 +211,7 @@ class QueryBuilder extends \yii\base\Object
/**
/**
* Builds a SQL statement for creating a new DB table.
* 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
* 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.
* 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.
* 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
...
@@ -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 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.
* @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.
* @return string the SQL statement for creating a new DB table.
*/
*/
...
@@ -734,7 +734,7 @@ class QueryBuilder extends \yii\base\Object
...
@@ -734,7 +734,7 @@ class QueryBuilder extends \yii\base\Object
}
else
{
}
else
{
throw
new
Exception
(
'Found unknown operator in query: '
.
$operator
);
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
);
return
$this
->
buildHashCondition
(
$condition
,
$params
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
yii/helpers/base/ArrayHelper.php
View file @
4686c7c3
...
@@ -93,11 +93,11 @@ class ArrayHelper
...
@@ -93,11 +93,11 @@ class ArrayHelper
* Usage examples,
* Usage examples,
*
*
* ~~~
* ~~~
* // $array = array('type'
=>'A', 'options'=>array(1,
2));
* // $array = array('type'
=> 'A', 'options' => array(1,
2));
* // working with array
* // working with array
* $type = \yii\helpers\ArrayHelper::remove($array, 'type');
* $type = \yii\helpers\ArrayHelper::remove($array, 'type');
* // $array content
* // $array content
* // $array = array('options'
=>array(1,
2));
* // $array = array('options'
=> array(1,
2));
* ~~~
* ~~~
*
*
* @param array $array the array to extract value from
* @param array $array the array to extract value from
...
...
This diff is collapsed.
Click to expand it.
yii/helpers/base/Markdown.php
View file @
4686c7c3
...
@@ -39,7 +39,7 @@ class Markdown
...
@@ -39,7 +39,7 @@ class Markdown
public
static
function
process
(
$content
,
$config
=
array
())
public
static
function
process
(
$content
,
$config
=
array
())
{
{
if
(
static
::
$markdown
===
null
)
{
if
(
static
::
$markdown
===
null
)
{
static
::
$markdown
=
new
MarkdownExtra
();
static
::
$markdown
=
new
MarkdownExtra
();
}
}
foreach
(
$config
as
$name
=>
$value
)
{
foreach
(
$config
as
$name
=>
$value
)
{
...
...
This diff is collapsed.
Click to expand it.
yii/i18n/GettextMoFile.php
View file @
4686c7c3
...
@@ -109,7 +109,7 @@ class GettextMoFile extends GettextFile
...
@@ -109,7 +109,7 @@ class GettextMoFile extends GettextFile
if
((
$context
&&
$separatorPosition
!==
false
&&
substr
(
$id
,
0
,
$separatorPosition
)
===
$context
)
||
if
((
$context
&&
$separatorPosition
!==
false
&&
substr
(
$id
,
0
,
$separatorPosition
)
===
$context
)
||
(
!
$context
&&
$separatorPosition
===
false
))
{
(
!
$context
&&
$separatorPosition
===
false
))
{
if
(
$separatorPosition
!==
false
)
{
if
(
$separatorPosition
!==
false
)
{
$id
=
substr
(
$id
,
$separatorPosition
+
1
);
$id
=
substr
(
$id
,
$separatorPosition
+
1
);
}
}
$message
=
$this
->
readString
(
$fileHandle
,
$targetLengths
[
$i
],
$targetOffsets
[
$i
]);
$message
=
$this
->
readString
(
$fileHandle
,
$targetLengths
[
$i
],
$targetOffsets
[
$i
]);
...
...
This diff is collapsed.
Click to expand it.
yii/i18n/I18N.php
View file @
4686c7c3
...
@@ -87,7 +87,7 @@ class I18N extends Component
...
@@ -87,7 +87,7 @@ class I18N extends Component
$language
=
Yii
::
$app
->
language
;
$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
))
{
if
(
strpos
(
$message
,
'|'
)
!==
false
&&
preg_match
(
'/^([\w\-\\/\.\\\\]+)\|(.*)/'
,
$message
,
$matches
))
{
$category
=
$matches
[
1
];
$category
=
$matches
[
1
];
$message
=
$matches
[
2
];
$message
=
$matches
[
2
];
...
...
This diff is collapsed.
Click to expand it.
yii/logging/FileTarget.php
View file @
4686c7c3
...
@@ -81,12 +81,12 @@ class FileTarget extends Target
...
@@ -81,12 +81,12 @@ class FileTarget extends Target
@
flock
(
$fp
,
LOCK_EX
);
@
flock
(
$fp
,
LOCK_EX
);
if
(
@
filesize
(
$this
->
logFile
)
>
$this
->
maxFileSize
*
1024
)
{
if
(
@
filesize
(
$this
->
logFile
)
>
$this
->
maxFileSize
*
1024
)
{
$this
->
rotateFiles
();
$this
->
rotateFiles
();
@
flock
(
$fp
,
LOCK_UN
);
@
flock
(
$fp
,
LOCK_UN
);
@
fclose
(
$fp
);
@
fclose
(
$fp
);
@
file_put_contents
(
$this
->
logFile
,
$text
,
FILE_APPEND
|
LOCK_EX
);
@
file_put_contents
(
$this
->
logFile
,
$text
,
FILE_APPEND
|
LOCK_EX
);
}
else
{
}
else
{
@
fwrite
(
$fp
,
$text
);
@
fwrite
(
$fp
,
$text
);
@
flock
(
$fp
,
LOCK_UN
);
@
flock
(
$fp
,
LOCK_UN
);
@
fclose
(
$fp
);
@
fclose
(
$fp
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
yii/logging/ProfileTarget.php
View file @
4686c7c3
...
@@ -166,7 +166,7 @@ class CProfileLogRoute extends CWebLogRoute
...
@@ -166,7 +166,7 @@ class CProfileLogRoute extends CWebLogRoute
}
}
$entries
=
array_values
(
$results
);
$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
);
usort
(
$entries
,
$func
);
$this
->
render
(
'profile-summary'
,
$entries
);
$this
->
render
(
'profile-summary'
,
$entries
);
...
...
This diff is collapsed.
Click to expand it.
yii/rbac/Manager.php
View file @
4686c7c3
...
@@ -33,9 +33,9 @@ use yii\base\InvalidParamException;
...
@@ -33,9 +33,9 @@ use yii\base\InvalidParamException;
* at appropriate places in the application code to check if the current user
* at appropriate places in the application code to check if the current user
* has the needed permission for an operation.
* has the needed permission for an operation.
*
*
* @property array $roles Roles (name
=>
Item).
* @property array $roles Roles (name
=>
Item).
* @property array $tasks Tasks (name
=>
Item).
* @property array $tasks Tasks (name
=>
Item).
* @property array $operations Operations (name
=>
Item).
* @property array $operations Operations (name
=>
Item).
*
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Alexander Kochetov <creocoder@gmail.com>
* @author Alexander Kochetov <creocoder@gmail.com>
...
@@ -107,7 +107,7 @@ abstract class Manager extends Component
...
@@ -107,7 +107,7 @@ abstract class Manager extends Component
* This is a shortcut method to [[Manager::getItems()]].
* 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
* @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.
* will be returned. Otherwise, all roles will be returned.
* @return Item[] roles (name
=>
AuthItem)
* @return Item[] roles (name
=>
AuthItem)
*/
*/
public
function
getRoles
(
$userId
=
null
)
public
function
getRoles
(
$userId
=
null
)
{
{
...
@@ -119,7 +119,7 @@ abstract class Manager extends Component
...
@@ -119,7 +119,7 @@ abstract class Manager extends Component
* This is a shortcut method to [[Manager::getItems()]].
* 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
* @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.
* will be returned. Otherwise, all tasks will be returned.
* @return Item[] tasks (name
=>
AuthItem)
* @return Item[] tasks (name
=>
AuthItem)
*/
*/
public
function
getTasks
(
$userId
=
null
)
public
function
getTasks
(
$userId
=
null
)
{
{
...
@@ -131,7 +131,7 @@ abstract class Manager extends Component
...
@@ -131,7 +131,7 @@ abstract class Manager extends Component
* This is a shortcut method to [[Manager::getItems()]].
* 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
* @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.
* will be returned. Otherwise, all operations will be returned.
* @return Item[] operations (name
=>
AuthItem)
* @return Item[] operations (name
=>
AuthItem)
*/
*/
public
function
getOperations
(
$userId
=
null
)
public
function
getOperations
(
$userId
=
null
)
{
{
...
...
This diff is collapsed.
Click to expand it.
yii/renderers/SmartyViewRenderer.php
View file @
4686c7c3
...
@@ -63,7 +63,7 @@ class SmartyViewRenderer extends ViewRenderer
...
@@ -63,7 +63,7 @@ class SmartyViewRenderer extends ViewRenderer
*/
*/
public
function
smarty_function_path
(
$params
,
\Smarty_Internal_Template
$template
)
public
function
smarty_function_path
(
$params
,
\Smarty_Internal_Template
$template
)
{
{
if
(
!
isset
(
$params
[
'route'
]))
{
if
(
!
isset
(
$params
[
'route'
]))
{
trigger_error
(
"path: missing 'route' parameter"
);
trigger_error
(
"path: missing 'route' parameter"
);
}
}
...
...
This diff is collapsed.
Click to expand it.
yii/test/TestCase.php
View file @
4686c7c3
...
@@ -10,9 +10,9 @@
...
@@ -10,9 +10,9 @@
namespace
yii\test
;
namespace
yii\test
;
require_once
(
'PHPUnit/Runner/Version.php'
);
require_once
(
'PHPUnit/Runner/Version.php'
);
spl_autoload_unregister
(
array
(
'Yii'
,
'autoload'
));
spl_autoload_unregister
(
array
(
'Yii'
,
'autoload'
));
require_once
(
'PHPUnit/Autoload.php'
);
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.
* TestCase is the base class for all test case classes.
...
...
This diff is collapsed.
Click to expand it.
yii/views/exception.php
View file @
4686c7c3
...
@@ -191,16 +191,15 @@ $title = $context->htmlEncode($exception instanceof \yii\base\Exception ? $excep
...
@@ -191,16 +191,15 @@ $title = $context->htmlEncode($exception instanceof \yii\base\Exception ? $excep
var traceReg = new RegExp("
(
^|
\
\s
)
trace
-
file
(
\
\s
|
$
)
");
var traceReg = new RegExp("
(
^|
\
\s
)
trace
-
file
(
\
\s
|
$
)
");
var collapsedReg = new RegExp("
(
^|
\
\s
)
collapsed
(
\
\s
|
$
)
");
var collapsedReg = new RegExp("
(
^|
\
\s
)
collapsed
(
\
\s
|
$
)
");
var e = document.getElementsByTagName(
"
div
"
);
var e = document.getElementsByTagName(
'div'
);
for
(var j=0,len=e.length;j<len;j++)
{
for
(var j = 0, len = e.length; j < len; j++)
{
if
(traceReg.test(e[j].className))
{
if
(traceReg.test(e[j].className))
{
e[j].onclick = function(){
e[j].onclick = function()
{
var trace = this.parentNode.parentNode;
var trace = this.parentNode.parentNode;
if(collapsedReg.test(trace.className)){
if (collapsedReg.test(trace.className)) {
trace.className = trace.className.replace("
collapsed
", "
expanded
");
trace.className = trace.className.replace('collapsed', 'expanded');
}
} else {
else{
trace.className = trace.className.replace('expanded', 'collapsed');
trace.className = trace.className.replace("
expanded
", "
collapsed
");
}
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
yii/web/Pagination.php
View file @
4686c7c3
...
@@ -42,7 +42,7 @@ use Yii;
...
@@ -42,7 +42,7 @@ use Yii;
* View:
* View:
*
*
* ~~~
* ~~~
* foreach($models as $model) {
* foreach
($models as $model) {
* // display $model here
* // display $model here
* }
* }
*
*
...
@@ -80,7 +80,7 @@ class Pagination extends \yii\base\Object
...
@@ -80,7 +80,7 @@ class Pagination extends \yii\base\Object
*/
*/
public
$route
;
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.
* 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.
* The array element indexed by [[pageVar]] is considered to be the current page number.
...
...
This diff is collapsed.
Click to expand it.
yii/web/Response.php
View file @
4686c7c3
...
@@ -98,10 +98,10 @@ class Response extends \yii\base\Response
...
@@ -98,10 +98,10 @@ class Response extends \yii\base\Response
* <b>Example</b>:
* <b>Example</b>:
* <pre>
* <pre>
* <?php
* <?php
* Yii::app()->request->xSendFile('/home/user/Pictures/picture1.jpg',array(
* Yii::app()->request->xSendFile('/home/user/Pictures/picture1.jpg',
array(
* 'saveName'
=>
'image1.jpg',
* 'saveName'
=>
'image1.jpg',
* 'mimeType'
=>
'image/jpeg',
* 'mimeType'
=>
'image/jpeg',
* 'terminate'
=>
false,
* 'terminate'
=>
false,
* ));
* ));
* ?>
* ?>
* </pre>
* </pre>
...
...
This diff is collapsed.
Click to expand it.
yii/web/Sort.php
View file @
4686c7c3
...
@@ -50,7 +50,7 @@ use yii\helpers\Html;
...
@@ -50,7 +50,7 @@ use yii\helpers\Html;
* // display links leading to sort actions
* // display links leading to sort actions
* echo $sort->link('name', 'Name') . ' | ' . $sort->link('age', 'Age');
* echo $sort->link('name', 'Name') . ' | ' . $sort->link('age', 'Age');
*
*
* foreach($models as $model) {
* foreach
($models as $model) {
* // display $model here
* // display $model here
* }
* }
* ~~~
* ~~~
...
...
This diff is collapsed.
Click to expand it.
yii/web/UrlRule.php
View file @
4686c7c3
...
@@ -36,7 +36,7 @@ class UrlRule extends Object
...
@@ -36,7 +36,7 @@ class UrlRule extends Object
*/
*/
public
$route
;
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
* When this rule is used to parse the incoming request, the values declared in this property
* will be injected into $_GET.
* will be injected into $_GET.
*/
*/
...
...
This diff is collapsed.
Click to expand it.
yii/widgets/ActiveField.php
View file @
4686c7c3
...
@@ -144,7 +144,7 @@ class ActiveField extends Component
...
@@ -144,7 +144,7 @@ class ActiveField extends Component
}
}
}
}
if
(
!
empty
(
$validators
))
{
if
(
!
empty
(
$validators
))
{
$options
[
'validate'
]
=
new
JsExpression
(
"function(attribute,
value,messages)
{"
.
implode
(
''
,
$validators
)
.
'}'
);
$options
[
'validate'
]
=
new
JsExpression
(
"function(attribute,
value, messages)
{"
.
implode
(
''
,
$validators
)
.
'}'
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
yii/widgets/ContentDecorator.php
View file @
4686c7c3
...
@@ -22,7 +22,7 @@ class ContentDecorator extends Widget
...
@@ -22,7 +22,7 @@ class ContentDecorator extends Widget
*/
*/
public
$viewFile
;
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
();
public
$params
=
array
();
...
...
This diff is collapsed.
Click to expand it.
yii/widgets/ListPager.php
View file @
4686c7c3
...
@@ -73,7 +73,7 @@ class ListPager extends Widget
...
@@ -73,7 +73,7 @@ class ListPager extends Widget
$selection
=
$this
->
pagination
->
createUrl
(
$currentPage
);
$selection
=
$this
->
pagination
->
createUrl
(
$currentPage
);
if
(
!
isset
(
$this
->
options
[
'onchange'
]))
{
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
);
echo
Html
::
dropDownList
(
null
,
$selection
,
$pages
,
$this
->
options
);
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment