Phpinspectionsea: Unnecessary parenthesis completely changes meaning if removed

Created on 14 Apr 2018  路  2Comments  路  Source: kalessil/phpinspectionsea

Given the following code:

if ((yield $results->advance()) !== false) {

PHPEA claims the inner braces are redundant and thus changes the code to the following:

if (yield $results->advance() !== false) {

The former yields whatever $results->advance() returns, the latter yields a boolean. Since these two statements are non-equivalent this must be considered a bug in the inspection.

bug / false-positive fixed

Most helpful comment

Good catch @Bilge , thank you

All 2 comments

Good catch @Bilge , thank you

Fixed

Was this page helpful?
0 / 5 - 0 ratings