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

TypeError: filter_var(): Argument #3 ($options) must be of type array|int, null given in ... #20

Open
ZhangSans opened this issue Aug 6, 2023 · 4 comments

Comments

@ZhangSans
Copy link

调用代码如下

image

php 版本8.1.21 使用 topthink/think-validate 对float 数据进行验证,

出现错误

TypeError: filter_var(): Argument #3 ($options) must be of type array|int, null given in .../vendor/topthink/think-validate/src/Validate.php:982

经过webman 2群群友提醒,php.net 文档如下

filter_var(mixed $value, int $filter = FILTER_DEFAULT, array|int $options = 0): mixed

Validate.php 函数 filter 中调用filter_var 第三个参数有问题,

建议修复代码如下

image

@jackyban
Copy link

补充:
修改在vendor/topthink/think-validate/src/Validate.php@976行
这个代码太久没更新了,对照最新的tp框架下的源码才发现的问题

@ncard23
Copy link

ncard23 commented Apr 18, 2024

是的,thinkphp8修复了这个问题,但是如果是webmen,还是用的thinkphp6里的这个validate代码,就会报错,这个如果每次修改 verdor里的方法也不是个办法,lz有没有计划修复下这个问题???

@liwy666
Copy link

liwy666 commented May 15, 2024

真的不打算修一下吗

@liwy666
Copy link

liwy666 commented May 15, 2024

看来作者是不打算修了,大家可以试试这个 https://github.com/taoser/webman-validate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants