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

False positive PhanCoalescingNeverNull in multi-dimensional array access in 2.4.7-dev #3638

Closed
TysonAndre opened this issue Jan 11, 2020 · 0 comments · Fixed by #3639
Closed
Assignees
Labels
bug A crash in Phan, a recent change causing incorrect analysis results, etc.

Comments

@TysonAndre
Copy link
Member

<?php
class Example {
    const X = [
        'foo' => [
            'a' => 'b',
        ],
    ];

    public function main(string $key) : ?string {
        // False positive PhanCoalescingNeverNull Using non-null self::X[$key]['a'] of type 'b' as the left hand side of a null coalescing (??) operation. The right hand side may be unnecessary.
        return self::X[$key]['a'] ?? null;
    }
}

Expected: Phan should infer the real type of self::X[$key] is nullable, and not warn.

@TysonAndre TysonAndre added the bug A crash in Phan, a recent change causing incorrect analysis results, etc. label Jan 11, 2020
@TysonAndre TysonAndre self-assigned this Jan 11, 2020
TysonAndre added a commit to TysonAndre/phan that referenced this issue Jan 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A crash in Phan, a recent change causing incorrect analysis results, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant