정적 분석기 결과 반영. 빠진 POST 인자 입력 등

This commit is contained in:
2018-04-08 20:51:40 +09:00
parent b78fe22633
commit 5b926ae5c5
11 changed files with 66 additions and 27 deletions
+25 -8
View File
@@ -3,6 +3,15 @@ namespace sammo;
class Util extends \utilphp\util
{
/**
* int 값 반환을 강제하는 부동소수점 반올림
* @param numeric $value
*/
public static function round($value) : int{
return intval(round($value));
}
private static function _parseReq($value, string $type)
{
if (is_array($value)) {
@@ -233,7 +242,11 @@ class Util extends \utilphp\util
}
}
public static function eraseNullValue($dict, $depth=512)
/**
* @param null|mixed|mixed[] $dict
* @return null|mixed|mixed[]
*/
public static function eraseNullValue($dict, int $depth=512)
{
//TODO:Test 추가
if ($dict === null) {
@@ -251,13 +264,17 @@ class Util extends \utilphp\util
foreach ($dict as $key=>$value) {
if ($value === null) {
unset($dict[$key]);
} elseif (Util::isDict($value)) {
$newValue = Util::eraseNullValue($value, $depth - 1);
if ($newValue === null) {
unset($dict[$key]);
} else {
$dict[$key] = $newValue;
}
continue;
}
if (!Util::isDict($value)) {
continue;
}
$newValue = Util::eraseNullValue($value, $depth - 1);
if ($newValue === null) {
unset($dict[$key]);
} else {
$dict[$key] = $newValue;
}
}