Coding-standard: RequiredShortTernaryOperator wrong fix

Created on 4 Jan 2021  路  4Comments  路  Source: slevomat/coding-standard

We have code like this in our codebase:

    public function qwe(string $someString)
    {
        return $someString === 'empty' || !$someString ? [] : $someString;
    }

When i check it with this rule suggested code is this:

-        return $someString === 'empty' || !$someString ? [] : $someString;
+        return $someString === 'empty' || $someString ?: [];

It completely ignores first part of condition. This is not fixable error if i see correctly.

Thanks.

Bug

Most helpful comment

All 4 comments

@aiphee What version did you tested? Can you test dev-master ?

Thanks for swift reply.

I have version 6.4.1 ran through "symplify/easy-coding-standard": "^9.0.14"

I tried explicitly setting slevomat/coding-standard to dev-master and result seems same.

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings