PHP TypeLang Help

Generic Types

Each type can take arguments containing other type declarations. Validation of arguments and their number lies on the implementing side; the parser does not limit their number or nesting and does not check their semantic correctness in any way.

Each argument is enclosed in triangle brackets < and > and separated by a comma (,).

Call-Site Hints

Each template argument allows you to define an additional hint, which can be used, for example, in static analyzers to indicate the call-site variance.

The hint is one of the words covariant, contravariant or invariant written in lower case before the type of the argument.

Wildcard Arguments

A template argument may be left unsaid, written as an asterisk (*) in the place of the type. A wildcard argument does not accept a hint.

List Syntax

In addition to modern list declarations such as list<int> or array<array-key, int>, the legacy int[] syntax is allowed.

10 November 2026