Changeset View
Changeset View
Standalone View
Standalone View
src/utils/utils.php
| Show First 20 Lines • Show All 736 Lines • ▼ Show 20 Lines | function array_mergev(array $arrayv) { | ||||
| if (!$arrayv) { | if (!$arrayv) { | ||||
| return array(); | return array(); | ||||
| } | } | ||||
| foreach ($arrayv as $key => $item) { | foreach ($arrayv as $key => $item) { | ||||
| if (!is_array($item)) { | if (!is_array($item)) { | ||||
| throw new InvalidArgumentException( | throw new InvalidArgumentException( | ||||
| pht( | pht( | ||||
| 'Expected all items passed to %s to be arrays, but '. | 'Expected all items passed to `%s` to be arrays, but '. | ||||
| 'argument with key "%s" has type "%s".', | 'argument with key "%s" has type "%s".', | ||||
| __FUNCTION__.'()', | __FUNCTION__.'()', | ||||
| $key, | $key, | ||||
| gettype($item))); | gettype($item))); | ||||
| } | } | ||||
| } | } | ||||
| return call_user_func_array('array_merge', $arrayv); | return call_user_func_array('array_merge', $arrayv); | ||||
| ▲ Show 20 Lines • Show All 371 Lines • ▼ Show 20 Lines | foreach ($value as $key => $subvalue) { | ||||
| $full_key = $path.' > '; | $full_key = $path.' > '; | ||||
| } else { | } else { | ||||
| $full_key = ''; | $full_key = ''; | ||||
| } | } | ||||
| if (!phutil_is_utf8($key)) { | if (!phutil_is_utf8($key)) { | ||||
| $full_key = $full_key.phutil_utf8ize($key); | $full_key = $full_key.phutil_utf8ize($key); | ||||
| return pht( | return pht( | ||||
| 'Dictionary key "%s" is not valid UTF8, and can not be JSON encoded.', | 'Dictionary key "%s" is not valid UTF8, and cannot be JSON encoded.', | ||||
| $full_key); | $full_key); | ||||
| } | } | ||||
| $full_key .= $key; | $full_key .= $key; | ||||
| $result = phutil_validate_json($subvalue, $full_key); | $result = phutil_validate_json($subvalue, $full_key); | ||||
| if ($result !== null) { | if ($result !== null) { | ||||
| return $result; | return $result; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (is_string($value)) { | if (is_string($value)) { | ||||
| if (!phutil_is_utf8($value)) { | if (!phutil_is_utf8($value)) { | ||||
| $display = substr($value, 0, 256); | $display = substr($value, 0, 256); | ||||
| $display = phutil_utf8ize($display); | $display = phutil_utf8ize($display); | ||||
| if (!strlen($path)) { | if (!strlen($path)) { | ||||
| return pht( | return pht( | ||||
| 'String value is not valid UTF8, and can not be JSON encoded: %s', | 'String value is not valid UTF8, and can not be JSON encoded: %s', | ||||
| $display); | $display); | ||||
| } else { | } else { | ||||
| return pht( | return pht( | ||||
| 'Dictionary value at key "%s" is not valid UTF8, and can not be '. | 'Dictionary value at key "%s" is not valid UTF8, and cannot be '. | ||||
| 'JSON encoded: %s', | 'JSON encoded: %s', | ||||
| $path, | $path, | ||||
| $display); | $display); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| return; | return; | ||||
| ▲ Show 20 Lines • Show All 246 Lines • Show Last 20 Lines | |||||