bermudaphp / reflection-type-matcher
v1.1
2025-04-09 21:41 UTC
Requires
- php: ^8.1
Requires (Dev)
- phpunit/phpunit: ^10.5
This package is auto-updated.
Last update: 2025-04-09 21:42:03 UTC
README
composer require bermudaphp/reflection-type-matcher
Usage
$reflector = new ReflectionFunction(static fn(int $a, int $b) => $a + $b); $param = $reflector->getParameters()[0]; $matcher = new TypeMatcher(); $matcher->match($param->getType(), '22'); // true $matcher->match($param->getType(), 22); // true $matcher->match($param->getType(), '22', true); // false $reflector = new ReflectionFunction(static fn(A&B $arg) => $arg); $param = $reflector->getParameters()[0]; $matcher->match($param->getType(), new class implements A, B {}) // true $matcher->match($param->getType(), new StdClass) // false