Skip to content

ClosureValidationRule::$callback is protected, but public in Laravel #729

Closed

Description

@ipsocode

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

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:

public function __construct(
protected Closure $callback
) {
}
declares it as the promoted 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

  1. binaryfire commented on Nov 3, 2026

    @binaryfire
    Member

    Fixed in #731.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions