PHPackages                             dneustadt/type-checker - 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. dneustadt/type-checker

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

dneustadt/type-checker
======================

Simple implementation for asserting PHP7 scalar type declarations and return types

1.0.0(7y ago)16MITPHPPHP ^7.0

Since Nov 22Pushed 7y ago1 watchersCompare

[ Source](https://github.com/dneustadt/type-checker)[ Packagist](https://packagist.org/packages/dneustadt/type-checker)[ Docs](https://davidneustadt.de)[ RSS](/packages/dneustadt-type-checker/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

TypeChecker
===========

[](#typechecker)

Simple implementation for asserting PHP7 scalar type declarations and return types.

`composer require dneustadt/type-checker`

Example
-------

[](#example)

```
function test_function(string $foo): string
{
    return '';
}

class TestClass extends ReflectionClass
{
    protected function return_string(): string
    {
        return '';
    }

    protected function return_class(): TestClass
    {
        return $this;
    }

    protected function test_parameters(
        string $foo,
        TestClass $bar
    ): bool {
        unset($foo, $bar);

        return false;
    }
}

\TypeChecker\TypeChecker::reflectFunction('test_function')
        ->returnTypeIsEqual('string');
// true

\TypeChecker\TypeChecker::reflectMethod('return_string', TestClass::class)
        ->returnTypeIsEqual('string');
// true

\TypeChecker\TypeChecker::reflectMethod('return_class', TestClass::class)
        ->returnTypeIsInstanceOf('ReflectionClass');
// true

\TypeChecker\TypeChecker::reflectFunction('test_function')
        ->getArgument(0)
        ->typeIsEqual('bool');
// false

\TypeChecker\TypeChecker::reflectMethod('test_parameters', TestClass::class)
        ->getArgument(1)
        ->typeIsInstanceOf('ReflectionClass');
// true
```

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

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

Unknown

Total

1

Last Release

2777d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/69c1745bd6023c706f651e9bdb38515fc7678caf52b9580126141381168669cd?d=identicon)[dneustadt](/maintainers/dneustadt)

---

Tags

assertcheckclassequalshintsinstancenamephp7returnscalartesttypecheckfunctionparametersmethodPHP7argumentsequalsreturn

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dneustadt-type-checker/health.svg)

```
[![Health](https://phpackages.com/badges/dneustadt-type-checker/health.svg)](https://phpackages.com/packages/dneustadt-type-checker)
```

###  Alternatives

[webmozart/assert

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

7.6k917.5M1.5k](/packages/webmozart-assert)[rybakit/arguments-resolver

ArgumentsResolver allows you to determine the arguments to pass to a function or method.

26111.1k7](/packages/rybakit-arguments-resolver)[param-processor/param-processor

Parameter processing library

20681.0k12](/packages/param-processor-param-processor)[githusband/validation

Parameters Validation

2331.4k](/packages/githusband-validation)[fangstar/php-validator

PHP参数校验组件

327.5k](/packages/fangstar-php-validator)[chanmix51/parameter-juicer

Parameter validator and cleaner

1318.9k](/packages/chanmix51-parameter-juicer)

PHPackages © 2026

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