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.
32 lines
880 B
C++
32 lines
880 B
C++
<?hh
|
|
/**
|
|
* Copyright (c) 2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
*/
|
|
|
|
/**
|
|
* This file contains a bunch of php stubs for functions that have been added
|
|
* to hhvm (though aren't in a release yet). These are important because the
|
|
* Hack typechecker can understand them
|
|
*/
|
|
|
|
class InvariantViolationException extends Exception {}
|
|
|
|
function invariant(mixed $test, string $message): void {
|
|
if (!$test) {
|
|
invariant_violation($message);
|
|
}
|
|
}
|
|
|
|
function invariant_violation(string $message): void {
|
|
throw new InvariantViolationException($message);
|
|
}
|
|
|
|
function class_meth(string $class, string $method) {
|
|
return array($class, $method);
|
|
} |