Repository navigation
Description
Before submitting
- I have read the contribution guide in full and this report meets its requirements.
- I have checked existing issues, documented differences, and deferred work; this is not already tracked or intentionally omitted.
- I have verified that the functionality exists in the upstream version or commit linked below.
- I have run the example below and verified that the behavior is missing from the stated Hypervel version.
Hypervel package and version
hypervel/components 0.4.x-dev, commit 88352d3 (Hypervel\Validation\ClosureValidationRule)
Upstream references
- Repository: https://github.com/laravel/framework
- Implementation: https://github.com/laravel/framework/blob/18bf64aee02dda4efe172c0e3e940be94847b7db/src/Illuminate/Validation/ClosureValidationRule.php#L13-L18
- Introduced in v5.5.0 (bd352a0d2ca93775fce8ef02365b03fc4fb8cbb0) as a public property, and public ever since: https://github.com/laravel/framework/blob/v5.5.0/src/Illuminate/Validation/ClosureValidationRule.php#L14
- Documentation: https://laravel.com/docs/12.x/validation#using-closures
Upstream comparison
Compared against laravel/framework branch 12.x at 18bf64aee02dda4efe172c0e3e940be94847b7db.
Laravel: https://github.com/laravel/framework/blob/18bf64aee02dda4efe172c0e3e940be94847b7db/src/Illuminate/Validation/ClosureValidationRule.php#L13-L18 declares public $callback;.
Hypervel:
components/src/validation/src/ClosureValidationRule.php
Lines 37 to 40 in 88352d3
| public function __construct( | |
| protected Closure $callback | |
| ) { | |
| } |
protected Closure $callback.
Missing behavior
In Laravel, the closure a ClosureValidationRule wraps is readable through its public $callback property. Code that receives the rule, such as the ClosureValidationRule that ValidationRuleParser builds from a closure in a rules array, can read the closure to describe the rule: its docblock, its parameters, or a reflection of it.
In Hypervel the property is protected, so reading $rule->callback throws an Error. The only way to reach the closure is reflection on a non-public member, which breaks without notice if the property is renamed.
The other public properties of Laravel's class ($failed and $messages) are still public in Hypervel, and only $callback changed visibility. I could not find it among the documented differences in src/docs/ or in docs/todo.md.
Expected fix, matching Laravel: public Closure $callback in the constructor.
Minimal example and reproduction steps
Environment: PHP 8.4.27 (CLI, Swoole), hypervel/components 0.4.x-dev at 88352d3.
From the root of any project with hypervel/components installed:
php -r 'require "vendor/autoload.php";
$rule = new Hypervel\Validation\ClosureValidationRule(function (string $attribute, mixed $value, Closure $fail): void {});
var_dump($rule->callback);'Expected (as in Laravel): object(Closure)#… (…), the closure passed to the constructor.
Actual:
Error: Cannot access protected property Hypervel\Validation\ClosureValidationRule::$callback
Activity
binaryfire commentedon Nov 3, 2026
Fixed in #731.