Files
linguist/samples/Hack/MySecureRequest.hh
Josh Watzman b2cb74cabf Add detection for Hack files with ".hh" file extension
Hack is Facebook's dialect of PHP: http://hacklang.org/. This adds support for detecting it via the ".hh" file extension; although that extension techincally conflicts with C++ headers, the files look different enough that the existing classifier based on sample code has no trouble distinguising them.

This diff deliberately does not deal with detecting ".php" as another valid extension for Hack code. That's much trickier since the code looks basically identical to PHP to the classifier, and needs a different approach.
2014-10-21 15:35:57 -07:00

14 lines
480 B
C++

<?hh // strict
require_once $_SERVER['DOCUMENT_ROOT'].'/core/funs/init.php';
final class MySecureRequest {
public function __construct(private Map<string, mixed> $GETParams) {}
public function stringParam(string $name): UNESCAPED_STRING {
invariant($this->GETParams->contains($name), 'Unknown GET param: '.$name);
$raw_string = $this->GETParams[$name];
invariant(is_string($raw_string), $name.' is not a string');
return unescaped_string($raw_string);
}
}