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 PhanRedundantCondition for possibly undefined variable with different real type set #3650

Closed
TysonAndre opened this issue Jan 13, 2020 · 0 comments · Fixed by #3652
Assignees
Labels
enhancement This improves the quality of Phan's analysis of a codebase

Comments

@TysonAndre
Copy link
Member

TysonAndre commented Jan 13, 2020

<?php
class X {
    /**
     * @param string $c
     */
    public function find($c) : void {
        $result = [];

        if ($c) {
            $result['c'] = $c;
        }
        '@phan-debug-var $result';

        // PhanRedundantCondition Redundant attempt to cast $result['c'] of type non-empty-mixed to isset
        if (isset($result['c'])) {
            echo "Found\n";
        }
    }
}

(Annotated)UnionType->getRealUnionType() should preserve whether the union type is possibly undefined.

@TysonAndre TysonAndre added the enhancement This improves the quality of Phan's analysis of a codebase label Jan 13, 2020
@TysonAndre TysonAndre self-assigned this Jan 13, 2020
TysonAndre added a commit to TysonAndre/phan that referenced this issue Jan 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This improves the quality of Phan's analysis of a codebase
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant