PHPackages                             pocketmine/callback-validator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. pocketmine/callback-validator

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

pocketmine/callback-validator
=============================

Fork of daverandom/callback-validator - Tools for validating callback signatures

1.0.4(4mo ago)2564.8k—3.9%[2 PRs](https://github.com/pmmp/CallbackValidator/pulls)6MITPHPPHP ^8.0CI passing

Since Mar 16Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/pmmp/CallbackValidator)[ Packagist](https://packagist.org/packages/pocketmine/callback-validator)[ RSS](/packages/pocketmine-callback-validator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (4)Versions (9)Used By (6)

Callback Validator
==================

[](#callback-validator)

Validates callback signatures against a prototype.

This is a fork of [daverandom/callback-validator](https://github.com/DaveRandom/CallbackValidator) used by PocketMine-MP. There are no significant changes from the upstream repository apart from more test versions, updated dependencies, and tagged releases for packages to use.

Since the upstream version has no release, it affects the composer stability of packages that use it. This caused problems for packages depending on [`pocketmine/pocketmine-mp`](https://github.com/pmmp/PocketMine-MP) because they could not receive its latest versions.

Status
------

[](#status)

[![CI](https://github.com/pmmp/CallbackValidator/workflows/CI/badge.svg)](https://github.com/pmmp/CallbackValidator/workflows/CI/badge.svg)

Usage
-----

[](#usage)

```
// Create a prototype function (can be any callable)
$prototype = function (A $a, B $b, $c): ?string {};

// Validate that callables match the prototype
$tests = [
    $prototype, // true
    function (A $a, B $b, $c) {}, // false - return type does not match
    function ($a, $b, $c): ?string {}, // true - arguments are contravariant
    function (A $a, B $b): ?string {}, // true - extra args don't cause errors
    function (A $a, B $b, $c, $d): ?string {}, // false - Insufficient args cause an error
    function (C $a, B $b, $c): ?string {}, // true if C is a supertype of A, false otherwise
    function (SuperTypeOfA $a, B $b, $c): ?string {}, // true
    function (A $a, B $b, $c): string {}, // true - return types are covariant
];

// Create a type from a prototype
$type = CallbackType::createFromCallable($prototype);

run_tests($type, $tests);

// ...or create a type by hand for more granular control over variance rules
$type = new CallbackType(
    new ReturnType(BuiltInTypes::STRING, ReturnType::NULLABLE | ReturnType::COVARIANT),
    new ParameterType('a', A::class),
    new ParameterType('b', B::class),
    new ParameterType('c')
);

run_tests($type, $tests);

function run_tests(CallbackType $type, array $tests)
{
    foreach ($tests as $test) {
        if ($type->isSatisfiedBy($test)) {
            echo "pass\n";
        } else {
            // CallbackType implements __toString() for easy inspections
            echo CallbackType::createFromCallable($test) . " does not satisfy {$type}\n";
        }
    }
}
```

TODO
----

[](#todo)

- Lots more tests
- Explain (text explanation of why callback does not validate)

###  Health Score

53

—

FairBetter than 97% of packages

Maintenance74

Regular maintenance activity

Popularity38

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~527 days

Total

5

Last Release

146d ago

PHP version history (3 changes)1.0.0PHP &gt;=7.1

1.0.3PHP ^7.1 || ^8.0

1.0.4PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/c8a755241617f6c78b33788a288ea7387a417410109293e3a9e3caad74720a44?d=identicon)[dktapps](/maintainers/dktapps)

![](https://www.gravatar.com/avatar/f43e76a228e4a42f099a6ac3c1dbfeadf5e94eaa77e2a70c1431fb12e753255b?d=identicon)[pmmp](/maintainers/pmmp)

---

Top Contributors

[![dktapps](https://avatars.githubusercontent.com/u/14214667?v=4)](https://github.com/dktapps "dktapps (37 commits)")[![DaveRandom](https://avatars.githubusercontent.com/u/2396425?v=4)](https://github.com/DaveRandom "DaveRandom (35 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (32 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (18 commits)")[![buchwasa](https://avatars.githubusercontent.com/u/17461354?v=4)](https://github.com/buchwasa "buchwasa (1 commits)")[![PeeHaa](https://avatars.githubusercontent.com/u/1330296?v=4)](https://github.com/PeeHaa "PeeHaa (1 commits)")

---

Tags

github-actions-enabledon-packagistphp83phpstan-l9phpstan-strict

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/pocketmine-callback-validator/health.svg)

```
[![Health](https://phpackages.com/badges/pocketmine-callback-validator/health.svg)](https://phpackages.com/packages/pocketmine-callback-validator)
```

###  Alternatives

[webmozart/assert

Assertions to validate method input/output with nice error messages.

7.6k894.0M1.2k](/packages/webmozart-assert)[bensampo/laravel-enum

Simple, extensible and powerful enumeration implementation for Laravel.

2.0k15.9M104](/packages/bensampo-laravel-enum)[swaggest/json-schema

High definition PHP structures with JSON-schema based validation

48612.5M73](/packages/swaggest-json-schema)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[ashallendesign/laravel-config-validator

A package for validating your Laravel app's config.

217905.3k5](/packages/ashallendesign-laravel-config-validator)[crazybooot/base64-validation

Laravel validators for base64 encoded files

1341.9M8](/packages/crazybooot-base64-validation)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
