Skip to content

carthage-software/suffete

A Carthaginian general before the Sophetim

"A Carthaginian general before the Sophetim", W. J. Morgan, from Ridpath's Universal History (1897). Public domain.

Suffete

Suffete: the Carthaginian high magistrate, the judge of the city. The thing that decides whether what stands before it is sound.

CI Status CodSpeed Crates.io License

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.

Status

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.

Roadmap

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.

Type System Documentation

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.

Getting Started

# Cargo.toml
[dependencies]
suffete = "0.1"

(See the warning above before you actually do this.)

Contributing

Contributions are welcome. Please read CONTRIBUTING.md and the Code of Conduct before opening a pull request.

License

Suffete is dual-licensed under either of:

at your option.

About

Suffete: the Carthaginian high magistrate, the judge of the city. The thing that decides whether what stands before it is sound.

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages