fp4php/psalm-toolkit
Composer 安装命令:
composer require fp4php/psalm-toolkit
包简介
Testing tool for psalm plugins
README 文档
README
Helpers for plugin authoring and static testing tool.
Installation
Package fp4php/functional must be installed manually.
$ composer require --dev fp4php/functional fp4php/psalm-toolkit
$ vendor/bin/psalm-plugin enable fp4php/psalm-toolkit
Usage
At the moment you can use two methods for static asserts:
seePsalmIssue: Checks that a code block from thehaveCodehave specific issue.seeReturnType: Verifies a return type from thehaveCodeblock.
Usage example below:
<?php namespace Fp\Decode\Test\Static; use Fp\PsalmToolkit\StaticTest\PsalmTest; use Fp\PsalmToolkit\StaticTest\StaticTestCase; use Fp\PsalmToolkit\StaticType\StaticTypes as t; final class ExampleTest extends PsalmTest { public function __invoke(): void { StaticTestCase::describe('See InvalidScalarArgument issue') ->haveCode(function() { $plus = fn(int $a, int $b): int => $a + $b; $plus(10, 10.00); }) ->seePsalmIssue( type: 'InvalidScalarArgument', message: 'Argument 2 expects int, float(10) provided', ); StaticTestCase::describe('See return type (invariant type compare)') ->haveCode(function() { return [ 'twenty' => 10 + 10, 'message' => 'Hello world!' ]; }) ->seeReturnType( is: t::shape([ 'twenty' => t::literal(20), 'message' => t::literal('Hello world!'), ]), ); StaticTestCase::describe('See return type (covariant type compare)') ->haveCode(function() { return [ 'twenty' => 10 + 10, 'message' => 'Hello world!' ]; }) ->seeReturnType( is: t::shape([ 'twenty' => t::int(), 'message' => t::string(), ]), invariant: false, ); } }
fp4php/psalm-toolkit 适用场景与选型建议
fp4php/psalm-toolkit 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.12k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2022 年 05 月 31 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 fp4php/psalm-toolkit 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 fp4php/psalm-toolkit 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 3.12k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 9
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-05-31