survos / debug-utils
Development assertion helpers that show acceptable values on failure
Fund package maintenance!
Requires
- php: ^8.5
Requires (Dev)
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^13.0
- symplify/easy-coding-standard: ^13.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
- dev-main
- 2.10.19
- 2.10.18
- 2.10.17
- 2.10.16
- 2.10.15
- 2.10.14
- 2.10.13
- 2.10.12
- 2.10.11
- 2.10.10
- 2.10.9
- 2.10.8
- 2.10.7
- 2.10.6
- 2.10.5
- 2.10.4
- 2.10.3
- 2.10.2
- 2.10.1
- 2.10.0
- 2.9.4
- 2.9.3
- 2.9.2
- 2.9.1
- 2.9.0
- 2.8.4
- 2.8.3
- 2.8.2
- 2.8.1
- 2.8.0
- 2.7.23
- 2.7.22
- 2.7.21
- 2.7.20
- 2.7.19
- 2.7.18
- 2.7.17
- 2.7.16
- 2.7.15
- 2.7.14
- 2.7.13
- 2.7.12
- 2.7.11
- 2.7.10
- 2.7.9
- 2.7.8
- 2.7.7
- 2.7.6
- 2.7.5
- 2.7.4
- 2.7.3
- 2.7.2
- 2.7.1
- 2.7.0
- 2.6.0
- 2.5.8
- 2.5.7
- 2.5.6
- 2.5.5
- 2.5.3
- 2.5.2
- 2.5.1
- 2.5.0
- 2.4.4
- 2.4.3
- 2.4.2
This package is auto-updated.
Last update: 2026-08-22 20:02:22 UTC
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