On 03/29/2011 10:48 AM, Platonides wrote:
I was expecting this the week hip-hop hit. What would be required "to target hip-hop"? How does that differ from working from Zend?
I've explored the issues and made some initial changes to my working copy. I'm now waiting for it to compile, and once it's tested, I'll commit it.
There is a list of things that differ here:
https://github.com/facebook/hiphop-php/blob/master/doc/inconsistencies
Unfortunately it seems to leave out the most important differences.
It seems incredible, and I'm hoping someone will correct me, but it seems that file inclusion has to be completely different in HipHop. Even the simplest script won't work. I put this in foo.php:
<?php class Foo { static function bar() { print "Hello\n"; } } ?>
And this in test.php:
<?php include 'foo.php'; Foo::bar(); ?>
This gives "HipHop Fatal error: Cannot redeclare class Foo" at runtime. All classes which are compiled exist from startup, and trying to declare them produces this error. This means that it is no longer possible to mix class and function declarations with code we want to execute. My working copy has fixes for the most important instances of this, such as in Setup.php and WebStart.php.
There are two exceptions to this. One is the interpreter. HipHop has an interpreter, which is used for eval() and for include() on a file with a fully-qualified path. We can use this to allow us to change LocalSettings.php without recompiling.
If you want to do include() and have it execute compiled code, you need to use a path which is relative to the base of the compiled code. My working copy has some functions which allow this to be done in a self-documenting way.
The other exception is volatile mode, which unfortunately appears to be completely broken, at least in the RPMs that I'm using. It's so broken that calling class_exists() on a literal string will break the class at compile time, making it impossible to use, with no way to repair it. My working copy has a wrapper for class_exists() which doesn't suffer from this problem.
Another undocumented difference is that HipHop does not use php.ini or anything like it, so most instances of ini_get() and ini_set() are broken. The functions exist, but only have stub functionality. HipHop has its own configuration files, but they aren't like php.ini.
When I'm ready to write all this up properly, the following page will appear on mediawiki.org:
http://www.mediawiki.org/wiki/HipHop
-- Tim Starling