Closed bicpi closed 7 months ago
This error has nothing to do with new
in initializers (there is no new
in your initializers). It is about support for enums in default values of an argument.
True, I think I also observed an issue with new
usage, I'll refine the description.
If there is also an issue with new
(which is likely as we haven't done anything to support it), please open a separate issue for it (as the fix might not be the same).
I reduced this issue to the problem with the enum argument; after testing the case with the new
usage in a method's default value, I created the separate issue https://github.com/phpspec/prophecy/issues/568.
I confirm the issue.
As soon as a default value is used for an argument typed with a Enum
, prophecy crash.
I can also confirm this. The problem is, that the generated default value is in the wrong namespace, because the leading \
is missing.
This seems only to be a problem in PHP 8.1, see: https://3v4l.org/3JPCM
I proposed a fix: #618
Hi, given this enum (PHP 8.1+):
And an interface with a method using the enum as default argument of a method:
And a service using the interface as a dependency:
The following test fails:
The error message is:
When passing the default value explicitly works though.