[5.6] Prevent considering an array attribute as callable in model factories#23372
Conversation
|
Wow, that's a very curious finding @themsaid, nice catch! I just have a question, what is the real use case behind this? when do you want to declare a factory that has one array as property?, i tried this case with a non existent class (and therefore a not existen method) and it throws a:
On the contrary, i think that it will be useful to be able to still be able to do this: $factory->define(App\User::class, function () {
return [
'lorem' => [new App\Ipsum, 'create'],
];
});as proposed in #20692 |
|
Check #23361 for the use case that discovered the bug. |
|
Oh, i get it now, a json casteable attribute, thanks @devcircus 👍 |
|
@DojoGeekRA I was surprised it's not discovered earlier actually :) |
|
Yeah, me too, and even more considering that i use that kind of attributes a lot 😅 I totally agree with the fix then, thanks @themsaid! |
Having:
While building the factory,
is_callable(['Storage', 'Bar'])will return true so the code will try to call the Bar method on the Storage class and that'll error.In this PR we exclude array forms from being dealt with as callables.