├── guides ├── hhvm │ ├── 98-FAQ │ │ ├── faq-category.txt │ │ └── faq-summary.txt │ ├── 01-installation │ │ ├── installation-category.txt │ │ ├── installation-summary.txt │ │ └── 08-deprecated-support.md │ ├── 02-basic-usage │ │ ├── basic-usage-category.txt │ │ └── basic-usage-summary.txt │ ├── 05-extensions │ │ ├── extensions-category.txt │ │ └── extensions-summary.txt │ ├── 03-advanced-usage │ │ ├── advanced-usage-category.txt │ │ ├── advanced-usage-summary.txt │ │ └── 03-daemon.md │ └── 04-configuration │ │ ├── configuration-category.txt │ │ ├── guides-generated-markdown │ │ └── configuration-summary.txt └── hack │ ├── 21-XHP │ ├── _category_.json │ └── 25-further-resources.md │ ├── 10-types │ └── _category_.json │ ├── 06-classes │ ├── _category_.json │ └── 01-introduction.md │ ├── 12-generics │ └── _category_.json │ ├── 16-readonly │ └── _category_.json │ ├── 17-modules │ └── _category_.json │ ├── 18-packages │ └── _category_.json │ ├── 04-statements │ ├── _category_.json │ └── 01-introduction.md │ ├── 05-functions │ ├── _category_.json │ └── 03-type-enforcement.md │ ├── 20-attributes │ └── _category_.json │ ├── 90-contributing │ └── _category_.json │ ├── 01-getting-started │ └── _category_.json │ ├── 11-built-in-types │ ├── _category_.json │ ├── 64-nonnull.md │ ├── 70-mixed.md │ ├── 31-arraykey.md │ └── 49-this.md │ ├── 14-reified-generics │ ├── _category_.json │ └── 01-introduction.md │ ├── 30-silencing-errors │ └── _category_.json │ ├── 55-expression-trees │ └── _category_.json │ ├── 07-traits-and-interfaces │ ├── _category_.json │ └── 01-introduction.md │ ├── 08-arrays-and-collections │ └── _category_.json │ ├── 56-memoization-options │ └── _category_.json │ ├── 80-experimental-features │ └── _category_.json │ ├── 15-asynchronous-operations │ └── _category_.json │ ├── 02-source-code-fundamentals │ └── _category_.json │ ├── 03-expressions-and-operators │ ├── _category_.json │ ├── 51-await.md │ ├── 69-string-concatenation.md │ ├── 49-casting.md │ ├── 09-echo.md │ ├── 47-error-control.md │ └── 99-XHP-attribute-selection.md │ └── 13-contexts-and-capabilities │ └── _category_.json ├── public ├── css │ └── main.css ├── sitemap.txt ├── robots.txt-do-not-crawl ├── favicon.png ├── fonts │ └── fontawesome-free-5.15.4-web ├── hack_logo_medium.png ├── images │ └── async │ │ ├── curl-async.png │ │ ├── source.graffle │ │ ├── limitations.png │ │ ├── async-slow-curl.png │ │ ├── async-always-busy.png │ │ ├── async-dependency.png │ │ ├── async-sequential.png │ │ └── curl-synchronous.png ├── robots.txt-default └── search.xml ├── DOCSITE_REV ├── hhast-lint.json ├── .deploy ├── terraform │ ├── .gitignore │ └── backend.tf ├── prod.Dockerfile ├── built-site.Dockerfile ├── init.sh └── build-repo.sh ├── api-examples ├── class.HH.ImmMap │ ├── at.md │ ├── get.md │ ├── map.md │ ├── zip.md │ ├── count.md │ ├── items.md │ ├── keys.md │ ├── lazy.md │ ├── skip.md │ ├── slice.md │ ├── take.md │ ├── toMap.md │ ├── toSet.md │ ├── concat.md │ ├── filter.md │ ├── values.md │ ├── contains.md │ ├── firstKey.md │ ├── isEmpty.md │ ├── lastKey.md │ ├── toDArray.md │ ├── toImmMap.md │ ├── toImmSet.md │ ├── toVector.md │ ├── firstValue.md │ ├── fromItems.md │ ├── immutable.md │ ├── lastValue.md │ ├── mapWithKey.md │ ├── skipWhile.md │ ├── takeWhile.md │ ├── __construct.md │ ├── containsKey.md │ ├── getIterator.md │ ├── toImmVector.md │ ├── toKeysArray.md │ ├── filterWithKey.md │ ├── toValuesArray.md │ ├── differenceByKey.md │ └── __toString.md ├── class.HH.ImmSet │ ├── map.md │ ├── zip.md │ ├── count.md │ ├── items.md │ ├── keys.md │ ├── lazy.md │ ├── skip.md │ ├── slice.md │ ├── take.md │ ├── toMap.md │ ├── toSet.md │ ├── __construct.md │ ├── concat.md │ ├── filter.md │ ├── values.md │ ├── contains.md │ ├── firstKey.md │ ├── isEmpty.md │ ├── lastKey.md │ ├── toDArray.md │ ├── toImmMap.md │ ├── toImmSet.md │ ├── toVArray.md │ ├── toVector.md │ ├── firstValue.md │ ├── fromArrays.md │ ├── fromItems.md │ ├── fromKeysOf.md │ ├── immutable.md │ ├── lastValue.md │ ├── mapWithKey.md │ ├── skipWhile.md │ ├── takeWhile.md │ ├── getIterator.md │ ├── toImmVector.md │ ├── toKeysArray.md │ ├── filterWithKey.md │ ├── toValuesArray.md │ └── __toString.md ├── class.HH.ImmVector │ ├── at.md │ ├── get.md │ ├── map.md │ ├── zip.md │ ├── count.md │ ├── items.md │ ├── keys.md │ ├── lazy.md │ ├── skip.md │ ├── slice.md │ ├── take.md │ ├── toMap.md │ ├── toSet.md │ ├── __construct.md │ ├── concat.md │ ├── filter.md │ ├── isEmpty.md │ ├── lastKey.md │ ├── values.md │ ├── firstKey.md │ ├── toImmMap.md │ ├── toImmSet.md │ ├── toVArray.md │ ├── toVector.md │ ├── firstValue.md │ ├── fromItems.md │ ├── fromKeysOf.md │ ├── immutable.md │ ├── lastValue.md │ ├── mapWithKey.md │ ├── skipWhile.md │ ├── takeWhile.md │ ├── containsKey.md │ ├── getIterator.md │ ├── linearSearch.md │ ├── toImmVector.md │ ├── toKeysArray.md │ ├── filterWithKey.md │ ├── toValuesArray.md │ └── __toString.md ├── class.HH.Pair │ ├── keys.md │ ├── lastKey.md │ ├── firstKey.md │ ├── lastValue.md │ ├── firstValue.md │ ├── toKeysArray.md │ ├── toVector.md │ ├── filter.md │ ├── values.md │ ├── toImmVector.md │ ├── toMap.md │ ├── toVArray.md │ ├── toImmMap.md │ ├── toValuesArray.md │ ├── count.md │ ├── isEmpty.md │ ├── __toString.md │ ├── concat.md │ ├── items.md │ ├── zip.md │ ├── get.md │ ├── map.md │ ├── slice.md │ ├── skip.md │ ├── take.md │ ├── linearSearch.md │ ├── containsKey.md │ ├── getIterator.md │ ├── at.md │ ├── toSet.md │ └── toImmSet.md ├── class.HH.Vector │ ├── keys.md │ ├── reverse.md │ ├── clear.md │ ├── count.md │ ├── isEmpty.md │ ├── take.md │ ├── toVArray.md │ ├── slice.md │ ├── toValuesArray.md │ ├── toKeysArray.md │ ├── toMap.md │ ├── skip.md │ ├── toImmMap.md │ ├── linearSearch.md │ ├── filterWithKey.md │ ├── firstKey.md │ ├── firstValue.md │ ├── get.md │ ├── __toString.md │ ├── mapWithKey.md │ ├── toSet.md │ ├── skipWhile.md │ ├── takeWhile.md │ ├── containsKey.md │ ├── toImmSet.md │ ├── immutable.md │ ├── setAll.md │ ├── getIterator.md │ ├── reserve.md │ ├── resize.md │ ├── removeKey.md │ ├── values.md │ ├── set.md │ ├── pop.md │ ├── filter.md │ ├── at.md │ ├── add.md │ ├── zip.md │ ├── shuffle.md │ ├── map.md │ ├── toImmVector.md │ ├── lastKey.md │ ├── fromItems.md │ ├── concat.md │ ├── lastValue.md │ └── items.md ├── function.HH.Lib.Math.log.md ├── function.HH.Lib.Math.max.md ├── function.HH.Lib.Math.maxva.md ├── function.HH.Lib.Math.min.md ├── function.HH.Lib.Math.sum.md ├── function.HH.Lib.Math.minva.md ├── class.HH.Set.md ├── class.HH.Set │ ├── values.md │ ├── toVector.md │ ├── clear.md │ ├── count.md │ ├── isEmpty.md │ ├── take.md │ ├── toMap.md │ ├── toDArray.md │ ├── toVArray.md │ ├── slice.md │ ├── toImmMap.md │ ├── toValuesArray.md │ ├── keys.md │ ├── retain.md │ ├── skip.md │ ├── filter.md │ ├── lastValue.md │ ├── contains.md │ ├── __toString.md │ ├── firstValue.md │ ├── firstKey.md │ ├── lastKey.md │ ├── fromArrays.md │ ├── removeAll.md │ ├── toKeysArray.md │ ├── remove.md │ ├── skipWhile.md │ ├── takeWhile.md │ ├── toImmSet.md │ ├── immutable.md │ ├── toSet.md │ ├── getIterator.md │ ├── reserve.md │ ├── fromItems.md │ ├── map.md │ ├── concat.md │ ├── toImmVector.md │ └── items.md ├── function.HH.Lib.Vec.reverse.md ├── function.HH.Lib.Math.sum_float.md ├── function.HH.Lib.Vec.unique.md ├── function.HH.Lib.Dict.fill_keys.md ├── function.HH.Lib.Str.strip_suffix.md ├── function.HH.Lib.Math.mean.md ├── class.AsyncMysqlResult │ ├── endTime.md │ ├── startTime.md │ └── elapsedMicros.md ├── function.HH.Lib.Math.floor.md ├── function.HH.Lib.Str.length.md ├── function.HH.Lib.Str.uppercase.md ├── class.HH.Map │ ├── keys.md │ ├── __toString.md │ ├── clear.md │ ├── count.md │ ├── isEmpty.md │ ├── toValuesArray.md │ ├── take.md │ ├── toKeysArray.md │ ├── toDArray.md │ ├── skip.md │ ├── slice.md │ ├── lastKey.md │ ├── lastValue.md │ ├── firstKey.md │ ├── firstValue.md │ ├── differenceByKey.md │ ├── toMap.md │ ├── get.md │ ├── reserve.md │ ├── mapWithKey.md │ ├── contains.md │ ├── containsKey.md │ ├── toImmMap.md │ ├── immutable.md │ ├── filter.md │ ├── remove.md │ ├── toSet.md │ ├── removeKey.md │ ├── toImmSet.md │ ├── getIterator.md │ ├── toVector.md │ ├── set.md │ ├── values.md │ ├── setAll.md │ ├── concat.md │ ├── add.md │ ├── __construct.md │ ├── fromItems.md │ └── zip.md ├── function.HH.Lib.Str.splice_l.md ├── function.HH.Lib.Vec.keys.md ├── function.HH.Lib.Dict.take.md ├── function.HH.Lib.Str.uppercase_l.md ├── function.HH.Lib.C.reduce.md ├── function.HH.Lib.Dict.drop.md ├── function.HH.Lib.Keyset.keys.md ├── function.HH.Lib.Str.split.md ├── function.HH.Lib.Str.trim.md ├── function.HH.Lib.Dict.chunk.md ├── function.HH.Lib.Keyset.take.md ├── function.HH.Lib.Math.from_base.md ├── function.HH.Lib.Math.int_div.md ├── function.HH.Lib.Vec.map.md ├── function.HH.Lib.Vec.slice.md ├── function.HH.Lib.Dict.group_by.md ├── function.HH.Lib.Dict.sort.md ├── function.HH.Lib.Keyset.sort.md ├── function.HH.Lib.Math.ceil.md ├── function.HH.Lib.Str.capitalize.md ├── function.HH.Lib.Dict.count_values.md ├── function.HH.Lib.Math.max_by.md ├── function.HH.Lib.Str.chunk.md ├── function.HH.Lib.Vec.chunk.md ├── function.HH.Lib.Dict.from_keys.md ├── function.HH.Lib.Keyset.union.md ├── function.HH.Lib.Vec.drop.md ├── function.HH.Lib.Keyset.diff.md ├── function.HH.Lib.Keyset.drop.md ├── function.HH.Lib.Keyset.map.md ├── function.HH.Lib.Str.join.md ├── function.HH.Lib.Vec.filter.md ├── function.HH.Lib.Dict.associate.md ├── function.HH.Lib.Vec.fill.md ├── function.HH.Lib.Keyset.chunk.md ├── function.HH.Lib.Dict.merge.md ├── function.HH.Lib.Vec.concat.md ├── function.HH.Lib.Keyset.partition.md ├── function.HH.Lib.Str.reverse.md ├── function.HH.Lib.Vec.range.md ├── function.HH.Lib.Keyset.map_with_key.md ├── function.HH.Lib.C.reduce_with_key.md ├── function.HH.Lib.Math.round.md ├── function.HH.Lib.Vec.take.md ├── function.HH.Lib.Str.ends_with.md ├── function.HH.Lib.Str.ends_with_ci.md ├── function.HH.Lib.Math.sin.md ├── function.HH.Lib.Str.starts_with.md ├── function.HH.Lib.Vec.intersect.md ├── function.HH.Lib.Math.tan.md ├── function.HH.Lib.Str.starts_with_ci.md ├── class.HH.Shapes │ ├── toArray.md │ ├── removeKey.md │ └── keyExists.md ├── function.HH.Lib.Keyset.equal.md ├── function.HH.Lib.Keyset.filter_nulls.md ├── function.HH.Lib.Math.base_convert.md ├── function.HH.Lib.Vec.diff.md ├── function.HH.Lib.C.count.md ├── function.HH.Lib.Keyset.intersect.md ├── function.HH.Lib.Math.abs.md ├── function.HH.Lib.Vec.sample.md ├── function.HH.Lib.Math.to_base.md ├── function.HH.Lib.Vec.zip.md ├── function.HH.Lib.Keyset.filter.md ├── function.HH.Lib.C.is_empty.md ├── function.HH.Lib.Str.replace.md ├── function.HH.Lib.Str.slice.md ├── function.HH.Lib.Vec.sort.md ├── function.HH.Lib.C.findx.md ├── function.HH.Lib.C.is_sorted_by.md ├── function.HH.Lib.Str.replace_ci.md ├── function.HH.Lib.C.lastx.md ├── function.HH.Lib.Vec.partition.md ├── function.HH.Lib.C.firstx.md ├── function.HH.Lib.Str.search.md ├── function.HH.Lib.Vec.flatten.md ├── function.HH.Lib.Dict.equal.md ├── function.HH.Lib.C.pop_backx.md ├── function.HH.Lib.Str.search_ci.md ├── function.HH.Lib.C.last.md ├── function.HH.Lib.C.pop_frontx.md ├── function.HH.Lib.Keyset.flatten.md ├── function.HH.Lib.C.last_keyx.md ├── function.HH.Lib.C.pop_back.md ├── function.HH.Lib.Keyset.filter_with_key.md ├── function.HH.Lib.Str.contains.md ├── function.HH.Lib.C.first.md ├── function.HH.Lib.C.first_keyx.md ├── function.HH.Lib.C.nfirst.md ├── function.HH.Lib.Str.replace_every.md ├── function.HH.Lib.Str.compare.md ├── function.HH.Lib.Str.replace_every_ci.md ├── function.HH.Lib.C.last_key.md ├── function.HH.Lib.C.pop_front.md ├── function.HH.Lib.Str.compare_ci.md ├── function.HH.Lib.C.first_key.md ├── function.HH.Lib.C.contains.md ├── class.MCRouter │ └── createSimple.md ├── function.HH.Lib.C.onlyx.md ├── function.HH.Lib.C.contains_key.md ├── function.HH.Lib.Dict.select_keys.md ├── function.HH.Lib.C.is_sorted.md ├── function.HH.Lib.Dict.from_values.md ├── function.HH.Lib.C.find.md └── function.HH.Lib.C.find_key.md ├── .dockerignore ├── .elasticbeanstalk └── config.yml ├── tests └── lib │ └── expect.php ├── hh_autoload.json ├── src ├── utils │ ├── examples │ │ ├── md.md_render.inc.hack │ │ ├── unpromotion.inc.hack │ │ ├── Testfile.txt │ │ └── async_mysql_require_env.inc.hack │ ├── type_alias_structure.php │ └── _private │ │ ├── ScopeExit.php │ │ └── SuperGlobals.php ├── main.hhi ├── codegen │ └── PRODUCT_TAGS.php ├── site │ ├── Router.php │ └── controllers │ │ ├── WebPageController.php │ │ ├── RoutableController.php │ │ ├── RoutableGetController.php │ │ └── codegen │ │ ├── SearchControllerURIBuilder.php │ │ ├── HomePageControllerURIBuilder.php │ │ └── RobotsTxtControllerURIBuilder.php ├── build │ └── BuildFlags.php └── markdown-extensions │ └── PrettyCodeBlock.php ├── hhvm.dev.ini ├── CODE_OF_CONDUCT.md ├── .devcontainer └── Dockerfile ├── sass ├── codeBlocks.scss ├── survey.scss └── core.scss ├── .vscode └── launch.json ├── LocalConfig.php ├── .gitignore ├── bin ├── rename-sections.sh └── update-versions ├── CONTRIBUTING.md └── .hhconfig /guides/hhvm/98-FAQ/faq-category.txt: -------------------------------------------------------------------------------- 1 | Learn 2 | -------------------------------------------------------------------------------- /public/css/main.css: -------------------------------------------------------------------------------- 1 | ../../build/final/main.css -------------------------------------------------------------------------------- /public/sitemap.txt: -------------------------------------------------------------------------------- 1 | ../build/final/sitemap.txt -------------------------------------------------------------------------------- /DOCSITE_REV: -------------------------------------------------------------------------------- 1 | 1fa47f258c6b68f8ec01899aa82fd6ffa0957109 2 | -------------------------------------------------------------------------------- /guides/hhvm/01-installation/installation-category.txt: -------------------------------------------------------------------------------- 1 | Learn 2 | -------------------------------------------------------------------------------- /guides/hhvm/02-basic-usage/basic-usage-category.txt: -------------------------------------------------------------------------------- 1 | Learn 2 | -------------------------------------------------------------------------------- /guides/hhvm/05-extensions/extensions-category.txt: -------------------------------------------------------------------------------- 1 | Learn 2 | -------------------------------------------------------------------------------- /hhast-lint.json: -------------------------------------------------------------------------------- 1 | { 2 | "roots": [ "src/", "tests/" ] 3 | } 4 | -------------------------------------------------------------------------------- /guides/hack/21-XHP/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "XHP" 3 | } 4 | -------------------------------------------------------------------------------- /guides/hhvm/03-advanced-usage/advanced-usage-category.txt: -------------------------------------------------------------------------------- 1 | Learn 2 | -------------------------------------------------------------------------------- /guides/hhvm/04-configuration/configuration-category.txt: -------------------------------------------------------------------------------- 1 | Learn 2 | -------------------------------------------------------------------------------- /public/robots.txt-do-not-crawl: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: / 3 | -------------------------------------------------------------------------------- /guides/hack/10-types/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Types" 3 | } 4 | -------------------------------------------------------------------------------- /guides/hack/06-classes/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Classes" 3 | } 4 | -------------------------------------------------------------------------------- /guides/hack/12-generics/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Generics" 3 | } 4 | -------------------------------------------------------------------------------- /guides/hack/16-readonly/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Readonly" 3 | } 4 | -------------------------------------------------------------------------------- /guides/hack/17-modules/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Modules" 3 | } 4 | -------------------------------------------------------------------------------- /guides/hack/18-packages/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Packages" 3 | } 4 | -------------------------------------------------------------------------------- /guides/hack/04-statements/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Statements" 3 | } 4 | -------------------------------------------------------------------------------- /guides/hack/05-functions/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Functions" 3 | } 4 | -------------------------------------------------------------------------------- /guides/hack/20-attributes/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Attributes" 3 | } 4 | -------------------------------------------------------------------------------- /guides/hack/90-contributing/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Contributing" 3 | } 4 | -------------------------------------------------------------------------------- /guides/hhvm/98-FAQ/faq-summary.txt: -------------------------------------------------------------------------------- 1 | Common information and questions regarding HHVM. 2 | -------------------------------------------------------------------------------- /.deploy/terraform/.gitignore: -------------------------------------------------------------------------------- 1 | terraform.tfvars 2 | .terraform/ 3 | .terraform.lock.hcl 4 | -------------------------------------------------------------------------------- /guides/hack/01-getting-started/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Getting Started" 3 | } 4 | -------------------------------------------------------------------------------- /guides/hack/11-built-in-types/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Built-In Types" 3 | } 4 | -------------------------------------------------------------------------------- /guides/hack/14-reified-generics/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Reified Generics" 3 | } 4 | -------------------------------------------------------------------------------- /guides/hack/30-silencing-errors/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Silencing Errors" 3 | } 4 | -------------------------------------------------------------------------------- /guides/hack/55-expression-trees/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Expression Trees" 3 | } 4 | -------------------------------------------------------------------------------- /public/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhvm/user-documentation/HEAD/public/favicon.png -------------------------------------------------------------------------------- /public/fonts/fontawesome-free-5.15.4-web: -------------------------------------------------------------------------------- 1 | ../../build/final/fontawesome-free-5.15.4-web/webfonts -------------------------------------------------------------------------------- /guides/hack/07-traits-and-interfaces/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Traits & Interfaces" 3 | } 4 | -------------------------------------------------------------------------------- /guides/hack/08-arrays-and-collections/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Arrays & Collections" 3 | } 4 | -------------------------------------------------------------------------------- /guides/hack/56-memoization-options/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Memoization Options" 3 | } 4 | -------------------------------------------------------------------------------- /guides/hack/80-experimental-features/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Experimental Features" 3 | } 4 | -------------------------------------------------------------------------------- /guides/hhvm/01-installation/installation-summary.txt: -------------------------------------------------------------------------------- 1 | How to install HHVM on a supported platform. 2 | -------------------------------------------------------------------------------- /guides/hhvm/04-configuration/guides-generated-markdown: -------------------------------------------------------------------------------- 1 | ../../../build/scratch/guides-generated-markdown -------------------------------------------------------------------------------- /guides/hack/15-asynchronous-operations/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Asynchronous Operations" 3 | } 4 | -------------------------------------------------------------------------------- /guides/hhvm/02-basic-usage/basic-usage-summary.txt: -------------------------------------------------------------------------------- 1 | The easiest way to run HHVM, with sensible defaults. 2 | -------------------------------------------------------------------------------- /guides/hack/02-source-code-fundamentals/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Source Code Fundamentals" 3 | } 4 | -------------------------------------------------------------------------------- /guides/hack/03-expressions-and-operators/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Expressions & Operators" 3 | } 4 | -------------------------------------------------------------------------------- /guides/hack/13-contexts-and-capabilities/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Contexts & Capabilities" 3 | } 4 | -------------------------------------------------------------------------------- /public/hack_logo_medium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhvm/user-documentation/HEAD/public/hack_logo_medium.png -------------------------------------------------------------------------------- /api-examples/class.HH.ImmMap/at.md: -------------------------------------------------------------------------------- 1 | See [`Map::at`](/hack/reference/class/Map/at/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmMap/get.md: -------------------------------------------------------------------------------- 1 | See [`Map::get`](/hack/reference/class/Map/get/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmMap/map.md: -------------------------------------------------------------------------------- 1 | See [`Map::map`](/hack/reference/class/Map/map/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmMap/zip.md: -------------------------------------------------------------------------------- 1 | See [`Map::zip`](/hack/reference/class/Map/zip/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmSet/map.md: -------------------------------------------------------------------------------- 1 | See [`Set::map`](/hack/reference/class/Set/map/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmSet/zip.md: -------------------------------------------------------------------------------- 1 | See [`Set::zip`](/hack/reference/class/Set/zip/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /guides/hhvm/03-advanced-usage/advanced-usage-summary.txt: -------------------------------------------------------------------------------- 1 | Advanced usage, with more ways to run and configure HHVM. 2 | -------------------------------------------------------------------------------- /guides/hhvm/05-extensions/extensions-summary.txt: -------------------------------------------------------------------------------- 1 | The built in and dynamic extensions that HHVM currently supports. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmMap/count.md: -------------------------------------------------------------------------------- 1 | See [`Map::count`](/hack/reference/class/Map/count/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmMap/items.md: -------------------------------------------------------------------------------- 1 | See [`Map::items`](/hack/reference/class/Map/items/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmMap/keys.md: -------------------------------------------------------------------------------- 1 | See [`Map::keys`](/hack/reference/class/Map/keys/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmMap/lazy.md: -------------------------------------------------------------------------------- 1 | See [`Map::lazy`](/hack/reference/class/Map/lazy/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmMap/skip.md: -------------------------------------------------------------------------------- 1 | See [`Map::skip`](/hack/reference/class/Map/skip/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmMap/slice.md: -------------------------------------------------------------------------------- 1 | See [`Map::slice`](/hack/reference/class/Map/slice/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmMap/take.md: -------------------------------------------------------------------------------- 1 | See [`Map::take`](/hack/reference/class/Map/take/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmMap/toMap.md: -------------------------------------------------------------------------------- 1 | See [`Map::toMap`](/hack/reference/class/Map/toMap/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmMap/toSet.md: -------------------------------------------------------------------------------- 1 | See [`Map::toSet`](/hack/reference/class/Map/toSet/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmSet/count.md: -------------------------------------------------------------------------------- 1 | See [`Set::count`](/hack/reference/class/Set/count/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmSet/items.md: -------------------------------------------------------------------------------- 1 | See [`Set::items`](/hack/reference/class/Set/items/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmSet/keys.md: -------------------------------------------------------------------------------- 1 | See [`Set::keys`](/hack/reference/class/Set/keys/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmSet/lazy.md: -------------------------------------------------------------------------------- 1 | See [`Set::lazy`](/hack/reference/class/Set/lazy/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmSet/skip.md: -------------------------------------------------------------------------------- 1 | See [`Set::skip`](/hack/reference/class/Set/skip/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmSet/slice.md: -------------------------------------------------------------------------------- 1 | See [`Set::slice`](/hack/reference/class/Set/slice/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmSet/take.md: -------------------------------------------------------------------------------- 1 | See [`Set::take`](/hack/reference/class/Set/take/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmSet/toMap.md: -------------------------------------------------------------------------------- 1 | See [`Set::toMap`](/hack/reference/class/Set/toMap/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmSet/toSet.md: -------------------------------------------------------------------------------- 1 | See [`Set::toSet`](/hack/reference/class/Set/toSet/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmVector/at.md: -------------------------------------------------------------------------------- 1 | See [`Vector::at`](/hack/reference/class/Vector/at/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.Pair/keys.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $p = Pair {'foo', -1.5}; 3 | \var_dump($p->keys()); 4 | ``` 5 | -------------------------------------------------------------------------------- /guides/hack/11-built-in-types/64-nonnull.md: -------------------------------------------------------------------------------- 1 | # Nonnull 2 | 3 | The type `nonnull` supports any value except `null`. 4 | -------------------------------------------------------------------------------- /guides/hhvm/04-configuration/configuration-summary.txt: -------------------------------------------------------------------------------- 1 | How to configure HHVM with various user-configurable options. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmMap/concat.md: -------------------------------------------------------------------------------- 1 | See [`Map::concat`](/hack/reference/class/Map/concat/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmMap/filter.md: -------------------------------------------------------------------------------- 1 | See [`Map::filter`](/hack/reference/class/Map/filter/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmMap/values.md: -------------------------------------------------------------------------------- 1 | See [`Map::values`](/hack/reference/class/Map/values/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmSet/__construct.md: -------------------------------------------------------------------------------- 1 | See [`Set`](/hack/reference/class/Set/__construct/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmSet/concat.md: -------------------------------------------------------------------------------- 1 | See [`Set::concat`](/hack/reference/class/Set/concat/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmSet/filter.md: -------------------------------------------------------------------------------- 1 | See [`Set::filter`](/hack/reference/class/Set/filter/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmSet/values.md: -------------------------------------------------------------------------------- 1 | See [`Set::values`](/hack/reference/class/Set/values/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmVector/get.md: -------------------------------------------------------------------------------- 1 | See [`Vector::get`](/hack/reference/class/Vector/get/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmVector/map.md: -------------------------------------------------------------------------------- 1 | See [`Vector::map`](/hack/reference/class/Vector/map/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmVector/zip.md: -------------------------------------------------------------------------------- 1 | See [`Vector::zip`](/hack/reference/class/Vector/zip/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.Pair/lastKey.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $p = Pair {'foo', -1.5}; 3 | \var_dump($p->lastKey()); 4 | ``` 5 | -------------------------------------------------------------------------------- /public/images/async/curl-async.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhvm/user-documentation/HEAD/public/images/async/curl-async.png -------------------------------------------------------------------------------- /public/images/async/source.graffle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhvm/user-documentation/HEAD/public/images/async/source.graffle -------------------------------------------------------------------------------- /api-examples/class.HH.ImmMap/contains.md: -------------------------------------------------------------------------------- 1 | See [`Map::contains`](/hack/reference/class/Map/contains/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmMap/firstKey.md: -------------------------------------------------------------------------------- 1 | See [`Map::firstKey`](/hack/reference/class/Map/firstKey/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmMap/isEmpty.md: -------------------------------------------------------------------------------- 1 | See [`Map::isEmpty`](/hack/reference/class/Map/isEmpty/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmMap/lastKey.md: -------------------------------------------------------------------------------- 1 | See [`Map::lastKey`](/hack/reference/class/Map/lastKey/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmMap/toDArray.md: -------------------------------------------------------------------------------- 1 | See [`Map::toDArray`](/hack/reference/class/Map/toDArray/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmMap/toImmMap.md: -------------------------------------------------------------------------------- 1 | See [`Map::toImmMap`](/hack/reference/class/Map/toImmMap/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmMap/toImmSet.md: -------------------------------------------------------------------------------- 1 | See [`Map::toImmSet`](/hack/reference/class/Map/toImmSet/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmMap/toVector.md: -------------------------------------------------------------------------------- 1 | See [`Map::toVector`](/hack/reference/class/Map/toVector/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmSet/contains.md: -------------------------------------------------------------------------------- 1 | See [`Set::contains`](/hack/reference/class/Set/contains/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmSet/firstKey.md: -------------------------------------------------------------------------------- 1 | See [`Set::firstKey`](/hack/reference/class/Set/firstKey/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmSet/isEmpty.md: -------------------------------------------------------------------------------- 1 | See [`Set::isEmpty`](/hack/reference/class/Set/isEmpty/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmSet/lastKey.md: -------------------------------------------------------------------------------- 1 | See [`Set::lastKey`](/hack/reference/class/Set/lastKey/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmSet/toDArray.md: -------------------------------------------------------------------------------- 1 | See [`Set::toDArray`](/hack/reference/class/Set/toDArray/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmSet/toImmMap.md: -------------------------------------------------------------------------------- 1 | See [`Set::toImmMap`](/hack/reference/class/Set/toImmMap/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmSet/toImmSet.md: -------------------------------------------------------------------------------- 1 | See [`Set::toImmSet`](/hack/reference/class/Set/toImmSet/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmSet/toVArray.md: -------------------------------------------------------------------------------- 1 | See [`Set::toVArray`](/hack/reference/class/Set/toVArray/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmSet/toVector.md: -------------------------------------------------------------------------------- 1 | See [`Set::toVector`](/hack/reference/class/Set/toVector/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmVector/count.md: -------------------------------------------------------------------------------- 1 | See [`Vector::count`](/hack/reference/class/Vector/count/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmVector/items.md: -------------------------------------------------------------------------------- 1 | See [`Vector::items`](/hack/reference/class/Vector/items/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmVector/keys.md: -------------------------------------------------------------------------------- 1 | See [`Vector::keys`](/hack/reference/class/Vector/keys/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmVector/lazy.md: -------------------------------------------------------------------------------- 1 | See [`Vector::lazy`](/hack/reference/class/Vector/lazy/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmVector/skip.md: -------------------------------------------------------------------------------- 1 | See [`Vector::skip`](/hack/reference/class/Vector/skip/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmVector/slice.md: -------------------------------------------------------------------------------- 1 | See [`Vector::slice`](/hack/reference/class/Vector/slice/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmVector/take.md: -------------------------------------------------------------------------------- 1 | See [`Vector::take`](/hack/reference/class/Vector/take/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmVector/toMap.md: -------------------------------------------------------------------------------- 1 | See [`Vector::toMap`](/hack/reference/class/Vector/toMap/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmVector/toSet.md: -------------------------------------------------------------------------------- 1 | See [`Vector::toSet`](/hack/reference/class/Vector/toSet/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.Pair/firstKey.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $p = Pair {'foo', -1.5}; 3 | \var_dump($p->firstKey()); 4 | ``` 5 | -------------------------------------------------------------------------------- /api-examples/class.HH.Pair/lastValue.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $p = Pair {'foo', -1.5}; 3 | \var_dump($p->lastValue()); 4 | ``` 5 | -------------------------------------------------------------------------------- /public/images/async/limitations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhvm/user-documentation/HEAD/public/images/async/limitations.png -------------------------------------------------------------------------------- /api-examples/class.HH.ImmMap/firstValue.md: -------------------------------------------------------------------------------- 1 | See [`Map::firstValue`](/hack/reference/class/Map/firstValue/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmMap/fromItems.md: -------------------------------------------------------------------------------- 1 | See [`Map::fromItems`](/hack/reference/class/Map/fromItems/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmMap/immutable.md: -------------------------------------------------------------------------------- 1 | See [`Map::immutable`](/hack/reference/class/Map/immutable/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmMap/lastValue.md: -------------------------------------------------------------------------------- 1 | See [`Map::lastValue`](/hack/reference/class/Map/lastValue/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmMap/mapWithKey.md: -------------------------------------------------------------------------------- 1 | See [`Map::mapWithKey`](/hack/reference/class/Map/mapWithKey/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmMap/skipWhile.md: -------------------------------------------------------------------------------- 1 | See [`Map::skipWhile`](/hack/reference/class/Map/skipWhile/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmMap/takeWhile.md: -------------------------------------------------------------------------------- 1 | See [`Map::takeWhile`](/hack/reference/class/Map/takeWhile/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmSet/firstValue.md: -------------------------------------------------------------------------------- 1 | See [`Set::firstValue`](/hack/reference/class/Set/firstValue/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmSet/fromArrays.md: -------------------------------------------------------------------------------- 1 | See [`Set::fromArrays`](/hack/reference/class/Set/fromArrays/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmSet/fromItems.md: -------------------------------------------------------------------------------- 1 | See [`Set::fromItems`](/hack/reference/class/Set/fromItems/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmSet/fromKeysOf.md: -------------------------------------------------------------------------------- 1 | See [`Set::fromKeysOf`](/hack/reference/class/Set/fromKeysOf/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmSet/immutable.md: -------------------------------------------------------------------------------- 1 | See [`Set::immutable`](/hack/reference/class/Set/immutable/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmSet/lastValue.md: -------------------------------------------------------------------------------- 1 | See [`Set::lastValue`](/hack/reference/class/Set/lastValue/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmSet/mapWithKey.md: -------------------------------------------------------------------------------- 1 | See [`Set::mapWithKey`](/hack/reference/class/Set/mapWithKey/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmSet/skipWhile.md: -------------------------------------------------------------------------------- 1 | See [`Set::skipWhile`](/hack/reference/class/Set/skipWhile/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmSet/takeWhile.md: -------------------------------------------------------------------------------- 1 | See [`Set::takeWhile`](/hack/reference/class/Set/takeWhile/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmVector/__construct.md: -------------------------------------------------------------------------------- 1 | See [`Vector`](/hack/reference/class/Vector/__construct/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmVector/concat.md: -------------------------------------------------------------------------------- 1 | See [`Vector::concat`](/hack/reference/class/Vector/concat/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmVector/filter.md: -------------------------------------------------------------------------------- 1 | See [`Vector::filter`](/hack/reference/class/Vector/filter/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmVector/isEmpty.md: -------------------------------------------------------------------------------- 1 | See [`Vector::isEmpty`](/hack/reference/class/Vector/isEmpty/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmVector/lastKey.md: -------------------------------------------------------------------------------- 1 | See [`Vector::lastKey`](/hack/reference/class/Vector/lastKey/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmVector/values.md: -------------------------------------------------------------------------------- 1 | See [`Vector::values`](/hack/reference/class/Vector/values/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.Pair/firstValue.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $p = Pair {'foo', -1.5}; 3 | \var_dump($p->firstValue()); 4 | ``` 5 | -------------------------------------------------------------------------------- /public/images/async/async-slow-curl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhvm/user-documentation/HEAD/public/images/async/async-slow-curl.png -------------------------------------------------------------------------------- /api-examples/class.HH.ImmMap/__construct.md: -------------------------------------------------------------------------------- 1 | See [`Map::__construct`](/hack/reference/class/Map/__construct/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmMap/containsKey.md: -------------------------------------------------------------------------------- 1 | See [`Map::containsKey`](/hack/reference/class/Map/containsKey/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmMap/getIterator.md: -------------------------------------------------------------------------------- 1 | See [`Map::getIterator`](/hack/reference/class/Map/getIterator/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmMap/toImmVector.md: -------------------------------------------------------------------------------- 1 | See [`Map::toImmVector`](/hack/reference/class/Map/toImmVector/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmMap/toKeysArray.md: -------------------------------------------------------------------------------- 1 | See [`Map::toKeysArray`](/hack/reference/class/Map/toKeysArray/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmSet/getIterator.md: -------------------------------------------------------------------------------- 1 | See [`Set::getIterator`](/hack/reference/class/Set/getIterator/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmSet/toImmVector.md: -------------------------------------------------------------------------------- 1 | See [`Set::toImmVector`](/hack/reference/class/Set/toImmVector/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmSet/toKeysArray.md: -------------------------------------------------------------------------------- 1 | See [`Set::toKeysArray`](/hack/reference/class/Set/toKeysArray/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmVector/firstKey.md: -------------------------------------------------------------------------------- 1 | See [`Vector::firstKey`](/hack/reference/class/Vector/firstKey/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmVector/toImmMap.md: -------------------------------------------------------------------------------- 1 | See [`Vector::toImmMap`](/hack/reference/class/Vector/toImmMap/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmVector/toImmSet.md: -------------------------------------------------------------------------------- 1 | See [`Vector::toImmSet`](/hack/reference/class/Vector/toImmSet/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmVector/toVArray.md: -------------------------------------------------------------------------------- 1 | See [`Vector::toVArray`](/hack/reference/class/Vector/toVArray/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmVector/toVector.md: -------------------------------------------------------------------------------- 1 | See [`Vector::toVector`](/hack/reference/class/Vector/toVector/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.Pair/toKeysArray.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $p = Pair {'foo', -1.5}; 3 | 4 | \var_dump($p->toKeysArray()); 5 | ``` 6 | -------------------------------------------------------------------------------- /public/images/async/async-always-busy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhvm/user-documentation/HEAD/public/images/async/async-always-busy.png -------------------------------------------------------------------------------- /public/images/async/async-dependency.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhvm/user-documentation/HEAD/public/images/async/async-dependency.png -------------------------------------------------------------------------------- /public/images/async/async-sequential.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhvm/user-documentation/HEAD/public/images/async/async-sequential.png -------------------------------------------------------------------------------- /public/images/async/curl-synchronous.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhvm/user-documentation/HEAD/public/images/async/curl-synchronous.png -------------------------------------------------------------------------------- /api-examples/class.HH.ImmMap/filterWithKey.md: -------------------------------------------------------------------------------- 1 | See [`Map::filterWithKey`](/hack/reference/class/Map/filterWithKey/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmMap/toValuesArray.md: -------------------------------------------------------------------------------- 1 | See [`Map::toValuesArray`](/hack/reference/class/Map/toValuesArray/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmSet/filterWithKey.md: -------------------------------------------------------------------------------- 1 | See [`Set::filterWithKey`](/hack/reference/class/Set/filterWithKey/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmSet/toValuesArray.md: -------------------------------------------------------------------------------- 1 | See [`Set::toValuesArray`](/hack/reference/class/Set/toValuesArray/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmVector/firstValue.md: -------------------------------------------------------------------------------- 1 | See [`Vector::firstValue`](/hack/reference/class/Vector/firstValue/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmVector/fromItems.md: -------------------------------------------------------------------------------- 1 | See [`Vector::fromItems`](/hack/reference/class/Vector/fromItems/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmVector/fromKeysOf.md: -------------------------------------------------------------------------------- 1 | See [`Vector::fromKeysOf`](/hack/reference/class/Vector/fromKeysOf/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmVector/immutable.md: -------------------------------------------------------------------------------- 1 | See [`Vector::immutable`](/hack/reference/class/Vector/immutable/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmVector/lastValue.md: -------------------------------------------------------------------------------- 1 | See [`Vector::lastValue`](/hack/reference/class/Vector/lastValue/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmVector/mapWithKey.md: -------------------------------------------------------------------------------- 1 | See [`Vector::mapWithKey`](/hack/reference/class/Vector/mapWithKey/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmVector/skipWhile.md: -------------------------------------------------------------------------------- 1 | See [`Vector::skipWhile`](/hack/reference/class/Vector/skipWhile/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmVector/takeWhile.md: -------------------------------------------------------------------------------- 1 | See [`Vector::takeWhile`](/hack/reference/class/Vector/takeWhile/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.Pair/toVector.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $p = Pair {'foo', -1.5}; 3 | 4 | $v = $p->toVector(); 5 | \var_dump($v); 6 | ``` 7 | -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/keys.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $v = Vector {'red', 'green', 'blue', 'yellow'}; 3 | \var_dump($v->keys()); 4 | ``` 5 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | .bundle/ 2 | .elasticbeanstalk/ 3 | build/ 4 | !build/extracted-examples/ 5 | !build/final/codegen/.gitkeep 6 | vendor/ 7 | vendor-rb/ 8 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmMap/differenceByKey.md: -------------------------------------------------------------------------------- 1 | See [`Map::differenceByKey`](/hack/reference/class/Map/differenceByKey/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmVector/containsKey.md: -------------------------------------------------------------------------------- 1 | See [`Vector::containsKey`](/hack/reference/class/Vector/containsKey/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmVector/getIterator.md: -------------------------------------------------------------------------------- 1 | See [`Vector::getIterator`](/hack/reference/class/Vector/getIterator/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmVector/linearSearch.md: -------------------------------------------------------------------------------- 1 | See [`Vector::linearSearch`](/hack/reference/class/Vector/linearSearch/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmVector/toImmVector.md: -------------------------------------------------------------------------------- 1 | See [`Vector::toImmVector`](/hack/reference/class/Vector/toImmVector/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmVector/toKeysArray.md: -------------------------------------------------------------------------------- 1 | See [`Vector::toKeysArray`](/hack/reference/class/Vector/toKeysArray/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /.elasticbeanstalk/config.yml: -------------------------------------------------------------------------------- 1 | deploy: 2 | artifact: Dockerrun.aws.json 3 | global: 4 | application_name: hhvm-hack-docs 5 | default_region: us-west-2 6 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmVector/filterWithKey.md: -------------------------------------------------------------------------------- 1 | See [`Vector::filterWithKey`](/hack/reference/class/Vector/filterWithKey/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmVector/toValuesArray.md: -------------------------------------------------------------------------------- 1 | See [`Vector::toValuesArray`](/hack/reference/class/Vector/toValuesArray/#examples) for usage examples. 2 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Math.log.md: -------------------------------------------------------------------------------- 1 | ``` 2 | $x = 10; 3 | $log = Math\log($x); 4 | echo "Log is $log \n"; // Output: Log is 2.302585092994 5 | ``` 6 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Math.max.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $v = vec[3, 2, 6, 1, 4]; 3 | $max = Math\max($v); 4 | echo "The max is $max"; 5 | ``` 6 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Math.maxva.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $maxval = Math\maxva(4, 3, 8, 1, 1, 2); 3 | echo "The max value is " . $maxval; 4 | ``` 5 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Math.min.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $v = vec[3, 2, 6, 1, 4]; 3 | $min = Math\min($v); 4 | echo "The min is $min"; 5 | ``` 6 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Math.sum.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $v = vec[2, 1, 4]; 3 | $sum = Math\sum($v); 4 | echo "Sum of array is $sum \n"; 5 | ``` 6 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Math.minva.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $minval = Math\minva(1, 2, 3, 4, 5, 5, 4); 3 | echo "The min value is " . $minval; 4 | ``` 5 | -------------------------------------------------------------------------------- /api-examples/class.HH.Set.md: -------------------------------------------------------------------------------- 1 | More documentation and examples are in the 2 | [`Set` and `ImmSet`](/hack/arrays-and-collections/collections#set-and-immset) 3 | guide. 4 | -------------------------------------------------------------------------------- /api-examples/class.HH.Set/values.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $s = Set {'red', 'green', 'blue', 'yellow'}; 3 | 4 | $v = $s->values(); 5 | 6 | \var_dump($v); 7 | ``` 8 | -------------------------------------------------------------------------------- /public/robots.txt-default: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: /__content 3 | Disallow: /__survey/ 4 | Disallow: /search 5 | Disallow: /j/ 6 | 7 | Sitemap: /sitemap.txt 8 | -------------------------------------------------------------------------------- /api-examples/class.HH.Pair/filter.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $p = Pair {-1.5, null}; 3 | 4 | $v = $p->filter($value ==> $value !== null); 5 | \var_dump($v); 6 | ``` 7 | -------------------------------------------------------------------------------- /api-examples/class.HH.Pair/values.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $p = Pair {'foo', -1.5}; 3 | 4 | $immutable_v = $p->values(); 5 | 6 | \var_dump($immutable_v); 7 | ``` 8 | -------------------------------------------------------------------------------- /api-examples/class.HH.Set/toVector.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $s = Set {'red', 'green', 'blue', 'yellow'}; 3 | 4 | $v = $s->toVector(); 5 | 6 | \var_dump($v); 7 | ``` 8 | -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/reverse.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $v = Vector {'red', 'green', 'blue', 'yellow'}; 3 | 4 | $v->reverse(); 5 | 6 | \var_dump($v); 7 | ``` 8 | -------------------------------------------------------------------------------- /api-examples/class.HH.Set/clear.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $s = Set {'red', 'green', 'blue', 'yellow'}; 3 | \var_dump($s); 4 | 5 | $s->clear(); 6 | \var_dump($s); 7 | ``` 8 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Vec.reverse.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $vector = vec[1, 2, 3, 4, 5, 6]; 3 | $reversed = Vec\reverse($vector); 4 | \print_r($reversed); 5 | ``` 6 | -------------------------------------------------------------------------------- /tests/lib/expect.php: -------------------------------------------------------------------------------- 1 | (T $in): ExpectObj { 6 | return new ExpectObj($in); 7 | } 8 | -------------------------------------------------------------------------------- /api-examples/class.HH.Pair/toImmVector.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $p = Pair {'foo', -1.5}; 3 | 4 | $immutable_v = $p->toImmVector(); 5 | 6 | \var_dump($immutable_v); 7 | ``` 8 | -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/clear.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $v = Vector {'red', 'green', 'blue', 'yellow'}; 3 | \var_dump($v); 4 | 5 | $v->clear(); 6 | \var_dump($v); 7 | ``` 8 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Math.sum_float.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $v = vec[2.3, 1, 4.15]; 3 | $sum = Math\sum_float($v); 4 | echo "Float sum of array is $sum \n"; 5 | ``` 6 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Vec.unique.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $vector = vec[1, 1, 2, 3, 4, 4, 4, 4]; 3 | $uniqueVals = Vec\unique($vector); 4 | \print_r($uniqueVals); 5 | ``` 6 | 7 | -------------------------------------------------------------------------------- /api-examples/class.HH.Pair/toMap.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $p = Pair {'foo', -1.5}; 3 | 4 | $map = $p->toMap(); 5 | 6 | \var_dump($map is \HH\Map<_, _>); 7 | \var_dump($map); 8 | ``` 9 | -------------------------------------------------------------------------------- /api-examples/class.HH.Set/count.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $s = Set {}; 3 | \var_dump($s->count()); 4 | 5 | $s = Set {'red', 'green', 'blue', 'yellow'}; 6 | \var_dump($s->count()); 7 | ``` 8 | -------------------------------------------------------------------------------- /api-examples/class.HH.Pair/toVArray.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $p = Pair {'foo', -1.5}; 3 | 4 | $array = $p->toVArray(); 5 | 6 | \var_dump(\HH\is_any_array($array)); 7 | \var_dump($array); 8 | ``` 9 | -------------------------------------------------------------------------------- /api-examples/class.HH.Set/isEmpty.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $s = Set {}; 3 | \var_dump($s->isEmpty()); 4 | 5 | $s = Set {'red', 'green', 'blue', 'yellow'}; 6 | \var_dump($s->isEmpty()); 7 | ``` 8 | -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/count.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $v = Vector {}; 3 | \var_dump($v->count()); 4 | 5 | $v = Vector {'red', 'green', 'blue', 'yellow'}; 6 | \var_dump($v->count()); 7 | ``` 8 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Dict.fill_keys.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $keys = vec['k1', 'k2', 'k3', 'k4']; 3 | $value = 5; 4 | $dict = Dict\fill_keys($keys, $value); 5 | \print_r($dict); 6 | ``` 7 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Str.strip_suffix.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $input = "\$100 USD"; 3 | $result = Str\strip_suffix($input, "USD"); 4 | echo "Strip suffix from $input : $result \n"; 5 | 6 | -------------------------------------------------------------------------------- /.deploy/prod.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM hhvm/hhvm-proxygen:4.164-latest 2 | 3 | ADD hhvm.prod.ini /etc/hhvm/site.ini 4 | ADD hhvm.hhbc /var/www/hhvm.hhbc 5 | ADD file.cache /var/www/file.cache 6 | 7 | EXPOSE 80 8 | -------------------------------------------------------------------------------- /api-examples/class.HH.Set/take.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $s = Set {'red', 'green', 'blue', 'yellow'}; 3 | 4 | // Take the first two elements 5 | $take2 = $s->take(2); 6 | 7 | \var_dump($take2); 8 | ``` 9 | -------------------------------------------------------------------------------- /api-examples/class.HH.Set/toMap.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $s = Set {'red', 'green', 'blue', 'yellow'}; 3 | 4 | $map = $s->toMap(); 5 | 6 | \var_dump($map is \HH\Map<_, _>); 7 | \var_dump($map); 8 | ``` 9 | -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/isEmpty.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $v = Vector {}; 3 | \var_dump($v->isEmpty()); 4 | 5 | $v = Vector {'red', 'green', 'blue', 'yellow'}; 6 | \var_dump($v->isEmpty()); 7 | ``` 8 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Math.mean.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $v = vec[1, 2, 3, 4, 5]; 3 | $mean = Math\mean($v); 4 | echo "Mean of the array is $mean \n"; // Output: Mean of the array is 3 5 | ``` 6 | -------------------------------------------------------------------------------- /hh_autoload.json: -------------------------------------------------------------------------------- 1 | { 2 | "roots": [ 3 | "src/", 4 | "build/final/codegen/", 5 | "tests/" 6 | ], 7 | "extraFiles": [ "LocalConfig.php" ], 8 | "devFailureHandler": null 9 | } 10 | -------------------------------------------------------------------------------- /api-examples/class.AsyncMysqlResult/endTime.md: -------------------------------------------------------------------------------- 1 | AsyncMysqlResult is abstract. See specific, concrete classes for examples of `AsyncMysqlResult::endTime` (e.g., AsyncMysqlConnectResult, AsyncMysqlErrorResult) 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.Pair/toImmMap.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $p = Pair {'foo', -1.5}; 3 | 4 | $imm_map = $p->toImmMap(); 5 | 6 | \var_dump($imm_map is \HH\ImmMap<_, _>); 7 | \var_dump($imm_map); 8 | ``` 9 | -------------------------------------------------------------------------------- /api-examples/class.HH.Pair/toValuesArray.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $p = Pair {'foo', -1.5}; 3 | 4 | $array = $p->toValuesArray(); 5 | 6 | \var_dump(\HH\is_any_array($array)); 7 | \var_dump($array); 8 | ``` 9 | -------------------------------------------------------------------------------- /api-examples/class.AsyncMysqlResult/startTime.md: -------------------------------------------------------------------------------- 1 | AsyncMysqlResult is abstract. See specific, concrete classes for examples of `AsyncMysqlResult::startTime` (e.g., AsyncMysqlConnectResult, AsyncMysqlErrorResult) 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/take.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $v = Vector {'red', 'green', 'blue', 'yellow'}; 3 | 4 | // Take the first two elements 5 | $take2 = $v->take(2); 6 | 7 | \var_dump($take2); 8 | ``` 9 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Math.floor.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $floor1 = Math\floor(4.7); 3 | echo "Floor of 4.7 is $floor1 \n"; 4 | 5 | $floor2 = Math\floor(5); 6 | echo "Floor or 5 is $floor2 \n"; 7 | ``` 8 | -------------------------------------------------------------------------------- /src/utils/examples/md.md_render.inc.hack: -------------------------------------------------------------------------------- 1 | namespace HHVM\UserDocumentation\Guides\Hack\XHP\Interfaces\Md; 2 | 3 | function md_render(string $md_source): string { 4 | return \htmlspecialchars($md_source); 5 | } 6 | -------------------------------------------------------------------------------- /api-examples/class.AsyncMysqlResult/elapsedMicros.md: -------------------------------------------------------------------------------- 1 | AsyncMysqlResult is abstract. See specific, concrete classes for examples of `AsyncMysqlResult::elapsedMicros` (e.g., AsyncMysqlConnectResult, AsyncMysqlErrorResult) 2 | -------------------------------------------------------------------------------- /api-examples/class.HH.Set/toDArray.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $s = Set {'red', 'green', 'blue', 'yellow'}; 3 | 4 | $array = $s->toDArray(); 5 | 6 | \var_dump(\HH\is_any_array($array)); 7 | \var_dump($array); 8 | ``` 9 | -------------------------------------------------------------------------------- /api-examples/class.HH.Set/toVArray.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $s = Set {'red', 'green', 'blue', 'yellow'}; 3 | 4 | $array = $s->toVArray(); 5 | 6 | \var_dump(\HH\is_any_array($array)); 7 | \var_dump($array); 8 | ``` 9 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Str.length.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result = Str\length("example_string"); 3 | echo($result); 4 | //result: 14 5 | 6 | $result = Str\length(""); 7 | echo($result); 8 | //result: 0 9 | ``` -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/toVArray.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $v = Vector {'red', 'green', 'blue', 'yellow'}; 3 | 4 | $array = $v->toVArray(); 5 | 6 | \var_dump(\HH\is_any_array($array)); 7 | \var_dump($array); 8 | ``` 9 | -------------------------------------------------------------------------------- /.deploy/terraform/backend.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | backend "s3" { 3 | region = "us-west-2" 4 | bucket = "hack-docs-terraform-state" 5 | key = "hack-docs/tfstate" 6 | dynamodb_table = "hack-docs-tfstate" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /api-examples/class.HH.Set/slice.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $s = Set {'red', 'green', 'blue', 'yellow'}; 3 | 4 | // Start at index 1 ('green') and include 3 elements 5 | $s2 = $s->slice(1, 3); 6 | 7 | \var_dump($s2); 8 | ``` 9 | -------------------------------------------------------------------------------- /api-examples/class.HH.Set/toImmMap.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $s = Set {'red', 'green', 'blue', 'yellow'}; 3 | 4 | $imm_map = $s->toImmMap(); 5 | 6 | \var_dump($imm_map is \HH\ImmMap<_, _>); 7 | \var_dump($imm_map); 8 | ``` 9 | -------------------------------------------------------------------------------- /api-examples/class.HH.Set/toValuesArray.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $s = Set {'red', 'green', 'blue', 'yellow'}; 3 | 4 | $array = $s->toValuesArray(); 5 | 6 | \var_dump(\HH\is_any_array($array)); 7 | \var_dump($array); 8 | ``` 9 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Str.uppercase.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $string = "hhvm"; 3 | 4 | $string_upper = Str\uppercase($string); 5 | echo "Uppercase string: $string_upper \n"; 6 | //result: Uppercase string: HHVM 7 | ``` 8 | -------------------------------------------------------------------------------- /api-examples/class.HH.Map/keys.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $m = Map { 3 | 'red' => '#ff0000', 4 | 'green' => '#00ff00', 5 | 'blue' => '#0000ff', 6 | 'yellow' => '#ffff00', 7 | }; 8 | \var_dump($m->keys()); 9 | ``` 10 | -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/slice.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $v = Vector {'red', 'green', 'blue', 'yellow'}; 3 | 4 | // Start at index 1 ('green') and include 3 elements 5 | $v2 = $v->slice(1, 3); 6 | 7 | \var_dump($v2); 8 | ``` 9 | -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/toValuesArray.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $v = Vector {'red', 'green', 'blue', 'yellow'}; 3 | 4 | $array = $v->toValuesArray(); 5 | 6 | \var_dump(\HH\is_any_array($array)); 7 | \var_dump($array); 8 | ``` 9 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Str.splice_l.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $locale = \HH\Lib\Locale\create("en_US.UTF-8"); 3 | $result = Str\splice_l($locale, "apple", "orange", 5, 0); 4 | echo "Splice string with en_US.UTF-8: $result \n"; 5 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Vec.keys.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result = Vec\keys(dict[1 => 100, 33 => 400 ]); 3 | print_r($result); 4 | //result: [1, 33] 5 | 6 | $result = Vec\keys(dict[]); 7 | print_r($result); 8 | //result: [] 9 | ``` -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/toKeysArray.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $v = Vector {'red', 'green', 'blue', 'yellow'}; 3 | 4 | $keys_array = $v->toKeysArray(); 5 | 6 | \var_dump(\HH\is_any_array($keys_array)); 7 | \var_dump($keys_array); 8 | ``` 9 | -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/toMap.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $v = Vector {'red', 'green', 'blue', 'yellow'}; 3 | 4 | $map = $v->toMap(); 5 | 6 | \var_dump($map is \HH\Map<_, _>); 7 | \var_dump($map->keys()); 8 | \var_dump($map); 9 | ``` 10 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Dict.take.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result = Dict\take(dict[1 => 2, 2 => 4, 3 => 9], 1); 3 | print_r($result); 4 | //dict[1=>2] 5 | 6 | $result = Dict\take(dict[], 1); 7 | print_r($result); 8 | //result: dict[] 9 | ``` -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Str.uppercase_l.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $locale = \HH\Lib\Locale\create("en_US.UTF-8"); 3 | $uppercase_string = Str\uppercase_l($locale, 'ifoo'); 4 | echo "Get uppercase string with en_US.UTF-8: $uppercase_string \n"; 5 | -------------------------------------------------------------------------------- /api-examples/class.HH.Pair/count.md: -------------------------------------------------------------------------------- 1 | This shows that a `Pair` always has a count of `2`: 2 | 3 | ```basic-usage.hack 4 | $p = Pair {'foo', -1.5}; 5 | \var_dump($p->count()); 6 | 7 | $p = Pair {null, null}; 8 | \var_dump($p->count()); 9 | ``` 10 | -------------------------------------------------------------------------------- /api-examples/class.HH.Set/keys.md: -------------------------------------------------------------------------------- 1 | This example shows that `keys()` returns a `Vector` of the `Set`'s values because `Set`s don't have keys: 2 | 3 | ```basic-usage.hack 4 | $s = Set {'red', 'green', 'blue', 'yellow'}; 5 | \var_dump($s->keys()); 6 | ``` 7 | -------------------------------------------------------------------------------- /api-examples/class.HH.Set/retain.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $s = Set {'red', 'green', 'blue', 'yellow'}; 3 | 4 | // Only keep values beginning with 'r' or 'b' 5 | $s->retain($color ==> $color[0] === 'r' || $color[0] === 'b'); 6 | \var_dump($s); 7 | ``` 8 | -------------------------------------------------------------------------------- /api-examples/class.HH.Set/skip.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $s = Set {'red', 'green', 'blue', 'yellow'}; 3 | 4 | // Create a new Set after skipping the first two elements ('red' and 'green') 5 | $skip2 = $s->skip(2); 6 | 7 | \var_dump($skip2); 8 | ``` 9 | -------------------------------------------------------------------------------- /hhvm.dev.ini: -------------------------------------------------------------------------------- 1 | hhvm.server.default_document=index.php 2 | hhvm.server.error_document404=index.php 3 | hhvm.server.thread_count=20 4 | hhvm.hack_compiler_workers=4 5 | hhvm.jit_worker_threads=1 6 | hhvm.jit_worker_arenas=1 7 | hhvm.check_return_type_hints=3 8 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code of Conduct 2 | Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please [read the full text](https://code.fb.com/codeofconduct) so that you can understand what actions will and will not be tolerated. -------------------------------------------------------------------------------- /api-examples/class.HH.Pair/isEmpty.md: -------------------------------------------------------------------------------- 1 | This example shows that a `Pair` can never be empty: 2 | 3 | ```basic-usage.hack 4 | $p = Pair {'foo', -1.5}; 5 | \var_dump($p->isEmpty()); 6 | 7 | $p = Pair {null, -1.5}; 8 | \var_dump($p->isEmpty()); 9 | ``` 10 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.C.reduce.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $values = vec[1,2,3,4,5]; 3 | $reduce_result = C\reduce($values, ($total, $value) ==> $total + $value, 0); 4 | echo "Reduce result: $reduce_result\n"; 5 | //Output: Reduce result: 15 6 | ``` 7 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Dict.drop.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result = Dict\drop(dict[1 => 2, 2 => 4, 3 => 9], 1); 3 | print_r($result); 4 | //result: dict[2=>4, 3=>9] 5 | 6 | $result = Dict\drop(dict[], 1); 7 | print_r($result); 8 | //result: dict[] 9 | ``` -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Keyset.keys.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result = Keyset\keys(dict[1 => 100, 33 => 400 ]); 3 | print_r($result); 4 | //result: keyset[1,33] 5 | 6 | $result = Keyset\keys(dict[]); 7 | print_r($result); 8 | //result: keyset[] 9 | ``` -------------------------------------------------------------------------------- /api-examples/class.HH.Pair/__toString.md: -------------------------------------------------------------------------------- 1 | The string version of a `Pair` is always `"Pair"`: 2 | 3 | ```basic-usage.hack 4 | $p = Pair {-1, 5}; 5 | echo $p->__toString()."\n"; 6 | 7 | $p2 = Pair {'foo', 'bar'}; 8 | echo $p2->__toString()."\n"; 9 | ``` 10 | -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/skip.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $v = Vector {'red', 'green', 'blue', 'yellow'}; 3 | 4 | // Create a new Vector after skipping the first two elements ('red' and 'green') 5 | $skip2 = $v->skip(2); 6 | 7 | \var_dump($skip2); 8 | ``` 9 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Str.split.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $str = "This, is, a, great, software, for sure."; 3 | $split_str = Str\split($str, ","); 4 | \print_r($split_str); 5 | 6 | $split_str2 = Str\split($str, ",", 3); 7 | \print_r($split_str2); 8 | ``` 9 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Str.trim.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result = Str\trim("example_string "); 3 | echo($result); 4 | //result: "example_string" 5 | 6 | $result = Str\trim(" example_string "); 7 | echo($result); 8 | //result: "example_string" 9 | ``` -------------------------------------------------------------------------------- /api-examples/class.HH.Map/__toString.md: -------------------------------------------------------------------------------- 1 | The string version of a `Map` is always `"Map"`: 2 | 3 | ```basic-usage.hack 4 | $m = Map {'a' => 1, 'b' => 2, 'c' => 3}; 5 | echo $m->__toString()."\n"; 6 | 7 | $m3 = Map {}; 8 | echo $m3->__toString()."\n"; 9 | ``` 10 | -------------------------------------------------------------------------------- /api-examples/class.HH.Map/clear.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $m = Map { 3 | 'red' => '#ff0000', 4 | 'green' => '#00ff00', 5 | 'blue' => '#0000ff', 6 | 'yellow' => '#ffff00', 7 | }; 8 | \var_dump($m); 9 | 10 | $m->clear(); 11 | \var_dump($m); 12 | ``` 13 | -------------------------------------------------------------------------------- /api-examples/class.HH.Pair/concat.md: -------------------------------------------------------------------------------- 1 | This example creates a new `ImmVector` by concatenating a `Traversable` with the values in the `Pair`. 2 | 3 | ```basic-usage.hack 4 | $p = Pair {'foo', -1.5}; 5 | 6 | $v = $p->concat(vec[100, 'bar']); 7 | \var_dump($v); 8 | ``` 9 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Dict.chunk.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result = Dict\chunk(dict[1 => 2, 2 => 4], 1); 3 | print_r($result); 4 | // result: vec[dict[1=>2], dict[2=>4]] 5 | 6 | $result = Dict\chunk(dict[], 1); 7 | print_r($result); 8 | //result: vec[] 9 | ``` -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Keyset.take.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result = Keyset\take(keyset[1,200, 5], 2); 3 | print_r($result); 4 | //result: keyset[1,200] 5 | 6 | $result = Keyset\take(keyset[100,2000,3,4], 0); 7 | print_r($result); 8 | //result: keyset[] 9 | ``` -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Math.from_base.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $val1 = Math\from_base("101", 2); 3 | echo "101 in base 2 represents the number $val1 \n"; 4 | 5 | $val2 = Math\from_base("e", 16); 6 | echo "e in base 16 represents the number $val2 \n"; 7 | ``` 8 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Math.int_div.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result1 = Math\int_div(8, 4); 3 | echo "Integer division of 8 by 4 yields $result1 \n"; 4 | 5 | $result2 = Math\int_div(7, 4); 6 | echo "Integer division of 7 by 4 yields $result2 \n"; 7 | 8 | ``` 9 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Vec.map.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $numbers = vec[1, 2, 3]; 3 | $new_numbers = Vec\map($numbers, $number ==> ($number + 1)); 4 | echo "new numbers are: \n"; 5 | \print_r($new_numbers); 6 | //Output: new numbers are: 7 | //vec[2, 3, 4] 8 | ``` -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Vec.slice.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $vector = vec[1, 2, 3, 4, 5, 6, 7]; 3 | $sliced_vector = Vec\slice($vector, 3); 4 | \print_r($sliced_vector); 5 | 6 | $sliced_vector2 = Vec\slice($vector, 2, 3); 7 | \print_r($sliced_vector2); 8 | ``` 9 | -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/toImmMap.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $v = Vector {'red', 'green', 'blue', 'yellow'}; 3 | 4 | $imm_map = $v->toImmMap(); 5 | 6 | \var_dump($imm_map is \HH\ImmMap<_, _>); 7 | \var_dump($imm_map->keys()); 8 | \var_dump($imm_map); 9 | ``` 10 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Dict.group_by.md: -------------------------------------------------------------------------------- 1 | Group numbers by their parity (separate even and odd numbers): 2 | 3 | ```basic-usage.hack 4 | $numbers = vec[1, 1, 2, 3, 5, 8, 14]; 5 | $groups = Dict\group_by($numbers, $value ==> $value % 2); 6 | \print_r($groups); 7 | ``` 8 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Dict.sort.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result = Dict\sort(dict[1 => 2000, 2 => 1000, 3 => 9]); 3 | print_r($result); 4 | //result: dict[3=>9, 2=>1000, 1=>2000] 5 | 6 | $result = Dict\sort(dict[]); 7 | print_r($result); 8 | //result: dict[] 9 | ``` -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Keyset.sort.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result = Keyset\sort(keyset[1,200, 5]); 3 | print_r($result); 4 | //result: keyset[1,5,200] 5 | 6 | $result = Keyset\sort(keyset[100,2000,3,4]); 7 | print_r($result); 8 | //result: keyset[3,4,100,2000] 9 | ``` -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Math.ceil.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $val_1 = 3.2; 3 | $ceil_1 = Math\ceil($val_1); 4 | echo "Ceiling of $val_1 is $ceil_1 \n"; 5 | 6 | $val_2 = 7; 7 | $ceil_2 = Math\ceil($val_2); 8 | echo "Ceiling of $val_2 is $ceil_2 \n"; 9 | ``` 10 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Str.capitalize.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result = Str\capitalize("example_string"); 3 | echo($result); 4 | // result "Example_string" 5 | 6 | $result = Str\capitalize("Example_string"); 7 | echo($result); 8 | // result "Example_string" 9 | ``` -------------------------------------------------------------------------------- /guides/hack/14-reified-generics/01-introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | **Topics covered in this section** 4 | 5 | * [Reified Generics](/docs/hack/reified-generics/reified-generics) 6 | * [Reified Generics Migration](/docs/hack/reified-generics/reified-generics-migration) 7 | -------------------------------------------------------------------------------- /api-examples/class.HH.Set/filter.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $colors = Set {'red', 'green', 'blue', 'yellow'}; 3 | 4 | // Create a Set of colors that contain the letter 'l' 5 | $l_colors = $colors->filter($color ==> \strpos($color, 'l') !== false); 6 | \var_dump($l_colors); 7 | ``` 8 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Dict.count_values.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result = Dict\count_values(vec[1,2,2,3,3,3]); 3 | print_r($result); 4 | //result: dict[1=>1, 2=>2, 3=>3] 5 | 6 | $result = Dict\count_values(vec[0,0,0,0,0]); 7 | print_r($result); 8 | //result: dict[0=>5] 9 | ``` -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Math.max_by.md: -------------------------------------------------------------------------------- 1 | ``` 2 | $items = vec[tuple('foo', 9), tuple('bar', 8), tuple('baz', 7)]; 3 | $maxItem = Math\max_by($items, $item ==> $item[1]); 4 | echo "The max item is " . $maxItem[0]; 5 | ``` 6 | Ouput 7 | ``` 8 | The max item is foo 9 | ``` 10 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Str.chunk.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result = Str\chunk("example_string", 5); 3 | print_r($result); 4 | //result: ["examp", "le_st", "ring"] 5 | 6 | $result = Str\chunk("example_string", 50); 7 | print_r($result); 8 | //result: ["example_string"] 9 | ``` -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Vec.chunk.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $example_vec = vec[1,2,3,4,5]; 3 | $chunks = Vec\chunk($example_vec, 3); 4 | print_r($chunks); 5 | // result [[1,2,3], [4,5]] 6 | $chunks = Vec\chunk($example_vec, 5); 7 | print_r($chunks); 8 | // result [1,2,3,4,5] 9 | ``` -------------------------------------------------------------------------------- /api-examples/class.HH.ImmMap/__toString.md: -------------------------------------------------------------------------------- 1 | The string version of an `ImmMap` is always `"ImmMap"`: 2 | 3 | ```basic-usage.hack 4 | $im = ImmMap {'a' => 1, 'b' => 2, 'c' => 3}; 5 | echo $im->__toString()."\n"; 6 | 7 | $im3 = ImmMap {}; 8 | echo $im3->__toString()."\n"; 9 | ``` 10 | -------------------------------------------------------------------------------- /api-examples/class.HH.Map/count.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $m = Map {}; 3 | \var_dump($m->count()); 4 | 5 | $m = Map { 6 | 'red' => '#ff0000', 7 | 'green' => '#00ff00', 8 | 'blue' => '#0000ff', 9 | 'yellow' => '#ffff00', 10 | }; 11 | \var_dump($m->count()); 12 | ``` 13 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Dict.from_keys.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $keys = vec[1, 2, 3, 4]; 3 | $dict = Dict\from_keys($keys, $x ==> $x + 1); 4 | \print_r($dict); 5 | 6 | $values = vec[1, 2, 3, 4]; 7 | $dict = Dict\from_keys($keys, $x ==> 5); 8 | \print_r($dict); 9 | ``` 10 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Keyset.union.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result = Keyset\union(keyset[1,2], vec[4,5] ); 3 | print_r($result); 4 | //result: keyset[1,2,4,5] 5 | 6 | $result = Keyset\union(keyset[1,2], vec[3,3,4,5] ); 7 | print_r($result); 8 | //result: keyset[1,2,3,4,5] 9 | ``` -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Vec.drop.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $example_vec = vec[1,2,3,4,5]; 3 | $result = Vec\drop($example_vec, 3); 4 | print_r($result); 5 | //result: [4,5] 6 | 7 | $result = Vec\drop($example_vec, 0); 8 | print_r($result); 9 | //result: [1,2,3,4,5] 10 | ``` -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Keyset.diff.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result = Keyset\diff(keyset[1,2,3,4,5,6], vec[1,2,3]); 3 | print_r($result); 4 | //result: keyset[4,5,6] 5 | 6 | $result = Keyset\diff(vec[1,2,3,4,5,6], keyset[]); 7 | print_r($result); 8 | //result: keyset[1,2,3,4,5,6] 9 | ``` -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Keyset.drop.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result = Keyset\drop(keyset[1,2,3,4,5,6], 3); 3 | print_r($result); 4 | //result: keyset[4,5,6] 5 | 6 | $result = Keyset\drop(vec[1,2,3,4,5,6], 0); 7 | print_r($result); 8 | //result: keyset[1,2,3,4,5,6] 9 | ``` 10 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Keyset.map.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result = Keyset\map(keyset[1,2,3,4], $val ==> $val*2); 3 | print_r($result); 4 | //result: keyset[2,4,6,8] 5 | 6 | $result = Keyset\map(keyset[1,2,3,4], $val ==> $val); 7 | print_r($result); 8 | //result: keyset[1,2,3,4] 9 | ``` -------------------------------------------------------------------------------- /src/main.hhi: -------------------------------------------------------------------------------- 1 | > 7 | function main(): void { 8 | } 9 | -------------------------------------------------------------------------------- /api-examples/class.HH.Pair/items.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $p = Pair {'foo', -1.5}; 3 | 4 | // Get an Iterable view of the Pair 5 | $iterable = $p->items(); 6 | 7 | // Print both values in the Iterable 8 | foreach ($iterable as $value) { 9 | echo (string)$value."\n"; 10 | } 11 | ``` 12 | -------------------------------------------------------------------------------- /api-examples/class.HH.Pair/zip.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $p = Pair {'foo', -1.5}; 3 | 4 | $labels = Vector {'First Value', 'Second Value'}; 5 | $labeled = $p->zip($labels); 6 | 7 | foreach ($labeled as list($value, $label)) { 8 | echo $label.': '.(string)$value."\n"; 9 | } 10 | ``` 11 | -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/linearSearch.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $v = Vector {'red', 'green', 'blue', 'yellow'}; 3 | 4 | // Prints 2 5 | \var_dump($v->linearSearch('blue')); 6 | 7 | // Prints -1 (since 'purple' is not in the Vector) 8 | \var_dump($v->linearSearch('purple')); 9 | ``` 10 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Str.join.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $strings= vec["a", "b", "c", "d"]; 3 | 4 | $joined_string_1 = Str\join($strings, ","); 5 | echo "First string: $joined_string_1 \n"; 6 | 7 | $joined_string_2 = Str\join($strings, "-"); 8 | echo "Second string: $joined_string_2"; 9 | ``` -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Vec.filter.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $numbers = vec[1, 2, 3, 4, 5]; 3 | $filter_numbers = Vec\filter($numbers, $number ==> $number % 2 === 0); 4 | echo "Filter numbers are: \n"; 5 | \print_r($filter_numbers); 6 | //Output: Filter numbers are: 7 | //vec[2, 4] 8 | ``` 9 | -------------------------------------------------------------------------------- /api-examples/class.HH.Set/lastValue.md: -------------------------------------------------------------------------------- 1 | This example shows how `lastValue()` can be used even when a `Set` may be empty: 2 | 3 | ```basic-usage.hack 4 | $s = Set {'red', 'green', 'blue', 'yellow'}; 5 | \var_dump($s->lastValue()); 6 | 7 | $s = Set {}; 8 | \var_dump($s->lastValue()); 9 | ``` 10 | -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/filterWithKey.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $v = Vector {'red', 'green', 'blue', 'yellow', 'purple'}; 3 | 4 | // Only include elements with an odd index 5 | $odd_elements = $v->filterWithKey(($index, $color) ==> ($index % 2) !== 0); 6 | 7 | \var_dump($odd_elements); 8 | ``` 9 | -------------------------------------------------------------------------------- /guides/hhvm/01-installation/08-deprecated-support.md: -------------------------------------------------------------------------------- 1 | The following distributions are only supported for [LTS releases](./introduction#lts-releases) up to 4.56. 2 | 3 | ### Ubuntu 16.04 Xenial 4 | 5 | Follow instructions for installing [LTS releases](/hhvm/installation/linux#obtaining-lts-releases). 6 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Dict.associate.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | // NOTE: $keys, $values must be the same length 3 | $keys = vec[1,2,3,4,5]; 4 | $values = vec[1,4,9,16,25]; 5 | $dict = Dict\associate($keys, $values); 6 | \print_r($dict); 7 | //Output: dict[1 => 1, 2 => 4, 3 => 9, 4 => 16, 5 => 25] 8 | ``` -------------------------------------------------------------------------------- /api-examples/class.HH.Pair/get.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $p = Pair {'foo', -1.5}; 3 | 4 | // Print the first value 5 | \var_dump($p->get(0)); 6 | 7 | // Print the second value 8 | \var_dump($p->get(1)); 9 | 10 | // Print NULL since index 2 doesn't exist in a Pair 11 | \var_dump($p->get(2)); 12 | ``` 13 | -------------------------------------------------------------------------------- /api-examples/class.HH.Set/contains.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $s = Set {'red', 'green', 'blue', 'yellow'}; 3 | 4 | // Prints "true", since $s contains "red" 5 | \var_dump($s->contains('red')); 6 | 7 | // Prints "false", since $s doesn't contain "blurple" 8 | \var_dump($s->contains('blurple')); 9 | ``` 10 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Vec.fill.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result = Vec\fill(2, 100); 3 | print_r($result); 4 | //result: [100, 100] 5 | 6 | $result = Vec\fill(0, 10); 7 | print_r($result); 8 | //result: [] 9 | 10 | $result = Vec\fill(5, 1); 11 | print_r($result); 12 | //result: [1,1,1,1,1] 13 | ``` -------------------------------------------------------------------------------- /api-examples/class.HH.Set/__toString.md: -------------------------------------------------------------------------------- 1 | The string version of a `Set` is always `"Set"`: 2 | 3 | ```basic-usage.hack 4 | $s = Set {1, 2, 3}; 5 | echo $s->__toString()."\n"; 6 | 7 | $s2 = Set {'a', 'b', 'c'}; 8 | echo $s2->__toString()."\n"; 9 | 10 | $s3 = Set {}; 11 | echo $s3->__toString()."\n"; 12 | ``` 13 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Keyset.chunk.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result = Keyset\chunk(vec[1,2,3,4,5,6],3); 3 | print_r($result); 4 | //result: [keyset[1,2,3], keyset[4,5,6]] 5 | 6 | $result = Keyset\chunk(vec[1,2,2,3,4,5],3); 7 | print_r($result); 8 | //result: [keyset[1,2], keyset[3,4,5]] 9 | ``` 10 | -------------------------------------------------------------------------------- /api-examples/class.HH.Map/isEmpty.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $m = Map {}; 3 | \var_dump($m->isEmpty()); 4 | 5 | $m = Map { 6 | 'red' => '#ff0000', 7 | 'green' => '#00ff00', 8 | 'blue' => '#0000ff', 9 | 'yellow' => '#ffff00', 10 | 'purple' => '#663399', 11 | }; 12 | \var_dump($m->isEmpty()); 13 | ``` 14 | -------------------------------------------------------------------------------- /api-examples/class.HH.Map/toValuesArray.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $m = Map { 3 | 'red' => '#ff0000', 4 | 'green' => '#00ff00', 5 | 'blue' => '#0000ff', 6 | 'yellow' => '#ffff00', 7 | }; 8 | 9 | $array = $m->toValuesArray(); 10 | 11 | \var_dump(\HH\is_any_array($array)); 12 | \var_dump($array); 13 | ``` 14 | -------------------------------------------------------------------------------- /src/utils/examples/unpromotion.inc.hack: -------------------------------------------------------------------------------- 1 | // not relevant for the guide but needed for typechecking 2 | 3 | namespace HHVM\UserDocumentation\Guides\Hack\Classes\Constructors\Unpromotion; 4 | 5 | final class ParsedName {} 6 | 7 | function parse_name(string $_name): ParsedName { 8 | return new ParsedName(); 9 | } 10 | -------------------------------------------------------------------------------- /api-examples/class.HH.Map/take.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $m = Map { 3 | 'red' => '#ff0000', 4 | 'green' => '#00ff00', 5 | 'blue' => '#0000ff', 6 | 'yellow' => '#ffff00', 7 | 'purple' => '#663399', 8 | }; 9 | 10 | // Take the first two elements 11 | $take2 = $m->take(2); 12 | 13 | \var_dump($take2); 14 | ``` 15 | -------------------------------------------------------------------------------- /api-examples/class.HH.Set/firstValue.md: -------------------------------------------------------------------------------- 1 | The following example gets the first value from a `Set`. An empty `Set` will return `null` as its first value. 2 | 3 | ```basic-usage.hack 4 | $s = Set {'red', 'green', 'blue', 'yellow'}; 5 | \var_dump($s->firstValue()); 6 | 7 | $s = Set {}; 8 | \var_dump($s->firstValue()); 9 | ``` 10 | -------------------------------------------------------------------------------- /api-examples/class.HH.Map/toKeysArray.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $m = Map { 3 | 'red' => '#ff0000', 4 | 'green' => '#00ff00', 5 | 'blue' => '#0000ff', 6 | 'yellow' => '#ffff00', 7 | }; 8 | 9 | $keys_array = $m->toKeysArray(); 10 | 11 | \var_dump(\HH\is_any_array($keys_array)); 12 | \var_dump($keys_array); 13 | ``` 14 | -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/firstKey.md: -------------------------------------------------------------------------------- 1 | The following example gets the first key from `Vector`. An empty `Vector` will return `null` as its first key. 2 | 3 | ```basic-usage.hack 4 | $v = Vector {'red', 'green', 'blue', 'yellow'}; 5 | \var_dump($v->firstKey()); 6 | 7 | $v = Vector {}; 8 | \var_dump($v->firstKey()); 9 | ``` 10 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmSet/__toString.md: -------------------------------------------------------------------------------- 1 | The string version of an `ImmSet` is always `"ImmSet"`: 2 | 3 | ```basic-usage.hack 4 | $is = ImmSet {1, 2, 3}; 5 | echo $is->__toString()."\n"; 6 | 7 | $is2 = ImmSet {'a', 'b', 'c'}; 8 | echo $is2->__toString()."\n"; 9 | 10 | $is3 = ImmSet {}; 11 | echo $is3->__toString()."\n"; 12 | ``` 13 | -------------------------------------------------------------------------------- /api-examples/class.HH.ImmVector/__toString.md: -------------------------------------------------------------------------------- 1 | The string version of a `Vector` is always `"Vector"`: 2 | 3 | ```basic-usage.hack 4 | $v = Vector {1, 2, 3}; 5 | echo $v->__toString()."\n"; 6 | 7 | $v2 = Vector {'a', 'b', 'c'}; 8 | echo $v2->__toString()."\n"; 9 | 10 | $v3 = Vector {}; 11 | echo $v3->__toString()."\n"; 12 | ``` 13 | -------------------------------------------------------------------------------- /api-examples/class.HH.Map/toDArray.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $m = Map { 3 | 'red' => '#ff0000', 4 | 'green' => '#00ff00', 5 | 'blue' => '#0000ff', 6 | 'yellow' => '#ffff00', 7 | 'purple' => '#663399', 8 | }; 9 | 10 | $array = $m->toDArray(); 11 | 12 | \var_dump(\HH\is_any_array($array)); 13 | \var_dump($array); 14 | ``` 15 | -------------------------------------------------------------------------------- /api-examples/class.HH.Pair/map.md: -------------------------------------------------------------------------------- 1 | In this example the `Pair`'s values are mapped to `0` if they're `NULL`: 2 | 3 | ```basic-usage.hack 4 | $p = Pair {null, -1.5}; 5 | 6 | $immutable_v = $p->map($value ==> { 7 | if ($value === null) { 8 | return 0; 9 | } 10 | return $value; 11 | }); 12 | \var_dump($immutable_v); 13 | ``` 14 | -------------------------------------------------------------------------------- /api-examples/class.HH.Pair/slice.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $p = Pair {'foo', -1.5}; 3 | 4 | // Get an ImmVector of both values 5 | \var_dump($p->slice(0, 2)); 6 | 7 | // Get an ImmVector of the first value 8 | \var_dump($p->slice(0, 1)); 9 | 10 | // Get an ImmVector of the second value 11 | \var_dump($p->slice(1, 1)); 12 | ``` 13 | -------------------------------------------------------------------------------- /api-examples/class.HH.Set/firstKey.md: -------------------------------------------------------------------------------- 1 | This example shows that `firstKey` returns the first value in the `Set`. An empty `Set` will return `null` as its first key. 2 | 3 | ```basic-usage.hack 4 | $s = Set {'red', 'green', 'blue', 'yellow'}; 5 | \var_dump($s->firstKey()); 6 | 7 | $s = Set {}; 8 | \var_dump($s->firstKey()); 9 | ``` 10 | -------------------------------------------------------------------------------- /api-examples/class.HH.Set/lastKey.md: -------------------------------------------------------------------------------- 1 | This example shows that `lastKey` returns the last value in the `Set`. An empty `Set` will return `null` as its last key/value. 2 | 3 | ```basic-usage.hack 4 | $s = Set {'red', 'green', 'blue', 'yellow'}; 5 | \var_dump($s->lastKey()); 6 | 7 | $s = Set {}; 8 | \var_dump($s->lastKey()); 9 | ``` 10 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Dict.merge.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result = Dict\merge(dict[1 => 2, 2 => 4], dict[7 => 2, 100 => 4]); 3 | print_r($result); 4 | //result: dict[1=>2, 2=>4, 7=>2, 100=>4] 5 | 6 | $result = Dict\merge(dict[1 => 2, 2 => 4], dict[7 => 2, 2 => 100]); 7 | print_r($result); 8 | //result: dict[1=>2, 2=>100, 7=>2] 9 | ``` -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Vec.concat.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $original_vec = vec["abc", "def", "ghi"]; 3 | $rest = vec["xxx", "yyy"]; 4 | $concat_vec = Vec\concat($original_vec, $rest); 5 | echo "Resulting concat vec: \n"; 6 | \print_r($concat_vec); 7 | //Output: Resulting concat vec: 8 | //vec["abc", "def", "ghi", "xxx", "yyy"] 9 | ``` -------------------------------------------------------------------------------- /api-examples/class.HH.Map/skip.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $m = Map { 3 | 'red' => '#ff0000', 4 | 'green' => '#00ff00', 5 | 'blue' => '#0000ff', 6 | 'yellow' => '#ffff00', 7 | }; 8 | 9 | // Create a new Map after skipping the first two elements ('red' and 'green') 10 | $skip2 = $m->skip(2); 11 | 12 | \var_dump($skip2); 13 | ``` 14 | -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/firstValue.md: -------------------------------------------------------------------------------- 1 | The following example gets the first value from `Vector`. An empty `Vector` will return `null` as its first value. 2 | 3 | ```basic-usage.hack 4 | $v = Vector {'red', 'green', 'blue', 'yellow'}; 5 | \var_dump($v->firstValue()); 6 | 7 | $v = Vector {}; 8 | \var_dump($v->firstValue()); 9 | ``` 10 | -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/get.md: -------------------------------------------------------------------------------- 1 | This example shows how `get` can be used to access an index that may not exist: 2 | 3 | ```basic-usage.hack 4 | $v = Vector {'red', 'green', 'blue', 'yellow'}; 5 | 6 | // Index 0 is the element 'red' 7 | \var_dump($v->get(0)); 8 | 9 | // Index 10 doesn't exist 10 | \var_dump($v->get(10)); 11 | ``` 12 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Keyset.partition.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result = Keyset\partition(keyset[1,2,3,4], $val ==> $val%2==0); 3 | print_r($result); 4 | //result: vec[keyset[2,4], keyset[1,3]] 5 | 6 | $result = Keyset\partition(keyset[1,2,3,4], $val ==> $val==0); 7 | print_r($result); 8 | //result: vec[keyset[], keyset[1,2,3,4]] 9 | ``` -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Str.reverse.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result = Str\reverse("example_string"); 3 | echo($result); 4 | //result: "gnirts_elpmaxe" 5 | 6 | $result = Str\reverse("Example_string"); 7 | echo($result); 8 | //result:"gnirts_elpmaxE" 9 | 10 | $result = Str\reverse(""); 11 | echo($result); 12 | //result: "" 13 | ``` -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Vec.range.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result = Vec\range(1, 10, 1); 3 | print_r($result); 4 | //result: [1,2,3,4,5,6,7,8,9,10] 5 | 6 | $result = Vec\range(1, 10, 2); 7 | print_r($result); 8 | //result: [1,3,5,7,9] 9 | 10 | $result = Vec\range(1, 10, 3); 11 | print_r($result); 12 | //result: [1,4,7,10] 13 | ``` -------------------------------------------------------------------------------- /.devcontainer/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM hhvm/hhvm-proxygen:4.164-latest 2 | 3 | ARG WORKSPACE 4 | 5 | RUN rm -rf /var/www; ln -s ${WORKSPACE} /var/www 6 | RUN ln -sf /var/www/hhvm.dev.ini /etc/hhvm/site.ini 7 | 8 | ADD .deploy/system-init.sh /var/tmp/system-init.sh 9 | RUN touch /.docker_build && /var/tmp/system-init.sh && rm /var/tmp/system-init.sh 10 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Keyset.map_with_key.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result = Keyset\map_with_key(dict[1 => 2, 2 => 4, 3 => 5], ($key, $val) ==> $val*$key); 3 | print_r($result); 4 | //result: keyset[2,8,15] 5 | 6 | $result = Keyset\map_with_key(dict[1 => 2, 2 => 4], ($key, $val) ==> $key); 7 | print_r($result); 8 | //result: keyset[1,2] 9 | ``` -------------------------------------------------------------------------------- /api-examples/class.HH.Map/slice.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $m = Map { 3 | 'red' => '#ff0000', 4 | 'green' => '#00ff00', 5 | 'blue' => '#0000ff', 6 | 'yellow' => '#ffff00', 7 | 'purple' => '#663399', 8 | }; 9 | 10 | // Start at key index 1 ('green') and include 3 elements 11 | $m2 = $m->slice(1, 3); 12 | 13 | \var_dump($m2); 14 | ``` 15 | -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/__toString.md: -------------------------------------------------------------------------------- 1 | The string version of an `ImmVector` is always `"ImmVector"`: 2 | 3 | ```basic-usage.hack 4 | $iv = ImmVector {1, 2, 3}; 5 | echo $iv->__toString()."\n"; 6 | 7 | $iv2 = ImmVector {'a', 'b', 'c'}; 8 | echo $iv2->__toString()."\n"; 9 | 10 | $iv3 = ImmVector {}; 11 | echo $iv3->__toString()."\n"; 12 | ``` 13 | -------------------------------------------------------------------------------- /api-examples/class.HH.Set/fromArrays.md: -------------------------------------------------------------------------------- 1 | This example shows that duplicate values in the input arrays only appear once in the final `Set`: 2 | 3 | ```basic-usage.hack 4 | $s = Set::fromArrays( 5 | varray['red'], 6 | varray['green', 'blue'], 7 | varray['yellow', 'red'], // Duplicate 'red' will be ignored 8 | ); 9 | 10 | \var_dump($s); 11 | ``` 12 | -------------------------------------------------------------------------------- /api-examples/class.HH.Set/removeAll.md: -------------------------------------------------------------------------------- 1 | This example removes multiple values from a `Set` and shows that the list of values to be removed can contain duplicates: 2 | 3 | ```basic-usage.hack 4 | $s = Set {'red', 'green', 'blue', 'yellow'}; 5 | 6 | $s->removeAll(Vector { 7 | 'red', 8 | 'blue', 9 | 'red', 10 | }); 11 | 12 | \var_dump($s); 13 | ``` 14 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.C.reduce_with_key.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $dict = dict["a" => 1, "b" => 2, "c" => 3]; 3 | $list = vec["a","b"]; 4 | $reduce_with_key_result = C\reduce_with_key($dict, ($a, $k, $v) ==> $a + (C\contains($list, $k) ? 0 : $v), 0); 5 | echo "Reduce with key result: $reduce_with_key_result\n"; 6 | //Output: Reduce with key result: 3 7 | ``` -------------------------------------------------------------------------------- /api-examples/class.HH.Set/toKeysArray.md: -------------------------------------------------------------------------------- 1 | This example shows that `toKeysArray` is the same as `toValuesArray` because `Set`s don't have keys: 2 | 3 | ```basic-usage.hack 4 | $s = Set {'red', 'green', 'blue', 'yellow'}; 5 | 6 | $keys_array = $s->toKeysArray(); 7 | 8 | \var_dump($keys_array === $s->toValuesArray()); 9 | \var_dump($keys_array); 10 | ``` 11 | -------------------------------------------------------------------------------- /api-examples/class.HH.Pair/skip.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $p = Pair {'foo', -1.5}; 3 | 4 | // Skipping 0 returns an ImmVector of both values 5 | \var_dump($p->skip(0)); 6 | 7 | // Skipping 1 returns an ImmVector of the second value 8 | \var_dump($p->skip(1)); 9 | 10 | // Skipping more than 1 returns an empty ImmVector 11 | \var_dump($p->skip(2)); 12 | ``` 13 | -------------------------------------------------------------------------------- /api-examples/class.HH.Pair/take.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $p = Pair {'foo', -1.5}; 3 | 4 | // Taking 0 returns an empty ImmVector 5 | \var_dump($p->take(0)); 6 | 7 | // Taking 1 returns an ImmVector of the first value 8 | \var_dump($p->take(1)); 9 | 10 | // Taking 2 (or more) returns an ImmVector containing both values 11 | \var_dump($p->take(2)); 12 | ``` 13 | -------------------------------------------------------------------------------- /api-examples/class.HH.Set/remove.md: -------------------------------------------------------------------------------- 1 | This example shows that removing a value that doesn't exist in the `Set` has no effect: 2 | 3 | ```basic-usage.hack 4 | $s = Set {'red', 'green'}; 5 | 6 | // Remove 'red' from the Set 7 | $s->remove('red'); 8 | \var_dump($s); 9 | 10 | // Remove 'red' again (has no effect) 11 | $s->remove('red'); 12 | \var_dump($s); 13 | ``` 14 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Math.round.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $round1 = Math\round(8.65); 3 | echo "8.65 rounded to default precision 0 yields $round1 \n"; 4 | 5 | $round2 = Math\round(8.65, 1); 6 | echo "8.65 rounded to precision 1 yields $round2 \n"; 7 | 8 | $round3 = Math\round(8.65, -1); 9 | echo "8.65 rounded to precision -1 yields $round3 \n"; 10 | ``` 11 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Vec.take.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $example_vec = vec[1,2,3,4,5]; 3 | $result = Vec\take($example_vec, 3); 4 | print_r($result); 5 | //result: [1,2,3] 6 | 7 | $result = Vec\take($example_vec, 0); 8 | print_r($result); 9 | //result: [] 10 | 11 | $result = Vec\take($example_vec, 5); 12 | print_r($result); 13 | //result: [1,2,3,4,5] 14 | ``` -------------------------------------------------------------------------------- /api-examples/class.HH.Map/lastKey.md: -------------------------------------------------------------------------------- 1 | This example shows how `lastKey()` can be used even when a `Map` may be empty: 2 | 3 | ```basic-usage.hack 4 | $m = Map { 5 | 'red' => '#ff0000', 6 | 'green' => '#00ff00', 7 | 'blue' => '#0000ff', 8 | 'yellow' => '#ffff00', 9 | }; 10 | \var_dump($m->lastKey()); 11 | 12 | $m = Map {}; 13 | \var_dump($m->lastKey()); 14 | ``` 15 | -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/mapWithKey.md: -------------------------------------------------------------------------------- 1 | This example shows how `mapWithKey` can be used to create a new `Vector` based on `$v`'s keys and values: 2 | 3 | ```basic-usage.hack 4 | $v = Vector {'red', 'green', 'blue', 'yellow'}; 5 | 6 | $sentences = $v->mapWithKey(($index, $color) ==> "Color at {$index}: {$color}"); 7 | 8 | echo \implode("\n", $sentences)."\n"; 9 | ``` 10 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Str.ends_with.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result = Str\ends_with("example_string", "string"); 3 | echo($result); 4 | //result: true 5 | 6 | $result = Str\ends_with("example_string", "STRING"); 7 | echo($result); 8 | //result: false 9 | 10 | $result = Str\ends_with("example_string", "uncontained"); 11 | echo($result); 12 | // result false 13 | ``` -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Str.ends_with_ci.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result = Str\ends_with_ci("example_string", "string"); 3 | echo($result); 4 | //result: true 5 | $result = Str\ends_with_ci("example_string", "STRING"); 6 | echo($result); 7 | //result: true 8 | $result = Str\ends_with_ci("example_string", "uncontained"); 9 | echo($result); 10 | //result: false 11 | ``` -------------------------------------------------------------------------------- /api-examples/class.HH.Map/lastValue.md: -------------------------------------------------------------------------------- 1 | This example shows how `lastValue()` can be used even when a `Map` may be empty: 2 | 3 | ```basic-usage.hack 4 | $m = Map { 5 | 'red' => '#ff0000', 6 | 'green' => '#00ff00', 7 | 'blue' => '#0000ff', 8 | 'yellow' => '#ffff00', 9 | }; 10 | \var_dump($m->lastValue()); 11 | 12 | $m = Map {}; 13 | \var_dump($m->lastValue()); 14 | ``` 15 | -------------------------------------------------------------------------------- /api-examples/class.HH.Set/skipWhile.md: -------------------------------------------------------------------------------- 1 | This example shows how `skipWhile` can be used to create a new `Set` by skipping elements at the beginning of an existing `Set`: 2 | 3 | ```basic-usage.hack 4 | $s = Set {0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144}; 5 | 6 | // Skip values until we reach one over 10 7 | $s2 = $s->skipWhile($x ==> $x <= 10); 8 | \var_dump($s2); 9 | ``` 10 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Math.sin.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $rotation = 0; 3 | $result = Math\sin($rotation); 4 | echo "Math\sin of $rotation : $result \n"; 5 | 6 | $rotation = 90; 7 | $result = Math\sin($rotation); 8 | echo "Math\sin of $rotation : $result \n"; 9 | 10 | $rotation = 180; 11 | $result = Math\sin($rotation); 12 | echo "Math\sin of $rotation : $result \n"; 13 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Str.starts_with.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result = Str\starts_with("example_string", "example"); 3 | echo($result); 4 | //result: true 5 | 6 | $result = Str\starts_with("example_string", "EXAMPLE"); 7 | echo($result); 8 | //result: false 9 | 10 | $result = Str\starts_with("example_string", "string"); 11 | echo($result); 12 | //result: false 13 | ``` -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Vec.intersect.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $example_vec1 = vec[1,2,3,4,5]; 3 | $example_vec2 = vec[1,3]; 4 | 5 | $result = Vec\intersect($example_vec1, $example_vec2); 6 | print_r($result); 7 | //result: [1,3] 8 | 9 | $example_vec3 = vec[6,7]; 10 | $result = Vec\intersect($example_vec1, $example_vec3); 11 | print_r($result); 12 | //result: [] 13 | ``` -------------------------------------------------------------------------------- /api-examples/class.HH.Set/takeWhile.md: -------------------------------------------------------------------------------- 1 | This example shows how `takeWhile` can be used to create a new `Set` by taking elements from the beginning of an existing `Set`: 2 | 3 | ```basic-usage.hack 4 | $s = Set {0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144}; 5 | 6 | // Include values until we reach one over 10 7 | $s2 = $s->takeWhile($x ==> $x <= 10); 8 | \var_dump($s2); 9 | ``` 10 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Math.tan.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $rotation = 0; 3 | $result = Math\tan($rotation); 4 | echo "Math\\tan of $rotation : $result \n"; 5 | 6 | $rotation = 90; 7 | $result = Math\tan($rotation); 8 | echo "Math\\tan of $rotation : $result \n"; 9 | 10 | $rotation = 180; 11 | $result = Math\tan($rotation); 12 | echo "Math\\tan of $rotation : $result \n"; 13 | -------------------------------------------------------------------------------- /guides/hack/07-traits-and-interfaces/01-introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | **Topics covered in this section** 4 | 5 | * [Using a Trait](/docs/hack/traits-and-interfaces/using-a-trait) 6 | * [Implementing an Interface](/docs/hack/traits-and-interfaces/implementing-an-interface) 7 | * [Trait and Interface Requirements](/docs/hack/traits-and-interfaces/trait-and-interface-requirements) 8 | -------------------------------------------------------------------------------- /src/utils/examples/Testfile.txt: -------------------------------------------------------------------------------- 1 | A Hack program is made up of a well-formed series of source *tokens* 2 | (such as user-defined names, keywords, operators, punctuators, and literals). 3 | To avoid ambiguity or to make source code more readable, in a source file, 4 | white space characters can be placed before the first token, after the last token, 5 | and between any two adjacent tokens. 6 | -------------------------------------------------------------------------------- /api-examples/class.HH.Pair/linearSearch.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $p = Pair {'foo', -1.5}; 3 | 4 | // Prints 0 (the index of the first value) 5 | \var_dump($p->linearSearch('foo')); 6 | 7 | // Prints 1 (the index of the second value) 8 | \var_dump($p->linearSearch(-1.5)); 9 | 10 | // Prints -1 (the value doesn't exist in the Pair) 11 | \var_dump($p->linearSearch('bar')); 12 | ``` 13 | -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/toSet.md: -------------------------------------------------------------------------------- 1 | This example shows that converting a `Vector` to a `Set` also removes duplicate values: 2 | 3 | ```basic-usage.hack 4 | // This Vector contains repetitions of 'red' and 'blue' 5 | $v = Vector {'red', 'green', 'red', 'blue', 'red', 'yellow', 'blue'}; 6 | 7 | $set = $v->toSet(); 8 | 9 | \var_dump($set is \HH\Set<_>); 10 | \var_dump($set); 11 | ``` 12 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Str.starts_with_ci.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result = Str\starts_with_ci("example_string", "example"); 3 | echo($result); 4 | //result: true 5 | 6 | $result = Str\starts_with_ci("example_string", "EXAMPLE"); 7 | echo($result); 8 | //result: true 9 | 10 | $result = Str\starts_with_ci("example_string", "string"); 11 | echo($result); 12 | //result: false 13 | ``` -------------------------------------------------------------------------------- /api-examples/class.HH.Shapes/toArray.md: -------------------------------------------------------------------------------- 1 | This example shows that `toArray` will return the underlying array of a `Shape`. The result will be loosely typed because a single `Shape` can contain arbitrary different types (e.g. `string`, `int`, `float`). 2 | 3 | ```basic-usage.hack 4 | $point = shape('name' => 'Jane Doe', 'age' => 55, 'points' => 25.30); 5 | \var_dump(Shapes::toArray($point)); 6 | ``` 7 | -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/skipWhile.md: -------------------------------------------------------------------------------- 1 | This example shows how `skipWhile` can be used to create a new `Vector` by skipping elements at the beginning of an existing `Vector`: 2 | 3 | ```basic-usage.hack 4 | $v = Vector {0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144}; 5 | 6 | // Skip values until we reach one over 10 7 | $v2 = $v->skipWhile($x ==> $x <= 10); 8 | \var_dump($v2); 9 | ``` 10 | -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/takeWhile.md: -------------------------------------------------------------------------------- 1 | This example shows how `takeWhile` can be used to create a new `Vector` by taking elements from the beginning of an existing `Vector`: 2 | 3 | ```basic-usage.hack 4 | $v = Vector {0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144}; 5 | 6 | // Include values until we reach one over 10 7 | $v2 = $v->takeWhile($x ==> $x <= 10); 8 | \var_dump($v2); 9 | ``` 10 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Keyset.equal.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result = Keyset\equal(keyset[1,2,3,4], keyset[1,2,3,4]); 3 | print_r($result); 4 | //result: true 5 | 6 | $result = Keyset\equal(keyset[1,2,3,4], keyset[4,2,3,1]); 7 | print_r($result); 8 | //result: true 9 | 10 | $result = Keyset\equal(keyset[1,2,3,4], keyset[1,2,3,4,5]); 11 | print_r($result); 12 | //result: false 13 | ``` -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Keyset.filter_nulls.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result = Keyset\filter_nulls(vec[1,2,3,4,null, null]); 3 | print_r($result); 4 | //result: keyset[1,2,3,4] 5 | 6 | $result = Keyset\filter_nulls(vec[1,2,3,4]); 7 | print_r($result); 8 | //result: keyset[1,2,3,4] 9 | 10 | $result = Keyset\filter_nulls(vec[]); 11 | print_r($result); 12 | //result: keyset[] 13 | ``` -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Math.base_convert.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result1 = Math\base_convert("30", 10, 16); 3 | echo "30 in base 10 is $result1 in base 16 \n"; 4 | 5 | $result2 = Math\base_convert("2f", 16, 10); 6 | echo "2f in base 16 is $result2 in base 10 \n"; 7 | 8 | $result3 = Math\base_convert("1111", 2, 16); 9 | echo "1111 in base 2 is $result3 in base 16 \n"; 10 | ``` 11 | -------------------------------------------------------------------------------- /api-examples/class.HH.Pair/containsKey.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $p = Pair {'foo', -1.5}; 3 | 4 | // Prints "true", since index 0 is the first value 5 | \var_dump($p->containsKey(0)); 6 | 7 | // Prints "true", since index 1 is the second value 8 | \var_dump($p->containsKey(1)); 9 | 10 | // Prints "false", since a Pair only has index 0 and index 1 11 | \var_dump($p->containsKey(2)); 12 | ``` 13 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Vec.diff.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $example_vec1 = vec[1,2,3,4,5]; 3 | $example_vec2 = vec[1,3]; 4 | 5 | $diffed_vec = Vec\diff($example_vec1, $example_vec2); 6 | print_r($diffed_vec); 7 | // result: [2,4,5] 8 | 9 | $example_vec3 = vec[6,7]; 10 | 11 | $diffed_vec = Vec\diff($example_vec1, $example_vec3); 12 | print_r($diffed_vec); 13 | // result: [1,2,3,4,5] 14 | ``` -------------------------------------------------------------------------------- /api-examples/class.HH.Map/firstKey.md: -------------------------------------------------------------------------------- 1 | The following example gets the first key from `Map`. An empty `Map` will return `null` as its first key. 2 | 3 | ```basic-usage.hack 4 | $m = Map { 5 | 'red' => '#ff0000', 6 | 'green' => '#00ff00', 7 | 'blue' => '#0000ff', 8 | 'yellow' => '#ffff00', 9 | }; 10 | \var_dump($m->firstKey()); 11 | 12 | $m = Map {}; 13 | \var_dump($m->firstKey()); 14 | ``` 15 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.C.count.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $strings = vec["a", "b", "c", "d", "e"]; 3 | $count_result_1 = C\count($strings); 4 | echo "First count result: $count_result_1\n"; 5 | //Output: First count result: 5 6 | 7 | $empty_strings = vec[]; 8 | $count_result_2 = C\count($empty_strings); 9 | echo "Second count result: $count_result_2\n"; 10 | //Output: Second count result: 0 11 | ``` -------------------------------------------------------------------------------- /api-examples/class.HH.Set/toImmSet.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | function expects_immutable(ImmSet $is): void { 3 | \var_dump($is); 4 | } 5 | 6 | <<__EntryPoint>> 7 | function basic_usage_main(): void { 8 | $s = Set {'red', 'green', 'blue', 'yellow'}; 9 | 10 | // Get a deep, immutable copy of $s 11 | $immutable_s = $s->toImmSet(); 12 | 13 | expects_immutable($immutable_s); 14 | } 15 | ``` 16 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Keyset.intersect.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $example_set1 = keyset[1,2,3,4,5]; 3 | $example_set2 = keyset[1,3]; 4 | 5 | $result = Keyset\intersect($example_set1, $example_set2); 6 | print_r($result); 7 | //result: keyset[1,3] 8 | 9 | $example_vec3 = keyset[6,7]; 10 | $result = Keyset\intersect($example_set1, $example_vec3); 11 | print_r($result); 12 | //result: keyset[] 13 | ``` -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Math.abs.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $negative_number = -25; 3 | $negative_number_abs = Math\abs($negative_number); 4 | echo "Negative test - before: $negative_number after: $negative_number_abs \n"; 5 | 6 | $positive_number = 25; 7 | $positive_number_abs = Math\abs($positive_number); 8 | echo "Positive test - before: $positive_number after: $positive_number_abs \n"; 9 | ``` 10 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Vec.sample.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $example_vec = vec[1,2,3,4,5]; 3 | $result = Vec\sample($example_vec, 3); 4 | print_r($result); 5 | //result: [2,5,3] OR any 3 elements 6 | 7 | $result = Vec\sample($example_vec, 0); 8 | print_r($result); 9 | //result: [] 10 | 11 | $result = Vec\sample($example_vec, 5); 12 | print_r($result); 13 | //result: [4,5,2,1,3]; All 5 elements 14 | ``` -------------------------------------------------------------------------------- /sass/codeBlocks.scss: -------------------------------------------------------------------------------- 1 | .highlight { 2 | @include codetext; 3 | border-left: 3px solid $orange; 4 | overflow-x: auto; 5 | padding: 10px; 6 | margin: 25px 0; 7 | 8 | &.fbgfm { 9 | padding: 0px; 10 | } 11 | } 12 | 13 | p + .highlight { 14 | margin-top: 0; 15 | } 16 | 17 | .output-block span { 18 | color: inherit; 19 | } 20 | 21 | .hljs { 22 | background: $lightergrey !important; 23 | } -------------------------------------------------------------------------------- /api-examples/class.HH.Map/firstValue.md: -------------------------------------------------------------------------------- 1 | The following example gets the first value from a `Map`. An empty `Map` will return `null` as its first value. 2 | 3 | ```basic-usage.hack 4 | $m = Map { 5 | 'red' => '#ff0000', 6 | 'green' => '#00ff00', 7 | 'blue' => '#0000ff', 8 | 'yellow' => '#ffff00', 9 | }; 10 | \var_dump($m->firstValue()); 11 | 12 | $m = Map {}; 13 | \var_dump($m->firstValue()); 14 | ``` 15 | -------------------------------------------------------------------------------- /api-examples/class.HH.Set/immutable.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | function expects_immutable(ImmSet $is): void { 3 | \var_dump($is); 4 | } 5 | 6 | <<__EntryPoint>> 7 | function basic_usage_main(): void { 8 | $s = Set {'red', 'green', 'blue', 'yellow'}; 9 | 10 | // Get a deep, immutable copy of $s 11 | $immutable_s = $s->immutable(); 12 | 13 | expects_immutable($immutable_s); 14 | } 15 | ``` 16 | -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/containsKey.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $v = Vector {'red', 'green', 'blue', 'yellow'}; 3 | 4 | // Prints "true", since index 0 is the first element 5 | \var_dump($v->containsKey(0)); 6 | 7 | // Prints "true", since index 3 is the last element 8 | \var_dump($v->containsKey(3)); 9 | 10 | // Prints "false", since index 10 doesn't exist 11 | \var_dump($v->containsKey(10)); 12 | ``` 13 | -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/toImmSet.md: -------------------------------------------------------------------------------- 1 | This example shows that converting a `Vector` to an `ImmSet` also removes duplicate values: 2 | 3 | ```basic-usage.hack 4 | // This Vector contains repetitions of 'red' and 'blue' 5 | $v = Vector {'red', 'green', 'red', 'blue', 'red', 'yellow', 'blue'}; 6 | 7 | $imm_set = $v->toImmSet(); 8 | 9 | \var_dump($imm_set is \HH\ImmSet<_>); 10 | \var_dump($imm_set); 11 | ``` 12 | -------------------------------------------------------------------------------- /api-examples/class.HH.Set/toSet.md: -------------------------------------------------------------------------------- 1 | This example shows that `toSet` returns a deep copy of the `Set`: 2 | 3 | ```basic-usage.hack 4 | $s = Set {'red', 'green', 'blue', 'yellow'}; 5 | 6 | // Make a deep copy of Set $s 7 | $s2 = $s->toSet(); 8 | 9 | // Modify $s2 by adding an element 10 | $s2->add('purple'); 11 | \var_dump($s2); 12 | 13 | // The original Set $s doesn't include 'purple' 14 | \var_dump($s); 15 | ``` 16 | -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/immutable.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | function expects_immutable(ImmVector $iv): void { 3 | \var_dump($iv); 4 | } 5 | 6 | <<__EntryPoint>> 7 | function basic_usage_main(): void { 8 | $v = Vector {'red', 'green', 'blue', 'yellow'}; 9 | 10 | // Get a deep, immutable copy of $v 11 | $immutable_v = $v->immutable(); 12 | 13 | expects_immutable($immutable_v); 14 | } 15 | ``` 16 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Math.to_base.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $in = 30; 3 | 4 | $base_1 = 10; 5 | $out_1 = Math\to_base($in, $base_1); 6 | echo "$in to base $base_1 is $out_1 \n"; 7 | 8 | $base_2 = 16; 9 | $out_2 = Math\to_base($in, $base_2); 10 | echo "$in to base $base_2 is $out_2 \n"; 11 | 12 | $base_3 = 2; 13 | $out_3 = Math\to_base($in, $base_3); 14 | echo "$in to base $base_3 is $out_3 \n"; 15 | ``` 16 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Vec.zip.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $example_vec1 = vec[1,2,3,4,5]; 3 | $example_vec2 = vec[11,17,23,44,55]; 4 | 5 | $result = Vec\zip($example_vec1, $example_vec2); 6 | print_r($result); 7 | //result: [[1, 11], [2,17], [3,23], [4, 44], [5,55]] 8 | 9 | $example_vec3 = vec[6,7]; 10 | $result = Vec\zip($example_vec1, $example_vec3); 11 | print_r($result); 12 | //result: [[1,6], [2,7]] 13 | ``` -------------------------------------------------------------------------------- /guides/hack/21-XHP/25-further-resources.md: -------------------------------------------------------------------------------- 1 | # Further Resources 2 | 3 | Besides our documentation, there are some other very useful resources to enhance your experience with XHP. 4 | * [XHP Library](https://github.com/facebook/xhp-lib): The class libraries for XHP. 5 | * [XHP Announcement](https://www.facebook.com/notes/facebook-engineering/xhp-a-new-way-to-write-php/294003943919): The original XHP announcement from 2010. 6 | -------------------------------------------------------------------------------- /.deploy/built-site.Dockerfile: -------------------------------------------------------------------------------- 1 | # Creates a docker image with a built copy of the site. Not repo-auth. 2 | # Useful as a scratch/testing area. 3 | FROM hhvm/hhvm:4.164-latest 4 | ENV TZ UTC 5 | ENV LANG en_US.UTF-8 6 | ENV LANGUAGE en_US:en 7 | ENV LC_ALL en_US.UTF-8 8 | ENV COMPOSER_ALLOW_SUPERUSER 1 9 | 10 | RUN rm -rf /var/www 11 | ADD . /var/www 12 | 13 | RUN cd /var/www && touch /.docker_build && .deploy/init.sh 14 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Keyset.filter.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result = Keyset\filter(keyset[1,2,3,4], $val ==> $val%2==0); 3 | print_r($result); 4 | //result: keyset[2,4] 5 | 6 | $result = Keyset\filter(keyset[1,2,3,4], $val ==> $val==0); 7 | print_r($result); 8 | //result: keyset[] 9 | 10 | $result = Keyset\filter(keyset[1,2,3,4], $val ==> $val == $val); 11 | print_r($result); 12 | //result: keyset[1,2,3,4] 13 | ``` -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/setAll.md: -------------------------------------------------------------------------------- 1 | This example shows how `setAll()` can be used with any `KeyedTraversable`: 2 | 3 | ```basic-usage.hack 4 | $v = Vector {'red', 'green', 'blue', 'yellow'}; 5 | 6 | // Set the elements at 0 and 1 7 | $v->setAll(Vector {'foo', 'bar'}); 8 | \var_dump($v); 9 | 10 | // Set the elements at 2 and 3 11 | $v->setAll(Map { 12 | 2 => 'baz', 13 | 3 => 'qux', 14 | }); 15 | \var_dump($v); 16 | ``` 17 | -------------------------------------------------------------------------------- /public/search.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hack/HHVM Docs 4 | Hack/HHVM Documentation Search 5 | UTF-8 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/codegen/PRODUCT_TAGS.php: -------------------------------------------------------------------------------- 1 | > 6 | */ 7 | namespace HHVM\UserDocumentation; 8 | 9 | const dict PRODUCT_TAGS = dict[ 10 | APIProduct::HACK => 'HHVM-4.164.0', 11 | APIProduct::HSL => 'v4.108.1', 12 | APIProduct::HSL_EXPERIMENTAL => 'v4.108.0', 13 | ]; 14 | -------------------------------------------------------------------------------- /api-examples/class.HH.Map/differenceByKey.md: -------------------------------------------------------------------------------- 1 | This example shows how `differenceByKey` can be used to get a new `Map` with some keys excluded: 2 | 3 | ```basic-usage.hack 4 | $m = Map { 5 | 'red' => '#ff0000', 6 | 'green' => '#00ff00', 7 | 'blue' => '#0000ff', 8 | 'yellow' => '#ffff00', 9 | 'purple' => '#663399', 10 | }; 11 | 12 | $m2 = $m->differenceByKey(Set {'red', 'green', 'blue'}); 13 | 14 | \var_dump($m2); 15 | ``` 16 | -------------------------------------------------------------------------------- /api-examples/class.HH.Pair/getIterator.md: -------------------------------------------------------------------------------- 1 | This example shows how to get an iterator from a `Pair` and how to consume it: 2 | 3 | ```basic-usage.hack 4 | $p = Pair {'foo', -1.5}; 5 | 6 | // Get a KeyedIterator for the Pair 7 | $iterator = $p->getIterator(); 8 | 9 | // Print both keys and values 10 | while ($iterator->valid()) { 11 | echo $iterator->key().' => '.(string)$iterator->current()."\n"; 12 | $iterator->next(); 13 | } 14 | ``` 15 | -------------------------------------------------------------------------------- /api-examples/class.HH.Set/getIterator.md: -------------------------------------------------------------------------------- 1 | This example shows how to get an iterator from a `Set` and how to consume it: 2 | 3 | ```basic-usage.hack 4 | $s = Set {'red', 'green', 'blue', 'yellow'}; 5 | 6 | // Get an iterator for the Set of colors 7 | $iterator = $s->getIterator(); 8 | 9 | // Print each color using the iterator 10 | while ($iterator->valid()) { 11 | echo $iterator->current()."\n"; 12 | $iterator->next(); 13 | } 14 | ``` 15 | -------------------------------------------------------------------------------- /api-examples/class.HH.Set/reserve.md: -------------------------------------------------------------------------------- 1 | This example reserves space for 1000 elements and then fills the `Set` with 1000 integers: 2 | 3 | ```basic-usage.hack no-auto-output 4 | const int SET_SIZE = 1000; 5 | 6 | <<__EntryPoint>> 7 | function basic_usage_main(): void { 8 | $s = Set {}; 9 | $s->reserve(SET_SIZE); 10 | 11 | for ($i = 0; $i < SET_SIZE; $i++) { 12 | $s[] = $i * 10; 13 | } 14 | 15 | \var_dump($s); 16 | } 17 | ``` 18 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.C.is_empty.md: -------------------------------------------------------------------------------- 1 | ```basie-usage.hack 2 | $strings = vec["a", "b", "c", "d", "e"]; 3 | $is_empty_result_1 = C\is_empty($strings); 4 | echo "First is_empty result: $is_empty_result_1\n"; 5 | //Output: First is_empty result: false 6 | 7 | $empty_strings = vec[]; 8 | $is_empty_result_2 = C\is_empty($empty_strings); 9 | echo "Second is_empty result: $is_empty_result_2\n"; 10 | //Output: Second is_empty result: true 11 | ``` 12 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Str.replace.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result = Str\replace("example_string", "string", "replacement"); 3 | echo($result); 4 | //result: "example_replacement" 5 | 6 | $result = Str\replace("example_string", "STRING", "replacement"); 7 | echo($result); 8 | //result: "example_string" 9 | 10 | $result = Str\replace("example_string", "uncontained", "replacement"); 11 | echo($result); 12 | //result: "example_string" 13 | ``` -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Str.slice.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result = Str\slice("example_string", 5); 3 | echo($result); 4 | //result: "le_string" 5 | 6 | $result = Str\slice("example_string", 5, 1); 7 | echo($result); 8 | //result: "l" 9 | 10 | $result = Str\slice("example_string", 2, 0); 11 | echo($result); 12 | //result: "" 13 | 14 | $result = Str\slice("example_string", 1000); 15 | echo($result); 16 | //result: 17 | ``` -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Vec.sort.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $example_vec = vec[100,2,4,1,6]; 3 | $result = Vec\sort($example_vec); 4 | print_r($result); 5 | //result: [1,2,4,6,100] 6 | 7 | $example_vec = vec[1,2,3,4,5]; 8 | $result = Vec\sort($example_vec); 9 | print_r($result); 10 | //result: [1,2,3,4,5] 11 | 12 | $example_vec = vec[0,0,0,0,0]; 13 | $result = Vec\sort($example_vec); 14 | print_r($result); 15 | //result: [0,0,0,0,0] 16 | ``` -------------------------------------------------------------------------------- /guides/hack/03-expressions-and-operators/51-await.md: -------------------------------------------------------------------------------- 1 | # Await 2 | 3 | `await` suspends the execution of an async function until the result of the asynchronous operation represented by the expression 4 | that follows this keyword, is available. 5 | 6 | See [awaitables](/docs/hack/asynchronous-operations/awaitables) for details of `await`, and [async](/docs/hack/asynchronous-operations/introduction) for a 7 | general discussion of asynchronous operations. 8 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "Build", 9 | "type": "hhvm", 10 | "request": "launch", 11 | "script": "${workspaceFolder}/bin/build.php" 12 | } 13 | ] 14 | } -------------------------------------------------------------------------------- /src/site/Router.php: -------------------------------------------------------------------------------- 1 | '#ff0000', 6 | 'green' => '#00ff00', 7 | 'blue' => '#0000ff', 8 | 'yellow' => '#ffff00', 9 | }; 10 | 11 | $m2 = $m->toMap(); 12 | $m2->add(Pair {'purple', '#663399'}); 13 | 14 | \var_dump($m); 15 | \var_dump($m2); 16 | ``` 17 | -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/getIterator.md: -------------------------------------------------------------------------------- 1 | This example shows how to get an iterator from a `Vector` and how to consume it: 2 | 3 | ```basic-usage.hack 4 | $v = Vector {'red', 'green', 'blue', 'yellow'}; 5 | 6 | // Get an iterator for the Vector of colors 7 | $iterator = $v->getIterator(); 8 | 9 | // Print each color using the iterator 10 | while ($iterator->valid()) { 11 | echo $iterator->current()."\n"; 12 | $iterator->next(); 13 | } 14 | ``` 15 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.C.findx.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $strings = vec["a", "b", "c", "d"]; 3 | $predicate_result_1 = C\findx($strings, $x ==> $x == "a"); 4 | echo "First predicate: $predicate_result_1\n"; 5 | //Output: First predicate: a 6 | 7 | $predicate_result_2 = C\findx($strings, $x ==> $x == "z"); 8 | //Output: Hit a php exception : exception 'InvariantViolationException' 9 | //with message 'HH\Lib\C\findx: Couldn't find target value.' 10 | ``` -------------------------------------------------------------------------------- /sass/survey.scss: -------------------------------------------------------------------------------- 1 | form.postLink { 2 | display: inline; 3 | } 4 | 5 | .userSurvey { 6 | border-style: dashed; 7 | border-color: $orange; 8 | border-width: 2px; 9 | border-radius: 3px; 10 | margin: 30px; 11 | padding: 10px; 12 | text-align:center; 13 | 14 | a { 15 | font-weight: 400; 16 | } 17 | } 18 | 19 | .feedbackWrapper { 20 | padding-bottom: 40px; 21 | 22 | .gitHubIssueButton { 23 | text-align: left; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /api-examples/class.HH.Map/get.md: -------------------------------------------------------------------------------- 1 | This example shows how `get` can be used to access the value at a key that may not exist: 2 | 3 | ```basic-usage.hack 4 | $m = Map { 5 | 'red' => '#ff0000', 6 | 'green' => '#00ff00', 7 | 'blue' => '#0000ff', 8 | 'yellow' => '#ffff00', 9 | }; 10 | 11 | // Prints the value at key 'red' 12 | \var_dump($m->get('red')); 13 | 14 | // Prints NULL since key 'blurple' doesn't exist 15 | \var_dump($m->get('blurple')); 16 | ``` 17 | -------------------------------------------------------------------------------- /api-examples/class.HH.Map/reserve.md: -------------------------------------------------------------------------------- 1 | This example reserves space for 1000 elements and then fills the `Map` with 1000 integer keys and values: 2 | 3 | ```basic-usage.hack no-auto-output 4 | const int MAP_SIZE = 1000; 5 | 6 | <<__EntryPoint>> 7 | function basic_usage_main(): void { 8 | $m = Map {}; 9 | $m->reserve(MAP_SIZE); 10 | 11 | for ($i = 0; $i < MAP_SIZE; $i++) { 12 | $m[$i] = $i * 10; 13 | } 14 | 15 | \var_dump($m); 16 | } 17 | ``` 18 | -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/reserve.md: -------------------------------------------------------------------------------- 1 | This example reserves space for 1000 elements and then fills the `Vector` with 1000 integers: 2 | 3 | ```basic-usage.hack no-auto-output 4 | const int VECTOR_SIZE = 1000; 5 | 6 | <<__EntryPoint>> 7 | function basic_usage_main(): void { 8 | $v = Vector {}; 9 | $v->reserve(VECTOR_SIZE); 10 | 11 | for ($i = 0; $i < VECTOR_SIZE; $i++) { 12 | $v[] = $i * 10; 13 | } 14 | 15 | \var_dump($v); 16 | } 17 | ``` 18 | -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/resize.md: -------------------------------------------------------------------------------- 1 | This example shows how `resize` can be used to decrease and increase the size of a `Vector`: 2 | 3 | ```basic-usage.hack 4 | $v = Vector {'red', 'green', 'blue', 'yellow'}; 5 | 6 | // Resize the Vector to 2 (removing 'blue' and 'yellow') 7 | $v->resize(2, null); 8 | \var_dump($v); 9 | 10 | // Resize the Vector back to 4 (filling in 'unknown' for new elements) 11 | $v->resize(4, 'unknown'); 12 | \var_dump($v); 13 | ``` 14 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.C.is_sorted_by.md: -------------------------------------------------------------------------------- 1 | ```basie-usage.hack 2 | $strings = vec[1,2,3,4,5]; 3 | $is_sorted_by_result_1 = C\is_sorted_by($strings, $x ==> $x); 4 | echo "First is_sorted_by result: $is_sorted_by_result_1\n"; 5 | //Output: First is_sorted_by result: true 6 | 7 | $is_sorted_by_result_2 = C\is_sorted_by($strings, $x ==> -$x); 8 | echo "Second is_sorted_by result: $is_sorted_by_result_2\n"; 9 | //Output: Second is_sorted_by result: false 10 | ``` -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Str.replace_ci.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result = Str\replace_ci("example_string", "string", "replacement"); 3 | echo($result); 4 | //result: example_replacement 5 | 6 | $result = Str\replace_ci("example_string", "STRING", "replacement"); 7 | echo($result); 8 | //result: example_replacement 9 | 10 | $result = Str\replace_ci("example_string", "uncontained", "replacement"); 11 | echo($result); 12 | //result: example_string 13 | ``` -------------------------------------------------------------------------------- /guides/hack/03-expressions-and-operators/69-string-concatenation.md: -------------------------------------------------------------------------------- 1 | # String Concatenation 2 | 3 | The binary operator `.` creates a string that is the concatenation of the left-hand operand and the right-hand operand, in that order. If 4 | either or both operands have type `int`, their values are converted to type `string`. Consider the following examples: 5 | 6 | ```hack 7 | "foo"."bar"; // "foobar" 8 | "A" . 25; // string result with value "A25" 9 | ``` 10 | -------------------------------------------------------------------------------- /.deploy/init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -ex 4 | 5 | if ! [ -e /.docker_build ]; then 6 | echo "This script should only be ran from a Dockerfile" 7 | exit 1 8 | fi 9 | 10 | if ! [ -x .deploy/system-init.sh ]; then 11 | echo "Run from the root directory of the source tree." 12 | exit 1 13 | fi 14 | 15 | .deploy/system-init.sh 16 | 17 | echo "** Installing Hack dependencies" 18 | composer install 19 | 20 | echo "** Run build" 21 | hhvm bin/build.php --auto 22 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.C.lastx.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $strings = vec["a", "b", "c"]; 3 | $last_string = C\lastx($strings); 4 | echo "Last string in traversable: $last_string \n"; 5 | //Output: Last string in traversable: c 6 | 7 | $empty_traversable = vec[]; 8 | $last_element = C\lastx($empty_traversable); 9 | //Output: Hit a php exception : exception 'InvariantViolationException' with message 10 | //'HH\Lib\C\lastx: Expected at least one element.' 11 | ``` 12 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Vec.partition.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $example_vec = vec[1,2,3,4,5]; 3 | $result = Vec\partition($example_vec, $val ==> $val%2 == 0); 4 | print_r($result); 5 | // result: [[2,4], [1,3,5]] 6 | 7 | $result = Vec\partition($example_vec, $val ==> $val == $val); 8 | print_r($result); 9 | //result: [[1,2,3,4,5], []] 10 | 11 | $result = Vec\partition($example_vec, $val ==> $val != 0); 12 | print_r($result); 13 | //result: [[1,2,3,4,5], []] 14 | ``` -------------------------------------------------------------------------------- /LocalConfig.php: -------------------------------------------------------------------------------- 1 | > 11 | public static function getBuildID(): string { 12 | invariant( 13 | \file_exists(BuildPaths::BUILD_ID_FILE), 14 | "Build ID does not exist", 15 | ); 16 | return Str\trim(\file_get_contents(BuildPaths::BUILD_ID_FILE)); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.C.firstx.md: -------------------------------------------------------------------------------- 1 | ```basie-usage.hack 2 | $strings = vec["a", "b", "c"]; 3 | $first_string = C\firstx($strings); 4 | echo "First string in traversable: $first_string \n"; 5 | //Output: First string in traversable: a 6 | 7 | $empty_traversable = vec[]; 8 | $first_element = C\firstx($empty_traversable); 9 | //Output: Hit a php exception : exception 'InvariantViolationException' with message 10 | //'HH\Lib\C\firstx: Expected at least one element.' 11 | ``` -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Str.search.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result = Str\search("example_string", "example"); 3 | echo($result); 4 | //result: 0 5 | 6 | $result = Str\search("example_string", "EXAMPLE"); 7 | echo($result); 8 | //result: null 9 | 10 | $result = Str\search("example_string", "example", 2); // with offset 11 | echo($result); 12 | //result: null 13 | 14 | $result = Str\search("example_string", "uncontained"); 15 | echo($result); 16 | //result: null 17 | ``` -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Vec.flatten.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $example_vec = vec[vec[1,2,3,4,5],vec[98,99]]; 3 | $result = Vec\flatten($example_vec); 4 | print_r($result); 5 | //result: [1,2,3,4,5,98,99] 6 | 7 | $example_vec = vec[vec[1,2,3,4,5,98,99]]; 8 | $result = Vec\flatten($example_vec); 9 | print_r($result); 10 | //result: [1,2,3,4,5,98,99] 11 | 12 | $example_vec = vec[]; 13 | $result = Vec\flatten($example_vec); 14 | print_r($result); 15 | //result: [] 16 | ``` -------------------------------------------------------------------------------- /api-examples/class.HH.Map/mapWithKey.md: -------------------------------------------------------------------------------- 1 | This example shows how `mapWithKey` can be used to create a new `Map` based on `$m`'s keys and values: 2 | 3 | ```basic-usage.hack 4 | $m = Map { 5 | 'red' => '#ff0000', 6 | 'green' => '#00ff00', 7 | 'blue' => '#0000ff', 8 | 'yellow' => '#ffff00', 9 | }; 10 | 11 | $css_colors = $m->mapWithKey( 12 | ($color, $hex_code) ==> "color: {$hex_code}; /* {$color} */", 13 | ); 14 | 15 | echo \implode("\n", $css_colors)."\n"; 16 | ``` 17 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Dict.equal.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result = Dict\equal(dict[], dict[]); 3 | print_r($result); 4 | //result: true 5 | 6 | $result = Dict\equal(dict[1 => 2, 2 => 4], dict[1 => 2, 2 => 4]); 7 | print_r($result); 8 | //result: true 9 | 10 | $result = Dict\equal(dict[1 => 2, 2 => 4], dict[1 => 2, 300 => 4]); 11 | print($result); 12 | //result: false 13 | 14 | $result = Dict\equal(dict[1 => 2, 2 => 4], dict[1 => 2, 2 => 7000]); 15 | //result: false 16 | ``` -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.C.pop_backx.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $strings = vec["a", "b"]; 3 | $pop_backx_result_1 = C\pop_backx(inout $strings); 4 | echo "First pop_backx result: $pop_backx_result_1\n"; 5 | //Output: First pop_backx result: b 6 | 7 | $empty_strings = vec[]; 8 | $pop_backx_result_2 = C\pop_backx(inout $empty_strings); 9 | //Output: Hit a php exception : exception 'InvariantViolationException' with message 10 | //'HH\Lib\C\pop_backx: Expected at least one element' 11 | ``` -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Str.search_ci.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result = Str\search_ci("example_string", "example"); 3 | echo($result); 4 | //result: 0 5 | 6 | $result = Str\search_ci("example_string", "EXAMPLE"); 7 | echo($result); 8 | //result: 0 9 | 10 | $result = Str\search_ci("example_string", "example", 2); // with offset 11 | echo($result); 12 | //result: null 13 | 14 | $result = Str\search_ci("example_string", "uncontained"); 15 | echo($result); 16 | //result: null 17 | ``` -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/removeKey.md: -------------------------------------------------------------------------------- 1 | Since `Vector::removeKey()` returns a [shallow copy](https://en.wikipedia.org/wiki/Object_copying#Shallow_copy) of `$v` itself, you can chain a bunch of `removeKey()` calls together. 2 | 3 | ```basic-usage.hack 4 | $v = Vector {'red', 'green', 'blue', 'yellow'}; 5 | 6 | // Remove 'blue' at index 2 7 | $v->removeKey(2); 8 | \var_dump($v); 9 | 10 | // Remove 'red' and then remove 'green' 11 | $v->removeKey(0)->removeKey(0); 12 | \var_dump($v); 13 | ``` 14 | -------------------------------------------------------------------------------- /src/build/BuildFlags.php: -------------------------------------------------------------------------------- 1 | "a", "key_2" => "b", "key_3" => "c"]; 3 | $last_keyx_result_1 = C\last_keyx($dict); 4 | echo "First last keyx result: $last_keyx_result_1\n"; 5 | //Output: First last keyx result: key_3 6 | 7 | $empty_dict = dict[]; 8 | $last_keyx_result_2 = C\last_keyx($empty_dict); 9 | //Output: Hit a php exception : exception 'InvariantViolationException' with message 10 | //'HH\Lib\C\last_keyx: Expected at least one element.' 11 | ``` -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.C.pop_back.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $strings = vec["a", "b"]; 3 | $pop_back_result_1 = C\pop_back(inout $strings); 4 | echo "First pop_back result: $pop_back_result_1\n"; 5 | //Output: First pop_back result: b 6 | 7 | $empty_strings = vec[]; 8 | $pop_back_result_2 = C\pop_back(inout $empty_strings); 9 | $pop_back_result_2_as_string = $pop_back_result_2 ?? "null"; 10 | echo "Second pop_back result: $pop_back_result_2_as_string\n"; 11 | //Output: Second pop_back result: null 12 | ``` -------------------------------------------------------------------------------- /api-examples/class.HH.Map/contains.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $m = Map { 3 | 'red' => '#ff0000', 4 | 'green' => '#00ff00', 5 | 'blue' => '#0000ff', 6 | 'yellow' => '#ffff00', 7 | }; 8 | 9 | // Prints "true", since key "red" is the first key 10 | \var_dump($m->containsKey('red')); 11 | 12 | // Prints "true", since key "yellow" is the last key 13 | \var_dump($m->containsKey('yellow')); 14 | 15 | // Prints "false", since key "blurple" isn't in the Map 16 | \var_dump($m->containsKey('blurple')); 17 | ``` 18 | -------------------------------------------------------------------------------- /api-examples/class.HH.Map/containsKey.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $m = Map { 3 | 'red' => '#ff0000', 4 | 'green' => '#00ff00', 5 | 'blue' => '#0000ff', 6 | 'yellow' => '#ffff00', 7 | }; 8 | 9 | // Prints "true", since key "red" is the first key 10 | \var_dump($m->containsKey('red')); 11 | 12 | // Prints "true", since key "yellow" is the last key 13 | \var_dump($m->containsKey('yellow')); 14 | 15 | // Prints "false", since key "blurple" isn't in the Map 16 | \var_dump($m->containsKey('blurple')); 17 | ``` 18 | -------------------------------------------------------------------------------- /api-examples/class.HH.Map/toImmMap.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | function expects_immutable(ImmMap $iv): void { 3 | \var_dump($iv); 4 | } 5 | 6 | <<__EntryPoint>> 7 | function basic_usage_main(): void { 8 | $m = Map { 9 | 'red' => '#ff0000', 10 | 'green' => '#00ff00', 11 | 'blue' => '#0000ff', 12 | 'yellow' => '#ffff00', 13 | }; 14 | 15 | // Get a deep, immutable copy of $m 16 | $immutable_map = $m->toImmMap(); 17 | 18 | expects_immutable($immutable_map); 19 | } 20 | ``` 21 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Keyset.filter_with_key.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result = Keyset\filter_with_key(dict[1 => 2, 2 => 4, 3 => 5], ($key, $val) ==> $val%2==0); 3 | print_r($result); 4 | //result: keyset[2,4] 5 | 6 | $result = Keyset\filter_with_key(dict[1 => 2, 2 => 4], ($key, $val) ==> $val==0); 7 | print_r($result); 8 | //result: keyset[] 9 | 10 | $result = Keyset\filter_with_key(dict[1 => 2, 2 => 4, 3 => 5], ($key, $val) ==> $val == $val); 11 | print_r($result); 12 | //result: keyset[2,4,5] 13 | ``` -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Str.contains.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result = Str\contains("example_string", "example"); 3 | echo($result); 4 | //result: true 5 | 6 | $result = Str\contains("example_string", "EXAMPLE"); // different case 7 | echo($result); 8 | //result: false 9 | 10 | $result = Str\contains("example_string", "example", 2); // with offset 11 | echo($result); 12 | //result: false 13 | 14 | $result = Str\contains("example_string", "uncontained"); 15 | echo($result); 16 | //result: false 17 | ``` -------------------------------------------------------------------------------- /api-examples/class.HH.Map/immutable.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | function expects_immutable(ImmMap $iv): void { 3 | \var_dump($iv); 4 | } 5 | 6 | <<__EntryPoint>> 7 | function basic_usage_main(): void { 8 | $m = Map { 9 | 'red' => '#ff0000', 10 | 'green' => '#00ff00', 11 | 'blue' => '#0000ff', 12 | 'yellow' => '#ffff00', 13 | }; 14 | 15 | // Get a deep, immutable copy of $m 16 | $immutable_map = $m->immutable(); 17 | 18 | expects_immutable($immutable_map); 19 | } 20 | ``` 21 | -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/values.md: -------------------------------------------------------------------------------- 1 | This example shows how `values()` is identical to `toVector()`. It returns a deep copy of `$v`, so mutating this new `Vector` doesn't affect the original. 2 | 3 | ```basic-usage.hack 4 | $v = Vector {'red', 'green', 'blue', 'yellow'}; 5 | 6 | // Make a deep Vector copy of $v 7 | $v2 = $v->values(); 8 | 9 | // Modify $v2 by adding an element 10 | $v2->add('purple'); 11 | \var_dump($v2); 12 | 13 | // The original Vector $v doesn't include 'purple' 14 | \var_dump($v); 15 | ``` 16 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.C.first.md: -------------------------------------------------------------------------------- 1 | ```basie-usage.hack 2 | $strings = vec["a", "b", "c"]; 3 | $first_string = C\first($strings); 4 | echo "First string in traversable: $first_string \n"; 5 | //Output: First string in traversable: a 6 | 7 | $empty_traversable = vec[]; 8 | $first_element = C\first($empty_traversable); 9 | $first_element_as_string = $first_element ?? "null"; 10 | echo "First element in empty traversable: $first_element_as_string"; 11 | //Output: First element in empty traversable: null 12 | ``` 13 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.C.first_keyx.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $dict = dict["key_1" => "a", "key_2" => "b", "key_3" => "c"]; 3 | $first_keyx_result_1 = C\first_keyx($dict); 4 | echo "First first keyx result: $first_keyx_result_1\n"; 5 | //Output: First first keyx result: key_1 6 | 7 | $empty_dict = dict[]; 8 | $first_keyx_result_2 = C\first_keyx($empty_dict); 9 | //Output: Hit a php exception : exception 'InvariantViolationException' with message 10 | //'HH\Lib\C\first_keyx: Expected at least one element.' 11 | ``` -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.C.nfirst.md: -------------------------------------------------------------------------------- 1 | ```basie-usage.hack 2 | $strings = vec["a", "b", "c"]; 3 | $first_string = C\nfirst($strings); 4 | echo "First string in traversable: $first_string \n"; 5 | //Output: First string in traversable: a 6 | 7 | $empty_traversable = vec[]; 8 | $first_element = C\nfirst($empty_traversable); 9 | $first_element_as_string = $first_element ?? "null"; 10 | echo "First element in empty traversable: $first_element_as_string"; 11 | //Output: First element in empty traversable: null 12 | ``` 13 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Str.replace_every.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result = Str\replace_every("example_string", dict["example"=>"test", "string"=>"value"]); 3 | echo($result); 4 | //result: test_value 5 | 6 | $result = Str\replace_every("example_string", dict["EXAMPLE"=>"test", "STRING"=>"value"]); 7 | echo($result); 8 | //result: example_string 9 | 10 | $result = Str\replace_every("example_string", dict["uncontained"=>"test", "uncontained_2"=>"value"]); 11 | echo($result); 12 | //result: example_string 13 | ``` -------------------------------------------------------------------------------- /sass/core.scss: -------------------------------------------------------------------------------- 1 | @import "variables"; 2 | @import "reset"; 3 | 4 | @import "fontawesome"; 5 | @import "solid"; 6 | 7 | @import "basics"; 8 | @import "layout"; 9 | @import "titles"; 10 | @import "lists"; 11 | @import "header"; 12 | @import "navigation"; 13 | @import "sprites"; 14 | @import "codeBlocks"; 15 | @import "innerContent"; 16 | @import "tables"; 17 | @import "pagination"; 18 | @import "feedback"; 19 | @import "search"; 20 | @import "survey"; 21 | @import "buttons"; 22 | @import "notices"; 23 | @import "footer"; 24 | -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/set.md: -------------------------------------------------------------------------------- 1 | Since `Vector::set()` returns a [shallow copy](https://en.wikipedia.org/wiki/Object_copying#Shallow_copy) of `$v` itself, you can chain a bunch of `set()` calls together. 2 | 3 | ```basic-usage.hack 4 | $v = Vector {'red', 'green', 'blue', 'yellow'}; 5 | 6 | // Set the first element to 'RED' 7 | $v->set(0, 'RED'); 8 | 9 | \var_dump($v); 10 | 11 | // Set the second and third elements using chaining 12 | $v->set(1, 'GREEN') 13 | ->set(2, 'BLUE'); 14 | 15 | \var_dump($v); 16 | ``` 17 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Str.compare.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $comparison_1 = Str\compare("apple", "banana"); 3 | echo "Result of first comparison: $comparison_1 \n"; 4 | 5 | $comparison_2 = Str\compare("banana", "apple"); 6 | echo "Result of second comparison: $comparison_2 \n"; 7 | 8 | $comparison_3 = Str\compare("apple", "apple"); 9 | echo "Result of third comparison: $comparison_3 \n"; 10 | 11 | $comparison_4 = Str\compare("apple", "Apple"); 12 | echo "Result of fourth comparison: $comparison_4 \n"; 13 | ``` 14 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Str.replace_every_ci.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $result = Str\replace_every_ci("example_string", dict["example"=>"test", "string"=>"value"]); 3 | echo($result); 4 | //result: test_value 5 | 6 | $result = Str\replace_every_ci("example_string", dict["EXAMPLE"=>"test", "STRING"=>"value"]); 7 | echo($result); 8 | //result: test_value 9 | 10 | $result = Str\replace_every_ci("example_string", dict["uncontained"=>"test", "uncontained_2"=>"value"]); 11 | echo($result); 12 | //result: example_string 13 | ``` -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | vendor 2 | vendor-rb 3 | composer.phar 4 | .commit-template 5 | www.pid 6 | *.swp 7 | *.php.diff 8 | *.php.out 9 | *.php.type-errors.diff 10 | *.php.type-errors.out 11 | *.hack.diff 12 | *.hack.out 13 | *.hack.type-errors.diff 14 | *.hack.type-errors.out 15 | *.css.map 16 | *.stdout 17 | *.stderr 18 | .*.hhast.*cache 19 | /api-sources/ 20 | /build/final/ 21 | /build/scratch/ 22 | /public/www.pid 23 | .sass-cache 24 | .bundle 25 | bourbon/ 26 | .DS_Store 27 | *~ 28 | *.orig 29 | *.rej 30 | Dockerrun.aws.json 31 | .var/ 32 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.C.last_key.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $dict = dict["key_1" => "a", "key_2" => "b", "key_3" => "c"]; 3 | $last_key_result_1 = C\last_key($dict); 4 | echo "First last key result: $last_key_result_1\n"; 5 | //Output: First last key result: key_3 6 | 7 | $empty_dict = dict[]; 8 | $last_key_result_2 = C\last_key($empty_dict); 9 | $last_key_result_2_as_string = $last_key_result_2 ?? "null"; 10 | echo "Second last key result: $last_key_result_2_as_string\n"; 11 | //Output: Second last key result: null 12 | ``` -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.C.pop_front.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $strings = vec["a", "b"]; 3 | $pop_front_result_1 = C\pop_front(inout $strings); 4 | echo "First pop_front result: $pop_front_result_1\n"; 5 | //Output: First pop_front result: a 6 | 7 | $empty_strings = vec[]; 8 | $pop_front_result_2 = C\pop_front(inout $empty_strings); 9 | $pop_front_result_2_as_string = $pop_front_result_2 ?? "null"; 10 | echo "Second pop_front result: $pop_front_result_2_as_string\n"; 11 | //Output: Second pop_front result: null 12 | ``` 13 | -------------------------------------------------------------------------------- /src/utils/examples/async_mysql_require_env.inc.hack: -------------------------------------------------------------------------------- 1 | namespace Hack\UserDocumentation\API\Examples\AsyncMysql; 2 | 3 | use type Hack\UserDocumentation\API\Examples\AsyncMysql\ConnectionInfo as CI; 4 | 5 | async function skipif_async(): Awaitable { 6 | \init_docs_autoloader(); 7 | 8 | $pool = new \AsyncMysqlConnectionPool(darray[]); 9 | try { 10 | await $pool->connect(CI::$host, CI::$port, CI::$db, CI::$user, CI::$passwd); 11 | } catch (\AsyncMysqlConnectException $_) { 12 | die('skip'); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /bin/rename-sections.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | FROM=$1 4 | TO=$2 5 | 6 | if [ -z "$FROM" -o -z "$TO" ]; then 7 | cat < 9 | 10 | e.g. $0 4 7 would rename sections 04 through 07 to 05 through 08 11 | EOF 12 | exit 1 13 | fi 14 | 15 | for i in $(seq $TO -1 $FROM); do 16 | if [ $i -lt 10 ]; then 17 | NAME_PREFIX=0$i 18 | else 19 | NAME_PREFIX=$i 20 | fi 21 | for file in $NAME_PREFIX*; do 22 | git mv $file $(echo $file | sed "s/$i/$(($i + 1))/"); 23 | done; 24 | done 25 | -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/pop.md: -------------------------------------------------------------------------------- 1 | This example shows that `pop()` returns the last element and removes it from the `Vector`: 2 | 3 | ```basic-usage.hack 4 | $v = Vector {'red', 'green', 'blue', 'yellow'}; 5 | 6 | $last_color = $v->pop(); 7 | 8 | \var_dump($last_color); 9 | \var_dump($v); 10 | ``` 11 | 12 | This example shows that trying to `pop` from an empty `Vector` will throw an exception: 13 | 14 | ```throw-exception.hack 15 | $v = Vector {}; 16 | 17 | $last_element = $v->pop(); // Throws InvalidOperationException 18 | ``` 19 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Str.compare_ci.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $comparison_1 = Str\compare_ci("apple", "banana"); 3 | echo "Result of first comparison: $comparison_1 \n"; 4 | 5 | $comparison_2 = Str\compare_ci("banana", "apple"); 6 | echo "Result of second comparison: $comparison_2 \n"; 7 | 8 | $comparison_3 = Str\compare_ci("apple", "Banana"); 9 | echo "Result of third comparison: $comparison_3 \n"; 10 | 11 | $comparison_4 = Str\compare_ci("apple", "Apple"); 12 | echo "Result of fourth comparison: $comparison_4 \n"; 13 | ``` 14 | -------------------------------------------------------------------------------- /api-examples/class.HH.Map/filter.md: -------------------------------------------------------------------------------- 1 | This example shows how `filter` returns a new `Map` containing only the values (and their corresponding keys) for which `$callback` returned `true`: 2 | 3 | ```basic-usage.hack 4 | $m = Map { 5 | 'red' => '#ff0000', 6 | 'green' => '#00ff00', 7 | 'blue' => '#0000ff', 8 | 'yellow' => '#ffff00', 9 | 'purple' => '#663399', 10 | }; 11 | 12 | // Filter $m for colors with a 100% red component 13 | $red_100 = $m->filter($hex_code ==> \strpos($hex_code, '#ff') === 0); 14 | \var_dump($red_100); 15 | ``` 16 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.C.first_key.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $dict = dict["key_1" => "a", "key_2" => "b", "key_3" => "c"]; 3 | $first_key_result_1 = C\first_key($dict); 4 | echo "First first key result: $first_key_result_1\n"; 5 | //Output: First first key result: key_1 6 | 7 | $empty_dict = dict[]; 8 | $first_key_result_2 = C\first_key($empty_dict); 9 | $first_key_result_2_as_string = $first_key_result_2 ?? "null"; 10 | echo "Second first key result: $first_key_result_2_as_string\n"; 11 | //Output: Second first key result: null 12 | ``` -------------------------------------------------------------------------------- /guides/hack/06-classes/01-introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Classes provide a way to group functionality and state together. 4 | 5 | To define a class, use the `class` keyword. 6 | 7 | ```hack 8 | class Counter { 9 | private int $i = 0; 10 | 11 | public function increment(): void { 12 | $this->i += 1; 13 | } 14 | 15 | public function get(): int { 16 | return $this->i; 17 | } 18 | } 19 | ``` 20 | 21 | To create an instance of a class, use 22 | [`new`](/docs/hack/expressions-and-operators/new), e.g. `new Counter();`. 23 | -------------------------------------------------------------------------------- /src/site/controllers/WebPageController.php: -------------------------------------------------------------------------------- 1 | '#ff0000', 6 | 'green' => '#00ff00', 7 | 'blue' => '#0000ff', 8 | 'yellow' => '#ffff00', 9 | }; 10 | 11 | // Remove key 'red' 12 | $m->remove('red'); 13 | \var_dump($m); 14 | 15 | // Remove keys 'green' and 'blue' 16 | $m->remove('green')->remove('blue'); 17 | \var_dump($m); 18 | ``` 19 | -------------------------------------------------------------------------------- /api-examples/class.HH.Map/toSet.md: -------------------------------------------------------------------------------- 1 | This example shows that converting a `Map` to a `Set` also removes duplicate values: 2 | 3 | ```basic-usage.hack 4 | // This Map contains repetitions of the hex codes for 'red' and 'blue' 5 | $m = Map { 6 | 'red' => '#ff0000', 7 | 'also red' => '#ff0000', 8 | 'green' => '#00ff00', 9 | 'another red' => '#ff0000', 10 | 'blue' => '#0000ff', 11 | 'another blue' => '#0000ff', 12 | 'yellow' => '#ffff00', 13 | }; 14 | 15 | $set = $m->toSet(); 16 | 17 | \var_dump($set is \HH\Set<_>); 18 | \var_dump($set); 19 | ``` 20 | -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/filter.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $colors = Vector {'red', 'green', 'blue', 'yellow'}; 3 | $primary_colors = Set {'red', 'green', 'blue'}; 4 | 5 | // Create a Vector of colors that contain the letter 'l' 6 | $l_colors = $colors->filter($color ==> \strpos($color, 'l') !== false); 7 | \var_dump($l_colors); 8 | 9 | // Create a Vector of colors that aren't listed in $primary_colors 10 | $non_primary_colors = $colors->filter( 11 | $color ==> !$primary_colors->contains($color), 12 | ); 13 | \var_dump($non_primary_colors); 14 | ``` 15 | -------------------------------------------------------------------------------- /guides/hhvm/03-advanced-usage/03-daemon.md: -------------------------------------------------------------------------------- 1 | You can run HHVM as a daemon (a background process instead of under the explicit control of a user), you just replace `-m server` with `-m daemon`. 2 | 3 | For example, here is how to run HHVM in daemon mode with Proxygen as the backend: 4 | 5 | ``` 6 | hhvm -m daemon -d hhvm.server.type=proxygen -d hhvm.server.port=8080 7 | ``` 8 | 9 | Here is how to run HHVM with a custom `server.ini` file using FastCGI: 10 | 11 | ``` 12 | hhvm -m daemon -c server.ini -d hhvm.server.type=fastcgi -d hhvm.server.port=9000 13 | ``` 14 | 15 | -------------------------------------------------------------------------------- /api-examples/class.HH.Map/removeKey.md: -------------------------------------------------------------------------------- 1 | Since `Map::removeKey()` returns a [shallow copy](https://en.wikipedia.org/wiki/Object_copying#Shallow_copy) of `$m` itself, you can chain a bunch of `removeKey()` calls together. 2 | 3 | ```basic-usage.hack 4 | $m = Map { 5 | 'red' => '#ff0000', 6 | 'green' => '#00ff00', 7 | 'blue' => '#0000ff', 8 | 'yellow' => '#ffff00', 9 | }; 10 | 11 | // Remove key 'red' 12 | $m->removeKey('red'); 13 | \var_dump($m); 14 | 15 | // Remove keys 'green' and 'blue' 16 | $m->removeKey('green')->removeKey('blue'); 17 | \var_dump($m); 18 | ``` 19 | -------------------------------------------------------------------------------- /api-examples/class.HH.Pair/at.md: -------------------------------------------------------------------------------- 1 | This example prints the first and second values of the `Pair`: 2 | 3 | ```existing-key.hack 4 | $p = Pair {'foo', -1.5}; 5 | 6 | // Print the first element 7 | \var_dump($p->at(0)); 8 | 9 | // Print the second element 10 | \var_dump($p->at(1)); 11 | ``` 12 | 13 | This example throws an `OutOfBoundsException` because a `Pair` only has the indexes `0` and `1`: 14 | 15 | ```missing-key.hack 16 | $p = Pair {'foo', -1.5}; 17 | 18 | // Index 2 doesn't exist because pairs always have exactly two elements 19 | \var_dump($p->at(2)); 20 | ``` 21 | -------------------------------------------------------------------------------- /src/site/controllers/RoutableController.php: -------------------------------------------------------------------------------- 1 | '#ff0000', 7 | 'also red' => '#ff0000', 8 | 'green' => '#00ff00', 9 | 'another red' => '#ff0000', 10 | 'blue' => '#0000ff', 11 | 'another blue' => '#0000ff', 12 | 'yellow' => '#ffff00', 13 | }; 14 | 15 | $imm_set = $m->toImmSet(); 16 | 17 | \var_dump($imm_set is \HH\ImmSet<_>); 18 | \var_dump($imm_set); 19 | ``` 20 | -------------------------------------------------------------------------------- /src/markdown-extensions/PrettyCodeBlock.php: -------------------------------------------------------------------------------- 1 | at(0)); 8 | 9 | // Print the last element 10 | \var_dump($v->at(3)); 11 | ``` 12 | 13 | This example throws an `OutOfBoundsException` because the `Vector` has no index 10: 14 | 15 | ```missing-key.hack 16 | $v = Vector {'red', 'green', 'blue', 'yellow'}; 17 | 18 | // Index 10 doesn't exist (this will throw an exception) 19 | \var_dump($v->at(10)); 20 | ``` 21 | -------------------------------------------------------------------------------- /guides/hack/11-built-in-types/70-mixed.md: -------------------------------------------------------------------------------- 1 | # Mixed 2 | 3 | The `mixed` type represents any value at all in Hack. 4 | 5 | For example, the following function can be passed anything. 6 | 7 | ```hack no-extract 8 | function takes_anything(mixed $m): void {} 9 | 10 | function call_it(): void { 11 | takes_anything("foo"); 12 | takes_anything(42); 13 | takes_anything(new MyClass()); 14 | } 15 | ``` 16 | 17 | `mixed` is equivalent to `?nonnull`. `nonnull` represents any value 18 | except `null`. 19 | 20 | We recommend you avoid using `mixed` whenever you can use a more 21 | specific type. 22 | -------------------------------------------------------------------------------- /api-examples/class.HH.Map/getIterator.md: -------------------------------------------------------------------------------- 1 | This example shows how to get a `KeyedIterator` from a `Map` and how to consume it: 2 | 3 | ```basic-usage.hack 4 | $m = Map { 5 | 'red' => '#ff0000', 6 | 'green' => '#00ff00', 7 | 'blue' => '#0000ff', 8 | 'yellow' => '#ffff00', 9 | }; 10 | 11 | // Get an iterator for the Map of colors to hex codes 12 | $iterator = $m->getIterator(); 13 | 14 | // Print each color (key) and hex code (value) using the iterator 15 | while ($iterator->valid()) { 16 | echo $iterator->key().' => '.$iterator->current()."\n"; 17 | $iterator->next(); 18 | } 19 | ``` 20 | -------------------------------------------------------------------------------- /guides/hack/05-functions/03-type-enforcement.md: -------------------------------------------------------------------------------- 1 | # Type Enforcement 2 | 3 | HHVM does a runtime type check for function arguments and return 4 | values. 5 | 6 | ```hack error 7 | function takes_int(int $_): void {} 8 | 9 | function check_parameter(): void { 10 | takes_int("not an int"); // runtime error. 11 | } 12 | 13 | function check_return_value(): int { 14 | return "not an int"; // runtime error. 15 | } 16 | ``` 17 | 18 | If a type is wrong, HHVM will raise a fatal error. This is controlled 19 | with the HHVM option `CheckReturnTypeHints`. Setting it to 0 or 1 will 20 | disable this. 21 | -------------------------------------------------------------------------------- /api-examples/class.HH.Map/toVector.md: -------------------------------------------------------------------------------- 1 | This example shows how `toVector()` returns a `Vector` of `$m`'s values, so mutating this new `Vector` doesn't affect the original `Map`. 2 | 3 | ```basic-usage.hack 4 | $m = Map { 5 | 'red' => '#ff0000', 6 | 'green' => '#00ff00', 7 | 'blue' => '#0000ff', 8 | 'yellow' => '#ffff00', 9 | }; 10 | 11 | // Make a deep Vector copy of the values of $m 12 | $v = $m->toVector(); 13 | 14 | // Modify $v by adding an element 15 | $v->add('#663399'); 16 | \var_dump($v); 17 | 18 | // The original Map $m doesn't include the value '#663399' 19 | \var_dump($m); 20 | ``` 21 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.C.contains.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $strings = vec["a", "b", "c", "d"]; 3 | $contains_result_1 = C\contains($strings, "a"); 4 | echo "First contains result: $contains_result_1\n"; 5 | //Output: First contains result: true 6 | 7 | $contains_result_2 = C\contains($strings, "z"); 8 | echo "Second contains result: $contains_result_2\n"; 9 | //Output: Second contains result: false 10 | 11 | $empty_strings = vec[]; 12 | $contains_result_3 = C\contains($empty_strings, "a"); 13 | echo "Third contains result: $contains_result_3\n"; 14 | //Output: Third contains result: false 15 | ``` -------------------------------------------------------------------------------- /api-examples/class.HH.Map/set.md: -------------------------------------------------------------------------------- 1 | Since `Map::set()` returns a [shallow copy](https://en.wikipedia.org/wiki/Object_copying#Shallow_copy) of `$m` itself, you can chain a bunch of `set()` calls together. 2 | 3 | ```basic-usage.hack 4 | $m = Map { 5 | 'red' => '#ff0000', 6 | 'green' => '#00ff00', 7 | 'blue' => '#0000ff', 8 | 'yellow' => '#ffff00', 9 | }; 10 | 11 | // Set the value at key 'red' 12 | $m->set('red', 'rgb(255, 0, 0)'); 13 | 14 | // Set the values at keys 'green' and 'blue' 15 | $m->set('green', 'rgb(0, 255, 0)') 16 | ->set('blue', 'rgb(0, 0, 255)'); 17 | 18 | \var_dump($m); 19 | ``` 20 | -------------------------------------------------------------------------------- /api-examples/class.HH.Pair/toSet.md: -------------------------------------------------------------------------------- 1 | This example shows that converting a `Pair` to a `Set` also removes duplicate values: 2 | 3 | ```basic-usage.hack 4 | // This Pair contains 'foo' twice 5 | $p = Pair {'foo', 'foo'}; 6 | 7 | $s = $p->toSet(); 8 | \var_dump($s); 9 | ``` 10 | 11 | This example shows that converting a `Pair` to a `Set` will throw a fatal error if the `Pair` contains a value that's not a `string` or an `int`: 12 | 13 | ```runtime-fatal.hack 14 | $p = Pair {'foo', -1.5}; 15 | 16 | /* HH_FIXME[4323] Fatal error will be thrown here */ 17 | $s = $p->toSet(); 18 | 19 | \var_dump($s); 20 | ``` 21 | -------------------------------------------------------------------------------- /src/utils/type_alias_structure.php: -------------------------------------------------------------------------------- 1 | (typename $typename): TypeStructure { 15 | return /* HH_IGNORE_ERROR[4104] */ type_structure($typename); 16 | } 17 | -------------------------------------------------------------------------------- /guides/hack/03-expressions-and-operators/09-echo.md: -------------------------------------------------------------------------------- 1 | # Echo 2 | 3 | This intrinsic function converts the value of an expression to `string` (if necessary) and writes the string to standard output. For example: 4 | 5 | ```hack 6 | $v1 = 23; 7 | echo '>>'.$v1."<<\n"; // outputs ">>23<<" 8 | 9 | $v3 = "abc{$v1}xyz"; 10 | echo "$v3\n"; 11 | ``` 12 | 13 | For a discussion of value substitution in strings, see [string literals](/docs/hack/source-code-fundamentals/literals#double-quoted-string-literals). 14 | For conversion to strings, see [type conversion](/docs/hack/types/type-conversion#converting-to-string). 15 | -------------------------------------------------------------------------------- /api-examples/class.HH.Map/values.md: -------------------------------------------------------------------------------- 1 | This example shows how `values()` is identical to `toVector()`. It returns a new `Vector` of `$m`'s values, so mutating this new `Vector` doesn't affect the original `Map`. 2 | 3 | ```basic-usage.hack 4 | $m = Map { 5 | 'red' => '#ff0000', 6 | 'green' => '#00ff00', 7 | 'blue' => '#0000ff', 8 | 'yellow' => '#ffff00', 9 | }; 10 | 11 | // Get a Vector of $m's values 12 | $v = $m->values(); 13 | 14 | // Modify $v by adding an element 15 | $v->add('#663399'); 16 | \var_dump($v); 17 | 18 | // The original Map $m doesn't include the value '#663399' 19 | \var_dump($m); 20 | ``` 21 | -------------------------------------------------------------------------------- /api-examples/class.HH.Set/fromItems.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | // Create a new Set from an array 3 | $s = Set::fromItems(varray['red', 'green', 'red', 'blue', 'blue', 'yellow']); 4 | \var_dump($s); 5 | 6 | // Create a new Set from a Vector 7 | $s = Set::fromItems(Vector {'red', 'green', 'red', 'blue', 'blue', 'yellow'}); 8 | \var_dump($s); 9 | 10 | // Create a new Set from the values of a Map 11 | $s = Set::fromItems(Map { 12 | 'red1' => 'red', 13 | 'green' => 'green', 14 | 'red2' => 'red', 15 | 'blue1' => 'blue', 16 | 'blue2' => 'blue', 17 | 'yellow' => 'yellow', 18 | }); 19 | \var_dump($s); 20 | ``` 21 | -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/add.md: -------------------------------------------------------------------------------- 1 | The following example adds a single value to the `Vector` `$v` and also adds multiple values to `$v` through chaining. Since `Vector::add()` returns a [shallow copy](https://en.wikipedia.org/wiki/Object_copying#Shallow_copy) of `$v` itself, you can chain a bunch of `add()` calls together, and that will add all those values to `$v`. 2 | 3 | ```basic-usage.hack 4 | $v = Vector {}; 5 | 6 | $v->add('red'); 7 | \var_dump($v); 8 | 9 | // Vector::add returns the Vector so it can be chained 10 | $v->add('green') 11 | ->add('blue') 12 | ->add('yellow'); 13 | \var_dump($v); 14 | ``` 15 | -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/zip.md: -------------------------------------------------------------------------------- 1 | This example shows how `zip` combines the values of the `Vector` and another `Traversable`. The resulting `Vector` `$labeled_colors` has three elements because `$labels` doesn't have a fourth element to pair with `$v`. 2 | 3 | ```basic-usage.hack 4 | $v = Vector {'red', 'green', 'blue', 'yellow'}; 5 | 6 | $labels = Vector {'My Favorite', 'My 2nd Favorite', 'My 3rd Favorite'}; 7 | $labeled_colors = $v->zip($labels); 8 | 9 | \var_dump($labeled_colors->count()); // 3 10 | 11 | foreach ($labeled_colors as list($color, $label)) { 12 | echo $label.': '.$color."\n"; 13 | } 14 | ``` 15 | -------------------------------------------------------------------------------- /api-examples/class.HH.Set/map.md: -------------------------------------------------------------------------------- 1 | In this example the `Set`'s elements are mapped to the same type (`string`s): 2 | 3 | ```map-to-strings.hack 4 | $s = Set {'red', 'green', 'blue', 'yellow'}; 5 | 6 | $capitalized = $s->map(fun('strtoupper')); 7 | \var_dump($capitalized); 8 | 9 | $shortened = $s->map($color ==> \substr($color, 0, 3)); 10 | \var_dump($shortened); 11 | ``` 12 | 13 | In this example the `Set`'s elements are mapped to a different type (`int`s): 14 | 15 | ```map-to-ints.hack 16 | $s = Set {'red', 'green', 'blue', 'yellow'}; 17 | 18 | $lengths = $s->map(fun('strlen')); 19 | \var_dump($lengths); 20 | ``` 21 | -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/shuffle.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $v = Vector {'red', 'green', 'blue', 'yellow'}; 3 | 4 | // Randomize the Vector elements in place 5 | $v->shuffle(); 6 | 7 | \var_dump($v); 8 | ```.hhvm.expectf 9 | object(HH\Vector) (4) { 10 | [0]=> 11 | string(%d) "%s" 12 | [1]=> 13 | string(%d) "%s" 14 | [2]=> 15 | string(%d) "%s" 16 | [3]=> 17 | string(%d) "%s" 18 | } 19 | ```.example.hhvm.out 20 | object(HH\Vector) (4) { 21 | [0]=> 22 | string(4) "blue" 23 | [1]=> 24 | string(5) "green" 25 | [2]=> 26 | string(6) "yellow" 27 | [3]=> 28 | string(3) "red" 29 | } 30 | ``` 31 | -------------------------------------------------------------------------------- /guides/hack/04-statements/01-introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | **Topics covered in this section** 4 | 5 | * [break/continue](/docs/hack/statements/break-and-continue) 6 | * [do/while](/docs/hack/statements/do) 7 | * [for](/docs/hack/statements/for) 8 | * [foreach](/docs/hack/statements/foreach) 9 | * [if/else if/else](/docs/hack/statements/if) 10 | * [return](/docs/hack/statements/return) 11 | * [switch](/docs/hack/statements/switch) 12 | * [throw/try/catch/finally](/docs/hack/statements/try) 13 | * [use](/docs/hack/statements/use) 14 | * [using](/docs/hack/statements/using) 15 | * [while](/docs/hack/statements/while) 16 | -------------------------------------------------------------------------------- /api-examples/class.MCRouter/createSimple.md: -------------------------------------------------------------------------------- 1 | The following example shows you how use `MCRouter::createSimple` to create an instance of `MCRouter`. You only need to pass it a `Vector` containing one or more locations of Memcached servers; default configurations are used after that (e.g, `route = 'PoolRoute|P'`). 2 | 3 | ```basic-usage.hack 4 | $servers = Vector {\getenv('HHVM_TEST_MCROUTER')}; 5 | $mc = \MCRouter::createSimple($servers); 6 | \var_dump($mc is \MCRouter); 7 | ```.hhvm.expectf 8 | bool(true) 9 | ```.example.hhvm.out 10 | bool(true) 11 | ```.skipif 12 | \Hack\UserDocumentation\API\Examples\MCRouter\skipif(); 13 | ``` 14 | -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/map.md: -------------------------------------------------------------------------------- 1 | In this example the `Vector`'s elements are mapped to the same type (`string`s): 2 | 3 | ```map-to-strings.hack 4 | $v = Vector {'red', 'green', 'blue', 'yellow'}; 5 | 6 | $capitalized = $v->map(fun('strtoupper')); 7 | \var_dump($capitalized); 8 | 9 | $shortened = $v->map($color ==> \substr($color, 0, 3)); 10 | \var_dump($shortened); 11 | ``` 12 | 13 | In this example the `Vector`'s elements are mapped to a different type (`int`s): 14 | 15 | ```map-to-ints.hack 16 | $v = Vector {'red', 'green', 'blue', 'yellow'}; 17 | 18 | $lengths = $v->map(fun('strlen')); 19 | \var_dump($lengths); 20 | ``` 21 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.C.onlyx.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $string = vec["a"]; 3 | $onlyx_result_1 = C\onlyx($string); 4 | echo "First onlyx result: $onlyx_result_1\n"; 5 | //Output: First onlyx result: a 6 | 7 | $strings = vec["a", "b"]; 8 | $onlyx_result_2 = C\onlyx($strings); 9 | //Output: Hit a php exception : exception 'InvariantViolationException' with message 10 | //'Expected exactly one element but got 2.' 11 | 12 | $empty_strings = vec[]; 13 | $onlyx_result_3 = C\onlyx($empty_strings); 14 | //Output: Hit a php exception : exception 'InvariantViolationException' with message 15 | //'Expected non-empty Traversable.' 16 | ``` -------------------------------------------------------------------------------- /api-examples/class.HH.Shapes/removeKey.md: -------------------------------------------------------------------------------- 1 | This example shows that `removeKey` directly removes a key from a `Shape`: 2 | 3 | ```basic-usage.hack 4 | function run(shape('x' => int, 'y' => int) $point): void { 5 | // Prints the value at key 'y' 6 | \var_dump($point['y']); 7 | 8 | Shapes::removeKey(inout $point, 'y'); 9 | 10 | // Prints NULL because the key 'y' doesn't exist any more 11 | /* HH_IGNORE_ERROR[4251] typechecker knows the key doesn't exist */ 12 | \var_dump(Shapes::idx($point, 'y')); 13 | } 14 | 15 | <<__EntryPoint>> 16 | function basic_usage_main(): void { 17 | run(shape('x' => 3, 'y' => -1)); 18 | } 19 | ``` 20 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.C.contains_key.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $dict = dict["key_1" => "a", "key_2" => "b"]; 3 | $contains_key_result_1 = C\contains_key($dict, "key_1"); 4 | echo "First contains key result: $contains_key_result_1\n"; 5 | //Output: First contains key result: true 6 | 7 | $contains_key_result_2 = C\contains_key($dict, "key_3"); 8 | echo "Second contains key result: $contains_key_result_2\n"; 9 | //Output: Second contains key result: false 10 | 11 | $contains_key_result_3 = C\contains_key($dict, ""); 12 | echo "Third contains key result: $contains_key_result_3\n"; 13 | //Output: Third contains key result: false 14 | ``` -------------------------------------------------------------------------------- /api-examples/class.HH.Map/setAll.md: -------------------------------------------------------------------------------- 1 | This example shows how `setAll()` can be used with any `KeyedTraversable`: 2 | 3 | ```basic-usage.hack 4 | $m = Map { 5 | 'red' => '#ff0000', 6 | 'green' => '#00ff00', 7 | 'blue' => '#0000ff', 8 | 'yellow' => '#ffff00', 9 | }; 10 | 11 | // Set the values at keys 'red' and 'green' 12 | $m->setAll(Map { 13 | 'red' => 'rgb(255, 0, 0)', 14 | 'green' => 'rgb(0, 255, 0)', 15 | }); 16 | 17 | // Set the values at keys 'blue' and 'yellow' with an associative array 18 | $m->setAll(darray[ 19 | 'blue' => 'rgb(0, 0, 255)', 20 | 'yellow' => 'rgb(255, 255, 0)', 21 | ]); 22 | 23 | \var_dump($m); 24 | ``` 25 | -------------------------------------------------------------------------------- /api-examples/class.HH.Pair/toImmSet.md: -------------------------------------------------------------------------------- 1 | This example shows that converting a `Pair` to an `ImmSet` also removes duplicate values: 2 | 3 | ```basic-usage.hack 4 | // This Pair contains 'foo' twice 5 | $p = Pair {'foo', 'foo'}; 6 | 7 | $imm_set = $p->toImmSet(); 8 | \var_dump($imm_set); 9 | ``` 10 | 11 | This example shows that converting a `Pair` to an `ImmSet` will throw a fatal error if the `Pair` contains a value that's not a `string` or an `int`: 12 | 13 | ```runtime-fatal.hack 14 | $p = Pair {'foo', -1.5}; 15 | 16 | /* HH_FIXME[4323] Fatal error will be thrown here */ 17 | $imm_set = $p->toImmSet(); 18 | 19 | \var_dump($imm_set); 20 | ``` 21 | -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/toImmVector.md: -------------------------------------------------------------------------------- 1 | This example shows that `toImmVector` returns an immutable copy of the `Vector`. Mutating the original `Vector` doesn't affect the immutable copy. 2 | 3 | ```basic-usage.hack 4 | function expects_immutable(ImmVector $iv): void { 5 | \var_dump($iv); 6 | } 7 | 8 | <<__EntryPoint>> 9 | function basic_usage_main(): void { 10 | $v = Vector {'red', 'green', 'blue', 'yellow'}; 11 | 12 | // Get a deep, immutable copy of $v 13 | $immutable_v = $v->immutable(); 14 | 15 | // Add a color to the original Vector $v 16 | $v->add('purple'); 17 | 18 | expects_immutable($immutable_v); 19 | } 20 | ``` 21 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Dict.select_keys.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $dict_with_all_keys = dict["key1" => "value 1", "key2" => "value 2", "key3" => "value 3"]; 3 | 4 | $present_required_keys = vec["key1"]; 5 | $keys_not_present_in_dict = vec["incorrect_keys"]; 6 | 7 | $dict_with_present_keys = Dict\select_keys($dict_with_all_keys, $present_required_keys); 8 | echo"Result when keys present in dict: \n"; 9 | \print_r($dict_with_present_keys); 10 | 11 | $dict_with_keys_not_present = Dict\select_keys($dict_with_all_keys, $keys_not_present_in_dict); 12 | echo"Result when keys not present in dict: \n"; 13 | \print_r($dict_with_keys_not_present); 14 | ``` -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/lastKey.md: -------------------------------------------------------------------------------- 1 | This example shows how `lastKey()` can be used even when a `Vector` may be empty: 2 | 3 | ```basic-usage.hack 4 | function echoLastKey(Vector $v): void { 5 | $last_key = $v->lastKey(); 6 | if ($last_key !== null) { 7 | echo 'Last key: '.$last_key."\n"; 8 | } else { 9 | echo 'No last key (Vector is empty)'."\n"; 10 | } 11 | } 12 | 13 | <<__EntryPoint>> 14 | function basic_usage_main(): void { 15 | // Will print "Last key: 3" 16 | echoLastKey(Vector {'red', 'green', 'blue', 'yellow'}); 17 | 18 | // Will print "No last key (Vector is empty)" 19 | echoLastKey(Vector {}); 20 | } 21 | ``` 22 | -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/fromItems.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | // Create a new Vector from an array 3 | $v = Vector::fromItems(varray['red', 'green', 'blue', 'yellow']); 4 | \var_dump($v); 5 | 6 | // Create a new Vector from a Set 7 | $v = Vector::fromItems(Set {'red', 'green', 'blue', 'yellow'}); 8 | \var_dump($v); 9 | 10 | // Create a new Vector from the values of a Map 11 | $v = Vector::fromItems(Map { 12 | 'red' => 'red', 13 | 'green' => 'green', 14 | 'blue' => 'blue', 15 | 'yellow' => 'yellow', 16 | }); 17 | \var_dump($v); 18 | 19 | // An empty Vector is created if null is provided 20 | $v = Vector::fromItems(null); 21 | \var_dump($v); 22 | ``` 23 | -------------------------------------------------------------------------------- /api-examples/class.HH.Map/concat.md: -------------------------------------------------------------------------------- 1 | This example creates new `Vector`s by concatenating the values in a `Map` with `Traversable`s: 2 | 3 | ```basic-usage.hack 4 | $m = Map { 5 | 'red' => '#ff0000', 6 | }; 7 | 8 | // Create a Vector by concating the values from $m with a Set 9 | $v1 = $m->concat(Set {'#00ff00', '#0000ff'}); 10 | 11 | // Create a Vector by concating the values from $m with a Vector 12 | $v2 = $m->concat(Vector {'#ffff00', '#663399'}); 13 | 14 | \var_dump($m->values()); // $m contains the value '#ff0000' 15 | \var_dump($v1); // $v1 contains '#ff0000', '#00ff00', '#0000ff' 16 | \var_dump($v2); // $v2 contains '#ff0000', '#ffff00', '#663399' 17 | ``` 18 | -------------------------------------------------------------------------------- /api-examples/class.HH.Set/concat.md: -------------------------------------------------------------------------------- 1 | This example creates new `Set`s by concatenating other `Traversable`s. Unlike `Set::addAll()` this method returns a new `Set` (not a [shallow copy](https://en.wikipedia.org/wiki/Object_copying#Shallow_copy)). 2 | 3 | ```basic-usage.hack 4 | $s = Set {'red'}; 5 | 6 | // Add all the values in a Vector 7 | $s1 = $s->concat(Vector {'green', 'blue'}); 8 | 9 | // Add all the values in an array 10 | $s2 = $s1->concat(varray['yellow', 'purple']); 11 | 12 | \var_dump($s); // $s contains 'red' 13 | \var_dump($s1); // $s1 contains 'red', 'green', 'blue' 14 | \var_dump($s2); // $s2 contains 'red', 'green', 'blue', 'yellow', 'purple' 15 | ``` 16 | -------------------------------------------------------------------------------- /api-examples/class.HH.Set/toImmVector.md: -------------------------------------------------------------------------------- 1 | This example shows that `toImmVector` returns an `ImmVector` containing the `Set`'s values. Mutating the original `Set` doesn't affect the `ImmVector`. 2 | 3 | ```basic-usage.hack 4 | function expects_immutable(ImmVector $iv): void { 5 | \var_dump($iv); 6 | } 7 | 8 | <<__EntryPoint>> 9 | function basic_usage_main(): void { 10 | $s = Set {'red', 'green', 'blue', 'yellow'}; 11 | 12 | // Get an immutable Vector $v of the values in Set $s 13 | $immutable_v = $s->toImmVector(); 14 | 15 | // Add a color to the original Set $s 16 | $s->add('purple'); 17 | 18 | expects_immutable($immutable_v); 19 | } 20 | ``` 21 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.C.is_sorted.md: -------------------------------------------------------------------------------- 1 | ```basie-usage.hack 2 | $strings = vec["a", "b", "c", "d", "e"]; 3 | $is_sorted_result_1 = C\is_sorted($strings); 4 | echo "First is_sorted result: $is_sorted_result_1\n"; 5 | //Output: First is_sorted result: true 6 | 7 | $second_strings = vec["a", "b", "a", "d", "e"]; 8 | $is_sorted_result_2 = C\is_sorted($second_strings); 9 | echo "Second is_sorted result: $is_sorted_result_2\n"; 10 | //Output: Second is_sorted result: false 11 | 12 | $empty_strings = vec[]; 13 | $is_sorted_result_3 = C\is_sorted($empty_strings); 14 | echo "Third is_sorted result: $is_sorted_result_3\n"; 15 | //Output: Third is_sorted result: true 16 | ``` 17 | -------------------------------------------------------------------------------- /src/utils/_private/ScopeExit.php: -------------------------------------------------------------------------------- 1 | callable)(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/concat.md: -------------------------------------------------------------------------------- 1 | This example creates new `Vector`s by concatenating other `Traversable`s. Unlike `Vector::addAll()` this method returns a new `Vector` (not a [shallow copy](https://en.wikipedia.org/wiki/Object_copying#Shallow_copy)). 2 | 3 | ```basic-usage.hack 4 | $v = Vector {'red'}; 5 | 6 | // Add all the values in a Set 7 | $v1 = $v->concat(Set {'green', 'blue'}); 8 | 9 | // Add all the values in an array 10 | $v2 = $v1->concat(varray['yellow', 'purple']); 11 | 12 | \var_dump($v); // $v contains 'red' 13 | \var_dump($v1); // $v1 contains 'red', 'green', 'blue' 14 | \var_dump($v2); // $v2 contains 'red', 'green', 'blue', 'yellow', 'purple' 15 | ``` 16 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.Dict.from_values.md: -------------------------------------------------------------------------------- 1 | ```hack.basic-usage.hack 2 | $original_dict_1 = dict[1 => 1, 2 => 2, 3 => 3]; 3 | $from_values_dict_1 = Dict\from_values($original_dict_1, $x ==> $x + 1); 4 | echo "Resulting from values dict 1: \n"; 5 | \print_r($from_values_dict_1); 6 | //Output: Resulting from values dict 1: 7 | //dict[2 => 1, 3 => 2, 4 => 3] 8 | 9 | $original_dict_2 = dict[1 => 1, 2 => 2, 3 => 3]; 10 | $from_values_repeat_value_dict_2 = Dict\from_values($original_dict_2, $x ==> $x * 0); 11 | echo "Resulting from repeat values dict 2: \n"; 12 | \print_r($from_values_repeat_value_dict_2); 13 | //Output: Resulting from repeat values dict 2: 14 | //dict[0 => 3] 15 | ``` -------------------------------------------------------------------------------- /src/utils/_private/SuperGlobals.php: -------------------------------------------------------------------------------- 1 | { 8 | return TypeCoerce\match>( 9 | \HH\global_get('_ENV'), 10 | ); 11 | } 12 | 13 | /** 14 | * This type is very big. 15 | * Add the keys that you need. 16 | * The more you add, the slower it becomes however. 17 | */ 18 | type TServerVariables = shape( 19 | 'HTTP_HOST' => string, 20 | ... 21 | ); 22 | 23 | function server_variables(): TServerVariables { 24 | return \HH\global_get('_SERVER') as TServerVariables; 25 | } 26 | -------------------------------------------------------------------------------- /api-examples/class.HH.Map/add.md: -------------------------------------------------------------------------------- 1 | The following example adds a single key-value pair to the `Map` `$m` and also adds multiple key-value pairs to `$m` through chaining. Since `Map::add()` returns a [shallow copy](https://en.wikipedia.org/wiki/Object_copying#Shallow_copy) of `$m` itself, you can chain a bunch of `add()` calls together, and that will add all those values to `$m`. 2 | 3 | ```basic-usage.hack 4 | $m = Map {}; 5 | 6 | $m->add(Pair {'red', '#ff0000'}); 7 | \var_dump($m); 8 | 9 | // Map::add returns the Map so it can be chained 10 | $m->add(Pair {'green', '#00ff00'}) 11 | ->add(Pair {'blue', '#0000ff'}) 12 | ->add(Pair {'yellow', '#ffff00'}); 13 | \var_dump($m); 14 | ``` 15 | -------------------------------------------------------------------------------- /src/site/controllers/codegen/SearchControllerURIBuilder.php: -------------------------------------------------------------------------------- 1 | > 9 | */ 10 | 11 | abstract final class SearchControllerURIBuilder 12 | extends \Facebook\HackRouter\UriBuilderCodegen { 13 | 14 | const classname<\Facebook\HackRouter\HasUriPattern> CONTROLLER = \SearchController::class; 15 | const type TParameters = shape( 16 | ); 17 | 18 | public static function getPath(): string { 19 | return self::createInnerBuilder() 20 | ->getPath(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/lastValue.md: -------------------------------------------------------------------------------- 1 | This example shows how `lastValue()` can be used even when a `Vector` may be empty: 2 | 3 | ```basic-usage.hack 4 | function echoLastValue(Vector $v): void { 5 | $last_value = $v->lastValue(); 6 | if ($last_value !== null) { 7 | echo 'Last value: '.$last_value."\n"; 8 | } else { 9 | echo 'No last value (Vector is empty)'."\n"; 10 | } 11 | } 12 | 13 | <<__EntryPoint>> 14 | function basic_usage_main(): void { 15 | // Will print "Last value: yellow" 16 | echoLastValue(Vector {'red', 'green', 'blue', 'yellow'}); 17 | 18 | // Will print "No last value (Vector is empty)" 19 | echoLastValue(Vector {}); 20 | } 21 | ``` 22 | -------------------------------------------------------------------------------- /src/site/controllers/codegen/HomePageControllerURIBuilder.php: -------------------------------------------------------------------------------- 1 | > 9 | */ 10 | 11 | abstract final class HomePageControllerURIBuilder 12 | extends \Facebook\HackRouter\UriBuilderCodegen { 13 | 14 | const classname<\Facebook\HackRouter\HasUriPattern> CONTROLLER = \HomePageController::class; 15 | const type TParameters = shape( 16 | ); 17 | 18 | public static function getPath(): string { 19 | return self::createInnerBuilder() 20 | ->getPath(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.C.find.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $strings = vec["a", "b", "c", "d"]; 3 | $predicate_string_1 = C\find($strings, $x ==> $x == "b"); 4 | echo "First predicate: $predicate_string_1\n"; 5 | //Output: First predicate: b 6 | 7 | $predicate_string_2 = C\find($strings, $x ==> $x == "z"); 8 | $predicate_string_2_as_string = $predicate_string_2 ?? "null"; 9 | echo "Second predicate: $predicate_string_2_as_string\n"; 10 | //Output: Second predicate: null 11 | 12 | $repeat_strings = vec["a1", "b", "a2", "d"]; 13 | $predicate_string_3 = C\find($repeat_strings, $x ==> ($x == "a1" || $x == "a2")); 14 | echo "Repeat_predicate: $predicate_string_3\n"; 15 | //Output: Repeat_predicate: a1 -------------------------------------------------------------------------------- /src/site/controllers/codegen/RobotsTxtControllerURIBuilder.php: -------------------------------------------------------------------------------- 1 | > 9 | */ 10 | 11 | abstract final class RobotsTxtControllerURIBuilder 12 | extends \Facebook\HackRouter\UriBuilderCodegen { 13 | 14 | const classname<\Facebook\HackRouter\HasUriPattern> CONTROLLER = \RobotsTxtController::class; 15 | const type TParameters = shape( 16 | ); 17 | 18 | public static function getPath(): string { 19 | return self::createInnerBuilder() 20 | ->getPath(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /.deploy/build-repo.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | echo "** Uninstalling dev-dependencies" 5 | composer install --no-dev 6 | 7 | echo "** Marking revision" 8 | git rev-parse HEAD > DOCSITE_REV 9 | 10 | echo "** Building repository" 11 | set -x 12 | hhvm --hphp \ 13 | -l3 \ 14 | -d hhvm.check_return_type_hints=3 \ 15 | --module src \ 16 | --module vendor \ 17 | --module build/final \ 18 | --ffile public/index.php \ 19 | --cfile DOCSITE_REV \ 20 | --cmodule public \ 21 | --cmodule build/final \ 22 | $(find guides -type f -name '*.txt' | sed 's,^,--cfile ,') \ 23 | --output-dir /var/out \ 24 | --file-cache /var/out/file.cache 25 | set +x 26 | 27 | echo "** Listing outputs" 28 | ls -lh /var/out 29 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Whether you have direct push access to the repo or are planning to submit a [pull request](https://github.com/hhvm/user-documentation/pulls) for some content changes, [the issues list](https://github.com/hhvm/user-documentation/issues/) is a good place to start. If there is an issue that interests you, comment on the issue and sign up for it. If you want to add some new content or modify existing content that doesn't have an associated issue, please [file an issue](https://github.com/hhvm/user-documentation/issues/new) so we can keep track and go for it. 4 | 5 | Check out https://docs.hhvm.com/hack/contributing/introduction to learn how to run a developer instance of this site and make changes. -------------------------------------------------------------------------------- /api-examples/class.HH.Shapes/keyExists.md: -------------------------------------------------------------------------------- 1 | This example shows that `keyExists` returns true if a key exists in the `Shape` (even if the corresponding value is `NULL`): 2 | 3 | ```basic-usage.hack 4 | function run(shape(?'x' => ?int, ?'y' => ?int, ?'z' => ?int) $point): void { 5 | // The key 'x' exists in Shape $point 6 | \var_dump(Shapes::keyExists($point, 'x')); 7 | 8 | // The key 'z' doesn't exist in $point 9 | \var_dump(Shapes::keyExists($point, 'z')); 10 | 11 | // The key 'y' exists in $point, even though its value is NULL 12 | \var_dump(Shapes::keyExists($point, 'y')); 13 | } 14 | 15 | <<__EntryPoint>> 16 | function basic_usage_main(): void { 17 | run(shape('x' => 3, 'y' => null)); 18 | } 19 | ``` 20 | -------------------------------------------------------------------------------- /guides/hack/03-expressions-and-operators/47-error-control.md: -------------------------------------------------------------------------------- 1 | # Error Control 2 | 3 | The operator `@` suppresses any error messages generated by the evaluation of the expression that follows it. For example: 4 | 5 | ```hack 6 | $infile = @fopen("NoSuchFile.txt", 'r'); 7 | ``` 8 | 9 | On open failure, the value returned by `fopen` is `false`, which you can use to handle the error. There is no need to 10 | have any error message displayed. 11 | 12 | If a custom error-handler has been established using the library function 13 | [`set_error_handler`](https://www.php.net/manual/en/function.set-error-handler.php) that handler is still called. 14 | 15 | This syntax can be disabled with the `disallow_silence` option in `.hhconfig`. 16 | -------------------------------------------------------------------------------- /api-examples/class.HH.Set/items.md: -------------------------------------------------------------------------------- 1 | This example shows that `items()` returns an `Iterable` view of the `Set`. The `Iterable` will produce the values of the `Set` at the time it's iterated. 2 | 3 | ```basic-usage.hack 4 | <<__EntryPoint>> 5 | function basic_usage_main(): void { 6 | $s = Set {'red', 'green', 'blue', 'yellow'}; 7 | 8 | // Get an Iterable view of the Set 9 | $iterable = $s->items(); 10 | 11 | // Add another color to the original Set $s 12 | $s->add('purple'); 13 | 14 | // Print each color using $iterable 15 | foreach ($iterable as $color) { 16 | echo $color."\n"; 17 | } 18 | } 19 | 20 | // This wouldn't work because the Iterable interface is read-only: 21 | // $iterable->add('orange'); 22 | ``` 23 | -------------------------------------------------------------------------------- /api-examples/class.HH.Map/__construct.md: -------------------------------------------------------------------------------- 1 | This example shows how to create a `Map` from various `KeyedTraversable`s: 2 | 3 | ```basic-usage.hack 4 | // Create a new string-keyed Map from an associative array 5 | $m = new Map(darray[ 6 | 'red' => '#ff0000', 7 | 'green' => '#00ff00', 8 | 'blue' => '#0000ff', 9 | 'yellow' => '#ffff00', 10 | ]); 11 | \var_dump($m); 12 | 13 | // Create a new integer-keyed Map from a Vector 14 | $m = new Map(Vector {'red', 'green', 'blue', 'yellow'}); 15 | \var_dump($m); 16 | ``` 17 | 18 | This example shows how passing `null` to the constructor creates an empty `Map`: 19 | 20 | ```null-empty.hack 21 | // An empty Map is created if null is provided 22 | $m = new Map(null); 23 | \var_dump($m); 24 | ``` 25 | -------------------------------------------------------------------------------- /api-examples/class.HH.Vector/items.md: -------------------------------------------------------------------------------- 1 | This example shows that `items()` returns an `Iterable` view of the `Vector`. The `Iterable` will produce the values of the `Vector` at the time it's iterated. 2 | 3 | ```basic-usage.hack 4 | <<__EntryPoint>> 5 | function basic_usage_main(): void { 6 | $v = Vector {'red', 'green', 'blue', 'yellow'}; 7 | 8 | // Get an Iterable view of the Vector 9 | $iterable = $v->items(); 10 | 11 | // Add another color to the original Vector $v 12 | $v->add('purple'); 13 | 14 | // Print each color using $iterable 15 | foreach ($iterable as $color) { 16 | echo $color."\n"; 17 | } 18 | } 19 | 20 | // This wouldn't work because the Iterable interface is read-only: 21 | // $iterable->add('orange'); 22 | ``` 23 | -------------------------------------------------------------------------------- /bin/update-versions: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env hhvm 2 | /* 3 | * Copyright (c) 2004-present, Facebook, Inc. 4 | * All rights reserved. 5 | * 6 | * This source code is licensed under the BSD-style license found in the 7 | * LICENSE file in the root directory of this source tree. An additional grant 8 | * of patent rights can be found in the PATENTS file in the same directory. 9 | * 10 | */ 11 | 12 | namespace HHVM\UserDocumentation; 13 | 14 | // As this file does not have an extension, it is not typechecked. Delegate 15 | // to the typechecked one. 16 | <<__EntryPoint>> 17 | async function update_versions_main_async_UNSAFE(): Awaitable { 18 | require_once(__DIR__.'/update-versions.hack'); 19 | await update_versions_main_async(); 20 | } 21 | -------------------------------------------------------------------------------- /guides/hack/11-built-in-types/31-arraykey.md: -------------------------------------------------------------------------------- 1 | # Arraykey 2 | 3 | The type `arraykey` can represent any integer or string value. For example: 4 | 5 | ```hack 6 | function process_key(arraykey $p): void { 7 | if ($p is int) { 8 | // we have an int 9 | } else { 10 | // we have a string 11 | } 12 | } 13 | ``` 14 | 15 | Values of array or collection type can be indexed by `int` or `string`. Suppose, for example, an operation was performed on an array 16 | to extract the keys, but we didn't know the type of the key. As such, we are left with using `mixed` (which is way too loose) or doing 17 | some sort of duplicative code. Instead, we can use `arraykey`. 18 | 19 | See the discussion of [type refinement](/docs/hack/types/type-refinement). 20 | -------------------------------------------------------------------------------- /guides/hack/11-built-in-types/49-this.md: -------------------------------------------------------------------------------- 1 | # This 2 | 3 | The type name `this` refers to *the current class type at run time*. As such, it can only be used from within a class, an interface, or 4 | a trait. (The type name `this` should not be confused with [`$this`](/docs/hack/source-code-fundamentals/names), which refers to *the current 5 | instance*, whose type is `this`.) For example: 6 | 7 | ```hack 8 | interface I1 { 9 | abstract const type T1 as arraykey; 10 | public function get_ID(): this::T1; 11 | } 12 | ``` 13 | 14 | Here, the function `get_ID` returns a value whose type is based on the type of the class that implements this interface type. 15 | 16 | Strictly speaking, `this` is *not* a new type name, just an alias for an existing one. 17 | -------------------------------------------------------------------------------- /api-examples/function.HH.Lib.C.find_key.md: -------------------------------------------------------------------------------- 1 | ```basic-usage.hack 2 | $dict = dict["key_1" => "a", "key_2" => "b", "key_3" => "c"]; 3 | $predicate_result_1 = C\find_key($dict, $x ==> $x == "a"); 4 | echo "First predicate: $predicate_result_1\n"; 5 | //Output: First predicate: key_1 6 | 7 | $predicate_result_2 = C\find_key($dict, $x ==> $x == "z"); 8 | $predicate_result_2_as_string = $predicate_result_2 ?? "null"; 9 | echo "Second predicate: $predicate_result_2_as_string\n"; 10 | //Output: Second predicate: null 11 | 12 | $repeat_dict = dict["key_1" => "a", "key_2" => "b", "key_3" => "c", "key_4" => "a"]; 13 | $predicate_result_3 = C\find_key($dict, $x ==> $x == "a"); 14 | echo "Repeat_predicate: $predicate_result_3\n"; 15 | //Output: Repeat_predicate: key_1 16 | ``` -------------------------------------------------------------------------------- /.hhconfig: -------------------------------------------------------------------------------- 1 | assume_php=false 2 | ignored_paths = [ "api-sources/.+", "vendor/.*tests/.+", "vendor-rb/.*", "vendor/bin/.*" ] 3 | disallow_elvis_space=true 4 | disallow_non_arraykey_keys=true 5 | disallow_unsafe_comparisons=true 6 | decl_override_require_hint=true 7 | disable_xhp_children_declarations=true 8 | check_xhp_attribute=true 9 | enable_experimental_tc_features=shape_field_check,sealed_classes,reified_generics 10 | allowed_decl_fixme_codes=1002,2053,4030,4035,4045,4047,4101,4323 11 | allowed_fixme_codes_strict=1002,2011,2049,2050,2053,4005,4006,4026,4027,4030,4035,4045,4047,4051,4053,4057,4063,4064,4067,4101,4104,4106,4107,4108,4110,4112,4128,4135,4165,4188,4193,4240,4251,4281,4297,4314,4323,4324,4347,4371,4390,4401,4417,4423 12 | enable_enum_supertyping=true 13 | -------------------------------------------------------------------------------- /guides/hack/03-expressions-and-operators/99-XHP-attribute-selection.md: -------------------------------------------------------------------------------- 1 | # XHP Attribute Selection 2 | 3 | When working with [XHP](/docs/hack/XHP/introduction), use the `->:` operator to retrieve an XHP class [attribute](/docs/hack/XHP/basic-usage#attributes) value. 4 | 5 | The operator can also be used on arbitrary expressions that resolve to an XHP object (e.g. `$a ?? $b)->:`). 6 | 7 | ```hack no-extract 8 | use namespace Facebook\XHP\Core as x; 9 | 10 | final xhp class user_info extends x\element { 11 | attribute int userid @required; 12 | attribute string name = ""; 13 | 14 | protected async function renderAsync(): Awaitable { 15 | return 16 | User with id {$this->:userid} has name {$this->:name}; 17 | } 18 | } 19 | ``` 20 | -------------------------------------------------------------------------------- /api-examples/class.HH.Map/fromItems.md: -------------------------------------------------------------------------------- 1 | This example shows that a `Map` can be created from any `Traversable` of key-value pairs: 2 | 3 | ```basic-usage.hack 4 | // Create a new Map from an array of key-value pairs 5 | $m = Map::fromItems(varray[ 6 | Pair {'red', '#ff0000'}, 7 | Pair {'green', '#00ff00'}, 8 | Pair {'blue', '#0000ff'}, 9 | Pair {'yellow', '#ffff00'}, 10 | ]); 11 | \var_dump($m); 12 | 13 | // Create a new Map from a Vector of key-value pairs 14 | $m = Map::fromItems(Vector { 15 | Pair {'red', '#ff0000'}, 16 | Pair {'green', '#00ff00'}, 17 | Pair {'blue', '#0000ff'}, 18 | Pair {'yellow', '#ffff00'}, 19 | }); 20 | \var_dump($m); 21 | 22 | // An empty Map is created if null is provided 23 | $m = Map::fromItems(null); 24 | \var_dump($m); 25 | ``` 26 | -------------------------------------------------------------------------------- /api-examples/class.HH.Map/zip.md: -------------------------------------------------------------------------------- 1 | This example shows how `zip` combines the values of the `Map` and another `Traversable`. The resulting `Map` `$labeled_colors` has three elements because `$labels` doesn't have a fourth element to pair with `$m`. 2 | 3 | ```basic-usage.hack 4 | $m = Map { 5 | 'red' => '#ff0000', 6 | 'green' => '#00ff00', 7 | 'blue' => '#0000ff', 8 | 'yellow' => '#ffff00', 9 | 'purple' => '#663399', 10 | }; 11 | 12 | $labels = Vector {'My Favorite', 'My 2nd Favorite', 'My 3rd Favorite'}; 13 | $labeled_colors = $m->zip($labels); 14 | 15 | \var_dump($labeled_colors->count()); // 3 16 | 17 | foreach ($labeled_colors as $color => $pair) { 18 | $hex_code = $pair[0]; 19 | $label = $pair[1]; 20 | echo "{$label}: {$color} ($hex_code)\n"; 21 | } 22 | ``` 23 | --------------------------------------------------------------------------------