"A Carthaginian general before the Sophetim", W. J. Morgan, from Ridpath's Universal History (1897). Public domain.
Suffete: the Carthaginian high magistrate, the judge of the city. The thing that decides whether what stands before it is sound.
Suffete is a standalone PHP type system written in Rust. It provides a representation of PHP types and a type checker. really, a type comparator. that answers questions like "is type A a subtype of type B?", "what is the union of these two types?", and "how do generic parameters resolve here?".
It is not a static analyzer, or a typed linter. It is the type-system core that such tools can build on top of.
The driving requirement is completeness: every PHP type that Mago, PHPStan, Psalm, or Hack can express should be representable here, with the semantics that working PHP analyzers expect.
Warning
Suffete is not stable. There is no estimated date for stability. The public API will break, often without warning, sometimes daily. Internals are in flux. Behavior may be incorrect.
If you are considering using suffete in your own project today: don't. Wait until this notice is gone.
The long-term goal is for suffete to replace the type-system core inside Mago, the Carthage Software PHP toolchain. Until that migration is feasible, suffete lives in its own repository so it can be designed, tested, and benchmarked in isolation, without an analyzer attached to it.
The type-system/ directory contains a type-theoretic description of the PHP type universe and the operations defined over it. Four chapters:
types.md: every atom, every refinement axis, what each type denotes.comparison.md: the subtyping relation, disjointness, overlap, and admissible coercions.combination.md: union as least upper bound, absorption rules, generalisation thresholds.intersection.md: intersection, difference, and narrowing under assertions.
These chapters describe the contract any implementation must satisfy. They are likely to evolve in detail as the implementation matures, but the shape of the universe is stable.
# Cargo.toml
[dependencies]
suffete = "0.1"(See the warning above before you actually do this.)
Contributions are welcome. Please read CONTRIBUTING.md and the Code of Conduct before opening a pull request.
Suffete is dual-licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT License (LICENSE-MIT or https://opensource.org/licenses/MIT)
at your option.