PHPackages                             koriym/var-type - 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. koriym/var-type

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

koriym/var-type
===============

0.1.0(1y ago)211MITPHPPHP ^8.0CI failing

Since Jul 4Pushed 1y ago1 watchersCompare

[ Source](https://github.com/koriym/Koriym.VarType)[ Packagist](https://packagist.org/packages/koriym/var-type)[ GitHub Sponsors](https://github.com/koriym)[ Fund](https://tidelift.com/funding/github/packagist/ray/aop)[ RSS](/packages/koriym-var-type/feed)WikiDiscussions 1.x Synced 1mo ago

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

VarType
=======

[](#vartype)

[![Continuous Integration](https://github.com/koriym/Koriym.VarType/actions/workflows/continuous-integration.yml/badge.svg)](https://github.com/koriym/Koriym.VarType/actions/workflows/continuous-integration.yml)

[![var type logo](https://camo.githubusercontent.com/2433dab279dbd709b75960749ad8fba27dce96306a76668ffacfde8101b01a15/68747470733a2f2f6b6f7269796d2e6769746875622e696f2f4b6f7269796d2e566172547970652f6c6f676f2e6a7067)](https://camo.githubusercontent.com/2433dab279dbd709b75960749ad8fba27dce96306a76668ffacfde8101b01a15/68747470733a2f2f6b6f7269796d2e6769746875622e696f2f4b6f7269796d2e566172547970652f6c6f676f2e6a7067)

VarType is a powerful PHP library that generates detailed type information from PHP variables, with a focus on producing "object-like array" and "array shape" representations. It's designed to enhance static analysis capabilities and improve IDE autocompletion and type inference. Features
--------

[](#features)

- Generate detailed type information for any PHP variable
- Produce "object-like array" and "array shape" representations
- Support for arrays, objects, and scalar types
- Distinguish between indexed arrays and associative arrays (array shapes)
- Recursively analyze nested structures
- Compatible with static analysis tools like Psalm and PHPStan
- Enhance IDE autocompletion and type prediction

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

[](#installation)

Install VarType using Composer:

```
composer require --dev koriym/var-type
```

Usage
-----

[](#usage)

Here's a quick example of VarType in action:

```
use Koriym\VarType\VarType;

$data = [
    'user' => [
        'name' => 'John Doe',
        'age' => 30,
        'skills' => ['PHP', 'JavaScript', 'Python'],
    ],
    'settings' => (object)['theme' => 'dark', 'notifications' => true]
];

VarType::dump($data);
```

This will output:

```
array{user: array{name: string, age: int, skills: array}, settings: stdClass{theme: string, notifications: bool}}

```

### Advanced Usage

[](#advanced-usage)

You can also use the VarType class as an invokable:

```
$varType = new VarType();
echo $varType($data);
```

Type Representations
--------------------

[](#type-representations)

VarType uses the following syntax to represent different types:

- Scalar types: `int`, `float`, `bool`, `string`, `null`
- Arrays:
    - Indexed arrays: `array`
    - Associative arrays (array shapes): `array{key1: type1, key2: type2, ...}`
- Objects (object-like arrays): `ClassName{property1: type1, property2: type2, ...}`

Why VarType?
------------

[](#why-vartype)

1. **Enhanced Static Analysis**: VarType provides detailed type information that can be used with tools like Psalm and PHPStan for more accurate static analysis.
2. **Improved IDE Support**: The detailed type strings generated by VarType can enhance IDE autocompletion and type inference, making development more efficient.
3. **Detailed Type Information**: While PHP's built-in functions can provide basic type information, VarType offers much more detailed type representations, including object-like arrays and array shapes.
4. **Debugging Aid**: Quickly understand the structure of complex variables, including nested object-like arrays and array shapes.
5. **Documentation**: Generate precise type information for APIs or function parameters, improving code readability and maintainability.

---

VarType - Unleash the full potential of PHP type information!

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

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

Total

2

Last Release

499d ago

Major Versions

0.1.0 → 1.x-dev2025-01-04

### Community

Maintainers

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

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/koriym-var-type/health.svg)

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

PHPackages © 2026

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