修正\traits\model\Auto 一处警告错误

This commit is contained in:
thinkphp
2016-02-02 11:29:12 +08:00
parent 52a0dd1dfc
commit fdb832cb19

View File

@@ -189,8 +189,11 @@ trait Auto
} }
// 检查填充条件 // 检查填充条件
if ($flags & $type) { if ($flags & $type) {
if (empty($auto[3])) {
$auto[3] = 'string';
}
switch (trim($auto[3])) { switch (trim($auto[3])) {
case 'function': // 使用函数进行填充 字段的值作为参数 case 'function':// 使用函数进行填充 字段的值作为参数
case 'callback': // 使用回调方法 case 'callback': // 使用回调方法
$args = isset($auto[4]) ? (array) $auto[4] : []; $args = isset($auto[4]) ? (array) $auto[4] : [];
if (is_string($auto[0]) && strpos($auto[0], ',')) { if (is_string($auto[0]) && strpos($auto[0], ',')) {
@@ -353,7 +356,7 @@ trait Auto
protected function _validationFieldItem($data, $val) protected function _validationFieldItem($data, $val)
{ {
switch (strtolower(trim($val[4]))) { switch (strtolower(trim($val[4]))) {
case 'function': // 使用函数进行验证 case 'function':// 使用函数进行验证
case 'callback': // 调用方法进行验证 case 'callback': // 调用方法进行验证
$args = isset($val[6]) ? (array) $val[6] : []; $args = isset($val[6]) ? (array) $val[6] : [];
if (is_string($val[0]) && strpos($val[0], ',')) { if (is_string($val[0]) && strpos($val[0], ',')) {
@@ -413,11 +416,11 @@ trait Auto
{ {
$type = strtolower(trim($type)); $type = strtolower(trim($type));
switch ($type) { switch ($type) {
case 'in': // 验证是否在某个指定范围之内 逗号分隔字符串或者数组 case 'in':// 验证是否在某个指定范围之内 逗号分隔字符串或者数组
case 'notin': case 'notin':
$range = is_array($rule) ? $rule : explode(',', $rule); $range = is_array($rule) ? $rule : explode(',', $rule);
return 'in' == $type ? in_array($value, $range) : !in_array($value, $range); return 'in' == $type ? in_array($value, $range) : !in_array($value, $range);
case 'between': // 验证是否在某个范围 case 'between':// 验证是否在某个范围
case 'notbetween': // 验证是否不在某个范围 case 'notbetween': // 验证是否不在某个范围
if (is_array($rule)) { if (is_array($rule)) {
$min = $rule[0]; $min = $rule[0];
@@ -426,7 +429,7 @@ trait Auto
list($min, $max) = explode(',', $rule); list($min, $max) = explode(',', $rule);
} }
return 'between' == $type ? $value >= $min && $value <= $max : $value < $min || $value > $max; return 'between' == $type ? $value >= $min && $value <= $max : $value < $min || $value > $max;
case 'equal': // 验证是否等于某个值 case 'equal':// 验证是否等于某个值
case 'notequal': // 验证是否等于某个值 case 'notequal': // 验证是否等于某个值
return 'equal' == $type ? $value == $rule : $value != $rule; return 'equal' == $type ? $value == $rule : $value != $rule;
case 'length': // 验证长度 case 'length': // 验证长度