Comments (12)
Paginator类中,jsonSerialize()方法在tp6上会被执行, 在tp8中被跳过了,问题出在这里,不知道为何跳过了
from think-orm.
刚无意间调整了 方法参数的位置, 发现在myJson($data, $msg, $code) 只要$data参数放第一位就可以自动toArray,
在tp6是可以随意摆放位置的,老大看看怎么回事修复一下
from think-orm.
看下你myjson代码
from think-orm.
看下你myjson代码
function myJson(int $code, string $msg, int|array|string $data): Json { return json([ 'code' => $code, 'msg' => $msg, 'data' => $data ]); }
我刚测试了 $data 在tp8下必须放第一位才会自动toArray,TP6没有这个问题
from think-orm.
你是说数组里的data放到数组开头,还是参数里的data放到参数开头。
from think-orm.
错误:
myJson(int $code, string $msg, int|array|string $data)
正常:
myJson($data, int $code, string $msg)
刚发现,$data还不能固定类型,不然依然不能toarray
from think-orm.
你可以在这个文件这一行
vendor\topthink\framework\src\think\Container.php
385行打印一下反射出来的参数,对比一下你调整位置之后,是不是一样的,如果是一样的,那跟tp就没啥关系。
有可能是传参不对
from think-orm.
或者是349行的获取到得args。
from think-orm.
我试了一下,没有复现出你说的情况。要不你更新下php的版本试试,之前的php8之后的版本,调整过反射相关的bug。
from think-orm.
我试了一下,没有复现出你说的情况。要不你更新下php的版本试试,之前的php8之后的版本,调整过反射相关的bug。
找到问题所在了,不是参数位置问题, 是类型问题: 之前是 int|string|array, 但是不能这么写,只有单独使用array或者mixed才可以
from think-orm.
应该也不是这个问题,我用你给的myjson测试,没有问题。可以再找找。mixed本身就能覆盖int、string等,不要紧的。
from think-orm.
应该也不是这个问题,我用你给的myjson测试,没有问题。可以再找找。mixed本身就能覆盖int、string等,不要紧的。
好的,谢谢
from think-orm.
Related Issues (20)
- 一对多关联字段查询BUG
- 模型自动转驼峰功能异常
- ->find()时hidden/appen/visible 逻辑问题 HOT 8
- withJoin()驼峰bug
- 非原生查询使用参数绑定
- 改一下吧 $a !== $b 不然 01 和 1 判定一样的了 HOT 1
- 一对一关联hasWhere和where同时使用bug HOT 1
- MongoDB下查询中包含数组/对象时自动加 $in 的问题。 HOT 1
- join语法不支持 cross join
- MongoDB如何批量修改
- 使用sql server时bug非常多,需要怎么修复? HOT 2
- 不开启字段缓存的情况下,即使模型中设置了schema属性,在新增数据的时候依然会从数据库中获取表字段信息 HOT 1
- find在无条件查询下返回NULL的问题 HOT 4
- 多对多模型中间表pivot提示外键不存在
- 更新数据时,创建时间字段create_time 未自动转换 HOT 4
- 关于使用自定义Collection方法且调用分页功能,列表数据为0时,找不到自定义Collection的扩展方法,从而造成的报错。
- pgsql数据库多schema支持问题
- inc, dec, setInc, setDec 步长应该支持整型、浮点型、字符串类型
- 远程关联执行 不走 模型
- where和hasWhere同时使用会出现的bug HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from think-orm.