/** * @param string $code * @return RealParsedFile */ public static function parse($code) { // Remove the hash-bang line if there, since PhpParser doesn't support it if (\substr($code, 0, 2) === '#!') { $code = \substr($code, strpos($code, "\n") + 1); } // Compile Hack to PHP if (\substr($code, 0, 4) === '<?hh') { $code = compile_hack($code); } $parser = new Parser(new Lexer()); $self = new self(); foreach ($parser->parse($code) as $node) { $self->processNode($node, ''); } return $self; }