language stringlengths 0 24 | filename stringlengths 9 214 | code stringlengths 99 9.93M |
|---|---|---|
Markdown | hhvm/hphp/hack/manual/hack/12-generics/04-type-parameters.md | A type parameter is a placeholder for a type that is supplied when a generic type is instantiated, or a generic method or function is invoked.
A type parameter is a compile-time construct. At run-time, each type parameter is matched to a run-time type that was specified by a
type argument.
The name of a type paramete... |
Markdown | hhvm/hphp/hack/manual/hack/12-generics/07-type-constraints.md | A *type constraint* on a generic type parameter indicates a requirement that a type must fulfill in order to be accepted as a type
argument for that type parameter. (For example, it might have to be a given class type or a subtype of that class type, or it might
have to implement a given interface.)
A constraint can h... |
Markdown | hhvm/hphp/hack/manual/hack/12-generics/10-variance.md | Hack supports both generic *covariance* and *contravariance* on a type parameter.
Each generic parameter can optionally be marked separately with a variance indicator:
* `+` for covariance
* `-` for contravariance
If no variance is indicated, the parameter is invariant.
## Covariance
If `Foo<int>` is a subtype of... |
Markdown | hhvm/hphp/hack/manual/hack/12-generics/19-type-erasure.md | Parameterized types with generics give you type safety without runtime
checks.
Generic type information is not available at runtime: this is called
"erasure". If you need this information, consider using [reified
generics](reified-generics).
```Hack
function takes_ints(vec<int> $items): vec<int> {
return $items;
}
... |
Markdown | hhvm/hphp/hack/manual/hack/13-contexts-and-capabilities/01-introduction.md | **Note:** Context and capabilities are enabled by default since
[HHVM 4.93](https://hhvm.com/blog/2021/01/19/hhvm-4.93.html).
Contexts and capabilities provide a way to specify a set of capabilities for a function's implementation and a permission system for its callers. These capabilities may be in terms of what func... |
Markdown | hhvm/hphp/hack/manual/hack/13-contexts-and-capabilities/02-local-operations.md | **Note:** Context and capabilities are enabled by default since
[HHVM 4.93](https://hhvm.com/blog/2021/01/19/hhvm-4.93.html).
The existence of a capability (or lack thereof) within the contexts of a function plays a direct role in the operations allowed within that function.
Consider the following potential (although... |
Markdown | hhvm/hphp/hack/manual/hack/13-contexts-and-capabilities/03-closures.md | **Note:** Context and capabilities are enabled by default since
[HHVM 4.93](https://hhvm.com/blog/2021/01/19/hhvm-4.93.html).
As with standard functions, closures may optionally choose to list one or more contexts. Note that the outer function may or may not have its own context list. Lambdas wishing to specify a list... |
Markdown | hhvm/hphp/hack/manual/hack/13-contexts-and-capabilities/04-higher-order-functions.md | **Note:** Context and capabilities are enabled by default since
[HHVM 4.93](https://hhvm.com/blog/2021/01/19/hhvm-4.93.html).
One may define a higher order function whose context depends on the dynamic context of one or more passed in function arguments.
```hack
function has_dependent_fn_arg(
(function()[_]: void) ... |
Markdown | hhvm/hphp/hack/manual/hack/13-contexts-and-capabilities/05-contexts-and-subtyping.md | **Note:** Context and capabilities are enabled by default since
[HHVM 4.93](https://hhvm.com/blog/2021/01/19/hhvm-4.93.html).
Capabilities are contravariant.
This implies that a closure that requires a set of capabilities S<sub>a</sub> may be passed where the expected type is a function that requires S<sub>b</sub> as... |
Markdown | hhvm/hphp/hack/manual/hack/13-contexts-and-capabilities/06-context-constants.md | **Note:** Context and capabilities are enabled by default since
[HHVM 4.93](https://hhvm.com/blog/2021/01/19/hhvm-4.93.html).
**Note:** Context constant *constraints* are available since HHVM 4.108.
Classes and interfaces may define context constants:
```hack no-extract
class WithConstant {
const ctx C = [io];
p... |
Markdown | hhvm/hphp/hack/manual/hack/13-contexts-and-capabilities/07-dependent-contexts-continued.md | **Note:** Context and capabilities are enabled by default since
[HHVM 4.93](https://hhvm.com/blog/2021/01/19/hhvm-4.93.html).
Dependent contexts may be accessed off of nullable parameters. If the dynamic value of the parameter is null, then the capability set required by that parameter is empty.
```hack no-extract
fu... |
Markdown | hhvm/hphp/hack/manual/hack/13-contexts-and-capabilities/08-available-contexts-and-capabilities.md | **Note:** Context and capabilities are enabled by default since
[HHVM 4.93](https://hhvm.com/blog/2021/01/19/hhvm-4.93.html).
The following contexts and capabilities are implemented at present.
## Capabilities
### IO
This gates the ability to use the `echo` and `print` intrinsics within function bodies.
Additionall... |
Markdown | hhvm/hphp/hack/manual/hack/14-reified-generics/01-introduction.md | **Topics covered in this section**
* [Reified Generics](reified-generics.md)
* [Reified Generics Migration](reified-generics-migration.md) |
Markdown | hhvm/hphp/hack/manual/hack/14-reified-generics/02-reified-generics.md | # Reified Generics
A _Reified Generic_ is a [Generic](/hack/generics/some-basics) with type information accessible at runtime.
## Introduction
Generics are currently implemented in HHVM through erasure, in which the runtime drops all information about generics. This means that generics are not available at runtime. ... |
Markdown | hhvm/hphp/hack/manual/hack/14-reified-generics/03-reified-generics-migration.md | # Migration Features for Reified Generics
In order to make migrating to reified generics easier, we have added the following migration features:
* The `<<__Soft>>` annotation on a type parameter implies the intent to switch it to reified state. If generics at call sites are not provided the type checker will raise an... |
Markdown | hhvm/hphp/hack/manual/hack/15-asynchronous-operations/01-introduction.md | Asynchronous operations allow cooperative multi-tasking. Code that utilizes the async infrastructure can hide I/O latency and data
fetching. So, if we have code that has operations that involve some sort of waiting (e.g., network access or database queries), async
minimizes the downtime our program has to be stalled b... |
Markdown | hhvm/hphp/hack/manual/hack/15-asynchronous-operations/07-awaitables.md | ```yamlmeta
{
"namespace": "HH\\Asio"
}
```
An *awaitable* is the key construct in `async` code. An awaitable is a first-class object that represents a possibly asynchronous
operation that may or may not have completed. We `await` the awaitable until the operation has completed.
An `Awaitable` represents a particul... |
Markdown | hhvm/hphp/hack/manual/hack/15-asynchronous-operations/10-exceptions.md | In general, an async operation has the following pattern:
* Call an `async` function
* Get an awaitable back
* `await` the awaitable to get a result
If an exception is thrown within an `async` function body, the function does not
technically throw - it returns an `Awaitable` that throws when resolved. This
means that ... |
Markdown | hhvm/hphp/hack/manual/hack/15-asynchronous-operations/13-async-blocks.md | Inside a lengthy async function, it's generally a good idea to group together data fetches that are independent of the rest of the
function. This reduces unneeded waiting for I/O.
To express this grouping inline, we would usually have to use a helper function; however, an async block allows for the immediate execution... |
Markdown | hhvm/hphp/hack/manual/hack/15-asynchronous-operations/14-concurrent.md | `concurrent` concurrently awaits all `await`s within a `concurrent` block and it works with [`await`-as-an-expression](await-as-an-expression.md) as well!
Note: [concurrent doesn't mean multithreading](some-basics#limitations)
## Syntax
```Hack no-extract
concurrent {
$x = await x_async();
await void_async();
... |
Markdown | hhvm/hphp/hack/manual/hack/15-asynchronous-operations/15-await-as-an-expression.md | To strike a balance between flexibility, latency, and performance, we require that the `await`s only appear in **unconditionally consumed expression positions**. This means that from the closest statement, the result of the `await` must be used under all non-throwing cases. This is important because all `await`s for a ... |
Markdown | hhvm/hphp/hack/manual/hack/15-asynchronous-operations/16-utility-functions.md | Async can be used effectively with the basic, built in infrastructure in HHVM, along with some HSL functions. This basic infrastructure includes:
* [`async`](../asynchronous-operations/introduction.md), [`await`](../asynchronous-operations/awaitables), [`Awaitable`](../asynchronous-operations/awaitables)
* `HH\Lib\Vec\... |
Markdown | hhvm/hphp/hack/manual/hack/15-asynchronous-operations/19-extensions.md | Async in and of itself is a highly useful construct that can provide possible time-saving through its cooperative multitasking
infrastructure. Async is especially useful with database access and caching, web resource access, and dealing with streams.
## MySQL
The async MySQL extension provides a Hack API to query MyS... |
Markdown | hhvm/hphp/hack/manual/hack/15-asynchronous-operations/22-generators.md | [Generators](http://php.net/manual/en/language.generators.overview.php) provide a more compact way to write an
[iterator](http://php.net/manual/en/language.oop5.iterations.php). Generators work by passing control back and forth between the
generator and the calling code. Instead of returning once or requiring something... |
Markdown | hhvm/hphp/hack/manual/hack/15-asynchronous-operations/28-guidelines.md | It might be tempting to just sprinkle `async`, `await` and `Awaitable` on all code. And while it is OK to have more `async` functions than
not—in fact, we should generally *not be afraid* to make a function `async` since there is no performance penalty for doing so—there are
some guidelines to follow in ord... |
Markdown | hhvm/hphp/hack/manual/hack/15-asynchronous-operations/31-examples.md | Here are some examples representing a slew of possible async scenarios. Obviously, this does not cover all possible situations, but they
provide an idea of how and where async can be used effectively. Some of these examples are found spread out through the rest of the async
documentation; they are added here again for ... |
Markdown | hhvm/hphp/hack/manual/hack/16-readonly/01-introduction.md | `readonly` is a keyword used to create immutable references to [Objects](/hack/classes/introduction) and their properties.
### How does it work?
Expressions in Hack can be annotated with the `readonly` keyword. When an object or reference is readonly, there are two main constraints on it:
* **Readonlyness:** Object pr... |
Markdown | hhvm/hphp/hack/manual/hack/16-readonly/02-syntax.md | The `readonly` keyword can be applied to various positions in Hack.
## Parameters and return values
Parameters and return values of any callable (e.g. a function or method) can be marked `readonly`.
```Hack
class Bar {
public function __construct(
public Foo $foo,
){}
}
class Foo {
public function __constru... |
Markdown | hhvm/hphp/hack/manual/hack/16-readonly/03-subtyping.md | From a typing perspective, one can think of a readonly object as a [supertype](/hack/types/supertypes-and-subtypes) of its mutable counterpart.
For example, readonly values cannot be passed to a function that takes mutable values.
```Hack error
class Foo {
public int $prop = 0;
}
function takes_mutable(Foo $x): voi... |
Markdown | hhvm/hphp/hack/manual/hack/16-readonly/04-explicit-readonly-keywords.md | There are a few places where an explicit readonly keyword is required when using readonly values.
## Calling a readonly function
Calling a function or method that returns readonly requires wrapping the result in a readonly expression.
```Hack
class Foo {}
function returns_readonly(): readonly Foo {
return readonly... |
Markdown | hhvm/hphp/hack/manual/hack/16-readonly/05-containers-and-collections.md | ## Basics
Readonly values cannot be written to normal container types (such as`vec`, `Vector`, or `dict`):
```Hack error
class Foo {}
function container_example(readonly Foo $x) : void {
$container = vec[];
$container[] = $x; // error, $x is readonly
}
```
To use readonly values within a container, you can either... |
Markdown | hhvm/hphp/hack/manual/hack/16-readonly/06-advanced-semantics.md | This page lists some more complicated interactions and nuances with readonly.
## `readonly (function (): T)` versus `(readonly function(): T)`: references vs. objects
A `(readonly function(): T)` may look very similar to a `readonly (function(): T)`, but they are actually different. The first denotes a readonly closur... |
Markdown | hhvm/hphp/hack/manual/hack/17-modules/01-introduction.md | Modules are an experimental feature for organizing code and separating your internal and external APIs. Modules are collections of Hack files that share an identity or utility.
## Module definitions
You can define a new module with the `new module` keywords.
```hack file:foomodule.hack
//// module.hack
new module foo... |
Markdown | hhvm/hphp/hack/manual/hack/17-modules/02-defining-modules.md | ## Defining modules
You can define a module with the `new module` syntax. A module, just like any other toplevel entity (classes, functions, etc), can have at most one definition.
```hack
new module foo {}
```
Module names live in their own namespace, and do not conflict with classes, functions, etc. Module names are ... |
Markdown | hhvm/hphp/hack/manual/hack/17-modules/03-using-internal.md | ## Internal and module level visibility
One goal of using modules is to separate a code unit's public and private APIs. If a file is part of a module, its toplevel functions, classes, interfaces, traits, enums, and typedefs can be marked `internal`. An internal toplevel symbol cannot be referenced outside of its module... |
Markdown | hhvm/hphp/hack/manual/hack/17-modules/04-inheritance.md | ## Inheriting methods and properties
In general, override rules for internal class members are consistent with that of private and protected: you can only override a class member with a visibility that's at least as visible as the previous.
```hack no-extract
module foo;
class Foo {
internal function foo(): void {... |
Markdown | hhvm/hphp/hack/manual/hack/17-modules/05-traits.md | Traits have special behavior in Hack when used with modules.
## Marking traits internal
An internal trait can only be used within the module it's defined. Internal traits can have public, protected, or internal methods.
```hack
//// newmodule.hack
new module foo {}
//// foo.hack
module foo;
internal trait TFoo {
p... |
Markdown | hhvm/hphp/hack/manual/hack/17-modules/06-type-aliases.md | Type aliases have special rules when it comes to internal types depending on which kind of type alias is used.
## Internal type aliases
A type alias declared with `type` can be marked internal. Just as with classes, this means that the type can only be referenced from within the module.
```hack
//// newmodule.hack
ne... |
Markdown | hhvm/hphp/hack/manual/hack/17-modules/07-closures-and-function-pointers.md | Within a module, you can create a pointer to an internal function and pass it anywhere for use. Pointers to internal functions can only be created from within a module, but can be called and acccessed from anywhere.
```hack
//// newmodule.hack
new module foo {}
//// foo.hack
module foo;
internal function f() : void {... |
Markdown | hhvm/hphp/hack/manual/hack/17-modules/08-reflection-and-migration.md | ## Reflection
You can reflect on the module of a class or function using its corresponding methods.
```Hack no-extract
ReflectionClass::getModule();
ReflectionFunctionAbstract::getModule();
```
You can check if a class, method or property is internal with the `isInternalToModule()` function.
```hack no-extract
Refl... |
Markdown | hhvm/hphp/hack/manual/hack/20-attributes/01-introduction.md | Attributes attach metadata to Hack definitions.
Hack provides built-in attributes that can change runtime or
typechecker behavior.
```Hack
<<__Memoize>>
function add_one(int $x): int {
return $x + 1;
}
```
You can attach multiple attributes to a definition, and attributes can
have arguments.
``` Hack
<<__Consiste... |
Markdown | hhvm/hphp/hack/manual/hack/20-attributes/07-predefined-attributes.md | The following attributes are defined:
* [__AcceptDisposable](#__acceptdisposable)
* [__ConsistentConstruct](#__consistentconstruct)
* [__Deprecated](#__deprecated)
* [__Docs](#__docs)
* [__DynamicallyCallable](#__dynamicallycallable)
* [__DynamicallyConstructible](#__dynamicallyconstructible)
* [__EnableMethodTraitDiam... |
Markdown | hhvm/hphp/hack/manual/hack/21-XHP/01-setup.md | XHP provides a native XML-like representation of output.
After adding the required dependencies, read the [Introduction](/hack/XHP/introduction).
## The XHP-Lib Library
While XHP syntax is a part of the Hack language, implementation is in [XHP-Lib](https://github.com/hhvm/xhp-lib/), a library that needs to be install... |
Markdown | hhvm/hphp/hack/manual/hack/21-XHP/04-introduction.md | XHP provides a native XML-like representation of output (which is usually HTML). This allows UI code to be typechecked, and automatically
avoids several common issues such as cross-site scripting (XSS) and double-escaping. It also applies other validation rules, e.g., `<head>`
must contain `<title>`.
Using traditional... |
Markdown | hhvm/hphp/hack/manual/hack/21-XHP/07-basic-usage.md | XHP is a syntax to create actual Hack objects, called *XHP objects*. They are meant to be used as a tree, where children can either be
other XHP objects or text nodes (or, rarely, other non-XHP objects).
## Creating a Simple XHP Object
Instead of using the `new` operator, creating XHP looks very much like XML:
```Ha... |
Markdown | hhvm/hphp/hack/manual/hack/21-XHP/10-interfaces.md | There are two important XHP types, the `\XHPChild` interface (HHVM built-in) and
the `\Facebook\XHP\Core\node` base class (declared in XHP-Lib). You will most
commonly encounter these in functions' return type annotations.
## `\XHPChild`
XHP presents a tree structure, and this interface defines what can be valid chil... |
Markdown | hhvm/hphp/hack/manual/hack/21-XHP/13-methods.md | Remember, all XHP Objects derive from the [`\Facebook\XHP\Core\node`](/hack/XHP/interfaces) base class, which has some public methods that can be called.
Method | Description
--------|------------
`toStringAsync(): Awaitable<string>` | Renders the element to a string for output. Mutating methods like `setAttribute` ca... |
Markdown | hhvm/hphp/hack/manual/hack/21-XHP/16-extending.md | XHP comes with classes for all standard HTML tags, but since these are first-class objects, you can create your own XHP classes for rendering
items that are not in the standard HTML specification.
## Basics
XHP class names must follow the same rules as any other Hack class names:
Letters, numbers and `_` are allowed ... |
Markdown | hhvm/hphp/hack/manual/hack/21-XHP/19-migration.md | You can incrementally port code to use XHP.
Assume your output is currently handled by the following function, which might
be called from many places.
```hack no-extract
function render_component(string $text, Uri $uri): string {
$uri = htmlspecialchars($uri->toString());
$text = htmlspecialchars($text);
return... |
Markdown | hhvm/hphp/hack/manual/hack/21-XHP/22-guidelines.md | Here are some general guidelines to know and follow when using XHP. In addition to its [basic usage](basic-usage.md),
[available methods](methods.md) and [extending XHP with your own objects](extending.md), these are other tips to make the best use of XHP.
## Validation of Attributes and Children
The constraints of X... |
Markdown | hhvm/hphp/hack/manual/hack/21-XHP/25-further-resources.md | Besides our documentation, there are some other very useful resources to enhance your experience with XHP.
* [XHP Library](https://github.com/facebook/xhp-lib): The class libraries for XHP.
* [XHP Announcement](https://www.facebook.com/notes/facebook-engineering/xhp-a-new-way-to-write-php/294003943919): The original XH... |
Markdown | hhvm/hphp/hack/manual/hack/30-silencing-errors/01-introduction.md | Errors reported by the Hack typechecker can be silenced with
`HH_FIXME` and `HH_IGNORE_ERROR` comments. Errors arising from type mismatches
on expressions may also be silenced using the `HH\FIXME\UNSAFE_CAST` function.
## Silencing Errors with `HH\FIXME\UNSAFE_CAST`
```no-extract
takes_int(HH\FIXME\UNSAFE_CAST<string... |
Markdown | hhvm/hphp/hack/manual/hack/30-silencing-errors/05-error-codes.md | This page lists the most common error codes, and suggests how to fix
them. You can see the full list of error codes in
[error_map.ml](https://github.com/facebook/hhvm/blob/master/hphp/hack/src/errors/error_codes.ml).
## 1002: Top-level code
```Hack no-extract
function foo(): void {}
/* HH_FIXME[1002] Top-level code ... |
Markdown | hhvm/hphp/hack/manual/hack/40-contributing/01-introduction.md | This website is itself written in Hack and running on HHVM. You can
see the current [HHVM version used on the deployed site](https://github.com/hhvm/user-documentation/blob/main/.deploy/built-site.Dockerfile#L3).
## Prerequisites
You'll need HHVM
(see [installation instructions](/hhvm/installation/introduction))
inst... |
Markdown | hhvm/hphp/hack/manual/hack/40-contributing/06-writing-content.md | The website has three content sections:
* [Hack
guides](https://github.com/hhvm/user-documentation/tree/main/guides/hack)
describe the Hack language
* [HHVM
guides](https://github.com/hhvm/user-documentation/tree/main/guides/hhvm)
describe how to install, configure and run the HHVM runtime
* The API reference ... |
Markdown | hhvm/hphp/hack/manual/hack/40-contributing/10-code-samples.md | All code samples are automatically type checked and executed, to ensure they're correct.
## Basic Usage
Code samples require triple backticks, and a file name.
~~~
```example.hack
<<__EntryPoint>>
function main(): void {
echo "Hello world!\n";
}
```
~~~
The build script will create a file of this name, type check... |
Markdown | hhvm/hphp/hack/manual/hack/40-contributing/12-information-macros.md | This website supports note, tip, caution, and danger macro messages.
## Note Message
```yamlmeta
{
"note": [
"This change was introduced in [HHVM 4.136](https://hhvm.com/blog/2021/11/19/hhvm-4.136.html)."
]
}
```
The `noreturn` type can be upcasted to `dynamic`.
## Tip Message
```yamlmeta
{
"tip": [
"T... |
Markdown | hhvm/hphp/hack/manual/hack/40-contributing/15-generated-content.md | ## Generating Markdown
Occasionally you may want to generate markdown programmatically. For
example, the [supported PHP INI settings
table](/hhvm/configuration/INI-settings#supported-php-ini-settings) is
autogenerated.
1. Define a `BuildStep` for the data you want to generate the markdown
from. See
[PHPIniSuppo... |
Markdown | hhvm/hphp/hack/manual/hack/51-experimental-features/01-introduction.md | The following pages of documentation describe Hack language features in the *experimental* phase.
## About Experimental Features
We have documented these features as they may appear in built-ins, including the Hack Standard Library.
We _do not_ recommend using any of these features until they are formally announced a... |
Markdown | hhvm/hphp/hack/manual/hack/55-expression-trees/01-introduction.md | Expression trees are an experimental Hack feature that allow you write domain specific languages (DSLs) with Hack syntax.
You can write expressions using normal Hack syntax, and all the normal Hack tools work: syntax highlighting, type checking, and code completion.
Unlike normal Hack code, **expression tree code is ... |
Markdown | hhvm/hphp/hack/manual/hack/55-expression-trees/05-syntax-supported.md | Expression tree DSLs can use most of the expression and statement syntax in Hack.
For a full list of supported syntax, see also [expr_tree.hhi](https://github.com/facebook/hhvm/blob/master/hphp/hack/test/hhi/expr_tree.hhi).
## Literals
| Example | Visitor Runtime | Typing |
|------... |
Markdown | hhvm/hphp/hack/manual/hack/55-expression-trees/10-splicing.md | Expression trees support "splicing", where you insert one expression tree into another.
```hack
<<file:__EnableUnstableFeatures('expression_trees')>>
function splicing_example(bool $b): ExprTree<ExampleDsl, mixed, ExampleString> {
$name = $b ? ExampleDsl`"world"` : ExampleDsl`"universe"`;
return ExampleDsl`"Hello... |
Markdown | hhvm/hphp/hack/manual/hack/55-expression-trees/15-defining-dsls.md | Adding a DSL to Hack requires you to define a new visitor.
This page will demonstrate defining a DSL supporting integer arithmetic:
```hack no-extract
$e = MyDsl`1 + 2`;
```
## DSLs are opt-in
Hack only allows expression tree syntax usage for approved DSLs. These are specified in `.hhconfig`.
```
allowed_expressio... |
Markdown | hhvm/hphp/hack/manual/hack/55-expression-trees/20-dsl-types.md | For every literal supported in a DSL, the visitor must provide a stub method that shows what type it should have.
```Hack file:types.hack
class MyDsl {
// Types for literals
public static function intType(): MyDslInt {
throw new Exception();
}
public static function floatType(): MyDslFloat {
throw new ... |
Markdown | hhvm/hphp/hack/manual/hack/56-memoization-options/01-introduction.md | ```yamlmeta
{
"fbonly messages": [
"There is [an internal wiki](https://www.internalfb.com/intern/wiki/Hack_Foundation/Memoization_options/) with more, Meta-specific guidance."
]
}
```
The `__Memoize` and `__MemoizeLSB` attributes in Hack support experimental options that control how the function behaves with ... |
hhvm/hphp/hack/scripts/.ocamlformat | # -*- conf -*-
# The .ml files in this directory are scripts for utop, not normal ocaml syntax.
disable = true | |
Shell Script | hhvm/hphp/hack/scripts/build_and_run.sh | #!/bin/bash
# Copyright (c) 2015, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the "hack" directory of this source tree.
set -e
SCRIPT_DIR="$(dirname "$0")"
FBCODE_ROOT="$(realpath "${SCRIPT_DIR}/../../../")"
HPHP_ROOT="${FBCODE_ROOT}/hphp... |
Shell Script | hhvm/hphp/hack/scripts/concatenate_all.sh | #!/bin/sh
# First arg is implicit with buck
INSTALL_DIR="${1#--install_dir=}"
ROOT="${2#--root=}"
OUTPUT_FILE="${3#--output_file=}"
if [ "${OUTPUT_FILE#/}" = "${OUTPUT_FILE}" ]; then
OUTPUT_FILE="${INSTALL_DIR}/${OUTPUT_FILE}"
fi
mkdir -p "$(dirname "${OUTPUT_FILE}")"
set -e
(
find "${ROOT}" -name "*.php" -o -n... |
hhvm/hphp/hack/scripts/dune | (rule
(targets get_build_id_gen.c)
(deps gen_build_id.ml utils.ml)
(action
(run ocaml -I scripts -w -3 unix.cma gen_build_id.ml get_build_id_gen.c))) | |
Shell Script | hhvm/hphp/hack/scripts/fail_on_unclean_repo.sh | #!/bin/bash
echo "List of modified files:"
CHANGED_FILES="$(hg st)"
echo "$CHANGED_FILES"
if [[ -z "$CHANGED_FILES" ]]
then
echo "No files changed!"
else
echo "ERROR: Files have changed! Please run \"$1\" and amend generated files into diff."
exit 1
fi |
Shell Script | hhvm/hphp/hack/scripts/generate_full_fidelity.sh | #!/bin/bash
set -u # terminate upon read of uninitalized variable
set -e # terminate upon non-zero-exit-codes (in case of pipe, only checks at end of pipe)
set -o pipefail # in a pipe, the whole pipe runs, but its exit code is that of the first failure
trap 'echo "exit code $? at line $LINENO" >&2' ERR
set -x # echo e... |
Shell Script | hhvm/hphp/hack/scripts/generate_hhis.sh | #!/bin/bash
set -e
# Shell suggests [ -z foo ] || ... which is invalid syntax
# shellcheck disable=SC2166
if [ -z "$1" -o -z "$2" -o -z "$3" -o -z "$4" ]; then
echo "Usage: $0 HH_PARSE_EXECUTABLE SOURCE_DIR OUTPUT_DIR STAMP_FILE"
exit 1
fi
HH_PARSE="$1"
SOURCE_DIR="${2%/}"
OUTPUT_DIR="${3%/}"
STAMP_FILE="$4"
if ... |
OCaml | hhvm/hphp/hack/scripts/gen_build_id.ml | (*
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the "hack" directory of this source tree.
*
*)
#use "utils.ml"
(**
* Computes some build identifiers based on the current commit. These IDs are
* used t... |
OCaml | hhvm/hphp/hack/scripts/gen_index.ml | (*
* Copyright (c) 2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the "hack" directory of this source tree.
*
*)
#use "scripts/utils.ml"
let get_idx =
let idx = ref 100 in
fun () -> incr idx; !idx
let rec iter rc dir =
le... |
Shell Script | hhvm/hphp/hack/scripts/invoke_cargo.sh | #!/bin/bash
set -e
HACK_SOURCE_ROOT="${HACK_SOURCE_ROOT:-$HACKDIR}"
HACK_BUILD_ROOT="${HACK_BUILD_ROOT:-$HACKDIR}"
if [ -z "$HACK_SOURCE_ROOT" ]; then
echo >&2 "ERROR: must set HACK_SOURCE_ROOT to point to hphp/hack source dir"
exit 1
fi
if (( "$#" < 2 )); then
echo "Usage: CARGO_BIN=path/to/cargo-bin $0 PAC... |
OCaml | hhvm/hphp/hack/scripts/utils.ml | (*
* Copyright (c) 2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the "hack" directory of this source tree.
*
*)
let with_pipe f =
let (fd_r, fd_w) = Unix.pipe () in
try
let res = f fd_r fd_w in
Unix.close fd_r;
U... |
hhvm/hphp/hack/src/.ocp-indent | # -*- conf -*-
# Starting the configuration file with a preset ensures you won't fallback to
# definitions from "~/.ocp/ocp-indent.conf".
# These are `normal`, `apprentice` and `JaneStreet` and set different defaults.
normal
#
# INDENTATION VALUES
#
# Number of spaces used in all base cases, for example:
# let... | |
hhvm/hphp/hack/src/Cargo.lock | # This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "aast_parser"
version = "0.0.0"
dependencies = [
"bitflags 1.3.2",
"bumpalo",
"core_utils_rust",
"decl_mode_parser",
"hash",
"hh_autoimport_rust",
"lowerer",
"mode_parser",
"namespaces_rus... | |
TOML | hhvm/hphp/hack/src/Cargo.toml | [workspace]
members = [
"arena_collections",
"arena_trait",
"asdl_to_rust/lrgen",
"client/ide_service/cargo/rust_batch_index_ffi",
"custom_error/cargo/custom_error_config_ffi",
"decl/cargo/rust_decl_ffi",
"decl/direct_decl_smart_constructors",
"deps/cargo/deps_rust",
"deps/cargo/deps... |
hhvm/hphp/hack/src/dune | (env
(_
(flags
(:standard -w @a-4-29-35-41-42-44-45-48-50-70 \ -strict-sequence))))
(executable
(name hh_single_type_check)
(modules hh_single_type_check)
(modes exe byte_complete)
(link_flags
(:standard
(:include dune_config/ld-opts.sexp)))
(libraries
camlp-streams
ifc
ifc_lib
client_get_defin... | |
OCaml | hhvm/hphp/hack/src/fullFidelityParseArgs.ml | (*
* Copyright (c) 2016, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the "hack" directory of this source tree.
*
*)
type t = {
(* Output options *)
full_fidelity_json_parse_tree: bool;
full_fidelity_json: bool;
full_fidelity... |
OCaml | hhvm/hphp/hack/src/generate_full_fidelity.ml | (*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the "hack" directory of this source tree.
*
*)
open Hh_prelude
let () =
List.iter
Generate_full_fidelity_data.templates
~f:Full_fidelity_schema.generate_file |
OCaml | hhvm/hphp/hack/src/generate_full_fidelity_data.ml | (*
* Copyright (c) 2016, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the "hack" directory of this source tree.
*
*)
module OcamlPrintf = Printf
open Hh_prelude
open Printf
open Full_fidelity_schema
let full_fidelity_path_prefix = "... |
OCaml | hhvm/hphp/hack/src/generate_hhi.ml | (*
* Copyright (c) 2016-present , Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the "hack" directory of this source tree.
*
*)
(**
* Usage: hh_parse --generate-hhi [FILE]
*
* Generates a .hhi file from a .hack or .php file; intende... |
OCaml | hhvm/hphp/hack/src/hackfmt.ml | (*
* Copyright (c) 2016, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the "hack" directory of this source tree.
*
*)
open Hh_prelude
module SyntaxError = Full_fidelity_syntax_error
module SyntaxTree =
Full_fidelity_syntax_tree.With... |
OCaml | hhvm/hphp/hack/src/hh_client.ml | (*
* Copyright (c) 2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the "hack" directory of this source tree.
*
*)
(**
* Hack for HipHop: type checker's client code.
*
* This code gets called in various different ways:
* - from... |
OCaml | hhvm/hphp/hack/src/hh_deps.ml | (*
* Copyright (c) 2021, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the "hack" directory of this source tree.
*
*)
open Hh_prelude
let children_files (file_list : String.t list) =
let module StringSet = Set.Make (String) in
le... |
OCaml | hhvm/hphp/hack/src/hh_parse.ml | (*
* Copyright (c) 2016, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the "hack" directory of this source tree.
*
*)
(**
*
* Usage: hh_parse [OPTIONS] [FILES]
*
* --full-fidelity-json
* --full-fidelity-json-parse-tree
* -... |
OCaml | hhvm/hphp/hack/src/hh_server.ml | (*
* Copyright (c) 2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the "hack" directory of this source tree.
*
*)
(**
* Hack for HipHop: type checker daemon code.
*
* See README for high level overview.
*
* Interesting files/... |
OCaml | hhvm/hphp/hack/src/hh_single_ai.ml | (*
* Copyright (c) 2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the "hack" directory of this source tree.
*
*)
open Hh_prelude
(*****************************************************************************)
(* Types, constants... |
OCaml | hhvm/hphp/hack/src/hh_single_complete.ml | (*
* Copyright (c) 2021, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the "hack" directory of this source tree.
*
*)
open Hh_prelude
let comma_string_to_iset (s : string) : ISet.t =
Str.split (Str.regexp ", *") s |> List.map ~f:in... |
OCaml | hhvm/hphp/hack/src/hh_single_decl.ml | (*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the "hack" directory of this source tree.
*
*)
open Hh_prelude
open Direct_decl_parser
let popt
~auto_namespace_map
~enable_xhp_class_modifier
~disable_xhp_elem... |
OCaml | hhvm/hphp/hack/src/hh_single_fanout.ml | (*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the "hack" directory of this source tree.
*
*)
open Hh_prelude
type options = { debug: bool }
let deps_mode = Typing_deps_mode.InMemoryMode None
let tcopt =
{
Glo... |
OCaml | hhvm/hphp/hack/src/hh_single_type_check.ml | (*
* Copyright (c) 2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the "hack" directory of this source tree.
*
*)
open Hh_prelude
open Sys_utils
module Cls = Decl_provider.Class
(***************************************************... |
OCaml | hhvm/hphp/hack/src/lwt_unix.ml | (*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the "hack" directory of this source tree.
*
*)
(** This file exists only to ensure that we don't accidentally link hh_server
against Lwt_unix. Something about the Lwt_unix m... |
Shell Script | hhvm/hphp/hack/src/oxidized_regen.sh | #!/bin/bash
set -u # terminate upon read of uninitalized variable
set -o pipefail # in a pipe, the whole pipe runs, but its exit code is that of the first failure
CYAN=""
WHITE=""
BOLD=""
RESET=""
# If these fail that's just fine.
if [ -t 1 ]; then
CYAN=$(tput setaf 6)
WHITE=$(tput setaf 7)
BOLD=$(tput bo... |
Markdown | hhvm/hphp/hack/src/style_guide.md | Style Guide
===========
As far as indentation rules go, ocp-indent should be used as the final word.
However, here are some examples.
Let Expressions
---------------
Try to fit a `let ... in` onto one line:
let foo = bar x y z in
...
If the expression is too long, first try
let foo =
some_long_... |
hhvm/hphp/hack/src/_tags | true: package(unix),package(str),package(bigarray),package(ppx_deriving.std)
<**/*.ml*>: ocaml, warn_A, warn(-3-4-6-29-35-44-48-50-52)
<*.ml*>: warn(-27)
<hhi/hhi.ml>: ppx(ppx/ppx_gen_hhi hhi)
<client/*.ml*>: warn(-27)
<deps/*.ml*>: warn(-27)
<dfind/*.ml*>: warn(-27)
<format/*.ml*>: warn(-27)
<heap/*.ml*>: warn(-27-34)... | |
hhvm/hphp/hack/src/ai/dune | (* -*- tuareg -*- *)
let library_entry name suffix =
Printf.sprintf
"(library
(name %s)
(wrapped false)
(modules)
(libraries %s_%s))" name name suffix
let executable_entry is_fb name =
if is_fb then
Printf.sprintf
"(executable
(name %s)
(modules %s)
(modes exe byte_comple... | |
OCaml | hhvm/hphp/hack/src/ai/zoncolan.ml | (*
* Copyright (c) 2018, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the "hack" directory of this source tree.
*
*)
(* Intentionally left blank *) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.