且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

可捕获的致命错误:传递给 ... 的参数 1 必须是 ... 的实例,给定数组

更新时间:2021-08-04 21:25:08

让我们把这个错误拆开来看看如何找出错误消息.

Let's take this error apart so you can see how to figure out error messages.

ContextErrorException: Catchable Fatal Error: 

这是错误的类型.您可以编写一个错误处理程序来处理这些问题.

This is the type of the error. You can write an error handler to handle these.

Argument 1 passed to VolleyScoutVolleyScoutBundleEntityUsers::setPlayer() 
must be an instance of VolleyScoutVolleyScoutBundleEntityPlayers, 

这意味着当调用 Users::setPlayer() 时,您必须在参数中使用 Player 对象来调用它.

This means that when Users::setPlayer() is called, you have to call it using a Player object in the argument.

array given, 

这意味着参数中有一个数组,而不是 Player 对象.

This means that instead of a Player object, there was an array in the argument.

called in /Applications/mampstack-5.4.20-0/apache2/htdocs/volleyscout/vendor
/symfony/symfony/src/Symfony/Component/PropertyAccess/PropertyAccessor.php 
on line 360

这会告诉您问题出在哪里:PropertyAccessor.php 的第 360 行.

This tells you where the problem is: line 360 of PropertyAccessor.php.

and defined in /Applications/mampstack-5.4.20-0/apache2/htdocs/volleyscout
/src/VolleyScout/VolleyScoutBundle/Entity/Users.php line 609

这会告诉您涉及用户类的哪一行.

This tells you what line of the class Users is involved.

因此,您所要做的就是将第 360 行的数组更改为 Player 对象.然后你可以继续下一个错误.

So, all you have to do is change that array on line 360 to a Player object. Then you can move on to the next error.

因为第 360 行是从其他地方调用的,所以您必须回溯到调用第 360 行的任何内容.在这种情况下,正是这一行给您带来了问题:

Because line 360 is being called from somewhere else, you'll have to trace backwards to whatever was calling line 360. In this case, it's this line that's giving you an issue:

$object->$setter($value);

$value 应该是 Player 对象,而不是数组.$value 来自哪里?

The $value is supposed to be a Player object, not an array. Where is $value coming from?