PHPackages                             sevavietl/type-guard - 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. sevavietl/type-guard

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

sevavietl/type-guard
====================

PHP type validator

v1.0(7y ago)681MITPHPPHP &gt;=7.2

Since Sep 17Pushed 7y ago2 watchersCompare

[ Source](https://github.com/Sevavietl/TypeGuard)[ Packagist](https://packagist.org/packages/sevavietl/type-guard)[ RSS](/packages/sevavietl-type-guard/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (4)Dependencies (3)Versions (5)Used By (0)

TypeGuard - PHP type validation partly inspired by [Ceylon Union and Intersection types](https://ceylon-lang.org/documentation/1.3/tour/types/)
===============================================================================================================================================

[](#typeguard---php-type-validation-partly-inspired-by-ceylon-union-and-intersection-types)

[![Build Status](https://camo.githubusercontent.com/6e30bf86767a1fbf456b5262b43f88fe14436eb4b9b39b98de055d563e596a21/68747470733a2f2f7472617669732d63692e636f6d2f54686f726f7567685048502f5479706547756172642e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/ThoroughPHP/TypeGuard)[![Coverage Status](https://camo.githubusercontent.com/1e1ff6e20f76bbaf6e19e36a9a2666e0b2549640b0933e9ef4977d0425bcd020/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f54686f726f7567685048502f5479706547756172642f62616467652e737667)](https://coveralls.io/github/ThoroughPHP/TypeGuard)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)[![PHPStan](https://camo.githubusercontent.com/441b5874ce4df0a2defc892979c96c46889b69cb32119d04f0b48626349f8bc9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d656e61626c65642d627269676874677265656e2e7376673f7374796c653d666c6174)](https://github.com/phpstan/phpstan)

Features
--------

[](#features)

TypeGuard can validate:

- Scalar types: `string`, `integer`, etc.:

```
(new TypeGuard('string'))->match('foo'); // => true
```

- Object types: `ArrayAccess`, `stdClass`, etc.:

```
(new TypeGuard('stdClass'))->match(new stdClass()); // => true
```

- Union types: `string|integer`:

```
$guard = new TypeGuard('string|integer');
$guard->match('foo'); // => true
$guard->match(1); // => true
```

- Intersection types: `ArrayAccess&Countable`:

```
(new TypeGuard('ArrayAccess&Countable'))->match(new ArrayIterator()); // => true
```

- Optional types: `?string`:

```
(new TypeGuard('?string'))->match(null); // => true
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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 ~57 days

Total

4

Last Release

2619d ago

Major Versions

v0.2 → v1.02019-03-09

PHP version history (2 changes)v0.1PHP &gt;=7.1

v1.0PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/4d447606cedb25aa0f2e4a57788d793bb46215aadaa5841b8ccf66f9477e5267?d=identicon)[sevavietl](/maintainers/sevavietl)

---

Top Contributors

[![Sevavietl](https://avatars.githubusercontent.com/u/1844827?v=4)](https://github.com/Sevavietl "Sevavietl (4 commits)")

---

Tags

guardphptypes

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/sevavietl-type-guard/health.svg)

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

###  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)[nette/forms

📝 Nette Forms: generating, validating and processing secure forms in PHP. Handy API, fully customizable, server &amp; client side validation and mature design.

54013.2M448](/packages/nette-forms)[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)

PHPackages © 2026

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