PHPackages                             jessegall/php-types - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. jessegall/php-types

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

jessegall/php-types
===================

Named typed constants and predicates — give meaning to magic literals like '', \[\], '{}', 0, true and null.

v1.14.1(4w ago)0827[1 issues](https://github.com/jessegall/php-types/issues)MITPHPPHP ^8.2

Since Jun 13Pushed 4w agoCompare

[ Source](https://github.com/jessegall/php-types)[ Packagist](https://packagist.org/packages/jessegall/php-types)[ RSS](/packages/jessegall-php-types/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (5)Versions (21)Used By (0)

php-types
=========

[](#php-types)

Named typed constants and predicates — give meaning to magic literals.

A raw `''`, `[]`, `'{}'`, `0`, `true`, or `null` carries an unstated intent and gets re-checked defensively all over a codebase (`if ($this->delimiter === '')`). These tiny static classes give that intent a name and the check a single home.

```
use JesseGall\PhpTypes\T_String;

$prefix = T_String::empty();              // '' with a name
if (T_String::isEmpty($delimiter)) { … }  // reads as intent

// as a first-class callable
$nonEmpty = array_filter($parts, T_String::isNotEmpty(...));
```

Types
-----

[](#types)

ClassConstant(s)FactoryPredicates`T_String``EMPTY`, `SPACE`, `NEWLINE`, `PARAGRAPH`, `CARRIAGE_RETURN`, `CRLF`, `TAB`, `NULL_BYTE`, `COMMA`, `COMMA_SPACE`, `SLASH`, `DOT`, `DASH``empty()``isEmpty()`, `isNotEmpty()`, `isBlank()`, `isNotBlank()``T_Array``EMPTY`, `MATRIX``empty()`, `matrix()``isEmpty()`, `isNotEmpty()``T_Json``EMPTY_OBJECT`, `EMPTY_ARRAY``emptyObject()`, `emptyArray()``isEmptyObject()`, `isEmptyArray()``T_Int``ZERO`, `ONE`, `MINUS_ONE``zero()``isZero()`, `isNotZero()``T_Float``ZERO``zero()``isZero()`, `isNotZero()``T_Bool``TRUE`, `FALSE`—`isTrue()`, `isFalse()``T_Null`——`isNull()`, `isNotNull()`Deferred defaults
-----------------

[](#deferred-defaults)

`Defaults` returns a zero-argument `Closure` that produces a type's default — for when a place wants a *callable* yielding the default rather than the value:

```
$make = Defaults::array();   // Closure(): array{}
$make();                     // []

// e.g. a resolver factory or a lazy fallback:
IsNull::make()->then(Defaults::array());
```

`Defaults::array()`, `string()`, `int()`, `float()`, `bool()` (`false`), `null()`. For the value directly, use the type's own accessor (`T_Array::empty()`, …).

`T_Json` predicates are semantic — `isEmptyObject('{ }')` and `isEmptyObject("{\n}")`are `true` (they decode to an empty object), while `isEmptyObject('[]')` and invalid JSON are `false`.

Install
-------

[](#install)

```
composer require jessegall/php-types
```

Requires PHP 8.2+. Zero runtime dependencies.

Test
----

[](#test)

```
composer test
```

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance94

Actively maintained with recent releases

Popularity20

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

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

Total

20

Last Release

29d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0a13b52a17e71644445ec3597dc1c8faf54ebd8b6b087e219c672aae06ac5332?d=identicon)[JesseGall](/maintainers/JesseGall)

---

Top Contributors

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

---

Tags

phpvalue objectsconstantstypespredicates

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/jessegall-php-types/health.svg)

```
[![Health](https://phpackages.com/badges/jessegall-php-types/health.svg)](https://phpackages.com/packages/jessegall-php-types)
```

PHPackages © 2026

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