PHP TypeLang Help

Conditional Types

A conditional (ternary) type describes a type that depends on the result of comparing a subject with some other type. It consists of a condition, followed by a question mark (?), the type used if the condition is true, a colon (:), and the type used if the condition is false.

<Subject> <Operator> <Type> ? <TypeIfTrue> : <TypeIfFalse>

Both the subject and the type being compared against can be an arbitrary type expression or a variable.

Equality Operators

The is keyword checks whether the subject is of the compared type, and is not checks the opposite. Both keywords are case-insensitive.

Comparison Operators

In addition to the is/is not equality checks, TypeLang also allows comparing the subject using the <, >, <= and >= operators.

Yoda-Style Conditions

Since the subject and the compared type can both be arbitrary type expressions, the condition may also be written in Yoda-style, with the concrete type on the left and the subject (a type or a variable) on the right.

05 July 2026