Phpinspectionsea: [False Positive] JsonEncodingApiUsageInspection

Created on 29 Jun 2020  路  6Comments  路  Source: kalessil/phpinspectionsea

| Subject | Details |
| :------------- | :---------------------------------------------------------------------------- |
| Plugin | Php Inspections (EA Extended), 4.0.4.1 |
| Language level | PHP 7.4 |

Current behaviour

json_encode

<?php

declare(strict_types=1);

$test = json_encode([], JSON_THROW_ON_ERROR);
$test2 = json_encode([], JSON_THROW_ON_ERROR | JSON_THROW_ON_ERROR);
$test3 = json_encode([], JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR);
$test4 = json_encode([], JSON_THROW_ON_ERROR, 512);
$test5 = json_encode([], JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR, 512);

image

The warnings show: _[EA] Please consider taking advantage of JSON_THROW_ON_ERROR flag for this call options._.

json_decode

<?php

declare(strict_types=1);

$test = json_decode('', true, 512, JSON_THROW_ON_ERROR);
$test2 = json_decode('', true, 512, JSON_THROW_ON_ERROR | JSON_THROW_ON_ERROR);
$test3 = json_decode('', true, 512, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR);

image

The warning shows: _[EA] Please consider taking advantage of JSON_THROW_ON_ERROR flag for this call options._.

Expected behaviour

No warning should be shown in either of these cases.

Additional details

Probable regression from this commit https://github.com/kalessil/phpinspectionsea/commit/933e4ca38a716a7662961457acc206606ab77096.

Environment details

PhpStorm 2020.1.2
Build #PS-201.7846.90, built on June 3, 2020
Runtime version: 11.0.7+10-b765.53 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 4.15.0-1090-oem
GC: ParNew, ConcurrentMarkSweep
Memory: 4012M
Cores: 12
Registry: run.processes.with.pty=TRUE, ide.balloon.shadow.size=0
Non-Bundled Plugins: Dilbert, com.failfast, com.vladsch.git-file-case-fixer, gr.jchrist.gitextender, zielu.gittoolbox, me.artspb.hackathon.git.bisect.run, net.ntworld.nhat-phan.merge-request-integration-ce, PlantUML integration, Statistic, String Manipulation, Gitflow, com.intellij.jira, awesome.console, com.github.lppedd.idea-conventional-commit, com.github.novotnyr.jwt-intellij-plugin, com.intellij.ideolog, org.intellij.plugins.postcss, org.intellij.plugins.hcl, com.jinsihou.react.snippets, commit-template-idea-plugin, de.ax.powermode, git-commit-message-plugin, mobi.hsz.idea.gitignore, ideanginx9, lermitage.intellij.extra.icons, name.kropp.intellij.makefile, net.sjrx.intellij.plugins.systemdunitfiles, net.vektah.codeglance, one.util.ideaplugin.screenshoter, BashSupport, com.github.beansoftapp.reatnative.idea, com.intellij.kubernetes, org.jetbrains.plugins.node-remote-interpreter, com.deadlock.scsyntax, com.intellij.lang.jsgraphql, ru.adelf.idea.dotenv, NEON support, com.aurimasniekis.phppsr4namespacedetector, com.funivan.idea.phpClean, lv.midiana.misc.phpstorm-plugins.deep-keys, lv.midiana.misc.idea-plugins.deep-js-completion, de.espend.idea.php.toolbox, de.espend.idea.php.annotation, fr.adrienbrault.idea.symfony2plugin, com.kalessil.phpStorm.phpInspectionsEA, com.ptby.dynamicreturntypeplugin, com.thanosp.phpstorm.inheritdoc, de.espend.idea.php.phpunit, net.king2500.plugins.PhpAdvancedAutoComplete, com.suming.react.PropTypes, intellij.prettierJS, org.toml.lang, ru.aic.template_generator
Current Desktop: KDE

bug / false-positive

Most helpful comment

Hi @jpvantelon, I made another attempt to fix the issue in db20a997169fdcbd75454876d1284154ae3cc944 (can not reproduce though, but probably it's the constant resolving issue).

All 6 comments

Looks similar to #1555, which fixed ages ago. Will check what we can do here.

Okay, I added a handling for this case, please let me know if the issue not being fixed with the next plugin update (perhaps we have to dig deeper into your dev-environment, but I hope the patch will work).

Hi @kalessil, sorry for the delay.

Thanks for the new version of the plugin (4.0.5), but unfortunately, it doesn't fix the problem for me (or anyone on my team).

Everything is still exactly the same for the different cases shown in this ticket.

Hi @jpvantelon, I made another attempt to fix the issue in db20a997169fdcbd75454876d1284154ae3cc944 (can not reproduce though, but probably it's the constant resolving issue).

Thanks. Will try as soon as new version is available.

Confirmed working on version 4.0.6. Thanks !

Was this page helpful?
0 / 5 - 0 ratings