mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 09:40:21 +00:00
Based on top of PR#1447. Adds a simple heuristic check for Hack files vs PHP files (`<?hh` vs other `<?`). Tested by verifying that the Hack example site was detected as 100% Hack and that Laravel was detected as 100% PHP. (Without the heuristic, Laravel gets detected as about 50% Hack, just by randomness in the classifier since PHP and Hack are very hard to distinguish unless you actually parse the file and look for specific language features.)
32 lines
880 B
PHP
32 lines
880 B
PHP
<?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);
|
|
} |