Danack / FunctionTypes

php needs function types
MIT License
3 stars 2 forks source link

checking type #1

Open Danack opened 4 years ago

Danack commented 4 years ago

Will people be able to check $callable instanceof function_type?

Danack commented 4 years ago

My instinct is to not use instance of for this, as that is to do with interfaces and although checking whether a 'callable' is compatible with a 'callable type' is similar, it is not the same.

Also, people would probably want to be able to detect problems, to be able to give sensible error messages, rather than just "no".

typedef foo = callable($x, $y): int;

function bar($x, $y): int|float {...}

$signatureProblems = get_signature_problems(foo, 'bar');

var_dump($signatureProblems);

//  "return type isn't compatible";