承接 survos/debug-utils 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

survos/debug-utils

最新稳定版本:2.8.1

Composer 安装命令:

composer require survos/debug-utils

包简介

Development assertion helpers that show acceptable values on failure

README 文档

README

Assertion helpers that show the acceptable values on failure — not just "key not found".

When a CSV header, API payload, or config array has the wrong key, the mistake is almost always a typo, an underscore-vs-hyphen, or a capitalisation slip. A plain array_key_exists check tells you name is missing; these helpers tell you name is missing and here are the keys that do exist — so you spot emial next to email instantly.

Intentionally a dev-only dependency. Do not require it in production code.

Requirements

  • PHP 8.4+

Installation

composer require --dev survos/debug-utils

Usage

All helpers are static methods on Survos\DebugUtils\Assert and throw \InvalidArgumentException on failure.

keyExists() — one key must be present

use Survos\DebugUtils\Assert;

$row = ['name' => 'Tac', 'email' => 'tac@example.com'];

Assert::keyExists('email', $row);   // ok
Assert::keyExists('emial', $row);   // throws
Missing key [emial]:
email
name

Accepts arrays or objects, and string or integer keys. The available keys are sorted, so the output is stable across runs.

keysExist() — several keys must all be present

Assert::keysExist(['name', 'email', 'phone'], $row);
Missing keys [phone]:
email
name

inArray() — value must be one of an allowed set

Assert::inArray($status, ['draft', 'published', 'archived']);
Unexpected value 'pubished'. Allowed: 'archived', 'draft', 'published'

Comparison is strict, so '1' is not accepted where 1 is allowed.

Custom messages

Every helper takes an optional trailing $message appended to the failure output:

Assert::keyExists('id', $payload, 'check the /api/items response shape');

Development

composer install
vendor/bin/phpunit          # run the test suite
vendor/bin/phpstan analyse  # static analysis
vendor/bin/ecs check        # coding standard

License

MIT

统计信息

  • 总下载量: 4
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-05-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固