-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[False positive] JSON_THROW_ON_ERROR is not recognized in named parameter call (PHP 8.0) #1725
Comments
I don't speak Java and I never developped a PHPStorm pluggin, so I don't know how I could help in fixing this. What I think is something can be done in this snippet: Lines 78 to 95 in ad57a4a
To me, the
To fix this, the Of course, this applies also to the Fixing naming recognition and fixing better understanding of the value of this parameter could be done in 2 separated PR. @kalessil If you or someone you know could be kind enough to explain me how to identify named parameters with the Thank you. |
This appears to be a duplicate of #1639 |
Thank you @AllenJB I wasn't able to find #1639 when I wrote this issue. It wasn't in my intentions to create a duplicate. Nevertheless, original issue is more about the fact that the suggestion is incorrect, while it's truely a false positive, implying such suggestion shouldn't be proposed. Also, it is less detailled than this one. Not even mentionning that the "Example Code" section is wrong as the parameter is named I think it could be helpful to close the original in favor of my issue rather than doing the opposite. Unless you think keeping both is ok and closing both at the same time once a fix will be applied is how the issues are managed in this repository. |
I "up" for this issue 🙂. |
I "UP" also for this issue. |
I also up-vote this issue. I have been experiencing this for a while (since around May or June this year) and it is as described by the OP; getting used to ignoring false-positives isn't good, and this is can be very confusing to less-experienced developers and make them prone to undo correctly-refactored code. |
And it would be great if it suggested
rather than
for PHP 8 |
@AlexeyKosov That would depend on the configuration set on PHPStorm Inspections about "prefer decode into array / prefer decode into object" choice. But yes, if the tool could suggest it without the |
@niconoe- To me, it seems that either whole implementation around Lines 78 to 95 in ad57a4a
Considering it uses positional arguments, and now PHP >8.0 allows for any argument to be in any position, as long as it's named, which means the same goes for all other argument-based validations... 🤷♂️ (I guess it's just that this specific case becomes more annoying, since everyone and their neighbor probably skips the max_depth arg anyway)I'll try to make some time to investigate and try to fix this, but although I'm experienced with Java, I've never even seen how JetBrains plugins work, like yourself... |
@CRC-Mismatch You're right: every validation that uses arguments without taking their names into account is a possible false-positive. IMO, as |
@kalessil @CRC-Mismatch @niconoe- Can someone help get my draft PR (#1815) to run? Or test it for me? |
I only looked at the source code proposal since I’m not working today, and it looks promising! I don’t know how can I test this locally to be honest. I don’t know if there are stuff like unit tests to provide here to secure your proposition, but maybe it could reassure @kalessil 😊 |
This seems to have stalled in October. If I knew Java I would try to help but I would love if we could get this fixed. |
We're still having this issue opened almost 2 years after its creation, and many duplicates have come during that period (#1873, #1845, #1825, and original #1639). @ricardoboss Do you know what prevents you to undraft your PR, and could you work on that? Maybe if the PR is ready, @kalessil could merge it? Thanks! |
@niconoe- the PR is still in draft because I am unable to test it. I just assume the code works. Someone with more experience might be able to test it for me and provide feedback. Then it may get out of the draft state. |
The issue is still present. The PR seems ok ; what about landing it ? |
Just to confirm it's present in PHPStorm 2024.1, too
|
Current behaviour
When calling
json_decode
with theflags:
names parameter set to JSON_THROW_ON_ERROR, the plugin is rising an error about[EA] Please consider taking advantage of JSON_THROW_ON_ERROR flag for this call options.
Expected behaviour
Expected behaviour is "no error" as I am taking advantage of the Throwable behavior.
Environment details
Probably some actions have been already taken regarding #1555 or #1592 but those were not about PHP 8.0 and the ability to use a named parameter.
Thanks a lot 🙂
The text was updated successfully, but these errors were encountered: