0

I am new to HipHop and I'm trying to get a custom PHP application to compile and run and the compilation error log file contains hundreds of errors relating to the $this variable being "Undeclared".. here is a simplified example:-

file bar.php:

class Bar {
     private $_baz = 'Hello';

     public function __construct() {
         echo 'Constructed';
     }

     public function foo() {
         echo $this->_baz;
     }
}

$bah = new Bar();
$bah->foo();

this file is listed as the only entry in a list text file f.lst and the HipHop compiler is invoked...

root@hiphop:/home/rich/www# hhvm --hphp --input-list=f.lst -k 1 --log=3
running hphp...
creating temporary directory /tmp/hphp_rC6OVL ...
parsing inputs...
parsing inputs took 0'00" (3605 us) wall time
pre-optimizing...
pre-optimizing took 0'00" (1757 us) wall time
analyze includes...
analyze includes took 0'00" (4 us) wall time
inferring types...
inferring types took 0'00" (1503 us) wall time
post-optimizing...
post-optimizing took 0'00" (2870 us) wall time
creating binary HHBC files...
creating binary HHBC files took 0'00" (254854 us) wall time
saving code errors...
all files saved in /tmp/hphp_rC6OVL ...
running hphp took 0'00" (357323 us) wall time

the resulting JSON error log /tmp/hphp_rC60VL/CodeError.js - contains this:-

[1,{"UseUndeclaredVariable":[{"c1":["bar.php",11,8,11,12]
 ,"d":"$this"}
]
}
]

Am I missing something obvious here?

TIA

Rich06
  • 61
  • 4

2 Answers2

2

Since I posted my question I raised an issue on GitHub and I was informed that they have fixed the bug that caused the issue -> https://github.com/facebook/hiphop-php/issues/698 - I've been diverted onto other things so I haven't had a chance to verify this yet but would assume it is OK now.

Rich Gray
  • 29
  • 4
0

Was this on HHVM? Trying your example works perfectly fine on HHVM for me.

Paul Tarjan
  • 48,968
  • 59
  • 172
  • 213