PHPackages                             jeroenvanderlaan/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. [Debugging &amp; Profiling](/categories/debugging)
4. /
5. jeroenvanderlaan/php-types

ActiveLibrary[Debugging &amp; Profiling](/categories/debugging)

jeroenvanderlaan/php-types
==========================

Utilities for working with and formatting PHP types.

1.0.0(2y ago)04MITPHPPHP &gt;=8.3

Since Dec 22Pushed 2y ago1 watchersCompare

[ Source](https://github.com/JeroenVanDerLaan/php-types)[ Packagist](https://packagist.org/packages/jeroenvanderlaan/php-types)[ RSS](/packages/jeroenvanderlaan-php-types/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (1)Versions (2)Used By (0)

PHP Types
=========

[](#php-types)

Utilities for working with and formatting PHP types.

```
use Jeroenvanderlaan\Types\Type;
use Jeroenvanderlaan\Types\TypeFormatter;
use Jeroenvanderlaan\Types\TypeInflector;

Type::get('float')->isCastableTo(Type::Int); // true

TypeInflector::typeof('John'); // Type::String

TypeFormatter::formatTypeOf([1, 2, 'a', 'b']); // 'list'
```

Installation
------------

[](#installation)

```
composer require jeroenvanderlaan/php-types
```

Usage
-----

[](#usage)

```
use Jeroenvanderlaan\Types\Type;
use Jeroenvanderlaan\Types\TypeFormatter;
use Jeroenvanderlaan\Types\TypeInflector;

// Get a Type by name or alias
Type::get('int'); // Type::Int
Type::get('integer'); // Type::Int

// Parse union Types
Type::parse('int|float'); // [Type::Int, Type::Float]

// Inflect a Type from a value
TypeInflector::typeof('foobar'); // Type::String
TypeInflector::typeof([1, 2]); // Type::List
TypeInflector::typeof(['a' => 'b'])); // Type::Map

// Format a Type
TypeFormatter::formatType(Type::Int); // 'int'
TypeFormatter::formatType(Type::Int, Type::Float); // 'int|float'

// Format the Type of value
TypeFormatter::formatTypeOf(1); // 'int'
TypeFormatter::formatTypeOf([1, 'a']); // 'list'
TypeFormatter::formatTypeOf([['a'], ['b']]); // 'list'
TypeFormatter::formatTypeOf(new stdClass); // 'stdClass'
```

Examples
--------

[](#examples)

```
use Jeroenvanderlaan\Types\Type;
use Jeroenvanderlaan\Types\TypeFormatter;
use Jeroenvanderlaan\Types\TypeInflector;

Type::get('null'); // Type::Null
Type::get('bool'); // Type::Bool
Type::get('int'); // Type::Int
Type::get('float'); // Type::Float
Type::get('number'); // Type::Number
Type::get('string'); // Type::String
Type::get('scalar'); // Type::Scalar
Type::get('resource'); // Type::Resource
Type::get('callable'); // Type::Callable
Type::get('object'); // Type::Object
Type::get('list'); // Type::List
Type::get('map'); // Type::Map
Type::get('array'); // Type::Array
Type::get('iterable'); // Type::Iterable

TypeInflector::typeof(null); // Type::Null
TypeInflector::typeof(true); // Type::Bool
TypeInflector::typeof(1); // Type::Int
TypeInflector::typeof(1.0); // Type::Float
TypeInflector::typeof('1.0'); // Type::Number
TypeInflector::typeof('John'); // Type::String
TypeInflector::typeof(STDOUT); // Type::Resource
TypeInflector::typeof(fn() => null); // Type::Callable
TypeInflector::typeof(new stdClass()); // Type::Object
TypeInflector::typeof([1, 2]); // Type::List
TypeInflector::typeof(['a' => 'b']); // Type::Map
TypeInflector::typeof([1, 'a' => 'b']); // Type::Array
TypeInflector::typeof(new ArrayIterator([1, 2])); // Type::Iterable

TypeFormatter::formatTypeOf(null); // 'null'
TypeFormatter::formatTypeOf(true); // 'bool'
TypeFormatter::formatTypeOf(1); // 'int'
TypeFormatter::formatTypeOf(1.0); // 'float'
TypeFormatter::formatTypeOf('1.0'); // 'number'
TypeFormatter::formatTypeOf('John'); // 'string'
TypeFormatter::formatTypeOf(STDOUT); // 'resource'
TypeFormatter::formatTypeOf(fn() => null); // 'callable'
TypeFormatter::formatTypeOf(new stdClass()); // 'stdClass
TypeFormatter::formatTypeOf([1, 2]); // 'list'
TypeFormatter::formatTypeOf([true, 1, 1.0, '1.0']); // 'list'
TypeFormatter::formatTypeOf(['a' => 'b']); // 'map'
TypeFormatter::formatTypeOf(['a' => 'b', 'b' => 1]); // 'map'
TypeFormatter::formatTypeOf([1, 'a' => 'b']); // 'array'
TypeFormatter::formatTypeOf(new ArrayIterator([1, 2])); // 'ArrayIterator'

Type::Bool->isEqualTo(Type::Bool); // true
Type::Int->isOneOf(Type::Int, Type::Float); // true
Type::Int->isCastableTo(Type::Float); // true
Type::Mixed->isMixed(); // true
Type::Number->isNumeric(); // true
Type::String->isScalar(); // true
Type::Resource->isComplex(); // true
Type::Iterable->isArrayLike(); // true
Type::Map->isObjectLike(); // true
```

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

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

Unknown

Total

1

Last Release

924d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d7d85544dbae99b354a96ff9d464beb0616f71a0cbef4b02d45188a4d2e54b77?d=identicon)[JeroenVanDerLaan](/maintainers/JeroenVanDerLaan)

---

Top Contributors

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

---

Tags

typedumptypesinspectdatatype

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[symfony/var-dumper

Provides mechanisms for walking through any arbitrary PHP variable

7.4k904.9M9.6k](/packages/symfony-var-dumper)[kint-php/kint

Kint - Advanced PHP dumper

2.9k20.6M304](/packages/kint-php-kint)[xrdebug/php

PHP client library for xrDebug

23824.8k3](/packages/xrdebug-php)[leeoniya/dump-r

a cleaner, leaner mix of print\_r() and var\_dump()

12368.9k5](/packages/leeoniya-dump-r)[jbzoo/jbdump

Script for debug and dump PHP variables and other stuff. This tool is a nice replacement for print\_r() and var\_dump() functions.

211.1M3](/packages/jbzoo-jbdump)[phalcon/dd

This package will add the `dd` and `dump` helpers to your Phalcon application.

24297.7k27](/packages/phalcon-dd)

PHPackages © 2026

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