Phpinspectionsea: Wrong inspection behavior

Created on 8 Jul 2020  路  8Comments  路  Source: kalessil/phpinspectionsea

Local variable is needed, but inspection says it isn't
image
image

bug / false-positive

All 8 comments

@xepozz assign $response at return?

$response is used in finally statement

@xepozz you cant use return $response = ...

@xepozz you cant use return $response = ...

You definitely can:
https://3v4l.org/PiOFX

I'm not sure if you should, but there's no technical issue

@orklah technically possible, but this is bad practice:

result will be returned after the finally block is executed

if $response is object, then it's can be changed in "finally" block

I can move the return statement out of try/catch block, but this is a short form looks and works nice, I don't want to do this.

Hm, that pretty awesome use of finally =) I made a fix to support this case.

Thanks!

Was this page helpful?
0 / 5 - 0 ratings