alice
alice copied to clipboard
Indexed arrays no longer work in Alice 3.x
Hello, our company has used Alice for fixture generation for a long time now we have a lot of complex fixtures in our project and we utilized parsing of indexed arrays to data formatters of our custom data fakers in Alice 2.x.
With the upgrade to Alice 3.x, however, this is no longer possible and passing of indexed arrays leads to internal token strings being given to the data fakers.
Example fixture file:
Results in value given to data faker:
I would like to ask if whether it is a bug in the new Alice version or if it was never meant to work this way and happened to work by chance in Alice 2.x. If that was the case, does anybody know of a clean way to passing indexed arrays to data fakers?
Thank you for answers and for a great library! Michal.
If that worked in 2.x it was pure luck :) I think a way to do it would be:
data: <dynamicObjectData(<(["property1" => intval(1)])>)>
Not sure that it will work though :/ It might be easier to just put everything in the faker provider directly.
@theofidry: Thank you for the fast reply.
I tried the format you recommended and it works only with a small adjustment when you take away space around the "=>".
So this works: <dynamicObjectData(<(["property1"=>intval(1)])>)>
It is a bit cumbersome to use and if there was a chance at some point, it would be great if alice supported indexed arrays by default.
For simple cases, it would be ok to put everything in a faker directly, however, in the scale of what we're building, it is unfortunately not maintainable to create custom logic for each different scenario.
Thank you, Mike.
I think a more viable long term plan would be https://github.com/nelmio/alice/issues/601#issuecomment-481601779.