Giter VIP home page Giter VIP logo

Comments (12)

yuyachong avatar yuyachong commented on July 23, 2024

Paginator类中,jsonSerialize()方法在tp6上会被执行, 在tp8中被跳过了,问题出在这里,不知道为何跳过了

from think-orm.

yuyachong avatar yuyachong commented on July 23, 2024

刚无意间调整了 方法参数的位置, 发现在myJson($data, $msg, $code) 只要$data参数放第一位就可以自动toArray,
在tp6是可以随意摆放位置的,老大看看怎么回事修复一下

from think-orm.

augushong avatar augushong commented on July 23, 2024

看下你myjson代码

from think-orm.

yuyachong avatar yuyachong commented on July 23, 2024

看下你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.

augushong avatar augushong commented on July 23, 2024

你是说数组里的data放到数组开头,还是参数里的data放到参数开头。

from think-orm.

yuyachong avatar yuyachong commented on July 23, 2024

错误:
myJson(int $code, string $msg, int|array|string $data)

正常:
myJson($data, int $code, string $msg)

刚发现,$data还不能固定类型,不然依然不能toarray

from think-orm.

augushong avatar augushong commented on July 23, 2024

你可以在这个文件这一行
vendor\topthink\framework\src\think\Container.php
385行打印一下反射出来的参数,对比一下你调整位置之后,是不是一样的,如果是一样的,那跟tp就没啥关系。
有可能是传参不对
图片

from think-orm.

augushong avatar augushong commented on July 23, 2024

或者是349行的获取到得args。

from think-orm.

augushong avatar augushong commented on July 23, 2024

我试了一下,没有复现出你说的情况。要不你更新下php的版本试试,之前的php8之后的版本,调整过反射相关的bug。

from think-orm.

yuyachong avatar yuyachong commented on July 23, 2024

我试了一下,没有复现出你说的情况。要不你更新下php的版本试试,之前的php8之后的版本,调整过反射相关的bug。

找到问题所在了,不是参数位置问题, 是类型问题: 之前是 int|string|array, 但是不能这么写,只有单独使用array或者mixed才可以

from think-orm.

augushong avatar augushong commented on July 23, 2024

应该也不是这个问题,我用你给的myjson测试,没有问题。可以再找找。mixed本身就能覆盖int、string等,不要紧的。

from think-orm.

yuyachong avatar yuyachong commented on July 23, 2024

应该也不是这个问题,我用你给的myjson测试,没有问题。可以再找找。mixed本身就能覆盖int、string等,不要紧的。

好的,谢谢

from think-orm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.