PHPackages                             perf/type-validation - 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. perf/type-validation

Abandoned → [jmf/type-validation](/?search=jmf%2Ftype-validation)Library[Validation &amp; Sanitization](/categories/validation)

perf/type-validation
====================

Allows to check if a variable is of the expected type, using a type specification string like the ones in PHPDoc blocks (int, \\Foo\\Bar\[\], null|string, etc).

4.0.0(2y ago)02291MITPHPPHP &gt;=8.2

Since Mar 30Pushed 2y ago1 watchersCompare

[ Source](https://github.com/jmfeurprier/type-validation)[ Packagist](https://packagist.org/packages/perf/type-validation)[ RSS](/packages/perf-type-validation/feed)WikiDiscussions 4.0 Synced 1mo ago

READMEChangelog (3)Dependencies (7)Versions (16)Used By (0)

type validation
===============

[](#type-validation)

This package allows to check if a variable is of the expected type, using a type specification string like the ones in PHPDoc blocks.

Type specifications strings can be like the following:

```
- integer
- scalar
- mixed
- string
- float[]
- int[][]
- {string:float}
- {int:\My\Stuff}
- {int:string}[]
- resource
- int|string
- {string:{int:\My\Stuff|int[]}}[]

```

etc.

Usage
-----

[](#usage)

### Static validation with exceptions

[](#static-validation-with-exceptions)

```
