$ account pinkary-project
A PHP library that provides a type-safe, static analysis-friendly way to narrow down mixed or union types at runtime. The core is a `Type` class (entry point via `type()` helper) that offers methods like `asString()`, `asInt()`, `as(ClassName::class)`, etc., each performing a runtime assertion and returning the narrowed type. It leverages PHPStan/Psalm's `@phpstan-assert-if-true` annotations to allow static analyzers to infer the narrowed type, preserving generic type information (e.g., `Collection<int, User>`). The library includes a `Not` class for negation checks (e.g., `type($x)->not()->null()`). It is part of the Pinkary Project, requires PHP 8.2+, and has zero runtime dependencies. The source is meticulously crafted with full test coverage, type-strict coding, and continuous integration enforcing linting, static analysis, and type coverage. It is a model example of how to expose runtime assertion functions with first-class static analysis support.