mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 09:40:21 +00:00
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.
14 lines
480 B
C++
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);
|
|
}
|
|
}
|