3 * Copyright (c) 2014, Facebook, Inc.
6 * This source code is licensed under the BSD-style license found in the
7 * LICENSE file in the "hack" directory of this source tree. An additional grant
8 * of patent rights can be found in the PATENTS file in the same directory.
13 * This file provides type information for some of PHP's predefined interfaces
15 * YOU SHOULD NEVER INCLUDE THIS FILE ANYWHERE!!!
19 * Represents an entity that can be iterated over using `foreach`, without
22 * The iteration variable will have a type of `T`.
24 * In addition to Hack collections, PHP `array`s and anything that implement
25 * `Iterator` are `Traversable`.
27 * In general, if you are implementing your own Hack class, you will want to
28 * implement `Iterable` instead of `Traversable` since `Traversable` is more
29 * of a bridge for PHP `array`s to work well with Hack collections.
31 * @guide /hack/collections/introduction
32 * @guide /hack/collections/interfaces
34 interface Traversable<+Tv> {}
37 * Represents an entity that can be iterated over using `foreach`, allowing
40 * The iteration variables will have a type of `Tk` for the key and `Tv` for the
43 * In addition to Hack collections, PHP `array`s and anything that implement
44 * `KeyedIterator` are `KeyedTraversable`.
46 * In general, if you are implementing your own Hack class, you will want to
47 * implement `KeyedIterable` instead of `KeyedTraversable` since
48 * `KeyedTraversable` is more of a bridge for PHP `array`s to work well with
51 * @guide /hack/collections/introduction
52 * @guide /hack/collections/interfaces
54 interface KeyedTraversable<+Tk, +Tv> extends Traversable<Tv> {}
57 * Represents an entity that can be iterated over using `foreach`, without
58 * requiring a key, except it does not include objects that implement
61 * The iteration variable will have a type of `T`.
63 * In addition to Hack collections, PHP `array`s are `Container`s.
65 * @guide /hack/collections/introduction
66 * @guide /hack/collections/interfaces
68 interface Container<+Tv> extends Traversable<Tv> {}
71 * Represents an entity that can be iterated over using `foreach`, allowing
72 * a key, except it does not include objects that implement `KeyedIterator` nor
75 * The iteration variables will have a type of `Tk` for the key and `Tv` for the
78 * In addition to Hack collections, PHP `array`s are `KeyedContainer`s.
80 * @guide /hack/collections/introduction
81 * @guide /hack/collections/interfaces
83 interface KeyedContainer<+Tk, +Tv> extends Container<Tv>, KeyedTraversable<Tk, Tv> {}
86 * Represents an entity that can be indexed using square-bracket syntax.
88 * Square bracket syntax is:
94 * At this point, this includes entities with keys of `int` and `string`.
96 * In addition to Hack collections, PHP `array`s are `Indexish`.
98 * @guide /hack/collections/introduction
99 * @guide /hack/collections/interfaces
100 * @guide /hack/collections/read-write
102 interface Indexish<+Tk, +Tv> extends KeyedContainer<Tk, Tv> {}
105 * For those entities that are `Traversable`, the `Iterator` interfaces provides
106 * the methods of iteration.
108 * If a class implements `Iterator`, then it provides the infrastructure to be
109 * iterated over using a `foreach` loop.
111 * @guide /hack/collections/introduction
112 * @guide /hack/collections/interfaces
114 * @link http://php.net/manual/en/class.iterator.php
116 interface Iterator<+Tv> extends Traversable<Tv> {
118 * Return the current value at the current iterator position.
120 * @return - The current value of type `Tv`.
122 public function current(): Tv;
124 * Move the iterator position to the next element.
127 public function next(): void;
129 * Rewind the iterator position to its beginning.
131 * This rewinds back to the first element of the `Iterator`.
133 public function rewind(): void;
135 * Checks to see if the current iterator position is valid.
137 * This method is called after `rewind()` and `next()` to check if the
138 * current iterator position is valid.
140 * @return - `true` if the position is valid; `false` otherwise.
142 public function valid(): bool;
146 * Allows for the iteration over the values provided by an `async` function.
148 * If an `async` function returns an `AsyncIterator<T>`, then you can iterate
149 * over the `T` values returned from that function.
152 * async function countdown(int $start): AsyncIterator<int> { ... }
154 * async function use_countdown(): Awaitable<void> {
155 * $async_iter = countdown(100);
156 * foreach ($async_gen await as $value) { ... }
160 * @guide /hack/async/introduction
161 * @guide /hack/async/guidelines
163 interface AsyncIterator<+Tv> {
165 * Move the async iterator to the next `Awaitable` position.
168 * foreach ($async_iter await $async_iter->next() $value)
171 * The above is the longhand syntax for `await as $value`.
173 * @return - The next `Awaitable` in the iterator sequence.
175 public function next(): Awaitable<?(mixed, Tv)>;
179 * Allows for the iteration over the keys and values provided by an `async`
182 * If an `async` function returns an `AsyncIterator<Tk, Tv>`, then you can
183 * iterate over the `Tk` and `Tv` values returned from that function.
186 * async function countdown(int $start): AsyncIterator<int, string> { ... }
188 * async function use_countdown(): Awaitable<void> {
189 * $async_iter = countdown(100);
190 * foreach ($async_gen await as $num => $str) { ... }
194 * @guide /hack/async/introduction
195 * @guide /hack/async/guidelines
197 interface AsyncKeyedIterator<+Tk, +Tv> extends AsyncIterator<Tv> {
199 * Move the async iterator to the next `Awaitable` position.
202 * foreach ($async_iter await $async_iter->next() $key=>$value)
205 * The above is the longhand syntax for `await as $key=>$value`.
207 * @return - The next `Awaitable` in the iterator sequence.
209 public function next(): Awaitable<?(Tk, Tv)>;
213 * For those entities that are `KeyedTraversable`, the `KeyedIterator`
214 * interfaces provides the methods of iteration, included being able to get
217 * If a class implements `KeyedIterator`, then it provides the infrastructure
218 * to be iterated over using a `foreach` loop.
220 * @guide /hack/collections/introduction
221 * @guide /hack/collections/interfaces
223 interface KeyedIterator<+Tk, +Tv> extends KeyedTraversable<Tk,Tv>, Iterator<Tv> {
225 * Return the current key at the current iterator position.
227 * @return - The current key of type `Tk`.
229 public function key(): Tk;
233 * Represents objects that can produce an `Iterator` object to iterate over
234 * their contents using `foreach`.
236 * Normally, this interface won't be used in type annotations; rather `Iterable`
237 * or `Traversable` will be the better interface.
239 * @guide /hack/collections/introduction
240 * @guide /hack/collections/interfaces
242 * @link http://php.net/manual/en/class.iteratoraggregate.php
244 interface IteratorAggregate<+Tv> extends Traversable<Tv> {
246 * Returns an iterator to be used to iterate over the object's elements.
248 * @return - An `Iterator` for iteration.
250 public function getIterator(): Iterator<Tv>;
254 * Represents any entity that can be iterated over using something like
255 * `foreach`. The entity does not necessarily have to have a key, just values.
257 * `Iterable` does not include `array`s.
259 * @guide /hack/collections/introduction
260 * @guide /hack/collections/interfaces
262 interface Iterable<+Tv> extends IteratorAggregate<Tv> {
264 * Returns an iterator that points to beginning of the current `Iterable`.
266 * @return - An `Iterator` that allows you to traverse the current `Iterable`.
268 public function getIterator(): Iterator<Tv>;
270 * Returns an `array` converted from the current `Iterable`.
272 * @return - an array converted from the current `Iterable`.
274 public function toArray(): array;
276 * Returns an `array` with the values from the current `Iterable`.
278 * The keys in the current `Iterable` are discarded and replaced with integer
279 * indices, starting with 0.
281 * @return - an `array` containing the values from the current `Iterable`.
283 public function toValuesArray(): array;
284 /* HH_FIXME[4120]: While this violates our variance annotations, we are
285 * returning a copy of the underlying collection, so it is actually safe
288 * Returns a `Vector` converted from the current `Iterable`.
290 * Any keys in the current `Iterable` are discarded and replaced with integer
291 * indices, starting with 0.
293 * @return - a `Vector` converted from the current `Iterable`.
295 public function toVector(): Vector<Tv>;
297 * Returns an immutable vector (`ImmVector`) converted from the current
300 * Any keys in the current `Iterable` are discarded and replaced with integer
301 * indices, starting with 0.
303 * @return - an `ImmVector` converted from the current `Iterable`.
305 public function toImmVector(): ImmVector<Tv>;
306 /* HH_FIXME[4120]: While this violates our variance annotations, we are
307 * returning a copy of the underlying collection, so it is actually safe.
310 * Returns a `Set` converted from the current `Iterable`.
312 * Any keys in the current `Iterable` are discarded.
314 * @return - a `Set` converted from the current `Iterable`.
316 public function toSet(): Set<Tv>;
318 * Returns an immutable set (`ImmSet`) converted from the current `Iterable`.
320 * Any keys in the current `Iterable` are discarded.
322 * @return - an `ImmSet` converted from the current `Iterable`.
324 public function toImmSet(): ImmSet<Tv>;
326 * Returns a lazy, access elements only when needed view of the current
329 * Normally, memory is allocated for all of the elements of the `Iterable`.
330 * With a lazy view, memory is allocated for an element only when needed or
331 * used in a calculation like in `map()` or `filter()`.
333 * @return - an `Iterable` representing the lazy view into the current
336 * @guide /hack/collections/examples
338 public function lazy(): Iterable<Tv>;
340 * Returns an `Iterable` containing the current `Iterable`'s values.
342 * Any keys are discarded.
344 * @return An `Iterable` with the values of the current `Iterable`.
346 public function values(): Iterable<Tv>;
348 * Returns an `Iterable` containing the values after an operation has been
349 * applied to each value in the current `Iterable`.
351 * Every value in the current `Iterable` is affected by a call to `map()`,
352 * unlike `filter()` where only values that meet a certain criteria are
355 * @param $fn - The callback containing the operation to apply to the
358 * @return - an `Iterable` containing the values after a user-specified
359 * operation is applied.
361 * @guide /hack/collections/examples
363 public function map<Tu>((function(Tv): Tu) $fn): Iterable<Tu>;
365 * Returns an `Iterable` containing the values of the current `Iterable` that
366 * meet a supplied condition.
368 * Only values that meet a certain criteria are affected by a call to
369 * `filter()`, while all values are affected by a call to `map()`.
371 * @param $fn - The callback containing the condition to apply to the
374 * @return - an `Iterable` containing the values after a user-specified
375 * condition is applied.
377 * @guide /hack/collections/examples
379 public function filter((function(Tv): bool) $fn): Iterable<Tv>;
381 * Returns an `Iterable` where each element is a `Pair` that combines the
382 * element of the current `Iterable` and the provided `Traversable`.
384 * If the number of elements of the `Iterable` are not equal to the number of
385 * elements in the `Traversable`, then only the combined elements up to and
386 * including the final element of the one with the least number of elements
389 * @param $traversable - The `Traversable` to use to combine with the
390 * elements of the current `Iterable`.
392 * @return - The `Iterable` that combines the values of the current
393 * `Itearable` with the provided `Traversable`.
395 public function zip<Tu>(Traversable<Tu> $traversable): Iterable<Pair<Tv, Tu>>;
397 * Returns an `Iterable` containing the first `n` values of the current
400 * The returned `Iterable` will always be a proper subset of the current
403 * `$n` is 1-based. So the first element is 1, the second 2, etc.
405 * @param $n - The last element that will be included in the returned
408 * @return - An `Iterable that is a proper subset of the current `Iterable`
409 * up to `n` elements.
411 public function take(int $n): Iterable<Tv>;
413 * Returns an `Iterable` containing the values of the current `Iterable` up
414 * to but not including the first value that produces `false` when passed to
415 * the specified callback.
417 * The returned `Iterable` will always be a proper subset of the current
420 * @param $fn - The callback that is used to determine the stopping
423 * @return - An `Iterable` that is a proper subset of the current `Iterable`
424 * up until the callback returns `false`.
426 public function takeWhile((function(Tv): bool) $fn): Iterable<Tv>;
428 * Returns an `Iterable` containing the values after the `n`-th element of the
429 * current `Iterable`.
431 * The returned `Iterable` will always be a proper subset of the current
434 * `$n` is 1-based. So the first element is 1, the second 2, etc.
436 * @param $n - The last element to be skipped; the `$n+1` element will be
437 * the first one in the returned `Iterable`.
439 * @return - An `Iterable` that is a proper subset of the current `Iterable`
440 * containing values after the specified `n`-th element.
442 public function skip(int $n): Iterable<Tv>;
444 * Returns an `Iterable` containing the values of the current `Iterable`
445 * starting after and including the first value that produces `true` when
446 * passed to the specified callback.
448 * The returned `Iterable` will always be a proper subset of the current
451 * @param $fn - The callback used to determine the starting element for the
452 * returned `Iterable`.
454 * @return - An `Iterable` that is a proper subset of the current `Iterable`
455 * starting after the callback returns `true`.
457 public function skipWhile((function(Tv): bool) $fn): Iterable<Tv>;
459 * Returns a subset of the current `Iterable` starting from a given key up
460 * to, but not including, the element at the provided length from the
463 * `$start` is 0-based. `$len` is 1-based. So `slice(0, 2)` would return the
464 * elements at key 0 and 1.
466 * The returned `Iterable` will always be a proper subset of the current
469 * @param $start - The starting key of the current `Iterable` to begin the
470 * returned `Iterable`.
471 * @param $len - The length of the returned `Iterable`.
473 * @return - An `Iterable` that is a proper subset of the current `Iterable`
474 * starting at `$start` up to but not including the element
477 public function slice(int $start, int $len): Iterable<Tv>;
479 * Returns an `Iterable` that is the concatenation of the values of the
480 * current `Iterable` and the values of the provided `Traversable`.
482 * The values of the provided `Traversable` is concatenated to the end of the
483 * current `Iterable` to produce the returned `Iterable`.
485 * @param $traversable - The `Traversable` to concatenate to the current
488 * @return - The concatenated `Iterable`.
490 * @guide /hack/generics/constraints
492 public function concat<Tu super Tv>(
493 Traversable<Tu> $traversable
496 * Returns the first value in the current `Iterable`.
498 * @return - The first value in the current `Iterable`, or `null` if the
499 * current `Iterable` is empty.
501 public function firstValue(): ?Tv;
503 * Returns the last value in the current `Iterable`.
505 * @return - The last value in the current `Iterable`, or `null` if the
506 * current `Iterable` is empty.
508 public function lastValue(): ?Tv;
512 * Represents any entity that can be iterated over using something like
513 * `foreach`. The entity is required to have a key in addition to values.
515 * `KeyedIterable` does not include `array`s.
517 * @guide /hack/collections/introduction
518 * @guide /hack/collections/interfaces
520 interface KeyedIterable<Tk, +Tv> extends KeyedTraversable<Tk, Tv>, Iterable<Tv> {
522 * Returns an iterator that points to beginning of the current
525 * @return - A `KeyedIterator` that allows you to traverse the current
528 public function getIterator(): KeyedIterator<Tk, Tv>;
530 * Returns an `array` with the keys from the current `KeyedIterable`.
532 * @return - an `array` containing the values from the current
535 public function toKeysArray(): array;
536 /* HH_FIXME[4120]: While this violates our variance annotations, we are
537 * returning a copy of the underlying collection, so it is actually safe
540 * Returns a `Map` based on the keys and values of the current
543 * @return - a `Map` that has the keys and associated values of the current
546 public function toMap(): Map<Tk, Tv>;
548 * Returns an immutable map (`ImmMap`) based on the keys and values of the
549 * current `KeyedIterable`.
551 * @return - an `ImmMap` that has the keys and associated values of the
552 * current `KeyedIterable`.
554 public function toImmMap(): ImmMap<Tk, Tv>;
556 * Returns a lazy, access elements only when needed view of the current
559 * Normally, memory is allocated for all of the elements of the
560 * `KeyedIterable`. With a lazy view, memory is allocated for an element only
561 * when needed or used in a calculation like in `map()` or `filter()`.
563 * @return - a `KeyedIterable` representing the lazy view into the current
566 * @guide /hack/collections/examples
568 public function lazy(): KeyedIterable<Tk, Tv>;
570 * Returns an `Iterable` containing the current `KeyedIterable`'s values.
572 * Any keys are discarded.
574 * @return An `Iterable` with the values of the current `KeyedIterable`.
576 public function values(): Iterable<Tv>;
578 * Returns an `Iterable` containing the current `KeyedIterable`'s keys.
580 * Any values are discarded.
582 * @return An `Iterable` with the keys of the current `KeyedIterable`.
584 public function keys(): Iterable<Tk>;
586 * Returns a `KeyedIterable` containing the values after an operation has been
587 * applied to each value in the current `KeyedIterable`.
589 * Every value in the current `KeyedIterable` is affected by a call to
590 * `map()`, unlike `filter()` where only values that meet a certain criteria
593 * @param $fn - The callback containing the operation to apply to the
594 * `KeyedIterable` values.
596 * @return - a `KeyedIterable` containing the values after a user-specified
597 * operation is applied.
599 * @guide /hack/collections/examples
601 public function map<Tu>((function(Tv): Tu) $fn): KeyedIterable<Tk, Tu>;
603 * Returns a `KeyedIterable` containing the values after an operation has
604 * been applied to each key and value in the current `KeyedIterable`.
606 * Every key and value in the current `KeyedIterable` is affected by a call to
607 * `mapWithKey()`, unlike `filterWithKey()` where only values that meet a
608 * certain criteria are affected.
610 * @param $fn - The callback containing the operation to apply to the
611 * `KeyedIterable` keys and values.
613 * @return - a `KeyedIterable` containing the values after a user-specified
614 * operation on the current `KeyedIterable`'s keys and values is
617 public function mapWithKey<Tu>((function(Tk, Tv): Tu) $fn):
618 KeyedIterable<Tk, Tu>;
620 * Returns a `KeyedIterable` containing the values of the current
621 * `KeyedIterable` that meet a supplied condition.
623 * Only values that meet a certain criteria are affected by a call to
624 * `filter()`, while all values are affected by a call to `map()`.
626 * @param $fn - The callback containing the condition to apply to the
627 * `KeyedItearble` values.
629 * @return - a `KeyedIterable` containing the values after a user-specified
630 * condition is applied.
632 * @guide /hack/collections/examples
634 public function filter((function(Tv): bool) $fn): KeyedIterable<Tk, Tv>;
636 * Returns a `KeyedIterable` containing the values of the current
637 * `KeyedIterable` that meet a supplied condition applied to its keys and
640 * Only keys and values that meet a certain criteria are affected by a call to
641 * `filterWithKey()`, while all values are affected by a call to
644 * @param $fn - The callback containing the condition to apply to the
645 * `KeyedIterable` keys and values.
647 * @return - a `KeyedIterable` containing the values after a user-specified
648 * condition is applied to the keys and values of the current
652 public function filterWithKey((function(Tk, Tv): bool) $fn):
653 KeyedIterable<Tk, Tv>;
655 * Returns a `KeyedIterable` where each element is a `Pair` that combines the
656 * element of the current `KeyedIterable` and the provided `Traversable`.
658 * If the number of elements of the `KeyedIterable` are not equal to the
659 * number of elements in the `Traversable`, then only the combined elements
660 * up to and including the final element of the one with the least number of
661 * elements is included.
663 * @param $traversable - The `Traversable` to use to combine with the
664 * elements of the current `KeyedIterable`.
666 * @return - The `KeyedIterable` that combines the values of the current
667 * `KeyedItearable` with the provided `Traversable`.
669 public function zip<Tu>(Traversable<Tu> $traversable):
670 KeyedIterable<Tk, Pair<Tv, Tu>>;
672 * Returns a `KeyedIterable` containing the first `n` values of the current
675 * The returned `KeyedIterable` will always be a proper subset of the current
678 * `$n` is 1-based. So the first element is 1, the second 2, etc.
680 * @param $n - The last element that will be included in the returned
683 * @return - A `KeyedIterable that is a proper subset of the current
684 * `KeyedIterable` up to `n` elements.
686 public function take(int $n): KeyedIterable<Tk, Tv>;
688 * Returns a `KeyedIterable` containing the values of the current
689 * `KeyedIterable` up to but not including the first value that produces
690 * `false` when passed to the specified callback.
692 * The returned `KeyedIterable` will always be a proper subset of the current
695 * @param $fn - The callback that is used to determine the stopping
698 * @return - A `KeyedIterable` that is a proper subset of the current
699 * `KeyedIterable` up until the callback returns `false`.
701 public function takeWhile((function(Tv): bool) $fn): KeyedIterable<Tk, Tv>;
703 * Returns a `KeyedIterable` containing the values after the `n`-th element
704 * of the current `KeyedIterable`.
706 * The returned `KeyedIterable` will always be a proper subset of the current
709 * `$n` is 1-based. So the first element is 1, the second 2, etc.
711 * @param $n - The last element to be skipped; the `$n+1` element will be
712 * the first one in the returned `KeyedIterable`.
714 * @return - A `KeyedIterable` that is a proper subset of the current
715 * `KeyedIterable` containing values after the specified `n`-th
718 public function skip(int $n): KeyedIterable<Tk, Tv>;
720 * Returns a `KeyedIterable` containing the values of the current
721 * `KeyedIterable` starting after and including the first value that produces
722 * `true` when passed to the specified callback.
724 * The returned `KeyedIterable` will always be a proper subset of the current
727 * @param $fn - The callback used to determine the starting element for the
728 * returned `KeyedIterable`.
730 * @return - A `KeyedIterable` that is a proper subset of the current
731 * `KeyedIterable` starting after the callback returns `true`.
733 public function skipWhile((function(Tv): bool) $fn): KeyedIterable<Tk, Tv>;
735 * Returns a subset of the current `KeyedIterable` starting from a given key
736 * up to, but not including, the element at the provided length from the
739 * `$start` is 0-based. `$len` is 1-based. So `slice(0, 2)` would return the
740 * elements at key 0 and 1.
742 * The returned `KeyedIterable` will always be a proper subset of the current
745 * @param $start - The starting key of the current `KeyedIterable` to begin
746 * the returned `KeyedIterable`.
747 * @param $len - The length of the returned `KeyedIterable`.
749 * @return - A `KeyedIterable` that is a proper subset of the current
750 * `KeyedIterable` starting at `$start` up to but not including the
751 * element `$start + $len`.
753 public function slice(int $start, int $len): KeyedIterable<Tk, Tv>;
755 * Returns an `Iterable` that is the concatenation of the values of the
756 * current `KeyedIterable` and the values of the provided `Traversable`.
758 * The values of the provided `Traversable` is concatenated to the end of the
759 * current `KeyedIterable` to produce the returned `Iterable`.
761 * @param $traversable - The `Traversable` to concatenate to the current
764 * @return - The concatenated `Iterable`.
766 * @guide /hack/generics/constraints
768 public function concat<Tu super Tv>(
769 Traversable<Tu> $traversable
772 * Returns the first value in the current `KeyedIterable`.
774 * @return - The first value in the current `KeyedIterable`, or `null` if the
775 * current `KeyedIterable` is empty.
777 public function firstValue(): ?Tv;
779 * Returns the first key in the current `KeyedIterable`.
781 * @return - The first key in the current `KeyedIterable`, or `null` if the
782 * current `KeyedIterable` is empty.
784 public function firstKey(): ?Tk;
786 * Returns the last value in the current `KeyedIterable`.
788 * @return - The last value in the current `KeyedIterable`, or `null` if the
789 * current `KeyedIterable` is empty.
791 public function lastValue(): ?Tv;
793 * Returns the last key in the current `KeyedIterable`.
795 * @return - The last key in the current `KeyedIterable`, or `null` if the
796 * current `KeyedIterable` is empty.
798 public function lastKey(): ?Tk;
801 interface Serializable {
802 public function serialize(): string;
803 public function unserialize($serialized): void;
806 interface Countable {
807 public function count(): int;
810 abstract final class dict<+Tk as arraykey, +Tv> implements Indexish<Tk, Tv> {}
812 interface RecursiveIterator<Tv> extends Iterator<Tv> {
813 public function getChildren(): this;
814 public function hasChildren(): bool;
817 interface SeekableIterator<Tv> extends Iterator<Tv> {
818 public function seek(int $position): void;
821 interface OuterIterator<Tv> extends Iterator<Tv> {
822 public function getInnerIterator(): Iterator<Tv>;
825 interface ArrayAccess<Tk, Tv> {
826 public function offsetExists(Tk $key): bool;
827 public function offsetGet(Tk $key): Tv;
828 public function offsetSet(Tk $key, Tv $val): void;
829 public function offsetUnset(Tk $key): void;
832 interface Awaitable<+T> {
833 public function getWaitHandle(): WaitHandle<T>;
837 * @see http://www.php.net/manual/en/jsonserializable.jsonserialize.php
839 interface JsonSerializable {
841 * Return data which can be serialized with json_encode.
843 public function jsonSerialize(): mixed;
847 * XHPChild is the base type of values that can be children of XHP elements.
848 * Most primitive types implement XHPChild: string, int, float, and array.
850 * Classes that implement XHPChild must do so by implementing the XHPChildClass
853 interface XHPChild {}
856 * Stringish is a type that matches strings as well as string-convertible
857 * objects: that is, objects that provide the __toString method
859 interface Stringish {
860 public function __toString(): string;
864 * Classes that implement IMemoizeParam may be used as parameters on
865 * <<__Memoize>> functions
867 * @guide /hack/attributes/introduction
868 * @guide /hack/attributes/special
870 interface IMemoizeParam {
872 * Serialize this object to a string that can be used as a
873 * dictionary key to differentiate instances of this class.
875 public function getInstanceKey(): string;