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
409c508f
Commit
409c508f
authored
Mar 31, 2012
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
7a234327
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
85 additions
and
71 deletions
+85
-71
Dictionary.php
framework/base/Dictionary.php
+12
-39
Module.php
framework/base/Module.php
+0
-0
Vector.php
framework/base/Vector.php
+3
-3
Exception.php
framework/db/Exception.php
+0
-1
BaseQuery.php
framework/db/dao/BaseQuery.php
+0
-1
ColumnSchema.php
framework/db/dao/ColumnSchema.php
+0
-1
Command.php
framework/db/dao/Command.php
+0
-1
Connection.php
framework/db/dao/Connection.php
+0
-1
DataReader.php
framework/db/dao/DataReader.php
+0
-1
Driver.php
framework/db/dao/Driver.php
+0
-1
Expression.php
framework/db/dao/Expression.php
+0
-1
Query.php
framework/db/dao/Query.php
+0
-1
QueryBuilder.php
framework/db/dao/QueryBuilder.php
+1
-2
TableSchema.php
framework/db/dao/TableSchema.php
+0
-1
Transaction.php
framework/db/dao/Transaction.php
+0
-1
Driver.php
framework/db/dao/mysql/Driver.php
+0
-1
QueryBuilder.php
framework/db/dao/mysql/QueryBuilder.php
+0
-1
Driver.php
framework/db/dao/sqlite/Driver.php
+0
-1
QueryBuilder.php
framework/db/dao/sqlite/QueryBuilder.php
+0
-1
DbTarget.php
framework/logging/DbTarget.php
+0
-1
EmailTarget.php
framework/logging/EmailTarget.php
+0
-1
FileTarget.php
framework/logging/FileTarget.php
+0
-1
Logger.php
framework/logging/Logger.php
+0
-1
ProfileTarget.php
framework/logging/ProfileTarget.php
+0
-1
Router.php
framework/logging/Router.php
+0
-1
Target.php
framework/logging/Target.php
+0
-1
WebTarget.php
framework/logging/WebTarget.php
+0
-1
ArrayHelper.php
framework/util/ArrayHelper.php
+67
-0
File.php
framework/util/File.php
+2
-2
Text.php
framework/util/Text.php
+0
-2
No files found.
framework/base/Dictionary.php
View file @
409c508f
...
@@ -9,6 +9,8 @@
...
@@ -9,6 +9,8 @@
namespace
yii\base
;
namespace
yii\base
;
use
yii\util\ArrayHelper
;
/**
/**
* Dictionary implements a collection that stores key-value pairs.
* Dictionary implements a collection that stores key-value pairs.
*
*
...
@@ -203,17 +205,15 @@ class Dictionary extends Object implements \IteratorAggregate, \ArrayAccess, \Co
...
@@ -203,17 +205,15 @@ class Dictionary extends Object implements \IteratorAggregate, \ArrayAccess, \Co
*
*
* Existing elements in the dictionary will be overwritten if their keys are the same as those in the source.
* Existing elements in the dictionary will be overwritten if their keys are the same as those in the source.
* If the merge is recursive, the following algorithm is performed:
* If the merge is recursive, the following algorithm is performed:
* <ul>
* <li>the dictionary data is saved as $a, and the source data is saved as $b;</li>
* <li>if $a and $b both have an array indxed at the same string key, the arrays will be merged using this algorithm;</li>
* <li>any integer-indexed elements in $b will be appended to $a and reindxed accordingly;</li>
* <li>any string-indexed elements in $b will overwrite elements in $a with the same index;</li>
* </ul>
*
*
* @param mixed $data the data to be merged with, must be an array or object implementing Traversable
* - the dictionary data is saved as $a, and the source data is saved as $b;
* @param boolean $recursive whether the merging should be recursive.
* - if $a and $b both have an array indexed at the same string key, the arrays will be merged using this algorithm;
* - any integer-indexed elements in $b will be appended to $a;
* - any string-indexed elements in $b will overwrite elements in $a with the same index;
*
*
* @throws Exception If data is neither an array nor an iterator.
* @param array|\Traversable $data the data to be merged with. It must be an array or object implementing Traversable
* @param boolean $recursive whether the merging should be recursive.
* @throws Exception if data is neither an array nor an object implementing `Traversable`.
*/
*/
public
function
mergeWith
(
$data
,
$recursive
=
true
)
public
function
mergeWith
(
$data
,
$recursive
=
true
)
{
{
...
@@ -227,9 +227,9 @@ class Dictionary extends Object implements \IteratorAggregate, \ArrayAccess, \Co
...
@@ -227,9 +227,9 @@ class Dictionary extends Object implements \IteratorAggregate, \ArrayAccess, \Co
foreach
(
$data
as
$key
=>
$value
)
{
foreach
(
$data
as
$key
=>
$value
)
{
$d
[
$key
]
=
$value
;
$d
[
$key
]
=
$value
;
}
}
$this
->
_d
=
self
::
mergeArray
(
$this
->
_d
,
$d
);
$this
->
_d
=
ArrayHelper
::
merge
(
$this
->
_d
,
$d
);
}
else
{
}
else
{
$this
->
_d
=
self
::
mergeArray
(
$this
->
_d
,
$data
);
$this
->
_d
=
ArrayHelper
::
merge
(
$this
->
_d
,
$data
);
}
}
}
else
{
}
else
{
foreach
(
$data
as
$key
=>
$value
)
{
foreach
(
$data
as
$key
=>
$value
)
{
...
@@ -237,7 +237,7 @@ class Dictionary extends Object implements \IteratorAggregate, \ArrayAccess, \Co
...
@@ -237,7 +237,7 @@ class Dictionary extends Object implements \IteratorAggregate, \ArrayAccess, \Co
}
}
}
}
}
else
{
}
else
{
throw
new
Exception
(
'
Dictionary data
must be an array or an object implementing Traversable.'
);
throw
new
Exception
(
'
The data to be merged with
must be an array or an object implementing Traversable.'
);
}
}
}
}
...
@@ -293,31 +293,4 @@ class Dictionary extends Object implements \IteratorAggregate, \ArrayAccess, \Co
...
@@ -293,31 +293,4 @@ class Dictionary extends Object implements \IteratorAggregate, \ArrayAccess, \Co
{
{
$this
->
remove
(
$offset
);
$this
->
remove
(
$offset
);
}
}
/**
* Merges two arrays into one recursively.
* If each array has an element with the same string key value, the latter
* will overwrite the former (different from array_merge_recursive).
* Recursive merging will be conducted if both arrays have an element of array
* type and are having the same key.
* For integer-keyed elements, the elements from the latter array will
* be appended to the former array.
* @param array $a array to be merged to
* @param array $b array to be merged from
* @return array the merged array (the original arrays are not changed.)
* @see mergeWith
*/
public
static
function
mergeArray
(
$a
,
$b
)
{
foreach
(
$b
as
$k
=>
$v
)
{
if
(
is_integer
(
$k
))
{
isset
(
$a
[
$k
])
?
$a
[]
=
$v
:
$a
[
$k
]
=
$v
;
}
elseif
(
is_array
(
$v
)
&&
isset
(
$a
[
$k
])
&&
is_array
(
$a
[
$k
]))
{
$a
[
$k
]
=
self
::
mergeArray
(
$a
[
$k
],
$v
);
}
else
{
$a
[
$k
]
=
$v
;
}
}
return
$a
;
}
}
}
framework/base/Module.php
View file @
409c508f
This diff is collapsed.
Click to expand it.
framework/base/Vector.php
View file @
409c508f
...
@@ -68,7 +68,7 @@ class Vector extends Object implements \IteratorAggregate, \ArrayAccess, \Counta
...
@@ -68,7 +68,7 @@ class Vector extends Object implements \IteratorAggregate, \ArrayAccess, \Counta
* Returns an iterator for traversing the items in the vector.
* Returns an iterator for traversing the items in the vector.
* This method is required by the SPL interface `IteratorAggregate`.
* This method is required by the SPL interface `IteratorAggregate`.
* It will be implicitly called when you use `foreach` to traverse the vector.
* It will be implicitly called when you use `foreach` to traverse the vector.
* @return Iterator an iterator for traversing the items in the vector.
* @return
Vector
Iterator an iterator for traversing the items in the vector.
*/
*/
public
function
getIterator
()
public
function
getIterator
()
{
{
...
@@ -262,7 +262,7 @@ class Vector extends Object implements \IteratorAggregate, \ArrayAccess, \Counta
...
@@ -262,7 +262,7 @@ class Vector extends Object implements \IteratorAggregate, \ArrayAccess, \Counta
/**
/**
* Merges iterable data into the vector.
* Merges iterable data into the vector.
* New items will be appended to the end of the existing items.
* New items will be appended to the end of the existing items.
* @param
mixed $data the data to be merged with, must be an array or an object implementing `Traversable`
* @param
array|\Traversable $data the data to be merged with. It must be an array or object implementing Traversable
* @throws Exception if data is neither an array nor an object implementing `Traversable`.
* @throws Exception if data is neither an array nor an object implementing `Traversable`.
*/
*/
public
function
mergeWith
(
$data
)
public
function
mergeWith
(
$data
)
...
@@ -275,7 +275,7 @@ class Vector extends Object implements \IteratorAggregate, \ArrayAccess, \Counta
...
@@ -275,7 +275,7 @@ class Vector extends Object implements \IteratorAggregate, \ArrayAccess, \Counta
$this
->
add
(
$item
);
$this
->
add
(
$item
);
}
}
}
else
{
}
else
{
throw
new
Exception
(
'
Data must be either
an array or an object implementing Traversable.'
);
throw
new
Exception
(
'
The data to be merged with must be
an array or an object implementing Traversable.'
);
}
}
}
}
...
...
framework/db/Exception.php
View file @
409c508f
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
/**
/**
* Exception class file.
* Exception class file.
*
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
* @license http://www.yiiframework.com/license/
...
...
framework/db/dao/BaseQuery.php
View file @
409c508f
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
/**
/**
* BaseQuery class file.
* BaseQuery class file.
*
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
* @license http://www.yiiframework.com/license/
...
...
framework/db/dao/ColumnSchema.php
View file @
409c508f
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
/**
/**
* ColumnSchema class file.
* ColumnSchema class file.
*
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
* @license http://www.yiiframework.com/license/
...
...
framework/db/dao/Command.php
View file @
409c508f
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
/**
/**
* Command class file.
* Command class file.
*
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
* @license http://www.yiiframework.com/license/
...
...
framework/db/dao/Connection.php
View file @
409c508f
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
/**
/**
* Connection class file
* Connection class file
*
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
* @license http://www.yiiframework.com/license/
...
...
framework/db/dao/DataReader.php
View file @
409c508f
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
/**
/**
* DataReader class file
* DataReader class file
*
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
* @license http://www.yiiframework.com/license/
...
...
framework/db/dao/Driver.php
View file @
409c508f
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
/**
/**
* Driver class file.
* Driver class file.
*
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
* @license http://www.yiiframework.com/license/
...
...
framework/db/dao/Expression.php
View file @
409c508f
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
/**
/**
* Expression class file.
* Expression class file.
*
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
* @license http://www.yiiframework.com/license/
...
...
framework/db/dao/Query.php
View file @
409c508f
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
/**
/**
* Query class file.
* Query class file.
*
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
* @license http://www.yiiframework.com/license/
...
...
framework/db/dao/QueryBuilder.php
View file @
409c508f
<?php
<?php
/**
/**
*
This file contains the Command class
.
*
QueryBuilder class file
.
*
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
* @license http://www.yiiframework.com/license/
...
...
framework/db/dao/TableSchema.php
View file @
409c508f
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
/**
/**
* TableSchema class file.
* TableSchema class file.
*
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2011 Yii Software LLC
* @copyright Copyright © 2008-2011 Yii Software LLC
* @license http://www.yiiframework.com/license/
* @license http://www.yiiframework.com/license/
...
...
framework/db/dao/Transaction.php
View file @
409c508f
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
/**
/**
* Transaction class file.
* Transaction class file.
*
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
* @license http://www.yiiframework.com/license/
...
...
framework/db/dao/mysql/Driver.php
View file @
409c508f
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
/**
/**
* Driver class file.
* Driver class file.
*
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
* @license http://www.yiiframework.com/license/
...
...
framework/db/dao/mysql/QueryBuilder.php
View file @
409c508f
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
/**
/**
* QueryBuilder class file.
* QueryBuilder class file.
*
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
* @license http://www.yiiframework.com/license/
...
...
framework/db/dao/sqlite/Driver.php
View file @
409c508f
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
/**
/**
* Driver class file.
* Driver class file.
*
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
* @license http://www.yiiframework.com/license/
...
...
framework/db/dao/sqlite/QueryBuilder.php
View file @
409c508f
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
/**
/**
* QueryBuilder class file.
* QueryBuilder class file.
*
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
* @license http://www.yiiframework.com/license/
...
...
framework/logging/DbTarget.php
View file @
409c508f
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
/**
/**
* DbTarget class file.
* DbTarget class file.
*
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
* @license http://www.yiiframework.com/license/
...
...
framework/logging/EmailTarget.php
View file @
409c508f
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
/**
/**
* EmailTarget class file.
* EmailTarget class file.
*
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
* @license http://www.yiiframework.com/license/
...
...
framework/logging/FileTarget.php
View file @
409c508f
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
/**
/**
* FileTarget class file.
* FileTarget class file.
*
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
* @license http://www.yiiframework.com/license/
...
...
framework/logging/Logger.php
View file @
409c508f
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
/**
/**
* Logger class file
* Logger class file
*
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
* @license http://www.yiiframework.com/license/
...
...
framework/logging/ProfileTarget.php
View file @
409c508f
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
/**
/**
* CProfileLogRoute class file.
* CProfileLogRoute class file.
*
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2011 Yii Software LLC
* @copyright Copyright © 2008-2011 Yii Software LLC
* @license http://www.yiiframework.com/license/
* @license http://www.yiiframework.com/license/
...
...
framework/logging/Router.php
View file @
409c508f
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
/**
/**
* Router class file.
* Router class file.
*
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
* @license http://www.yiiframework.com/license/
...
...
framework/logging/Target.php
View file @
409c508f
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
/**
/**
* Target class file.
* Target class file.
*
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
* @license http://www.yiiframework.com/license/
...
...
framework/logging/WebTarget.php
View file @
409c508f
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
/**
/**
* CWebLogRoute class file.
* CWebLogRoute class file.
*
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2011 Yii Software LLC
* @copyright Copyright © 2008-2011 Yii Software LLC
* @license http://www.yiiframework.com/license/
* @license http://www.yiiframework.com/license/
...
...
framework/util/ArrayHelper.php
0 → 100644
View file @
409c508f
<?php
/**
* ArrayHelper class file.
*
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\util
;
/**
* ArrayHelper is ...
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
ArrayHelper
extends
\yii\base\Component
{
/**
* Merges two arrays into one recursively.
* If each array has an element with the same string key value, the latter
* will overwrite the former (different from array_merge_recursive).
* Recursive merging will be conducted if both arrays have an element of array
* type and are having the same key.
* For integer-keyed elements, the elements from the latter array will
* be appended to the former array.
* @param array $a array to be merged to
* @param array $b array to be merged from
* @return array the merged array (the original arrays are not changed.)
* @see mergeWith
*/
public
static
function
merge
(
$a
,
$b
)
{
foreach
(
$b
as
$k
=>
$v
)
{
if
(
is_integer
(
$k
))
{
isset
(
$a
[
$k
])
?
$a
[]
=
$v
:
$a
[
$k
]
=
$v
;
}
elseif
(
is_array
(
$v
)
&&
isset
(
$a
[
$k
])
&&
is_array
(
$a
[
$k
]))
{
$a
[
$k
]
=
static
::
merge
(
$a
[
$k
],
$v
);
}
else
{
$a
[
$k
]
=
$v
;
}
}
return
$a
;
}
/**
* Retrieves the value of an array element with the specified key.
*
* If the key does not exist in the array, the default value will be returned instead.
* For example,
*
* ~~~
* $username = \yii\util\ArrayHelper::get($_POST, 'username');
* ~~~
*
* @param array $array array to extract value from
* @param string $key key name of the array element
* @param mixed $default the default value to be returned if the specified key does not exist
* @return mixed
*/
public
static
function
get
(
$array
,
$key
,
$default
=
null
)
{
return
isset
(
$array
[
$key
])
||
array_key_exists
(
$key
,
$array
)
?
$array
[
$key
]
:
$default
;
}
}
\ No newline at end of file
framework/util/File.php
View file @
409c508f
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
/**
/**
* Filesystem helper class file.
* Filesystem helper class file.
*
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Alex Makarov <sam@rmcreative.ru>
* @link http://www.yiiframework.com/
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
* @license http://www.yiiframework.com/license/
...
@@ -14,6 +12,8 @@ namespace yii\util;
...
@@ -14,6 +12,8 @@ namespace yii\util;
/**
/**
* Filesystem helper
* Filesystem helper
*
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Alex Makarov <sam@rmcreative.ru>
* @since 2.0
* @since 2.0
*/
*/
class
File
class
File
...
...
framework/util/Text.php
View file @
409c508f
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
/**
/**
* Text helper class file.
* Text helper class file.
*
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Alex Makarov <sam@rmcreative.ru>
* @link http://www.yiiframework.com/
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
* @license http://www.yiiframework.com/license/
...
...
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