Skip to content

Releases: xphp-lang/xphp

v0.2.0

12 Jun 10:19
85ff090

Choose a tag to compare

What's Changed

v0.2.0

The first feature release on top of the core monomorphization pipeline.
v0.1.0 specialized generic classes. v0.2.0 extends generics across the
whole declaration surface — classes, interfaces, traits, methods, free
functions, closures, and arrows — each with bounds, defaults, and
variance, behind forward-compatible turbofish syntax at every call site.

Still the same promise: it all compiles down to vanilla PHP with native
type hints and zero runtime dispatch.

Highlights

  • Type bounds, checked at compile time — single (<T: \Stringable>),
    intersection (T: \Stringable & \Countable), DNF
    ((\Stringable & \Countable) | \Iterator), and F-bounded
    (<T: Comparable<T>>). Errors point at your instantiation, not the
    generated hash.
  • Default type parameters everywhere — class, method, function,
    closure, arrow — with forward refs (Pair<A, B = A>), empty turbofish
    ::<>, and bare new Cache; for all-defaults templates.
  • Variance+T / -T markers with parse-time position checks and
    real subtype edges: Producer<Banana> actually extends
    Producer<Fruit> when Banana extends Fruit.
  • Function-level generics — generic methods on static/instance
    receivers, generic free functions, and nullsafe turbofish
    $obj?->m::<T>().
  • Generic closures & arrowsfunction<T>(…){…} and fn<T>(…) => …,
    including use (…) and by-ref use (&$x) captures.
  • Pseudo-typesself<T> / static<T> / parent<T> in type-hint
    and constructor positions.
  • Full docs/ tree — a per-feature syntax tour,
    getting started, how-it-works, runtime semantics, a type-system
    comparison, caveats, and errors.

Changed

  • Call-site syntax aligned with the PHP RFC: turbofish Name::<...>.
    Parenless new Name<...> is now rejected with a message pointing you at
    the ::<...> form.

Known limitations

See caveats for the full list. In short:

  • Variance markers are class-level only (not yet on methods, functions,
    closures, or arrows).
  • Generic closures/arrows that capture $this, and static closures, are
    rejected at the call site.
  • Reflection sees the dispatcher shape, not the original closure body.
  • The variance validator doesn't walk into trait-imported signatures.

Install

composer require xphp-lang/xphp

Full changelog: v0.1.0...v0.2.0

v0.1.0

01 Jun 20:30
cd45ad0

Choose a tag to compare

Merge pull request #13 from xphp-lang/split-repos

repo: collapse monorepo to single xphp package