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 PhanTypeMismatch for cast from callable-object to callable shape #4343

Closed
TysonAndre opened this issue Jan 4, 2021 · 0 comments
Assignees
Labels
enhancement This improves the quality of Phan's analysis of a codebase

Comments

@TysonAndre
Copy link
Member

<?php
/**
 * @param callable(int):bool $x
 */
function foo(callable $x): bool {
    return $x(1);
}

function test($x): void {
    if (is_callable($x) && is_object($x)) {
        // PhanTypeMismatchArgument Argument 1 ($x) is $x of type callable-object but \foo() takes callable(int):bool defined at src/test.php:5
        foo($x);
    }
}

A recent change changed the expanded union type of classes with __invoke from including callable to callable-object
Possibly support callable-object(int):bool extended syntax

@TysonAndre TysonAndre added the enhancement This improves the quality of Phan's analysis of a codebase label Jan 4, 2021
@TysonAndre TysonAndre self-assigned this Jan 4, 2021
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

No branches or pull requests

1 participant