The Symfony TypeInfo component is a PHP library for extracting and representing PHP type information. It provides a rich type system that can resolve types from reflection objects, PHP doc comments, raw type strings, and values. The architecture cleanly separates type representation (Type classes), type resolution (Resolver classes), and contextual information (TypeContext). Key features include sophisticated type inference from values, support for complex type constructs (unions, intersections, generics), and integration with PHP doc block templates and type aliases.
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.
This repository is a modern PHP package skeleton created by Nuno Maduro. It provides a minimal, opinionated starting point for building PHP libraries, featuring a pre-configured toolchain including Laravel Pint for code style, Pest for testing, PHPStan for static analysis, and Rector for automated refactoring. The actual source contains only a placeholder Example class to verify the setup, while the value lies in the well-organized directory structure, Composer scripts, GitHub Actions workflows (testing across OS and dependency versions), and configuration files that enforce high code quality standards. It is designed to be cloned via `composer create-project` and immediately used for new package development. The repo is actively maintained with no open issues, modern dependency versions, and comprehensive CI coverage.