Skip to content
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

YodaComparison fix produces incorrect code. #1689

Open
Marian-Kechlibar opened this issue Jul 10, 2024 · 0 comments
Open

YodaComparison fix produces incorrect code. #1689

Marian-Kechlibar opened this issue Jul 10, 2024 · 0 comments

Comments

@Marian-Kechlibar
Copy link

When I run nette/coding-standard, which uses Slevomat Coding Standards, the YodaComparison fix seems to be breaking the following class:

<?php

declare(strict_types=1);

trait TestNullTrait
{
    public const NAME = 'name';

    public function renderNull(?ActiveRow $row): int
    {
        if (null === $row->{self::NAME}) {
            return 0;
        }
        return 1;
    }
}

The fix looks like this:

if ($row->{self::NAME === null}) {

Which is wrong, it should be

if ($row->{self::NAME} === null) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant