hhvm icon indicating copy to clipboard operation
hhvm copied to clipboard

Typehint callable not supported

Open lstrojny opened this issue 14 years ago • 4 comments

PHP 5.4 introduces the callable typehint to allow closures, string $function and array($obj, 'method'). See http://php.net/manual/de/language.types.callable.php for details. HipHop analyzes callable as UnknownClass.

lstrojny avatar Sep 11 '12 08:09 lstrojny

HipHop does not currently support all PHP 5.4 features. We plan to add support for the "callable" typehint some time in the coming months.

paroski avatar Oct 12 '12 21:10 paroski

It's there now: https://github.com/facebook/hiphop-php/commit/cc37fe637a945bace3f0f6f7bbe32e33add2024c

ptarjan avatar May 13 '13 21:05 ptarjan

This is still failing for me:

<?php

function callMe(callable $b) {

    $b();

}

callMe(function() {

    echo "hello\n";

});

Throws:

HipHop Fatal error: Argument 1 passed to callMe() must be an instance of callable, Closure$callMe$47daeefeedcd4b135f362b25e98454cc$ given in /Users/evert/code/sabre/event/tests/foo3.php on line 7

Version:

$ hhvm --version
HipHop VM v2.3.0-dev (rel)
Compiler: heads/master-0-gf6413a9d4ca5a0646290bf180702e967ff1daf61
Repo schema: 536d56f98b940f0920eafa10249dca34d2e855de

evert avatar Dec 02 '13 22:12 evert

@paroski, this seems to work only when EnableHipHopSyntax=1. Any idea why?

scannell avatar Dec 02 '13 23:12 scannell