phunkie/phpstan
最新稳定版本:1.0.0
Composer 安装命令:
composer require phunkie/phpstan
包简介
PHPStan extensions for Phunkie functional programming library
README 文档
README
PHPStan extensions for the Phunkie functional programming library.
Installation
composer require --dev phunkie/phpstan
The extension is automatically registered via PHPStan's extension mechanism.
What it provides
Generic Type Transformation
Phunkie uses container types (IO, Option, Validation, etc.) that transform their type parameters through method calls. PHPStan often loses this type information when closures are involved.
This extension provides a single configurable resolver that handles common patterns:
| Pattern | Description | Example |
|---|---|---|
wrap |
F<A> → F<Wrapper<Fixed, A>> |
IO<A>::attempt() → IO<Validation<Throwable, A>> |
map |
F<A>.f(A→B) → F<B> |
IO<A>::map(fn) → IO<B> |
pair |
F<A>.f(A→B) → F<Pair<A, B>> |
IO<A>::zipWith(fn) → IO<Pair<A, B>> |
preserve |
F<A>.method() → F<A> |
Methods that don't change type |
Configuration
The extension is configured in extension.neon:
services: - class: Phunkie\PHPStan\GenericMethodReturnTypeExtension arguments: targetClass: Phunkie\Effect\IO\IO methods: - method: attempt pattern: wrap wrapper: Phunkie\Validation\Validation fixedTypes: [Throwable] - method: map pattern: map tags: - phpstan.broker.dynamicMethodReturnTypeExtension
Covariant Type Support
The Phunkie core library includes @template-covariant annotations so that:
Success<A>is aValidation<never, A>(compatible with anyValidation<E, A>)Failure<E>is aValidation<E, never>(compatible with anyValidation<E, A>)
Requirements
- PHP 8.2+
- PHPStan 2.0+
- Phunkie 1.0+
License
MIT
统计信息
- 总下载量: 170
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 4
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-12-08