Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Callback Validator Laravel Package

daverandom/callback-validator

Validate PHP callable signatures against a prototype with variance support. Build a CallbackType from an existing callable or define it manually, then test other callables for parameter/return compatibility (contra/covariance, nullability) and inspect mismatches via __toString().

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit: Niche but valuable for custom plugin architectures or hook systems where runtime callback signature validation is required. Laravel's native event system relies on static type hints and PHPStan for validation, making this package redundant for standard use cases. However, it fills a gap for dynamic, user-defined callbacks in third-party extensions where static analysis isn't feasible.
Integration feasibility: High. Pure PHP with no dependencies beyond PHP's reflection extension (already in Laravel). Requires manual wiring into service providers or callback registration logic (e.g., validating config-based callbacks in boot()). No Laravel-specific abstractions exist, so custom implementation is needed.
Technical risk: Moderate. Low adoption (0 dependents), "readme" maturity status, and incomplete tests in TODO list indicate potential edge-case bugs. Reflection-based validation adds measurable overhead in high-frequency paths (e.g., per-request). Low score (0.305) reflects minimal community maintenance.
Key questions:

  • How does this compare to PHPStan's static analysis for callback validation?
  • What is the performance impact of validating callbacks during app boot vs. runtime?
  • Are there existing Laravel ecosystem packages (e.g., for plugin systems) that already handle this?
  • Can PHP 8+ union types and attributes reduce the need for runtime validation?

Integration Approach

Stack fit: Ideal for custom callback-driven systems like plugin architectures, CLI command handlers, or middleware pipelines where user-provided callbacks must strictly conform to signatures. Not suitable for Laravel's built-in event system or standard controller actions where static typing suffices.
Migration path: Start with config-based validation during app boot (e.g., validate callbacks in config/plugins.php), then expand to critical event listeners or macros. Cache validated CallbackType instances to avoid repeated reflection. Avoid per-request validation.
Compatibility: Fully compatible with Laravel 8+ and PHP 7.4+. Requires no changes to Laravel core. Works alongside PHPStan but does not replace it—complements static analysis with runtime checks for dynamic callbacks.
Sequencing: 1) Validate static config callbacks at boot time; 2) Use for specific high-risk event listeners (e.g., payment hooks); 3) Only adopt for new plugin systems where strict runtime validation is non-negotiable. Never use in hot paths like HTTP request handling.

Operational Impact

Maintenance: High internal ownership required. Low community activity (0 dependents) means the team must fix bugs, update for PHP versions, and address edge cases (e.g., variadic params not handled). The "TODO" list (e.g., better error messages) implies ongoing internal work.
Support: Minimal external support—issues would require internal debugging or contributing to the package. No

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport