1

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.

Josh Watzman
  • 7,060
  • 1
  • 18
  • 26
user280209
  • 675
  • 5
  • 5
  • Only tangentially related, but if you're doing a PHP to Hack conversion, you may want to look at the existing tools that FB open sourced with Hack: http://docs.hhvm.com/manual/en/install.hack.conversion.php is the official docs, and https://www.youtube.com/watch?v=5tEnAL_Fad4&index=3&list=PLb0IAmt7-GS2fdbb1vVdP8Z8zx1l2L8YS is a talk I gave about them. – Josh Watzman Aug 26 '14 at 17:41

1 Answers1

2

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.

  • Thank you :) Can you direct me to the resource that you found the hhvm.enable_hip_hop_syntax documentation? I was trying hhvm.enable_hiphop_syntax, and had no luck... – user280209 Aug 26 '14 at 13:50
  • Don't worry about the option (which might be `hhvm.force_hh` in INI, or maybe both what Simon and I said will work, but it doesn't matter). It's a leftover from before Hack existed -- several Hack features predate Hack itself in HHVM, and there had to be an option to turn them on. Nowadays, just use the ` – Josh Watzman Aug 26 '14 at 17:40