Merge pull request #2506 from dereuromark/2.5-string

Correct tokenize for empty strings.
This commit is contained in:
José Lorenzo Rodríguez 2013-12-21 10:31:52 -08:00
commit 60d2ece035
2 changed files with 8 additions and 4 deletions

View file

@ -99,17 +99,17 @@ class String {
/**
* Tokenizes a string using $separator, ignoring any instance of $separator that appears between
* $leftBound and $rightBound
* $leftBound and $rightBound.
*
* @param string $data The data to tokenize
* @param string $data The data to tokenize.
* @param string $separator The token to split the data on.
* @param string $leftBound The left boundary to ignore separators in.
* @param string $rightBound The right boundary to ignore separators in.
* @return mixed Array of tokens in $data or original input if empty.
*/
public static function tokenize($data, $separator = ',', $leftBound = '(', $rightBound = ')') {
if (empty($data) || is_array($data)) {
return $data;
if (empty($data)) {
return array();
}
$depth = 0;