CompileNodeToValueTest: failing tests for unsupported default values (enum case, new)#1353
CompileNodeToValueTest: failing tests for unsupported default values (enum case, new)#1353janedbal wants to merge 1 commit intoRoave:6.11.xfrom
Conversation
|
This is correct: |
|
@janedbal it can be “fixed” in https://github.com/ondrejmirtes/BetterReflection |
|
Certainly, but the basic invariant here is "don't load code", so that will certainly not happen here. Also for the fork, loading runtime code could even be categorized as a security issue, from my point of view: instead of loading the code, load the AST for it instead. |
|
If it cannot be fixed, which I understand, could it at least throw better exception in such cases? |
|
@JanTvrdik what's the current exception you get? We generally have quite specific exception types. Is it this one, perhaps? Another alternative that comes to mind is having |
|
Maybe worth updating Compatibility page with this issue? ReflectionAttribute is missing there completely. |
|
@Ocramius It's actually https://github.com/Roave/BetterReflection/blob/6.11.x/src/NodeCompiler/CompileNodeToValue.php#L250, because the "enum case fetch" is represented as |
|
@janedbal please do send a patch :-) @JanTvrdik is it possible to have a test with a better message expectation, perhaps? That would certainly improve the DX a lot :) |
I was trying to fix this issue, but it looks like it is not designed for non-scalar values:
ReflectionParameter::getDefaultValue(): string|int|float|bool|array|null.The actual issue we are facing is that we initialize custom attribute within custom phpstan rule. When a default value of such attribute is enum case, phpstan collapses.