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(7mo ago)2606.3k↓24.9%1[1 issues](https://github.com/pmmp/CallbackValidator/issues)[2 PRs](https://github.com/pmmp/CallbackValidator/pulls)9MITPHPPHP ^8.0CI passing

Since Mar 16Pushed 7mo 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 2w ago

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

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

49

—

FairBetter than 94% of packages

Maintenance52

Moderate activity, may be stable

Popularity40

Moderate usage in the ecosystem

Community26

Small or concentrated contributor base

Maturity67

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

237d 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

[toplan/laravel-sms

A mobile phone number validation solution based on laravel

83580.2k2](/packages/toplan-laravel-sms)[drupal/coder

Coder is a library to review Drupal code.

3046.8M629](/packages/drupal-coder)[ph-7/eu-vat-validator

A simple and clean PHP class that validates EU VAT numbers against the central ec.europa.eu database (using the official europa API).

97510.7k1](/packages/ph-7-eu-vat-validator)[hyperf/validation

hyperf validation

122.2M213](/packages/hyperf-validation)[udokmeci/yii2-phone-validator

Modern Yii2 Phone validator wrapper on top of PhoneNumberUtil library also used by Android devices

36227.5k1](/packages/udokmeci-yii2-phone-validator)[snowcap/vat-validation

EU VAT number validation

10112.3k](/packages/snowcap-vat-validation)

PHPackages © 2026

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