Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

改善链式方法的IDE自动提示 #2

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 134 additions & 0 deletions src/validate/Rule.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2017 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <[email protected]>
// +----------------------------------------------------------------------

namespace think\validate;

/**
* Rule链式方法助手类
* Interface Rule
* @author : evalor <[email protected]>
* @package think\validate
*/
interface Rule
{
/* @return Rule */
function confirm($field, $msg = ''): self; // 验证是否和某个字段的值一致
/* @return Rule */
function different($field, $msg = ''); // 验证是否和某个字段的值是否不同
/* @return Rule */
function egt($value, $msg = ''); // 验证是否大于等于某个值
/* @return Rule */
function gt($value, $msg = ''); // 验证是否大于某个值
/* @return Rule */
function elt($value, $msg = ''); // 验证是否小于等于某个值
/* @return Rule */
function lt($value, $msg = ''); // 验证是否小于某个值
/* @return Rule */
function eg($value, $msg = ''); // 验证是否等于某个值
/* @return Rule */
function in($values, $msg = ''); // 验证是否在范围内
/* @return Rule */
function notIn($values, $msg = ''); // 验证是否不在某个范围
/* @return Rule */
function between($values, $msg = ''); // 验证是否在某个区间
/* @return Rule */
function notBetween($values, $msg = ''); // 验证是否不在某个区间
/* @return Rule */
function length($length, $msg = ''); // 验证数据长度
/* @return Rule */
function max($max, $msg = ''); // 验证数据最大长度
/* @return Rule */
function min($min, $msg = ''); // 验证数据最小长度
/* @return Rule */
function after($date, $msg = ''); // 验证日期
/* @return Rule */
function before($date, $msg = ''); // 验证日期
/* @return Rule */
function expire($dates, $msg = ''); // 验证有效期
/* @return Rule */
function allowIp($ip, $msg = ''); // 验证IP许可
/* @return Rule */
function denyIp($ip, $msg = ''); // 验证IP禁用
/* @return Rule */
function regex($rule, $msg = ''); // 使用正则验证数据
/* @return Rule */
function token($token, $msg = ''); // 验证表单令牌
/* @return Rule */
function is($rule = null, $msg = ''); // 验证字段值是否为有效格式
/* @return Rule */
function isRequire($rule = null, $msg = ''); // 验证字段必须
/* @return Rule */
function isNumber($rule = null, $msg = ''); // 验证字段值是否为数字
/* @return Rule */
function isArray($rule = null, $msg = ''); // 验证字段值是否为数组
/* @return Rule */
function isInteger($rule = null, $msg = ''); // 验证字段值是否为整形
/* @return Rule */
function isFloat($rule = null, $msg = ''); // 验证字段值是否为浮点数
/* @return Rule */
function isMobile($rule = null, $msg = ''); // 验证字段值是否为手机
/* @return Rule */
function isIdCard($rule = null, $msg = ''); // 验证字段值是否为身份证号码
/* @return Rule */
function isChs($rule = null, $msg = ''); // 验证字段值是否为中文
/* @return Rule */
function isChsDash($rule = null, $msg = ''); // 验证字段值是否为中文字母及下划线
/* @return Rule */
function isChsAlpha($rule = null, $msg = ''); // 验证字段值是否为中文和字母
/* @return Rule */
function isChsAlphaNum($rule = null, $msg = ''); // 验证字段值是否为中文字母和数字
/* @return Rule */
function isDate($rule = null, $msg = ''); // 验证字段值是否为有效格式
/* @return Rule */
function isBool($rule = null, $msg = ''); // 验证字段值是否为布尔值
/* @return Rule */
function isAlpha($rule = null, $msg = ''); // 验证字段值是否为字母
/* @return Rule */
function isAlphaDash($rule = null, $msg = ''); // 验证字段值是否为字母和下划线
/* @return Rule */
function isAlphaNum($rule = null, $msg = ''); // 验证字段值是否为字母和数字
/* @return Rule */
function isAccepted($rule = null, $msg = ''); // 验证字段值是否为yes, on, 或是 1
/* @return Rule */
function isEmail($rule = null, $msg = ''); // 验证字段值是否为有效邮箱格式
/* @return Rule */
function isUrl($rule = null, $msg = ''); // 验证字段值是否为有效URL地址
/* @return Rule */
function activeUrl($rule = null, $msg = ''); // 验证是否为合格的域名或者IP
/* @return Rule */
function ip($rule = null, $msg = ''); // 验证是否有效IP
/* @return Rule */
function fileExt($ext, $msg = ''); // 验证文件后缀
/* @return Rule */
function fileMime($mime, $msg = ''); // 验证文件类型
/* @return Rule */
function fileSize($size, $msg = ''); // 验证文件大小
/* @return Rule */
function image($rule, $msg = ''); // 验证图像文件
/* @return Rule */
function method($method, $msg = ''); // 验证请求类型
/* @return Rule */
function dateFormat($format, $msg = ''); // 验证时间和日期是否符合指定格式
/* @return Rule */
function unique($rule, $msg = ''); // 验证是否唯一
/* @return Rule */
function behavior($rule, $msg = ''); // 使用行为类验证
/* @return Rule */
function filter($rule, $msg = ''); // 使用filter_var方式验证
/* @return Rule */
function requireIf($rule, $msg = ''); // 验证某个字段等于某个值的时候必须
/* @return Rule */
function requireCallback($rule, $msg = ''); // 通过回调方法验证某个字段是否必须
/* @return Rule */
function requireWith($rule, $msg = ''); // 验证某个字段有值的情况下必须
/* @return Rule */
function must($rule = null, $msg = ''); // 必须验证
}
112 changes: 56 additions & 56 deletions src/validate/ValidateRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,62 +14,62 @@
/**
* Class ValidateRule
* @package think\validate
* @method ValidateRule confirm(mixed $field, string $msg = '') static 验证是否和某个字段的值一致
* @method ValidateRule different(mixed $field, string $msg = '') static 验证是否和某个字段的值是否不同
* @method ValidateRule egt(mixed $value, string $msg = '') static 验证是否大于等于某个值
* @method ValidateRule gt(mixed $value, string $msg = '') static 验证是否大于某个值
* @method ValidateRule elt(mixed $value, string $msg = '') static 验证是否小于等于某个值
* @method ValidateRule lt(mixed $value, string $msg = '') static 验证是否小于某个值
* @method ValidateRule eg(mixed $value, string $msg = '') static 验证是否等于某个值
* @method ValidateRule in(mixed $values, string $msg = '') static 验证是否在范围内
* @method ValidateRule notIn(mixed $values, string $msg = '') static 验证是否不在某个范围
* @method ValidateRule between(mixed $values, string $msg = '') static 验证是否在某个区间
* @method ValidateRule notBetween(mixed $values, string $msg = '') static 验证是否不在某个区间
* @method ValidateRule length(mixed $length, string $msg = '') static 验证数据长度
* @method ValidateRule max(mixed $max, string $msg = '') static 验证数据最大长度
* @method ValidateRule min(mixed $min, string $msg = '') static 验证数据最小长度
* @method ValidateRule after(mixed $date, string $msg = '') static 验证日期
* @method ValidateRule before(mixed $date, string $msg = '') static 验证日期
* @method ValidateRule expire(mixed $dates, string $msg = '') static 验证有效期
* @method ValidateRule allowIp(mixed $ip, string $msg = '') static 验证IP许可
* @method ValidateRule denyIp(mixed $ip, string $msg = '') static 验证IP禁用
* @method ValidateRule regex(mixed $rule, string $msg = '') static 使用正则验证数据
* @method ValidateRule token(mixed $token, string $msg = '') static 验证表单令牌
* @method ValidateRule is(mixed $rule = null, string $msg = '') static 验证字段值是否为有效格式
* @method ValidateRule isRequire(mixed $rule = null, string $msg = '') static 验证字段必须
* @method ValidateRule isNumber(mixed $rule = null, string $msg = '') static 验证字段值是否为数字
* @method ValidateRule isArray(mixed $rule = null, string $msg = '') static 验证字段值是否为数组
* @method ValidateRule isInteger(mixed $rule = null, string $msg = '') static 验证字段值是否为整形
* @method ValidateRule isFloat(mixed $rule = null, string $msg = '') static 验证字段值是否为浮点数
* @method ValidateRule isMobile(mixed $rule = null, string $msg = '') static 验证字段值是否为手机
* @method ValidateRule isIdCard(mixed $rule = null, string $msg = '') static 验证字段值是否为身份证号码
* @method ValidateRule isChs(mixed $rule = null, string $msg = '') static 验证字段值是否为中文
* @method ValidateRule isChsDash(mixed $rule = null, string $msg = '') static 验证字段值是否为中文字母及下划线
* @method ValidateRule isChsAlpha(mixed $rule = null, string $msg = '') static 验证字段值是否为中文和字母
* @method ValidateRule isChsAlphaNum(mixed $rule = null, string $msg = '') static 验证字段值是否为中文字母和数字
* @method ValidateRule isDate(mixed $rule = null, string $msg = '') static 验证字段值是否为有效格式
* @method ValidateRule isBool(mixed $rule = null, string $msg = '') static 验证字段值是否为布尔值
* @method ValidateRule isAlpha(mixed $rule = null, string $msg = '') static 验证字段值是否为字母
* @method ValidateRule isAlphaDash(mixed $rule = null, string $msg = '') static 验证字段值是否为字母和下划线
* @method ValidateRule isAlphaNum(mixed $rule = null, string $msg = '') static 验证字段值是否为字母和数字
* @method ValidateRule isAccepted(mixed $rule = null, string $msg = '') static 验证字段值是否为yes, on, 或是 1
* @method ValidateRule isEmail(mixed $rule = null, string $msg = '') static 验证字段值是否为有效邮箱格式
* @method ValidateRule isUrl(mixed $rule = null, string $msg = '') static 验证字段值是否为有效URL地址
* @method ValidateRule activeUrl(mixed $rule = null, string $msg = '') static 验证是否为合格的域名或者IP
* @method ValidateRule ip(mixed $rule = null, string $msg = '') static 验证是否有效IP
* @method ValidateRule fileExt(mixed $ext, string $msg = '') static 验证文件后缀
* @method ValidateRule fileMime(mixed $mime, string $msg = '') static 验证文件类型
* @method ValidateRule fileSize(mixed $size, string $msg = '') static 验证文件大小
* @method ValidateRule image(mixed $rule, string $msg = '') static 验证图像文件
* @method ValidateRule method(mixed $method, string $msg = '') static 验证请求类型
* @method ValidateRule dateFormat(mixed $format, string $msg = '') static 验证时间和日期是否符合指定格式
* @method ValidateRule unique(mixed $rule, string $msg = '') static 验证是否唯一
* @method ValidateRule behavior(mixed $rule, string $msg = '') static 使用行为类验证
* @method ValidateRule filter(mixed $rule, string $msg = '') static 使用filter_var方式验证
* @method ValidateRule requireIf(mixed $rule, string $msg = '') static 验证某个字段等于某个值的时候必须
* @method ValidateRule requireCallback(mixed $rule, string $msg = '') static 通过回调方法验证某个字段是否必须
* @method ValidateRule requireWith(mixed $rule, string $msg = '') static 验证某个字段有值的情况下必须
* @method ValidateRule must(mixed $rule = null, string $msg = '') static 必须验证
* @method Rule confirm(mixed $field, string $msg = '') static 验证是否和某个字段的值一致
* @method Rule different(mixed $field, string $msg = '') static 验证是否和某个字段的值是否不同
* @method Rule egt(mixed $value, string $msg = '') static 验证是否大于等于某个值
* @method Rule gt(mixed $value, string $msg = '') static 验证是否大于某个值
* @method Rule elt(mixed $value, string $msg = '') static 验证是否小于等于某个值
* @method Rule lt(mixed $value, string $msg = '') static 验证是否小于某个值
* @method Rule eg(mixed $value, string $msg = '') static 验证是否等于某个值
* @method Rule in(mixed $values, string $msg = '') static 验证是否在范围内
* @method Rule notIn(mixed $values, string $msg = '') static 验证是否不在某个范围
* @method Rule between(mixed $values, string $msg = '') static 验证是否在某个区间
* @method Rule notBetween(mixed $values, string $msg = '') static 验证是否不在某个区间
* @method Rule length(mixed $length, string $msg = '') static 验证数据长度
* @method Rule max(mixed $max, string $msg = '') static 验证数据最大长度
* @method Rule min(mixed $min, string $msg = '') static 验证数据最小长度
* @method Rule after(mixed $date, string $msg = '') static 验证日期
* @method Rule before(mixed $date, string $msg = '') static 验证日期
* @method Rule expire(mixed $dates, string $msg = '') static 验证有效期
* @method Rule allowIp(mixed $ip, string $msg = '') static 验证IP许可
* @method Rule denyIp(mixed $ip, string $msg = '') static 验证IP禁用
* @method Rule regex(mixed $rule, string $msg = '') static 使用正则验证数据
* @method Rule token(mixed $token, string $msg = '') static 验证表单令牌
* @method Rule is(mixed $rule = null, string $msg = '') static 验证字段值是否为有效格式
* @method Rule isRequire(mixed $rule = null, string $msg = '') static 验证字段必须
* @method Rule isNumber(mixed $rule = null, string $msg = '') static 验证字段值是否为数字
* @method Rule isArray(mixed $rule = null, string $msg = '') static 验证字段值是否为数组
* @method Rule isInteger(mixed $rule = null, string $msg = '') static 验证字段值是否为整形
* @method Rule isFloat(mixed $rule = null, string $msg = '') static 验证字段值是否为浮点数
* @method Rule isMobile(mixed $rule = null, string $msg = '') static 验证字段值是否为手机
* @method Rule isIdCard(mixed $rule = null, string $msg = '') static 验证字段值是否为身份证号码
* @method Rule isChs(mixed $rule = null, string $msg = '') static 验证字段值是否为中文
* @method Rule isChsDash(mixed $rule = null, string $msg = '') static 验证字段值是否为中文字母及下划线
* @method Rule isChsAlpha(mixed $rule = null, string $msg = '') static 验证字段值是否为中文和字母
* @method Rule isChsAlphaNum(mixed $rule = null, string $msg = '') static 验证字段值是否为中文字母和数字
* @method Rule isDate(mixed $rule = null, string $msg = '') static 验证字段值是否为有效格式
* @method Rule isBool(mixed $rule = null, string $msg = '') static 验证字段值是否为布尔值
* @method Rule isAlpha(mixed $rule = null, string $msg = '') static 验证字段值是否为字母
* @method Rule isAlphaDash(mixed $rule = null, string $msg = '') static 验证字段值是否为字母和下划线
* @method Rule isAlphaNum(mixed $rule = null, string $msg = '') static 验证字段值是否为字母和数字
* @method Rule isAccepted(mixed $rule = null, string $msg = '') static 验证字段值是否为yes, on, 或是 1
* @method Rule isEmail(mixed $rule = null, string $msg = '') static 验证字段值是否为有效邮箱格式
* @method Rule isUrl(mixed $rule = null, string $msg = '') static 验证字段值是否为有效URL地址
* @method Rule activeUrl(mixed $rule = null, string $msg = '') static 验证是否为合格的域名或者IP
* @method Rule ip(mixed $rule = null, string $msg = '') static 验证是否有效IP
* @method Rule fileExt(mixed $ext, string $msg = '') static 验证文件后缀
* @method Rule fileMime(mixed $mime, string $msg = '') static 验证文件类型
* @method Rule fileSize(mixed $size, string $msg = '') static 验证文件大小
* @method Rule image(mixed $rule, string $msg = '') static 验证图像文件
* @method Rule method(mixed $method, string $msg = '') static 验证请求类型
* @method Rule dateFormat(mixed $format, string $msg = '') static 验证时间和日期是否符合指定格式
* @method Rule unique(mixed $rule, string $msg = '') static 验证是否唯一
* @method Rule behavior(mixed $rule, string $msg = '') static 使用行为类验证
* @method Rule filter(mixed $rule, string $msg = '') static 使用filter_var方式验证
* @method Rule requireIf(mixed $rule, string $msg = '') static 验证某个字段等于某个值的时候必须
* @method Rule requireCallback(mixed $rule, string $msg = '') static 通过回调方法验证某个字段是否必须
* @method Rule requireWith(mixed $rule, string $msg = '') static 验证某个字段有值的情况下必须
* @method Rule must(mixed $rule = null, string $msg = '') static 必须验证
*/
class ValidateRule
{
Expand Down