Search code examples
hhvmhacklang

Setting EnableHipHopSyntax to True with HHVM


When I run my code, I get the following error:

Syntax only allowed with -v Eval.EnableHipHopSyntax=true in /var/web/site/myfile.php on line 26

myfile.php has a function at that line that has:

public static function set (
string $theme                   // <str> The theme to set as active.
,   string $style = "default"       // <str> The style that you want to set.
,   string $layout = "default"      // <str> The layout that you want to assign.
): string                           // RETURNS <str>

The bottom line, ): string" is the appropriate syntax for the hack language, but for some reason HHVM decided to brilliantly disable its own syntax by default.

I can't seem to find any documentation with HHVM that indicates how to set that config file. How can one go about this process?

Edit:

It turns out my HHVM conversion tool was not converting <?php to <?hh as I had instructed it to, due to having converted itself. In other words, it was attempting to convert <?hh to <?hh, which did me no good.

I had mistakenly assumed that HHVM was disabling it for <?hh tags, which was not the case.


Solution

  • This syntax is part of Hack, but you have a PHP file. If you change the opening tag from <?php to <?hh, it'll work.

    Alternatively, you can add hhvm.enable_hip_hop_syntax = true to /etc/hhvm/php.ini.